Go to the documentation of this file.00001
00010
00011
00012
00013
00014 #include "../../include/kobuki_driver/packets/core_sensors.hpp"
00015 #include "../../include/kobuki_driver/packet_handler/payload_headers.hpp"
00016
00017
00018
00019
00020
00021 namespace kobuki {
00022
00023
00024
00025
00026
00027 bool CoreSensors::serialise(ecl::PushAndPop<unsigned char> & byteStream)
00028 {
00029 buildBytes(Header::CoreSensors, byteStream);
00030 buildBytes(length, byteStream);
00031 buildBytes(data.time_stamp, byteStream);
00032 buildBytes(data.bumper, byteStream);
00033 buildBytes(data.wheel_drop, byteStream);
00034 buildBytes(data.cliff, byteStream);
00035 buildBytes(data.left_encoder, byteStream);
00036 buildBytes(data.right_encoder, byteStream);
00037 buildBytes(data.left_pwm, byteStream);
00038 buildBytes(data.right_pwm, byteStream);
00039 buildBytes(data.buttons, byteStream);
00040 buildBytes(data.charger, byteStream);
00041 buildBytes(data.battery, byteStream);
00042 buildBytes(data.over_current, byteStream);
00043
00044 return true;
00045 }
00046 bool CoreSensors::deserialise(ecl::PushAndPop<unsigned char> & byteStream)
00047 {
00048 if (byteStream.size() < length+2)
00049 {
00050
00051 return false;
00052 }
00053
00054 unsigned char header_id, length_packed;
00055 buildVariable(header_id, byteStream);
00056 buildVariable(length_packed, byteStream);
00057 if( header_id != Header::CoreSensors ) return false;
00058 if( length_packed != length ) return false;
00059
00060 buildVariable(data.time_stamp, byteStream);
00061 buildVariable(data.bumper, byteStream);
00062 buildVariable(data.wheel_drop, byteStream);
00063 buildVariable(data.cliff, byteStream);
00064 buildVariable(data.left_encoder, byteStream);
00065 buildVariable(data.right_encoder, byteStream);
00066 buildVariable(data.left_pwm, byteStream);
00067 buildVariable(data.right_pwm, byteStream);
00068 buildVariable(data.buttons, byteStream);
00069 buildVariable(data.charger, byteStream);
00070 buildVariable(data.battery, byteStream);
00071 buildVariable(data.over_current, byteStream);
00072
00073 return true;
00074 }
00075
00076
00077
00078 }