modify for Hydro version

Dependencies:   MODSERIAL

Fork of rosserial_mbed_lib by nucho

Committer:
jjzak
Date:
Sat Oct 26 15:38:35 2013 +0000
Revision:
5:8cd48977ec68
Parent:
3:1cf99502f396
modify for Hydro version

Who changed what in which revision?

UserRevisionLine numberNew contents of line
nucho 3:1cf99502f396 1 #ifndef _ROS_rosserial_msgs_Log_h
nucho 3:1cf99502f396 2 #define _ROS_rosserial_msgs_Log_h
nucho 0:77afd7560544 3
nucho 0:77afd7560544 4 #include <stdint.h>
nucho 0:77afd7560544 5 #include <string.h>
nucho 0:77afd7560544 6 #include <stdlib.h>
nucho 3:1cf99502f396 7 #include "ros/msg.h"
nucho 0:77afd7560544 8
nucho 0:77afd7560544 9 namespace rosserial_msgs
nucho 0:77afd7560544 10 {
nucho 0:77afd7560544 11
nucho 0:77afd7560544 12 class Log : public ros::Msg
nucho 0:77afd7560544 13 {
nucho 0:77afd7560544 14 public:
nucho 3:1cf99502f396 15 uint8_t level;
nucho 0:77afd7560544 16 char * msg;
jjzak 5:8cd48977ec68 17 enum { ROSDEBUG = 0 };
nucho 0:77afd7560544 18 enum { INFO = 1 };
nucho 0:77afd7560544 19 enum { WARN = 2 };
nucho 0:77afd7560544 20 enum { ERROR = 3 };
nucho 0:77afd7560544 21 enum { FATAL = 4 };
nucho 0:77afd7560544 22
nucho 3:1cf99502f396 23 virtual int serialize(unsigned char *outbuffer) const
nucho 0:77afd7560544 24 {
nucho 0:77afd7560544 25 int offset = 0;
nucho 3:1cf99502f396 26 *(outbuffer + offset + 0) = (this->level >> (8 * 0)) & 0xFF;
nucho 0:77afd7560544 27 offset += sizeof(this->level);
jjzak 5:8cd48977ec68 28 uint32_t length_msg = strlen( (const char*) this->msg);
jjzak 5:8cd48977ec68 29 memcpy(outbuffer + offset, &length_msg, sizeof(uint32_t));
nucho 0:77afd7560544 30 offset += 4;
jjzak 5:8cd48977ec68 31 memcpy(outbuffer + offset, this->msg, length_msg);
jjzak 5:8cd48977ec68 32 offset += length_msg;
nucho 0:77afd7560544 33 return offset;
nucho 0:77afd7560544 34 }
nucho 0:77afd7560544 35
nucho 0:77afd7560544 36 virtual int deserialize(unsigned char *inbuffer)
nucho 0:77afd7560544 37 {
nucho 0:77afd7560544 38 int offset = 0;
jjzak 5:8cd48977ec68 39 this->level = ((uint8_t) (*(inbuffer + offset)));
nucho 0:77afd7560544 40 offset += sizeof(this->level);
jjzak 5:8cd48977ec68 41 uint32_t length_msg;
jjzak 5:8cd48977ec68 42 memcpy(&length_msg, (inbuffer + offset), sizeof(uint32_t));
nucho 0:77afd7560544 43 offset += 4;
nucho 0:77afd7560544 44 for(unsigned int k= offset; k< offset+length_msg; ++k){
nucho 0:77afd7560544 45 inbuffer[k-1]=inbuffer[k];
nucho 3:1cf99502f396 46 }
nucho 0:77afd7560544 47 inbuffer[offset+length_msg-1]=0;
nucho 0:77afd7560544 48 this->msg = (char *)(inbuffer + offset-1);
nucho 0:77afd7560544 49 offset += length_msg;
nucho 0:77afd7560544 50 return offset;
nucho 0:77afd7560544 51 }
nucho 0:77afd7560544 52
nucho 0:77afd7560544 53 virtual const char * getType(){ return "rosserial_msgs/Log"; };
jjzak 5:8cd48977ec68 54 virtual const char * getMD5(){ return "11abd731c25933261cd6183bd12d6295"; };
nucho 0:77afd7560544 55
nucho 0:77afd7560544 56 };
nucho 0:77afd7560544 57
nucho 0:77afd7560544 58 }
jjzak 5:8cd48977ec68 59 #endif