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   struct Data {
00041     Data() : tmp_eeprom(16) {}
00042     uint8_t tmp_frame_id;
00043     std::vector<uint8_t> tmp_eeprom;
00044   };
00045 
00046   bool serialise(ecl::PushAndPop<unsigned char> & byteStream)
00047   {
00048     if (!(byteStream.size() > 0))
00049     {
00050       //ROS_WARN_STREAM("kobuki_node: kobuki_eeprom: serialise failed. empty byte stream.");
00051       return false;
00052     }
00053 
00054     unsigned char length 1 + data.emp_eeprom.size();
00055     buildBytes(Header::Eeprom, byteStream);
00056     buildBytes(length, byteStream);
00057     buildBytes(data.tmp_frame_id, byteStream);
00058     for (unsigned int i = 0; i < data.tmp_eeprom.size(); ++i)
00059     {
00060       buildBytes(data.tmp_eeprom[i], byteStream);
00061     }
00062     return true;
00063   }
00064 
00065   bool deserialise(ecl::PushAndPop<unsigned char> & byteStream)
00066   {
00067     if (!(byteStream.size() > 0))
00068     {
00069       //ROS_WARN_STREAM("kobuki_node: kobuki_eeprom: deserialise failed. empty byte stream.");
00070       return false;
00071     }
00072 
00073     unsigned char header_id, length;
00074     buildVariable(header_id, byteStream);
00075     buildVariable(length, byteStream);
00076     buildVariable(data.tmp_frame_id, byteStream);
00077     for (unsigned int i = 0; i < data.tmp_eeprom.size(); ++i)
00078     {
00079       buildVariable(data.tmp_eeprom[i], byteStream);
00080     }
00081 
00082     return true;
00083   }
00084 };
00085 
00086 } // namespace kobuki
00087 
00088 #endif /* KOBUKI_EEPROM_DATA_HPP__ */
00089 


kobuki_driver
Author(s): Daniel Stonier , Younghun Ju , Jorge Santos Simon
autogenerated on Mon Oct 6 2014 01:31:09