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

MuxList.h

00001 #ifndef _ROS_SERVICE_MuxList_h
00002 #define _ROS_SERVICE_MuxList_h
00003 #include <stdint.h>
00004 #include <string.h>
00005 #include <stdlib.h>
00006 #include "ros/msg.h"
00007 
00008 namespace topic_tools
00009 {
00010 
00011 static const char MUXLIST[] = "topic_tools/MuxList";
00012 
00013   class MuxListRequest : public ros::Msg
00014   {
00015     public:
00016 
00017     MuxListRequest()
00018     {
00019     }
00020 
00021     virtual int serialize(unsigned char *outbuffer) const
00022     {
00023       int offset = 0;
00024       return offset;
00025     }
00026 
00027     virtual int deserialize(unsigned char *inbuffer)
00028     {
00029       int offset = 0;
00030      return offset;
00031     }
00032 
00033     const char * getType(){ return MUXLIST; };
00034     const char * getMD5(){ return "d41d8cd98f00b204e9800998ecf8427e"; };
00035 
00036   };
00037 
00038   class MuxListResponse : public ros::Msg
00039   {
00040     public:
00041       uint32_t topics_length;
00042       typedef char* _topics_type;
00043       _topics_type st_topics;
00044       _topics_type * topics;
00045 
00046     MuxListResponse():
00047       topics_length(0), topics(NULL)
00048     {
00049     }
00050 
00051     virtual int serialize(unsigned char *outbuffer) const
00052     {
00053       int offset = 0;
00054       *(outbuffer + offset + 0) = (this->topics_length >> (8 * 0)) & 0xFF;
00055       *(outbuffer + offset + 1) = (this->topics_length >> (8 * 1)) & 0xFF;
00056       *(outbuffer + offset + 2) = (this->topics_length >> (8 * 2)) & 0xFF;
00057       *(outbuffer + offset + 3) = (this->topics_length >> (8 * 3)) & 0xFF;
00058       offset += sizeof(this->topics_length);
00059       for( uint32_t i = 0; i < topics_length; i++){
00060       uint32_t length_topicsi = strlen(this->topics[i]);
00061       varToArr(outbuffer + offset, length_topicsi);
00062       offset += 4;
00063       memcpy(outbuffer + offset, this->topics[i], length_topicsi);
00064       offset += length_topicsi;
00065       }
00066       return offset;
00067     }
00068 
00069     virtual int deserialize(unsigned char *inbuffer)
00070     {
00071       int offset = 0;
00072       uint32_t topics_lengthT = ((uint32_t) (*(inbuffer + offset))); 
00073       topics_lengthT |= ((uint32_t) (*(inbuffer + offset + 1))) << (8 * 1); 
00074       topics_lengthT |= ((uint32_t) (*(inbuffer + offset + 2))) << (8 * 2); 
00075       topics_lengthT |= ((uint32_t) (*(inbuffer + offset + 3))) << (8 * 3); 
00076       offset += sizeof(this->topics_length);
00077       if(topics_lengthT > topics_length)
00078         this->topics = (char**)realloc(this->topics, topics_lengthT * sizeof(char*));
00079       topics_length = topics_lengthT;
00080       for( uint32_t i = 0; i < topics_length; i++){
00081       uint32_t length_st_topics;
00082       arrToVar(length_st_topics, (inbuffer + offset));
00083       offset += 4;
00084       for(unsigned int k= offset; k< offset+length_st_topics; ++k){
00085           inbuffer[k-1]=inbuffer[k];
00086       }
00087       inbuffer[offset+length_st_topics-1]=0;
00088       this->st_topics = (char *)(inbuffer + offset-1);
00089       offset += length_st_topics;
00090         memcpy( &(this->topics[i]), &(this->st_topics), sizeof(char*));
00091       }
00092      return offset;
00093     }
00094 
00095     const char * getType(){ return MUXLIST; };
00096     const char * getMD5(){ return "b0eef9a05d4e829092fc2f2c3c2aad3d"; };
00097 
00098   };
00099 
00100   class MuxList {
00101     public:
00102     typedef MuxListRequest Request;
00103     typedef MuxListResponse Response;
00104   };
00105 
00106 }
00107 #endif