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_MuxSelect_h
nucho 3:1cf99502f396 2 #define _ROS_SERVICE_MuxSelect_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 MUXSELECT[] = "topic_tools/MuxSelect";
nucho 3:1cf99502f396 12
nucho 3:1cf99502f396 13 class MuxSelectRequest : 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 MUXSELECT; };
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 MuxSelectResponse : public ros::Msg
nucho 3:1cf99502f396 49 {
nucho 3:1cf99502f396 50 public:
nucho 3:1cf99502f396 51 char * prev_topic;
nucho 3:1cf99502f396 52
nucho 3:1cf99502f396 53 virtual int serialize(unsigned char *outbuffer) const
nucho 3:1cf99502f396 54 {
nucho 3:1cf99502f396 55 int offset = 0;
nucho 3:1cf99502f396 56 uint32_t * length_prev_topic = (uint32_t *)(outbuffer + offset);
nucho 3:1cf99502f396 57 *length_prev_topic = strlen( (const char*) this->prev_topic);
nucho 3:1cf99502f396 58 offset += 4;
nucho 3:1cf99502f396 59 memcpy(outbuffer + offset, this->prev_topic, *length_prev_topic);
nucho 3:1cf99502f396 60 offset += *length_prev_topic;
nucho 3:1cf99502f396 61 return offset;
nucho 3:1cf99502f396 62 }
nucho 3:1cf99502f396 63
nucho 3:1cf99502f396 64 virtual int deserialize(unsigned char *inbuffer)
nucho 3:1cf99502f396 65 {
nucho 3:1cf99502f396 66 int offset = 0;
nucho 3:1cf99502f396 67 uint32_t length_prev_topic = *(uint32_t *)(inbuffer + offset);
nucho 3:1cf99502f396 68 offset += 4;
nucho 3:1cf99502f396 69 for(unsigned int k= offset; k< offset+length_prev_topic; ++k){
nucho 3:1cf99502f396 70 inbuffer[k-1]=inbuffer[k];
nucho 3:1cf99502f396 71 }
nucho 3:1cf99502f396 72 inbuffer[offset+length_prev_topic-1]=0;
nucho 3:1cf99502f396 73 this->prev_topic = (char *)(inbuffer + offset-1);
nucho 3:1cf99502f396 74 offset += length_prev_topic;
nucho 3:1cf99502f396 75 return offset;
nucho 3:1cf99502f396 76 }
nucho 3:1cf99502f396 77
nucho 3:1cf99502f396 78 virtual const char * getType(){ return MUXSELECT; };
nucho 3:1cf99502f396 79 virtual const char * getMD5(){ return "3db0a473debdbafea387c9e49358c320"; };
nucho 3:1cf99502f396 80
nucho 3:1cf99502f396 81 };
nucho 3:1cf99502f396 82
nucho 3:1cf99502f396 83 class MuxSelect {
nucho 3:1cf99502f396 84 public:
nucho 3:1cf99502f396 85 typedef MuxSelectRequest Request;
nucho 3:1cf99502f396 86 typedef MuxSelectResponse Response;
nucho 3:1cf99502f396 87 };
nucho 3:1cf99502f396 88
nucho 3:1cf99502f396 89 }
nucho 3:1cf99502f396 90 #endif