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 String.h Source File

String.h

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