hardware.hpp
Go to the documentation of this file.
00001 
00009 /*****************************************************************************
00010 ** Preprocessor
00011 *****************************************************************************/
00012 
00013 #ifndef KOBUKI_HW_DATA_HPP__
00014 #define KOBUKI_HW_DATA_HPP__
00015 
00016 /*****************************************************************************
00017 ** Include
00018 *****************************************************************************/
00019 
00020 #include "../packet_handler/payload_base.hpp"
00021 #include "../packet_handler/payload_headers.hpp"
00022 
00023 /*****************************************************************************
00024 ** Namespace
00025 *****************************************************************************/
00026 
00027 namespace kobuki
00028 {
00029 
00030 /*****************************************************************************
00031 ** Interface
00032 *****************************************************************************/
00033 
00034 class Hardware : public packet_handler::payloadBase
00035 {
00036 public:
00037   Hardware() : packet_handler::payloadBase(true, 2) {};
00038   struct Data {
00039     uint32_t version;
00040   } data;
00041 
00042   // methods
00043   bool serialise(ecl::PushAndPop<unsigned char> & byteStream)
00044   {
00045     unsigned char length = 4;
00046     buildBytes(Header::Hardware, byteStream);
00047     buildBytes(length, byteStream);
00048     buildBytes(data.version, byteStream);
00049     return true;
00050   }
00051 
00052   bool deserialise(ecl::PushAndPop<unsigned char> & byteStream)
00053   {
00054     if (byteStream.size() < length+2)
00055     {
00056       //std::cout << "kobuki_node: kobuki_hw: deserialise failed. not enough byte stream." << std::endl;
00057       return false;
00058     }
00059 
00060     unsigned char header_id, length_packed;
00061     buildVariable(header_id, byteStream);
00062     buildVariable(length_packed, byteStream);
00063     if( header_id != Header::Hardware ) return false;
00064     if( length_packed != 2 and length_packed != 4) return false;
00065 
00066     // TODO First 3 firmware versions coded version number on 2 bytes, so we need convert manually to our new
00067     // 4 bytes system; remove this horrible, dirty hack as soon as we upgrade the firmware to 1.1.2 or 1.2.0
00068     if (length_packed == 2)
00069     {
00070       uint16_t old_style_version = 0;
00071       buildVariable(old_style_version, byteStream);
00072 
00073       if (old_style_version == 104)
00074         data.version = 0x00010004;//65540; // 1.0.4
00075     }
00076     else
00077     {
00078       buildVariable(data.version, byteStream);
00079     }
00080 
00081     //showMe();
00082     return constrain();
00083   }
00084 
00085   bool constrain()
00086   {
00087     return true;
00088   }
00089 
00090   void showMe()
00091   {
00092   }
00093 };
00094 
00095 } // namespace kobuki
00096 
00097 #endif /* KOBUKI_HW_DATA_HPP__ */
00098 


kobuki_driver
Author(s): Daniel Stonier , Younghun Ju , Jorge Santos Simon
autogenerated on Thu Aug 27 2015 13:43:58