RequestParam.h
Go to the documentation of this file.
1 #ifndef _ROS_SERVICE_RequestParam_h
2 #define _ROS_SERVICE_RequestParam_h
3 #include <stdint.h>
4 #include <string.h>
5 #include <stdlib.h>
6 #include "ros/msg.h"
7 
8 namespace rosabridge_msgs
9 {
10 
11 static const char REQUESTPARAM[] = "rosabridge_msgs/RequestParam";
12 
14  {
15  public:
16  const char* name;
17 
18  virtual int serialize(unsigned char *outbuffer) const
19  {
20  int offset = 0;
21  uint32_t length_name = strlen(this->name);
22  memcpy(outbuffer + offset, &length_name, sizeof(uint32_t));
23  offset += 4;
24  memcpy(outbuffer + offset, this->name, length_name);
25  offset += length_name;
26  return offset;
27  }
28 
29  virtual int deserialize(unsigned char *inbuffer)
30  {
31  int offset = 0;
32  uint32_t length_name;
33  memcpy(&length_name, (inbuffer + offset), sizeof(uint32_t));
34  offset += 4;
35  for(unsigned int k= offset; k< offset+length_name; ++k){
36  inbuffer[k-1]=inbuffer[k];
37  }
38  inbuffer[offset+length_name-1]=0;
39  this->name = (char *)(inbuffer + offset-1);
40  offset += length_name;
41  return offset;
42  }
43 
44  const char * getType(){ return REQUESTPARAM; };
45  const char * getMD5(){ return "c1f3d28f1b044c871e6eff2e9fc3c667"; };
46 
47  };
48 
50  {
51  public:
52  uint8_t ints_length;
53  int32_t st_ints;
54  int32_t * ints;
55  uint8_t floats_length;
56  float st_floats;
57  float * floats;
58  uint8_t strings_length;
59  char* st_strings;
60  char* * strings;
61 
62  virtual int serialize(unsigned char *outbuffer) const
63  {
64  int offset = 0;
65  *(outbuffer + offset++) = ints_length;
66  *(outbuffer + offset++) = 0;
67  *(outbuffer + offset++) = 0;
68  *(outbuffer + offset++) = 0;
69  for( uint8_t i = 0; i < ints_length; i++){
70  union {
71  int32_t real;
72  uint32_t base;
73  } u_intsi;
74  u_intsi.real = this->ints[i];
75  *(outbuffer + offset + 0) = (u_intsi.base >> (8 * 0)) & 0xFF;
76  *(outbuffer + offset + 1) = (u_intsi.base >> (8 * 1)) & 0xFF;
77  *(outbuffer + offset + 2) = (u_intsi.base >> (8 * 2)) & 0xFF;
78  *(outbuffer + offset + 3) = (u_intsi.base >> (8 * 3)) & 0xFF;
79  offset += sizeof(this->ints[i]);
80  }
81  *(outbuffer + offset++) = floats_length;
82  *(outbuffer + offset++) = 0;
83  *(outbuffer + offset++) = 0;
84  *(outbuffer + offset++) = 0;
85  for( uint8_t i = 0; i < floats_length; i++){
86  union {
87  float real;
88  uint32_t base;
89  } u_floatsi;
90  u_floatsi.real = this->floats[i];
91  *(outbuffer + offset + 0) = (u_floatsi.base >> (8 * 0)) & 0xFF;
92  *(outbuffer + offset + 1) = (u_floatsi.base >> (8 * 1)) & 0xFF;
93  *(outbuffer + offset + 2) = (u_floatsi.base >> (8 * 2)) & 0xFF;
94  *(outbuffer + offset + 3) = (u_floatsi.base >> (8 * 3)) & 0xFF;
95  offset += sizeof(this->floats[i]);
96  }
97  *(outbuffer + offset++) = strings_length;
98  *(outbuffer + offset++) = 0;
99  *(outbuffer + offset++) = 0;
100  *(outbuffer + offset++) = 0;
101  for( uint8_t i = 0; i < strings_length; i++){
102  uint32_t length_stringsi = strlen(this->strings[i]);
103  memcpy(outbuffer + offset, &length_stringsi, sizeof(uint32_t));
104  offset += 4;
105  memcpy(outbuffer + offset, this->strings[i], length_stringsi);
106  offset += length_stringsi;
107  }
108  return offset;
109  }
110 
111  virtual int deserialize(unsigned char *inbuffer)
112  {
113  int offset = 0;
114  uint8_t ints_lengthT = *(inbuffer + offset++);
115  if(ints_lengthT > ints_length)
116  this->ints = (int32_t*)realloc(this->ints, ints_lengthT * sizeof(int32_t));
117  offset += 3;
118  ints_length = ints_lengthT;
119  for( uint8_t i = 0; i < ints_length; i++){
120  union {
121  int32_t real;
122  uint32_t base;
123  } u_st_ints;
124  u_st_ints.base = 0;
125  u_st_ints.base |= ((uint32_t) (*(inbuffer + offset + 0))) << (8 * 0);
126  u_st_ints.base |= ((uint32_t) (*(inbuffer + offset + 1))) << (8 * 1);
127  u_st_ints.base |= ((uint32_t) (*(inbuffer + offset + 2))) << (8 * 2);
128  u_st_ints.base |= ((uint32_t) (*(inbuffer + offset + 3))) << (8 * 3);
129  this->st_ints = u_st_ints.real;
130  offset += sizeof(this->st_ints);
131  memcpy( &(this->ints[i]), &(this->st_ints), sizeof(int32_t));
132  }
133  uint8_t floats_lengthT = *(inbuffer + offset++);
134  if(floats_lengthT > floats_length)
135  this->floats = (float*)realloc(this->floats, floats_lengthT * sizeof(float));
136  offset += 3;
137  floats_length = floats_lengthT;
138  for( uint8_t i = 0; i < floats_length; i++){
139  union {
140  float real;
141  uint32_t base;
142  } u_st_floats;
143  u_st_floats.base = 0;
144  u_st_floats.base |= ((uint32_t) (*(inbuffer + offset + 0))) << (8 * 0);
145  u_st_floats.base |= ((uint32_t) (*(inbuffer + offset + 1))) << (8 * 1);
146  u_st_floats.base |= ((uint32_t) (*(inbuffer + offset + 2))) << (8 * 2);
147  u_st_floats.base |= ((uint32_t) (*(inbuffer + offset + 3))) << (8 * 3);
148  this->st_floats = u_st_floats.real;
149  offset += sizeof(this->st_floats);
150  memcpy( &(this->floats[i]), &(this->st_floats), sizeof(float));
151  }
152  uint8_t strings_lengthT = *(inbuffer + offset++);
153  if(strings_lengthT > strings_length)
154  this->strings = (char**)realloc(this->strings, strings_lengthT * sizeof(char*));
155  offset += 3;
156  strings_length = strings_lengthT;
157  for( uint8_t i = 0; i < strings_length; i++){
158  uint32_t length_st_strings;
159  memcpy(&length_st_strings, (inbuffer + offset), sizeof(uint32_t));
160  offset += 4;
161  for(unsigned int k= offset; k< offset+length_st_strings; ++k){
162  inbuffer[k-1]=inbuffer[k];
163  }
164  inbuffer[offset+length_st_strings-1]=0;
165  this->st_strings = (char *)(inbuffer + offset-1);
166  offset += length_st_strings;
167  memcpy( &(this->strings[i]), &(this->st_strings), sizeof(char*));
168  }
169  return offset;
170  }
171 
172  const char * getType(){ return REQUESTPARAM; };
173  const char * getMD5(){ return "9f0e98bda65981986ddf53afa7a40e49"; };
174 
175  };
176 
177  class RequestParam {
178  public:
181  };
182 
183 }
184 #endif
virtual int serialize(unsigned char *outbuffer) const
Definition: RequestParam.h:62
static const char REQUESTPARAM[]
Definition: RequestParam.h:11
RequestParamResponse Response
Definition: RequestParam.h:180
virtual int deserialize(unsigned char *inbuffer)
Definition: RequestParam.h:111
RequestParamRequest Request
Definition: RequestParam.h:179
virtual int serialize(unsigned char *outbuffer) const
Definition: RequestParam.h:18
virtual int deserialize(unsigned char *inbuffer)
Definition: RequestParam.h:29


rosabridge_arduino
Author(s): Chad Attermann
autogenerated on Sat Apr 10 2021 02:37:49