ROS Serial library for Mbed platforms for ROS Indigo Igloo. Check http://wiki.ros.org/rosserial_mbed/ for more information

Dependencies:   BufferedSerial

Dependents:   rosserial_mbed_hello_world_publisher rtos_base_control rosserial_mbed_F64MA ROS-RTOS ... more

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers Log.h Source File

Log.h

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       uint8_t level;
00016       const char* msg;
00017       enum { ROSDEBUG = 0 };
00018       enum { INFO = 1 };
00019       enum { WARN = 2 };
00020       enum { ERROR = 3 };
00021       enum { FATAL = 4 };
00022 
00023     Log():
00024       level(0),
00025       msg("")
00026     {
00027     }
00028 
00029     virtual int serialize(unsigned char *outbuffer) const
00030     {
00031       int offset = 0;
00032       *(outbuffer + offset + 0) = (this->level >> (8 * 0)) & 0xFF;
00033       offset += sizeof(this->level);
00034       uint32_t length_msg = strlen(this->msg);
00035       memcpy(outbuffer + offset, &length_msg, sizeof(uint32_t));
00036       offset += 4;
00037       memcpy(outbuffer + offset, this->msg, length_msg);
00038       offset += length_msg;
00039       return offset;
00040     }
00041 
00042     virtual int deserialize(unsigned char *inbuffer)
00043     {
00044       int offset = 0;
00045       this->level =  ((uint8_t) (*(inbuffer + offset)));
00046       offset += sizeof(this->level);
00047       uint32_t length_msg;
00048       memcpy(&length_msg, (inbuffer + offset), sizeof(uint32_t));
00049       offset += 4;
00050       for(unsigned int k= offset; k< offset+length_msg; ++k){
00051           inbuffer[k-1]=inbuffer[k];
00052       }
00053       inbuffer[offset+length_msg-1]=0;
00054       this->msg = (char *)(inbuffer + offset-1);
00055       offset += length_msg;
00056      return offset;
00057     }
00058 
00059     const char * getType(){ return "rosserial_msgs/Log"; };
00060     const char * getMD5(){ return "11abd731c25933261cd6183bd12d6295"; };
00061 
00062   };
00063 
00064 }
00065 #endif