eeprom.hpp
Go to the documentation of this file.
1 
11 /*****************************************************************************
12 ** Preprocessor
13 *****************************************************************************/
14 
15 #ifndef KOBUKI_EEPROM_DATA_HPP__
16 #define KOBUKI_EEPROM_DATA_HPP__
17 
18 /*****************************************************************************
19 ** Include
20 *****************************************************************************/
21 
22 #include <vector>
24 #include "../packet_handler/payload_headers.hpp"
25 
26 /*****************************************************************************
27 ** Namespace
28 *****************************************************************************/
29 
30 namespace kobuki
31 {
32 
33 /*****************************************************************************
34 ** Interface
35 *****************************************************************************/
36 
38 {
39 public:
40  Eeprom() : packet_handler::payloadBase(false, 17) {};
41  struct Data {
42  Data() : tmp_eeprom(16) {}
43  uint8_t tmp_frame_id;
44  std::vector<uint8_t> tmp_eeprom;
45  };
46 
48  {
49  buildBytes(Header::Eeprom, byteStream);
50  buildBytes(length, byteStream);
51  buildBytes(data.tmp_frame_id, byteStream);
52  for (unsigned int i = 0; i < data.tmp_eeprom.size(); ++i)
53  {
54  buildBytes(data.tmp_eeprom[i], byteStream);
55  }
56  return true;
57  }
58 
60  {
61  if (byteStream.size() < length+2)
62  {
63  //std::cout << "kobuki_node: kobuki_eeprom: deserialise failed. not enough byte stream." << std::endl;
64  return false;
65  }
66 
67  unsigned char header_id, length_packed;
68  buildVariable(header_id, byteStream);
69  buildVariable(length_packed, byteStream);
70  if( header_id != Header::Eeprom ) return false;
71  if( length_packed != length ) return false;
72 
73  buildVariable(data.tmp_frame_id, byteStream);
74  for (unsigned int i = 0; i < data.tmp_eeprom.size(); ++i)
75  {
76  buildVariable(data.tmp_eeprom[i], byteStream);
77  }
78 
79  //showMe();
80  return constrain();
81  }
82 
83  bool constrain()
84  {
85  return true;
86  }
87 
88  void showMe()
89  {
90  }
91 };
92 
93 } // namespace kobuki
94 
95 #endif /* KOBUKI_EEPROM_DATA_HPP__ */
96 
unsigned int size() const
bool deserialise(ecl::PushAndPop< unsigned char > &byteStream)
Definition: eeprom.hpp:59
uint8_t tmp_frame_id
Definition: eeprom.hpp:43
bool constrain()
Definition: eeprom.hpp:83
const unsigned char length
void showMe()
Definition: eeprom.hpp:88
Provides base class for payloads.
Base class for payloads.
payloadBase(const bool is_dynamic_=false, const unsigned char length_=0)
bool serialise(ecl::PushAndPop< unsigned char > &byteStream)
Definition: eeprom.hpp:47
std::vector< uint8_t > tmp_eeprom
Definition: eeprom.hpp:44
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 Fri Sep 18 2020 03:22:01