void handleTimerEvent(const TimerEvent&) { if (get_node_info_client_.hasPendingCalls()) { return; } const NodeID node_id = pickNextNodeToQueryAndCleanupMap(); if (!node_id.isUnicast()) { trace(TraceDiscoveryTimerStop, 0); stop(); return; } if (!handler_.canDiscoverNewNodes()) { return; // Timer must continue to run in order to not stuck when it unlocks } trace(TraceDiscoveryGetNodeInfoRequest, node_id.get()); UAVCAN_TRACE("dynamic_node_id_server::NodeDiscoverer", "Requesting GetNodeInfo from node %d", int(node_id.get())); const int res = get_node_info_client_.call(node_id, protocol::GetNodeInfo::Request()); if (res < 0) { getNode().registerInternalFailure("NodeDiscoverer GetNodeInfo call"); } }
/** * Unicast the message to the specified destination Node ID. * Returns negative error code. */ int unicast(const DataType& message, NodeID dst_node_id) { if (!dst_node_id.isUnicast()) { UAVCAN_ASSERT(0); return -ErrInvalidParam; } return BaseType::publish(message, TransferTypeMessageUnicast, dst_node_id); }
Frame(DataTypeID data_type_id, TransferType transfer_type, NodeID src_node_id, NodeID dst_node_id, uint_fast8_t frame_index, TransferID transfer_id, bool last_frame = false) : transfer_priority_(getDefaultPriorityForTransferType(transfer_type)) , transfer_type_(transfer_type) , data_type_id_(data_type_id) , payload_len_(0) , src_node_id_(src_node_id) , dst_node_id_(dst_node_id) , frame_index_(frame_index) , transfer_id_(transfer_id) , last_frame_(last_frame) { UAVCAN_ASSERT((transfer_type == TransferTypeMessageBroadcast) == dst_node_id.isBroadcast()); UAVCAN_ASSERT(data_type_id.isValidForDataTypeKind(getDataTypeKindForTransferType(transfer_type))); UAVCAN_ASSERT(src_node_id.isUnicast() ? (src_node_id != dst_node_id) : true); UAVCAN_ASSERT(frame_index <= getMaxIndex()); }
virtual void handleTimerEvent(const TimerEvent&) { if (pending_nodes_.isEmpty()) { TimerBase::stop(); UAVCAN_TRACE("FirmwareUpdateTrigger", "Timer stopped"); return; } const NodeID node_id = pickNextNodeID(); if (!node_id.isUnicast()) { return; } FirmwareFilePath* const path = pending_nodes_.access(node_id); if (path == UAVCAN_NULLPTR) { UAVCAN_ASSERT(0); // pickNextNodeID() returned a node ID that is not present in the map return; } protocol::file::BeginFirmwareUpdate::Request req; req.source_node_id = getNode().getNodeID().get(); if (!common_path_prefix_.empty()) { req.image_file_remote_path.path += common_path_prefix_.c_str(); req.image_file_remote_path.path.push_back(protocol::file::Path::SEPARATOR); } req.image_file_remote_path.path += path->c_str(); UAVCAN_TRACE("FirmwareUpdateTrigger", "Request to %d with path: %s", int(node_id.get()), req.image_file_remote_path.path.c_str()); const int call_res = begin_fw_update_client_.call(node_id, req); if (call_res < 0) { getNode().registerInternalFailure("FirmwareUpdateTrigger call"); } }
bool needToQuery(NodeID node_id) { UAVCAN_ASSERT(node_id.isUnicast()); /* * Fast check */ if (committed_node_mask_[node_id.get()]) { return false; } /* * Slow check - may involve full log search */ const INodeDiscoveryHandler::NodeAwareness awareness = handler_.checkNodeAwareness(node_id); if (awareness == INodeDiscoveryHandler::NodeAwarenessUnknown) { return true; } else if (awareness == INodeDiscoveryHandler::NodeAwarenessKnownButNotCommitted) { removeNode(node_id); return false; } else if (awareness == INodeDiscoveryHandler::NodeAwarenessKnownAndCommitted) { trace(TraceDiscoveryCommitCacheUpdated, node_id.get()); committed_node_mask_[node_id.get()] = true; removeNode(node_id); return false; } else { UAVCAN_ASSERT(0); return false; } }
virtual void handleTimerEvent(const TimerEvent&) { bool at_least_one_request_needed = false; const NodeID next = pickNextNodeToQuery(at_least_one_request_needed); if (next.isUnicast()) { UAVCAN_ASSERT(at_least_one_request_needed); getEntry(next).updated_since_last_attempt = false; const int res = get_node_info_client_.call(next, protocol::GetNodeInfo::Request()); if (res < 0) { get_node_info_client_.getNode().registerInternalFailure("NodeInfoRetriever GetNodeInfo call"); } } else { if (!at_least_one_request_needed) { TimerBase::stop(); UAVCAN_TRACE("NodeInfoRetriever", "Timer stopped"); } } }
bool isVotedForSet() const { return voted_for_.isUnicast(); }