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 
37 class Eeprom : public packet_handler::payloadBase
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 
47  bool serialise(ecl::PushAndPop<unsigned char> & byteStream)
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 
packet_handler::payloadBase::length
const unsigned char length
Definition: payload_base.hpp:73
kobuki
Definition: command.hpp:31
kobuki::Eeprom::Eeprom
Eeprom()
Definition: eeprom.hpp:54
payload_base.hpp
Base class for payloads.
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
packet_handler::payloadBase::buildVariable
void buildVariable(T &V, ecl::PushAndPop< unsigned char > &buffer)
Definition: payload_base.hpp:96
kobuki::Eeprom::constrain
bool constrain()
Definition: eeprom.hpp:97
packet_handler::payloadBase::buildBytes
void buildBytes(const T &V, ecl::PushAndPop< unsigned char > &buffer)
Definition: payload_base.hpp:110
kobuki::Eeprom::Data::Data
Data()
Definition: eeprom.hpp:56
kobuki::Eeprom::showMe
void showMe()
Definition: eeprom.hpp:102
kobuki::Eeprom::deserialise
bool deserialise(ecl::PushAndPop< unsigned char > &byteStream)
Definition: eeprom.hpp:73
kobuki::Header::Eeprom
@ Eeprom
Definition: payload_headers.hpp:54
ecl::PushAndPop< unsigned char >
kobuki::Eeprom::Data::tmp_frame_id
uint8_t tmp_frame_id
Definition: eeprom.hpp:57
packet_handler
Definition: payload_base.hpp:27
ecl::PushAndPop::size
unsigned int size() const
kobuki::Eeprom::serialise
bool serialise(ecl::PushAndPop< unsigned char > &byteStream)
Definition: eeprom.hpp:61
kobuki::Eeprom::Data::tmp_eeprom
std::vector< uint8_t > tmp_eeprom
Definition: eeprom.hpp:58


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