eeprom.hpp
Go to the documentation of this file.
00001 
00011 /*****************************************************************************
00012 ** Preprocessor
00013 *****************************************************************************/
00014 
00015 #ifndef KOBUKI_EEPROM_DATA_HPP__
00016 #define KOBUKI_EEPROM_DATA_HPP__
00017 
00018 /*****************************************************************************
00019 ** Include
00020 *****************************************************************************/
00021 
00022 #include <vector>
00023 #include "packet_handler/payload_base.hpp"
00024 #include "../packet_handler/payload_headers.hpp"
00025 
00026 /*****************************************************************************
00027 ** Namespace
00028 *****************************************************************************/
00029 
00030 namespace kobuki
00031 {
00032 
00033 /*****************************************************************************
00034 ** Interface
00035 *****************************************************************************/
00036 
00037 class Eeprom : public packet_handler::payloadBase
00038 {
00039 public:
00040   Eeprom() : packet_handler::payloadBase(false, 17) {};
00041   struct Data {
00042     Data() : tmp_eeprom(16) {}
00043     uint8_t tmp_frame_id;
00044     std::vector<uint8_t> tmp_eeprom;
00045   };
00046 
00047   bool serialise(ecl::PushAndPop<unsigned char> & byteStream)
00048   {
00049     buildBytes(Header::Eeprom, byteStream);
00050     buildBytes(length, byteStream);
00051     buildBytes(data.tmp_frame_id, byteStream);
00052     for (unsigned int i = 0; i < data.tmp_eeprom.size(); ++i)
00053     {
00054       buildBytes(data.tmp_eeprom[i], byteStream);
00055     }
00056     return true;
00057   }
00058 
00059   bool deserialise(ecl::PushAndPop<unsigned char> & byteStream)
00060   {
00061     if (byteStream.size() < length+2)
00062     {
00063       //std::cout << "kobuki_node: kobuki_eeprom: deserialise failed. not enough byte stream." << std::endl;
00064       return false;
00065     }
00066 
00067     unsigned char header_id, length_packed;
00068     buildVariable(header_id, byteStream);
00069     buildVariable(length_packed, byteStream);
00070     if( header_id != Header::Eeprom ) return false;
00071     if( length_packed != length ) return false;
00072 
00073     buildVariable(data.tmp_frame_id, byteStream);
00074     for (unsigned int i = 0; i < data.tmp_eeprom.size(); ++i)
00075     {
00076       buildVariable(data.tmp_eeprom[i], byteStream);
00077     }
00078 
00079     //showMe();
00080     return constrain();
00081   }
00082 
00083   bool constrain()
00084   {
00085     return true;
00086   }
00087 
00088   void showMe()
00089   {
00090   }
00091 };
00092 
00093 } // namespace kobuki
00094 
00095 #endif /* KOBUKI_EEPROM_DATA_HPP__ */
00096 


kobuki_driver
Author(s): Daniel Stonier , Younghun Ju , Jorge Santos Simon
autogenerated on Thu Jun 6 2019 20:24:37