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   struct Data {
00038     uint32_t version;
00039   } data;
00040 
00041   // methods
00042   bool serialise(ecl::PushAndPop<unsigned char> & byteStream)
00043   {
00044     if (!(byteStream.size() > 0))
00045     {
00046       printf("kobuki_node: kobuki_hw: serialise failed. empty byte stream.");
00047       return false;
00048     }
00049 
00050     unsigned char length = 4;
00051     buildBytes(Header::Hardware, byteStream);
00052     buildBytes(length, byteStream);
00053     buildBytes(data.version, byteStream);
00054     return true;
00055   }
00056 
00057   bool deserialise(ecl::PushAndPop<unsigned char> & byteStream)
00058   {
00059     if (!(byteStream.size() > 0))
00060     {
00061       printf("kobuki_node: kobuki_hw: deserialise failed. empty byte stream.");
00062       return false;
00063     }
00064 
00065     unsigned char header_id = 0, length = 0;
00066     buildVariable(header_id, byteStream);
00067     buildVariable(length, byteStream);
00068 
00069     // TODO First 3 firmware versions coded version number on 2 bytes, so we need convert manually to our new
00070     // 4 bytes system; remove this horrible, dirty hack as soon as we upgrade the firmware to 1.1.2 or 1.2.0
00071     if (length == 2)
00072     {
00073       uint16_t old_style_version = 0;
00074       buildVariable(old_style_version, byteStream);
00075 
00076       if (old_style_version == 104)
00077         data.version = 0x00010004;//65540; // 1.0.4
00078     }
00079     else
00080     {
00081       buildVariable(data.version, byteStream);
00082     }
00083 
00084     //showMe();
00085     return constrain();
00086   }
00087 
00088   bool constrain()
00089   {
00090     return true;
00091   }
00092 
00093   void showMe()
00094   {
00095     //printf("--[%02x || %03d | %03d | %03d]\n", data.bump, acc[2], acc[1], acc[0] );
00096   }
00097 };
00098 
00099 } // namespace kobuki
00100 
00101 #endif /* KOBUKI_HW_DATA_HPP__ */
00102 


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