dynamic_node_id_client.hpp
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2015 Pavel Kirienko <pavel.kirienko@gmail.com>
3  */
4 
5 #ifndef UAVCAN_PROTOCOL_DYNAMIC_NODE_ID_CLIENT_HPP_INCLUDED
6 #define UAVCAN_PROTOCOL_DYNAMIC_NODE_ID_CLIENT_HPP_INCLUDED
7 
10 #include <uavcan/node/timer.hpp>
12 #include <uavcan/build_config.hpp>
13 #include <uavcan/protocol/dynamic_node_id/Allocation.hpp>
14 #include <uavcan/protocol/HardwareVersion.hpp>
15 
16 namespace uavcan
17 {
32 {
34  void (DynamicNodeIDClient::*)
37 
38  enum Mode
39  {
42  NumModes
43  };
44 
47 
48  uint8_t unique_id_[protocol::HardwareVersion::FieldTypes::unique_id::MaxSize];
50 
54 
55  void terminate();
56 
57  static MonotonicDuration getRandomDuration(uint32_t lower_bound_msec, uint32_t upper_bound_msec);
58 
59  void restartTimer(const Mode mode);
60 
61  virtual void handleTimerEvent(const TimerEvent&);
62 
63  void handleAllocation(const ReceivedDataStructure<protocol::dynamic_node_id::Allocation>& msg);
64 
65 public:
66  typedef protocol::HardwareVersion::FieldTypes::unique_id UniqueID;
67 
69  : TimerBase(node)
70  , dnida_pub_(node)
71  , dnida_sub_(node)
73  , unique_id_{0}
74 #endif
75  , size_of_received_unique_id_(0)
76  { }
77 
87  int start(const UniqueID& unique_id,
88  const NodeID preferred_node_id = NodeID::Broadcast,
90 
94  bool isAllocationComplete() const { return getAllocatedNodeID().isUnicast(); }
95 
102  NodeID getAllocatedNodeID() const { return allocated_node_id_; }
103 
110  NodeID getAllocatorNodeID() const { return allocator_node_id_; }
111 };
112 
113 }
114 
115 #endif // UAVCAN_PROTOCOL_DYNAMIC_NODE_ID_CLIENT_HPP_INCLUDED
std::uint8_t uint8_t
Definition: std.hpp:24
ROSCPP_DECL void start()
static const NodeID Broadcast
Definition: transfer.hpp:122
Publisher< protocol::dynamic_node_id::Allocation > dnida_pub_
protocol::HardwareVersion::FieldTypes::unique_id UniqueID
Subscriber< protocol::dynamic_node_id::Allocation, AllocationCallback > dnida_sub_
std::uint32_t uint32_t
Definition: std.hpp:26
static const TransferPriority OneHigherThanLowest
Definition: transfer.hpp:40


uavcan_communicator
Author(s):
autogenerated on Wed Jan 11 2023 03:59:39