Working towards recieving twists

Dependencies:   BufferedSerial

Fork of ros_lib_kinetic by Gary Servin

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       typedef const char* _data_type;
00016       _data_type data;
00017 
00018     String():
00019       data("")
00020     {
00021     }
00022 
00023     virtual int serialize(unsigned char *outbuffer) const
00024     {
00025       int offset = 0;
00026       uint32_t length_data = strlen(this->data);
00027       varToArr(outbuffer + offset, length_data);
00028       offset += 4;
00029       memcpy(outbuffer + offset, this->data, length_data);
00030       offset += length_data;
00031       return offset;
00032     }
00033 
00034     virtual int deserialize(unsigned char *inbuffer)
00035     {
00036       int offset = 0;
00037       uint32_t length_data;
00038       arrToVar(length_data, (inbuffer + offset));
00039       offset += 4;
00040       for(unsigned int k= offset; k< offset+length_data; ++k){
00041           inbuffer[k-1]=inbuffer[k];
00042       }
00043       inbuffer[offset+length_data-1]=0;
00044       this->data = (char *)(inbuffer + offset-1);
00045       offset += length_data;
00046      return offset;
00047     }
00048 
00049     const char * getType(){ return "std_msgs/String"; };
00050     const char * getMD5(){ return "992ce8a1687cec8c8bd883ec73ca41d1"; };
00051 
00052   };
00053 
00054 }
00055 #endif