Statistics
| Branch: | Revision:

root / quad2 / arduino / src / ros_lib / rosgraph_msgs / Log.h @ c1426757

History | View | Annotate | Download (5.12 KB)

1
#ifndef _ROS_rosgraph_msgs_Log_h
2
#define _ROS_rosgraph_msgs_Log_h
3

    
4
#include <stdint.h>
5
#include <string.h>
6
#include <stdlib.h>
7
#include "ros/msg.h"
8
#include "std_msgs/Header.h"
9
#include "rosgraph_msgs/byte.h"
10

    
11
namespace rosgraph_msgs
12
{
13

    
14
  class Log : public ros::Msg
15
  {
16
    public:
17
      std_msgs::Header header;
18
      rosgraph_msgs::byte level;
19
      char * name;
20
      char * msg;
21
      char * file;
22
      char * function;
23
      uint32_t line;
24
      uint8_t topics_length;
25
      char* st_topics;
26
      char* * topics;
27
      enum { DEBUG = 1  };
28
      enum { INFO = 2   };
29
      enum { WARN = 4   };
30
      enum { ERROR = 8  };
31
      enum { FATAL = 16  };
32

    
33
    virtual int serialize(unsigned char *outbuffer) const
34
    {
35
      int offset = 0;
36
      offset += this->header.serialize(outbuffer + offset);
37
      offset += this->level.serialize(outbuffer + offset);
38
      uint32_t * length_name = (uint32_t *)(outbuffer + offset);
39
      *length_name = strlen( (const char*) this->name);
40
      offset += 4;
41
      memcpy(outbuffer + offset, this->name, *length_name);
42
      offset += *length_name;
43
      uint32_t * length_msg = (uint32_t *)(outbuffer + offset);
44
      *length_msg = strlen( (const char*) this->msg);
45
      offset += 4;
46
      memcpy(outbuffer + offset, this->msg, *length_msg);
47
      offset += *length_msg;
48
      uint32_t * length_file = (uint32_t *)(outbuffer + offset);
49
      *length_file = strlen( (const char*) this->file);
50
      offset += 4;
51
      memcpy(outbuffer + offset, this->file, *length_file);
52
      offset += *length_file;
53
      uint32_t * length_function = (uint32_t *)(outbuffer + offset);
54
      *length_function = strlen( (const char*) this->function);
55
      offset += 4;
56
      memcpy(outbuffer + offset, this->function, *length_function);
57
      offset += *length_function;
58
      *(outbuffer + offset + 0) = (this->line >> (8 * 0)) & 0xFF;
59
      *(outbuffer + offset + 1) = (this->line >> (8 * 1)) & 0xFF;
60
      *(outbuffer + offset + 2) = (this->line >> (8 * 2)) & 0xFF;
61
      *(outbuffer + offset + 3) = (this->line >> (8 * 3)) & 0xFF;
62
      offset += sizeof(this->line);
63
      *(outbuffer + offset++) = topics_length;
64
      *(outbuffer + offset++) = 0;
65
      *(outbuffer + offset++) = 0;
66
      *(outbuffer + offset++) = 0;
67
      for( uint8_t i = 0; i < topics_length; i++){
68
      uint32_t * length_topicsi = (uint32_t *)(outbuffer + offset);
69
      *length_topicsi = strlen( (const char*) this->topics[i]);
70
      offset += 4;
71
      memcpy(outbuffer + offset, this->topics[i], *length_topicsi);
72
      offset += *length_topicsi;
73
      }
74
      return offset;
75
    }
76

    
77
    virtual int deserialize(unsigned char *inbuffer)
78
    {
79
      int offset = 0;
80
      offset += this->header.deserialize(inbuffer + offset);
81
      offset += this->level.deserialize(inbuffer + offset);
82
      uint32_t length_name = *(uint32_t *)(inbuffer + offset);
83
      offset += 4;
84
      for(unsigned int k= offset; k< offset+length_name; ++k){
85
          inbuffer[k-1]=inbuffer[k];
86
      }
87
      inbuffer[offset+length_name-1]=0;
88
      this->name = (char *)(inbuffer + offset-1);
89
      offset += length_name;
90
      uint32_t length_msg = *(uint32_t *)(inbuffer + offset);
91
      offset += 4;
92
      for(unsigned int k= offset; k< offset+length_msg; ++k){
93
          inbuffer[k-1]=inbuffer[k];
94
      }
95
      inbuffer[offset+length_msg-1]=0;
96
      this->msg = (char *)(inbuffer + offset-1);
97
      offset += length_msg;
98
      uint32_t length_file = *(uint32_t *)(inbuffer + offset);
99
      offset += 4;
100
      for(unsigned int k= offset; k< offset+length_file; ++k){
101
          inbuffer[k-1]=inbuffer[k];
102
      }
103
      inbuffer[offset+length_file-1]=0;
104
      this->file = (char *)(inbuffer + offset-1);
105
      offset += length_file;
106
      uint32_t length_function = *(uint32_t *)(inbuffer + offset);
107
      offset += 4;
108
      for(unsigned int k= offset; k< offset+length_function; ++k){
109
          inbuffer[k-1]=inbuffer[k];
110
      }
111
      inbuffer[offset+length_function-1]=0;
112
      this->function = (char *)(inbuffer + offset-1);
113
      offset += length_function;
114
      this->line |= ((uint32_t) (*(inbuffer + offset + 0))) << (8 * 0);
115
      this->line |= ((uint32_t) (*(inbuffer + offset + 1))) << (8 * 1);
116
      this->line |= ((uint32_t) (*(inbuffer + offset + 2))) << (8 * 2);
117
      this->line |= ((uint32_t) (*(inbuffer + offset + 3))) << (8 * 3);
118
      offset += sizeof(this->line);
119
      uint8_t topics_lengthT = *(inbuffer + offset++);
120
      if(topics_lengthT > topics_length)
121
        this->topics = (char**)realloc(this->topics, topics_lengthT * sizeof(char*));
122
      offset += 3;
123
      topics_length = topics_lengthT;
124
      for( uint8_t i = 0; i < topics_length; i++){
125
      uint32_t length_st_topics = *(uint32_t *)(inbuffer + offset);
126
      offset += 4;
127
      for(unsigned int k= offset; k< offset+length_st_topics; ++k){
128
          inbuffer[k-1]=inbuffer[k];
129
      }
130
      inbuffer[offset+length_st_topics-1]=0;
131
      this->st_topics = (char *)(inbuffer + offset-1);
132
      offset += length_st_topics;
133
        memcpy( &(this->topics[i]), &(this->st_topics), sizeof(char*));
134
      }
135
     return offset;
136
    }
137

    
138
    const char * getType(){ return "rosgraph_msgs/Log"; };
139
    const char * getMD5(){ return "acffd30cd6b6de30f120938c17c593fb"; };
140

    
141
  };
142

    
143
}
144
#endif