This program is porting rosserial_arduino for mbed http://www.ros.org/wiki/rosserial_arduino This program supported the revision of 169 of rosserial.

Dependencies:  

Dependents:   rosserial_mbed robot_S2

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers Logger.h Source File

Logger.h

00001 #ifndef _ROS_roscpp_Logger_h
00002 #define _ROS_roscpp_Logger_h
00003 
00004 #include <stdint.h>
00005 #include <string.h>
00006 #include <stdlib.h>
00007 #include "ros/msg.h"
00008 
00009 namespace roscpp
00010 {
00011 
00012   class Logger : public ros::Msg
00013   {
00014     public:
00015       char * name;
00016       char * level;
00017 
00018     virtual int serialize(unsigned char *outbuffer) const
00019     {
00020       int offset = 0;
00021       uint32_t * length_name = (uint32_t *)(outbuffer + offset);
00022       *length_name = strlen( (const char*) this->name);
00023       offset += 4;
00024       memcpy(outbuffer + offset, this->name, *length_name);
00025       offset += *length_name;
00026       uint32_t * length_level = (uint32_t *)(outbuffer + offset);
00027       *length_level = strlen( (const char*) this->level);
00028       offset += 4;
00029       memcpy(outbuffer + offset, this->level, *length_level);
00030       offset += *length_level;
00031       return offset;
00032     }
00033 
00034     virtual int deserialize(unsigned char *inbuffer)
00035     {
00036       int offset = 0;
00037       uint32_t length_name = *(uint32_t *)(inbuffer + offset);
00038       offset += 4;
00039       for(unsigned int k= offset; k< offset+length_name; ++k){
00040           inbuffer[k-1]=inbuffer[k];
00041       }
00042       inbuffer[offset+length_name-1]=0;
00043       this->name = (char *)(inbuffer + offset-1);
00044       offset += length_name;
00045       uint32_t length_level = *(uint32_t *)(inbuffer + offset);
00046       offset += 4;
00047       for(unsigned int k= offset; k< offset+length_level; ++k){
00048           inbuffer[k-1]=inbuffer[k];
00049       }
00050       inbuffer[offset+length_level-1]=0;
00051       this->level = (char *)(inbuffer + offset-1);
00052       offset += length_level;
00053      return offset;
00054     }
00055 
00056     virtual const char * getType(){ return "roscpp/Logger"; };
00057     virtual const char * getMD5(){ return "a6069a2ff40db7bd32143dd66e1f408e"; };
00058 
00059   };
00060 
00061 }
00062 #endif