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

Committer:
nucho
Date:
Wed Feb 29 23:00:21 2012 +0000
Revision:
4:684f39d0c346
Parent:
3:1cf99502f396

        

Who changed what in which revision?

UserRevisionLine numberNew contents of line
nucho 3:1cf99502f396 1 #ifndef _ROS_SERVICE_MuxAdd_h
nucho 3:1cf99502f396 2 #define _ROS_SERVICE_MuxAdd_h
nucho 3:1cf99502f396 3 #include <stdint.h>
nucho 3:1cf99502f396 4 #include <string.h>
nucho 3:1cf99502f396 5 #include <stdlib.h>
nucho 3:1cf99502f396 6 #include "ros/msg.h"
nucho 3:1cf99502f396 7
nucho 3:1cf99502f396 8 namespace topic_tools
nucho 3:1cf99502f396 9 {
nucho 3:1cf99502f396 10
nucho 3:1cf99502f396 11 static const char MUXADD[] = "topic_tools/MuxAdd";
nucho 3:1cf99502f396 12
nucho 3:1cf99502f396 13 class MuxAddRequest : public ros::Msg
nucho 3:1cf99502f396 14 {
nucho 3:1cf99502f396 15 public:
nucho 3:1cf99502f396 16 char * topic;
nucho 3:1cf99502f396 17
nucho 3:1cf99502f396 18 virtual int serialize(unsigned char *outbuffer) const
nucho 3:1cf99502f396 19 {
nucho 3:1cf99502f396 20 int offset = 0;
nucho 3:1cf99502f396 21 uint32_t * length_topic = (uint32_t *)(outbuffer + offset);
nucho 3:1cf99502f396 22 *length_topic = strlen( (const char*) this->topic);
nucho 3:1cf99502f396 23 offset += 4;
nucho 3:1cf99502f396 24 memcpy(outbuffer + offset, this->topic, *length_topic);
nucho 3:1cf99502f396 25 offset += *length_topic;
nucho 3:1cf99502f396 26 return offset;
nucho 3:1cf99502f396 27 }
nucho 3:1cf99502f396 28
nucho 3:1cf99502f396 29 virtual int deserialize(unsigned char *inbuffer)
nucho 3:1cf99502f396 30 {
nucho 3:1cf99502f396 31 int offset = 0;
nucho 3:1cf99502f396 32 uint32_t length_topic = *(uint32_t *)(inbuffer + offset);
nucho 3:1cf99502f396 33 offset += 4;
nucho 3:1cf99502f396 34 for(unsigned int k= offset; k< offset+length_topic; ++k){
nucho 3:1cf99502f396 35 inbuffer[k-1]=inbuffer[k];
nucho 3:1cf99502f396 36 }
nucho 3:1cf99502f396 37 inbuffer[offset+length_topic-1]=0;
nucho 3:1cf99502f396 38 this->topic = (char *)(inbuffer + offset-1);
nucho 3:1cf99502f396 39 offset += length_topic;
nucho 3:1cf99502f396 40 return offset;
nucho 3:1cf99502f396 41 }
nucho 3:1cf99502f396 42
nucho 3:1cf99502f396 43 virtual const char * getType(){ return MUXADD; };
nucho 3:1cf99502f396 44 virtual const char * getMD5(){ return "d8f94bae31b356b24d0427f80426d0c3"; };
nucho 3:1cf99502f396 45
nucho 3:1cf99502f396 46 };
nucho 3:1cf99502f396 47
nucho 3:1cf99502f396 48 class MuxAddResponse : public ros::Msg
nucho 3:1cf99502f396 49 {
nucho 3:1cf99502f396 50 public:
nucho 3:1cf99502f396 51
nucho 3:1cf99502f396 52 virtual int serialize(unsigned char *outbuffer) const
nucho 3:1cf99502f396 53 {
nucho 3:1cf99502f396 54 int offset = 0;
nucho 3:1cf99502f396 55 return offset;
nucho 3:1cf99502f396 56 }
nucho 3:1cf99502f396 57
nucho 3:1cf99502f396 58 virtual int deserialize(unsigned char *inbuffer)
nucho 3:1cf99502f396 59 {
nucho 3:1cf99502f396 60 int offset = 0;
nucho 3:1cf99502f396 61 return offset;
nucho 3:1cf99502f396 62 }
nucho 3:1cf99502f396 63
nucho 3:1cf99502f396 64 virtual const char * getType(){ return MUXADD; };
nucho 3:1cf99502f396 65 virtual const char * getMD5(){ return "d41d8cd98f00b204e9800998ecf8427e"; };
nucho 3:1cf99502f396 66
nucho 3:1cf99502f396 67 };
nucho 3:1cf99502f396 68
nucho 3:1cf99502f396 69 class MuxAdd {
nucho 3:1cf99502f396 70 public:
nucho 3:1cf99502f396 71 typedef MuxAddRequest Request;
nucho 3:1cf99502f396 72 typedef MuxAddResponse Response;
nucho 3:1cf99502f396 73 };
nucho 3:1cf99502f396 74
nucho 3:1cf99502f396 75 }
nucho 3:1cf99502f396 76 #endif