std::string toString() const { std::ostringstream os; os << "ts_m=" << ts_monotonic << " ts_utc=" << ts_utc << " tt=" << transfer_type << " tid=" << int(transfer_id.get()) << " snid=" << int(src_node_id.get()) << " dnid=" << int(dst_node_id.get()) << " dtid=" << int(data_type.getID().get()) << "\n\t'" << payload << "'"; return os.str(); }
bool handleRestartRequest(uavcan::NodeID request_source) override { ::syslog(LOG_INFO, "UAVCAN: Restarting by request from %i\n", int(request_source.get())); ::usleep(20 * 1000 * 1000); px4_systemreset(false); return true; // Will never be executed BTW }
void printStatusLine(uavcan::NodeID nid, const uavcan::NodeStatusMonitor::NodeStatus& status) { const auto color_and_string = statusCodeToColoredString(status.status_code); const int nid_int = nid.get(); std::cout << color_and_string.first; std::cout << " " << std::setw(3) << std::left << nid_int << " | " << std::setw(13) << std::left << color_and_string.second << " | " << uptimes_[nid_int]; std::cout << OstreamColorizer() << "\n"; }
bool operator==(const Transfer& rhs) const { return (ts_monotonic == rhs.ts_monotonic) && ((!ts_utc.isZero() && !rhs.ts_utc.isZero()) ? (ts_utc == rhs.ts_utc) : true) && (transfer_type == rhs.transfer_type) && (transfer_id == rhs.transfer_id) && (src_node_id == rhs.src_node_id) && ((dst_node_id.isValid() && rhs.dst_node_id.isValid()) ? (dst_node_id == rhs.dst_node_id) : true) && (data_type == rhs.data_type) && (payload == rhs.payload); }
Transfer makeTransfer(uavcan::TransferPriority priority, uavcan::TransferType transfer_type, uint8_t source_node_id, const std::string& payload, const uavcan::DataTypeDescriptor& type, uavcan::NodeID dst_node_id_override = uavcan::NodeID()) { ts_ += uavcan::MonotonicDuration::fromUSec(100); const uavcan::UtcTime utc = uavcan::UtcTime::fromUSec(ts_.toUSec() + 1000000000ul); const uavcan::NodeID dst_node_id = (transfer_type == uavcan::TransferTypeMessageBroadcast) ? uavcan::NodeID::Broadcast : (dst_node_id_override.isValid() ? dst_node_id_override : dst_node_id_); const Transfer tr(ts_, utc, priority, transfer_type, tid_, source_node_id, dst_node_id, payload, type); tid_.increment(); return tr; }
bool match(StatusType status, uavcan::NodeID server_node_id, const typename DataType::Response& response) const { if (status == last_status && server_node_id == last_server_node_id && response == last_response) { return true; } else { std::cout << "MISMATCH: status=" << last_status << ", last_server_node_id=" << int(last_server_node_id.get()) << ", last response:\n" << last_response << std::endl; return false; } }
bool handleRestartRequest(uavcan::NodeID request_source) override { PX4_INFO("UAVCAN: Restarting by request from %i\n", int(request_source.get())); board_reset(false); return true; // Will never be executed BTW }