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

TopicInfo.h

00001 #ifndef _ROS_rosserial_msgs_TopicInfo_h
00002 #define _ROS_rosserial_msgs_TopicInfo_h
00003 
00004 #include <stdint.h>
00005 #include <string.h>
00006 #include <stdlib.h>
00007 #include "ros/msg.h"
00008 
00009 namespace rosserial_msgs
00010 {
00011 
00012   class TopicInfo : public ros::Msg
00013   {
00014     public:
00015       typedef uint16_t _topic_id_type;
00016       _topic_id_type topic_id;
00017       typedef const char* _topic_name_type;
00018       _topic_name_type topic_name;
00019       typedef const char* _message_type_type;
00020       _message_type_type message_type;
00021       typedef const char* _md5sum_type;
00022       _md5sum_type md5sum;
00023       typedef int32_t _buffer_size_type;
00024       _buffer_size_type buffer_size;
00025       enum { ID_PUBLISHER = 0 };
00026       enum { ID_SUBSCRIBER = 1 };
00027       enum { ID_SERVICE_SERVER = 2 };
00028       enum { ID_SERVICE_CLIENT = 4 };
00029       enum { ID_PARAMETER_REQUEST = 6 };
00030       enum { ID_LOG = 7 };
00031       enum { ID_TIME = 10 };
00032       enum { ID_TX_STOP = 11 };
00033 
00034     TopicInfo():
00035       topic_id(0),
00036       topic_name(""),
00037       message_type(""),
00038       md5sum(""),
00039       buffer_size(0)
00040     {
00041     }
00042 
00043     virtual int serialize(unsigned char *outbuffer) const
00044     {
00045       int offset = 0;
00046       *(outbuffer + offset + 0) = (this->topic_id >> (8 * 0)) & 0xFF;
00047       *(outbuffer + offset + 1) = (this->topic_id >> (8 * 1)) & 0xFF;
00048       offset += sizeof(this->topic_id);
00049       uint32_t length_topic_name = strlen(this->topic_name);
00050       varToArr(outbuffer + offset, length_topic_name);
00051       offset += 4;
00052       memcpy(outbuffer + offset, this->topic_name, length_topic_name);
00053       offset += length_topic_name;
00054       uint32_t length_message_type = strlen(this->message_type);
00055       varToArr(outbuffer + offset, length_message_type);
00056       offset += 4;
00057       memcpy(outbuffer + offset, this->message_type, length_message_type);
00058       offset += length_message_type;
00059       uint32_t length_md5sum = strlen(this->md5sum);
00060       varToArr(outbuffer + offset, length_md5sum);
00061       offset += 4;
00062       memcpy(outbuffer + offset, this->md5sum, length_md5sum);
00063       offset += length_md5sum;
00064       union {
00065         int32_t real;
00066         uint32_t base;
00067       } u_buffer_size;
00068       u_buffer_size.real = this->buffer_size;
00069       *(outbuffer + offset + 0) = (u_buffer_size.base >> (8 * 0)) & 0xFF;
00070       *(outbuffer + offset + 1) = (u_buffer_size.base >> (8 * 1)) & 0xFF;
00071       *(outbuffer + offset + 2) = (u_buffer_size.base >> (8 * 2)) & 0xFF;
00072       *(outbuffer + offset + 3) = (u_buffer_size.base >> (8 * 3)) & 0xFF;
00073       offset += sizeof(this->buffer_size);
00074       return offset;
00075     }
00076 
00077     virtual int deserialize(unsigned char *inbuffer)
00078     {
00079       int offset = 0;
00080       this->topic_id =  ((uint16_t) (*(inbuffer + offset)));
00081       this->topic_id |= ((uint16_t) (*(inbuffer + offset + 1))) << (8 * 1);
00082       offset += sizeof(this->topic_id);
00083       uint32_t length_topic_name;
00084       arrToVar(length_topic_name, (inbuffer + offset));
00085       offset += 4;
00086       for(unsigned int k= offset; k< offset+length_topic_name; ++k){
00087           inbuffer[k-1]=inbuffer[k];
00088       }
00089       inbuffer[offset+length_topic_name-1]=0;
00090       this->topic_name = (char *)(inbuffer + offset-1);
00091       offset += length_topic_name;
00092       uint32_t length_message_type;
00093       arrToVar(length_message_type, (inbuffer + offset));
00094       offset += 4;
00095       for(unsigned int k= offset; k< offset+length_message_type; ++k){
00096           inbuffer[k-1]=inbuffer[k];
00097       }
00098       inbuffer[offset+length_message_type-1]=0;
00099       this->message_type = (char *)(inbuffer + offset-1);
00100       offset += length_message_type;
00101       uint32_t length_md5sum;
00102       arrToVar(length_md5sum, (inbuffer + offset));
00103       offset += 4;
00104       for(unsigned int k= offset; k< offset+length_md5sum; ++k){
00105           inbuffer[k-1]=inbuffer[k];
00106       }
00107       inbuffer[offset+length_md5sum-1]=0;
00108       this->md5sum = (char *)(inbuffer + offset-1);
00109       offset += length_md5sum;
00110       union {
00111         int32_t real;
00112         uint32_t base;
00113       } u_buffer_size;
00114       u_buffer_size.base = 0;
00115       u_buffer_size.base |= ((uint32_t) (*(inbuffer + offset + 0))) << (8 * 0);
00116       u_buffer_size.base |= ((uint32_t) (*(inbuffer + offset + 1))) << (8 * 1);
00117       u_buffer_size.base |= ((uint32_t) (*(inbuffer + offset + 2))) << (8 * 2);
00118       u_buffer_size.base |= ((uint32_t) (*(inbuffer + offset + 3))) << (8 * 3);
00119       this->buffer_size = u_buffer_size.real;
00120       offset += sizeof(this->buffer_size);
00121      return offset;
00122     }
00123 
00124     const char * getType(){ return "rosserial_msgs/TopicInfo"; };
00125     const char * getMD5(){ return "0ad51f88fc44892f8c10684077646005"; };
00126 
00127   };
00128 
00129 }
00130 #endif