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 
35 {
36 public:
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 
56  bool deserialise(ecl::PushAndPop<unsigned char> & byteStream)
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 
bool deserialise(ecl::PushAndPop< unsigned char > &byteStream)
const unsigned char length
struct kobuki::UniqueDeviceID::Data data
bool serialise(ecl::PushAndPop< unsigned char > &byteStream)
Provides base class for payloads.
payloadBase(const bool is_dynamic_=false, const unsigned char length_=0)
void buildVariable(T &V, ecl::PushAndPop< unsigned char > &buffer)
void buildBytes(const T &V, ecl::PushAndPop< unsigned char > &buffer)


kobuki_driver
Author(s): Daniel Stonier , Younghun Ju , Jorge Santos Simon
autogenerated on Mon Mar 27 2017 01:02:59