Kobuki 1.0.0
C++ API for the Kobuki research robot
Loading...
Searching...
No Matches
eeprom.hpp
Go to the documentation of this file.
1
11/*****************************************************************************
12** Preprocessor
13*****************************************************************************/
14
15#ifndef KOBUKI_CORE_EEPROM_DATA_HPP__
16#define KOBUKI_CORE_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
30namespace kobuki
31{
32
33/*****************************************************************************
34** Interface
35*****************************************************************************/
36
38{
39public:
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
59 bool deserialise(ecl::PushAndPop<unsigned char> & byteStream)
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_CORE_EEPROM_DATA_HPP__ */
96
Definition eeprom.hpp:38
Provides base class for payloads.
Definition payload_base.hpp:39
const unsigned char length
Definition payload_base.hpp:59
Base class for payloads.
Definition eeprom.hpp:41