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

Dependencies:   rosserial_mbed_lib mbed Servo

Committer:
nucho
Date:
Sat Nov 12 23:53:04 2011 +0000
Revision:
3:dff241b66f84
Parent:
0:06fc856e99ca
This program supported the revision of 167 of rosserial.

Who changed what in which revision?

UserRevisionLine numberNew contents of line
nucho 3:dff241b66f84 1 #ifndef _ROS_std_msgs_String_h
nucho 3:dff241b66f84 2 #define _ROS_std_msgs_String_h
nucho 3:dff241b66f84 3
nucho 3:dff241b66f84 4 #include <stdint.h>
nucho 3:dff241b66f84 5 #include <string.h>
nucho 3:dff241b66f84 6 #include <stdlib.h>
nucho 3:dff241b66f84 7 #include "ros/msg.h"
nucho 3:dff241b66f84 8
nucho 3:dff241b66f84 9 namespace std_msgs
nucho 3:dff241b66f84 10 {
nucho 3:dff241b66f84 11
nucho 3:dff241b66f84 12 class String : public ros::Msg
nucho 3:dff241b66f84 13 {
nucho 3:dff241b66f84 14 public:
nucho 3:dff241b66f84 15 char * data;
nucho 3:dff241b66f84 16
nucho 3:dff241b66f84 17 virtual int serialize(unsigned char *outbuffer) const
nucho 3:dff241b66f84 18 {
nucho 3:dff241b66f84 19 int offset = 0;
nucho 3:dff241b66f84 20 uint32_t * length_data = (uint32_t *)(outbuffer + offset);
nucho 3:dff241b66f84 21 *length_data = strlen( (const char*) this->data);
nucho 3:dff241b66f84 22 offset += 4;
nucho 3:dff241b66f84 23 memcpy(outbuffer + offset, this->data, *length_data);
nucho 3:dff241b66f84 24 offset += *length_data;
nucho 3:dff241b66f84 25 return offset;
nucho 3:dff241b66f84 26 }
nucho 3:dff241b66f84 27
nucho 3:dff241b66f84 28 virtual int deserialize(unsigned char *inbuffer)
nucho 3:dff241b66f84 29 {
nucho 3:dff241b66f84 30 int offset = 0;
nucho 3:dff241b66f84 31 uint32_t length_data = *(uint32_t *)(inbuffer + offset);
nucho 3:dff241b66f84 32 offset += 4;
nucho 3:dff241b66f84 33 for(unsigned int k= offset; k< offset+length_data; ++k){
nucho 3:dff241b66f84 34 inbuffer[k-1]=inbuffer[k];
nucho 3:dff241b66f84 35 }
nucho 3:dff241b66f84 36 inbuffer[offset+length_data-1]=0;
nucho 3:dff241b66f84 37 this->data = (char *)(inbuffer + offset-1);
nucho 3:dff241b66f84 38 offset += length_data;
nucho 3:dff241b66f84 39 return offset;
nucho 3:dff241b66f84 40 }
nucho 3:dff241b66f84 41
nucho 3:dff241b66f84 42 virtual const char * getType(){ return "std_msgs/String"; };
nucho 3:dff241b66f84 43 virtual const char * getMD5(){ return "992ce8a1687cec8c8bd883ec73ca41d1"; };
nucho 3:dff241b66f84 44
nucho 3:dff241b66f84 45 };
nucho 3:dff241b66f84 46
nucho 3:dff241b66f84 47 }
nucho 0:06fc856e99ca 48 #endif