Statistics
| Branch: | Revision:

root / quad2 / arduino / src / ros_lib / rosserial_msgs / TopicInfo.h @ c1426757

History | View | Annotate | Download (4.04 KB)

1
#ifndef _ROS_rosserial_msgs_TopicInfo_h
2
#define _ROS_rosserial_msgs_TopicInfo_h
3

    
4
#include <stdint.h>
5
#include <string.h>
6
#include <stdlib.h>
7
#include "ros/msg.h"
8

    
9
namespace rosserial_msgs
10
{
11

    
12
  class TopicInfo : public ros::Msg
13
  {
14
    public:
15
      uint16_t topic_id;
16
      char * topic_name;
17
      char * message_type;
18
      char * md5sum;
19
      int32_t buffer_size;
20
      enum { ID_PUBLISHER = 0 };
21
      enum { ID_SUBSCRIBER = 1 };
22
      enum { ID_SERVICE_SERVER = 2 };
23
      enum { ID_SERVICE_CLIENT = 4 };
24
      enum { ID_PARAMETER_REQUEST = 6 };
25
      enum { ID_LOG = 7 };
26
      enum { ID_TIME = 10 };
27

    
28
    virtual int serialize(unsigned char *outbuffer) const
29
    {
30
      int offset = 0;
31
      *(outbuffer + offset + 0) = (this->topic_id >> (8 * 0)) & 0xFF;
32
      *(outbuffer + offset + 1) = (this->topic_id >> (8 * 1)) & 0xFF;
33
      offset += sizeof(this->topic_id);
34
      uint32_t * length_topic_name = (uint32_t *)(outbuffer + offset);
35
      *length_topic_name = strlen( (const char*) this->topic_name);
36
      offset += 4;
37
      memcpy(outbuffer + offset, this->topic_name, *length_topic_name);
38
      offset += *length_topic_name;
39
      uint32_t * length_message_type = (uint32_t *)(outbuffer + offset);
40
      *length_message_type = strlen( (const char*) this->message_type);
41
      offset += 4;
42
      memcpy(outbuffer + offset, this->message_type, *length_message_type);
43
      offset += *length_message_type;
44
      uint32_t * length_md5sum = (uint32_t *)(outbuffer + offset);
45
      *length_md5sum = strlen( (const char*) this->md5sum);
46
      offset += 4;
47
      memcpy(outbuffer + offset, this->md5sum, *length_md5sum);
48
      offset += *length_md5sum;
49
      union {
50
        int32_t real;
51
        uint32_t base;
52
      } u_buffer_size;
53
      u_buffer_size.real = this->buffer_size;
54
      *(outbuffer + offset + 0) = (u_buffer_size.base >> (8 * 0)) & 0xFF;
55
      *(outbuffer + offset + 1) = (u_buffer_size.base >> (8 * 1)) & 0xFF;
56
      *(outbuffer + offset + 2) = (u_buffer_size.base >> (8 * 2)) & 0xFF;
57
      *(outbuffer + offset + 3) = (u_buffer_size.base >> (8 * 3)) & 0xFF;
58
      offset += sizeof(this->buffer_size);
59
      return offset;
60
    }
61

    
62
    virtual int deserialize(unsigned char *inbuffer)
63
    {
64
      int offset = 0;
65
      this->topic_id |= ((uint16_t) (*(inbuffer + offset + 0))) << (8 * 0);
66
      this->topic_id |= ((uint16_t) (*(inbuffer + offset + 1))) << (8 * 1);
67
      offset += sizeof(this->topic_id);
68
      uint32_t length_topic_name = *(uint32_t *)(inbuffer + offset);
69
      offset += 4;
70
      for(unsigned int k= offset; k< offset+length_topic_name; ++k){
71
          inbuffer[k-1]=inbuffer[k];
72
      }
73
      inbuffer[offset+length_topic_name-1]=0;
74
      this->topic_name = (char *)(inbuffer + offset-1);
75
      offset += length_topic_name;
76
      uint32_t length_message_type = *(uint32_t *)(inbuffer + offset);
77
      offset += 4;
78
      for(unsigned int k= offset; k< offset+length_message_type; ++k){
79
          inbuffer[k-1]=inbuffer[k];
80
      }
81
      inbuffer[offset+length_message_type-1]=0;
82
      this->message_type = (char *)(inbuffer + offset-1);
83
      offset += length_message_type;
84
      uint32_t length_md5sum = *(uint32_t *)(inbuffer + offset);
85
      offset += 4;
86
      for(unsigned int k= offset; k< offset+length_md5sum; ++k){
87
          inbuffer[k-1]=inbuffer[k];
88
      }
89
      inbuffer[offset+length_md5sum-1]=0;
90
      this->md5sum = (char *)(inbuffer + offset-1);
91
      offset += length_md5sum;
92
      union {
93
        int32_t real;
94
        uint32_t base;
95
      } u_buffer_size;
96
      u_buffer_size.base = 0;
97
      u_buffer_size.base |= ((uint32_t) (*(inbuffer + offset + 0))) << (8 * 0);
98
      u_buffer_size.base |= ((uint32_t) (*(inbuffer + offset + 1))) << (8 * 1);
99
      u_buffer_size.base |= ((uint32_t) (*(inbuffer + offset + 2))) << (8 * 2);
100
      u_buffer_size.base |= ((uint32_t) (*(inbuffer + offset + 3))) << (8 * 3);
101
      this->buffer_size = u_buffer_size.real;
102
      offset += sizeof(this->buffer_size);
103
     return offset;
104
    }
105

    
106
    const char * getType(){ return "rosserial_msgs/TopicInfo"; };
107
    const char * getMD5(){ return "63aa5e8f1bdd6f35c69fe1a1b9d28e9f"; };
108

    
109
  };
110

    
111
}
112
#endif