Go to the documentation of this file.00001
00009
00010
00011
00012
00013 #ifndef KOBUKI_HW_DATA_HPP__
00014 #define KOBUKI_HW_DATA_HPP__
00015
00016
00017
00018
00019
00020 #include "../packet_handler/payload_base.hpp"
00021 #include "../packet_handler/payload_headers.hpp"
00022
00023
00024
00025
00026
00027 namespace kobuki
00028 {
00029
00030
00031
00032
00033
00034 class Hardware : public packet_handler::payloadBase
00035 {
00036 public:
00037 struct Data {
00038 uint32_t version;
00039 } data;
00040
00041
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
00070
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;
00078 }
00079 else
00080 {
00081 buildVariable(data.version, byteStream);
00082 }
00083
00084
00085 return constrain();
00086 }
00087
00088 bool constrain()
00089 {
00090 return true;
00091 }
00092
00093 void showMe()
00094 {
00095
00096 }
00097 };
00098
00099 }
00100
00101 #endif
00102