unique_device_id.hpp
Go to the documentation of this file.
1 
9 /*****************************************************************************
10 ** Preprocessor
11 *****************************************************************************/
12 
13 #ifndef KOBUKI_UDID_DATA_HPP__
14 #define KOBUKI_UDID_DATA_HPP__
15 
16 /*****************************************************************************
17 ** Include
18 *****************************************************************************/
19 
20 #include "../packet_handler/payload_base.hpp"
21 #include "../packet_handler/payload_headers.hpp"
22 
23 /*****************************************************************************
24 ** Namespace
25 *****************************************************************************/
26 
27 namespace kobuki
28 {
29 
30 /*****************************************************************************
31 ** Interface
32 *****************************************************************************/
33 
34 class UniqueDeviceID : public packet_handler::payloadBase
35 {
36 public:
37  UniqueDeviceID() : packet_handler::payloadBase(false, 12) {};
38 
39  struct Data {
40  uint32_t udid0;
41  uint32_t udid1;
42  uint32_t udid2;
43  } data;
44 
45  // methods
46  bool serialise(ecl::PushAndPop<unsigned char> & byteStream)
47  {
49  buildBytes(length, byteStream);
50  buildBytes(data.udid0, byteStream);
51  buildBytes(data.udid1, byteStream);
52  buildBytes(data.udid2, byteStream);
53  return true;
54  }
55 
57  {
58  if (byteStream.size() < length+2)
59  {
60  //std::cout << "kobuki_node: kobuki_udid: deserialise failed. not enough byte stream." << std::endl;
61  return false;
62  }
63 
64  unsigned char header_id, length_packed;
65  buildVariable(header_id, byteStream);
66  buildVariable(length_packed, byteStream);
67  if( header_id != Header::UniqueDeviceID ) return false;
68  if( length_packed != length ) return false;
69 
70  buildVariable(data.udid0, byteStream);
71  buildVariable(data.udid1, byteStream);
72  buildVariable(data.udid2, byteStream);
73 
74  //showMe();
75  return constrain();
76  }
77 
78  bool constrain()
79  {
80  return true;
81  }
82 
83  void showMe()
84  {
85  }
86 };
87 
88 } // namespace kobuki
89 
90 #endif /* KOBUKI_UDID_DATA_HPP__ */
91 
kobuki::UniqueDeviceID::Data::udid1
uint32_t udid1
Definition: unique_device_id.hpp:55
packet_handler::payloadBase::length
const unsigned char length
Definition: payload_base.hpp:73
kobuki
Definition: command.hpp:31
kobuki::UniqueDeviceID::data
struct kobuki::UniqueDeviceID::Data data
kobuki::UniqueDeviceID::UniqueDeviceID
UniqueDeviceID()
Definition: unique_device_id.hpp:51
kobuki::UniqueDeviceID::Data::udid0
uint32_t udid0
Definition: unique_device_id.hpp:54
packet_handler::payloadBase::payloadBase
payloadBase(const bool is_dynamic_=false, const unsigned char length_=0)
Definition: payload_base.hpp:78
packet_handler::payloadBase
Provides base class for payloads.
Definition: payload_base.hpp:44
kobuki::UniqueDeviceID::deserialise
bool deserialise(ecl::PushAndPop< unsigned char > &byteStream)
Definition: unique_device_id.hpp:70
kobuki::Header::UniqueDeviceID
@ UniqueDeviceID
Definition: payload_headers.hpp:56
packet_handler::payloadBase::buildVariable
void buildVariable(T &V, ecl::PushAndPop< unsigned char > &buffer)
Definition: payload_base.hpp:96
kobuki::UniqueDeviceID::serialise
bool serialise(ecl::PushAndPop< unsigned char > &byteStream)
Definition: unique_device_id.hpp:60
packet_handler::payloadBase::buildBytes
void buildBytes(const T &V, ecl::PushAndPop< unsigned char > &buffer)
Definition: payload_base.hpp:110
ecl::PushAndPop< unsigned char >
kobuki::UniqueDeviceID::Data::udid2
uint32_t udid2
Definition: unique_device_id.hpp:56
packet_handler
Definition: payload_base.hpp:27
ecl::PushAndPop::size
unsigned int size() const
kobuki::UniqueDeviceID::showMe
void showMe()
Definition: unique_device_id.hpp:97
kobuki::UniqueDeviceID::constrain
bool constrain()
Definition: unique_device_id.hpp:92


kobuki_driver
Author(s): Daniel Stonier , Younghun Ju , Jorge Santos Simon
autogenerated on Wed Mar 2 2022 00:26:14