Log.h
Go to the documentation of this file.
00001 #ifndef ros_rosserial_msgs_Log_h
00002 #define ros_rosserial_msgs_Log_h
00003 
00004 #include <stdint.h>
00005 #include <string.h>
00006 #include <stdlib.h>
00007 #include "../ros/msg.h"
00008 
00009 namespace rosserial_msgs
00010 {
00011 
00012   class Log : public ros::Msg
00013   {
00014     public:
00015       unsigned char level;
00016       char * msg;
00017       enum { DEBUG = 0 };
00018       enum { INFO = 1 };
00019       enum { WARN = 2 };
00020       enum { ERROR = 3 };
00021       enum { FATAL = 4 };
00022 
00023     virtual int serialize(unsigned char *outbuffer)
00024     {
00025       int offset = 0;
00026       union {
00027         unsigned char real;
00028         unsigned char base;
00029       } u_level;
00030       u_level.real = this->level;
00031       *(outbuffer + offset + 0) = (u_level.base >> (8 * 0)) & 0xFF;
00032       offset += sizeof(this->level);
00033       long * length_msg = (long *)(outbuffer + offset);
00034       *length_msg = strlen( (const char*) this->msg);
00035       offset += 4;
00036       memcpy(outbuffer + offset, this->msg, *length_msg);
00037       offset += *length_msg;
00038       return offset;
00039     }
00040 
00041     virtual int deserialize(unsigned char *inbuffer)
00042     {
00043       int offset = 0;
00044       union {
00045         unsigned char real;
00046         unsigned char base;
00047       } u_level;
00048       u_level.base = 0;
00049       u_level.base |= ((typeof(u_level.base)) (*(inbuffer + offset + 0))) << (8 * 0);
00050       this->level = u_level.real;
00051       offset += sizeof(this->level);
00052       uint32_t length_msg = *(uint32_t *)(inbuffer + offset);
00053       offset += 4;
00054       for(unsigned int k= offset; k< offset+length_msg; ++k){
00055           inbuffer[k-1]=inbuffer[k];
00056            }
00057       inbuffer[offset+length_msg-1]=0;
00058       this->msg = (char *)(inbuffer + offset-1);
00059       offset += length_msg;
00060      return offset;
00061     }
00062 
00063     const char * getType(){ return "rosserial_msgs/Log"; };
00064 
00065   };
00066 
00067 }
00068 #endif
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Defines


traxbot_robot
Author(s): André Gonçalves Araújo
autogenerated on Fri Feb 1 2013 13:21:12