kitt_platform
 All Classes Namespaces Files Functions Variables Typedefs Enumerator Macros
Test.h
Go to the documentation of this file.
1 #ifndef _ROS_SERVICE_Test_h
2 #define _ROS_SERVICE_Test_h
3 #include <stdint.h>
4 #include <string.h>
5 #include <stdlib.h>
6 #include "ros/msg.h"
7 
8 namespace rosserial_arduino
9 {
10 
11 static const char TEST[] = "rosserial_arduino/Test";
12 
13  class TestRequest : public ros::Msg
14  {
15  public:
16  const char* input;
17 
19  input("")
20  {
21  }
22 
23  virtual int serialize(unsigned char *outbuffer) const
24  {
25  int offset = 0;
26  uint32_t length_input = strlen(this->input);
27  memcpy(outbuffer + offset, &length_input, sizeof(uint32_t));
28  offset += 4;
29  memcpy(outbuffer + offset, this->input, length_input);
30  offset += length_input;
31  return offset;
32  }
33 
34  virtual int deserialize(unsigned char *inbuffer)
35  {
36  int offset = 0;
37  uint32_t length_input;
38  memcpy(&length_input, (inbuffer + offset), sizeof(uint32_t));
39  offset += 4;
40  for(unsigned int k= offset; k< offset+length_input; ++k){
41  inbuffer[k-1]=inbuffer[k];
42  }
43  inbuffer[offset+length_input-1]=0;
44  this->input = (char *)(inbuffer + offset-1);
45  offset += length_input;
46  return offset;
47  }
48 
49  const char * getType(){ return TEST; };
50  const char * getMD5(){ return "39e92f1778057359c64c7b8a7d7b19de"; };
51 
52  };
53 
54  class TestResponse : public ros::Msg
55  {
56  public:
57  const char* output;
58 
60  output("")
61  {
62  }
63 
64  virtual int serialize(unsigned char *outbuffer) const
65  {
66  int offset = 0;
67  uint32_t length_output = strlen(this->output);
68  memcpy(outbuffer + offset, &length_output, sizeof(uint32_t));
69  offset += 4;
70  memcpy(outbuffer + offset, this->output, length_output);
71  offset += length_output;
72  return offset;
73  }
74 
75  virtual int deserialize(unsigned char *inbuffer)
76  {
77  int offset = 0;
78  uint32_t length_output;
79  memcpy(&length_output, (inbuffer + offset), sizeof(uint32_t));
80  offset += 4;
81  for(unsigned int k= offset; k< offset+length_output; ++k){
82  inbuffer[k-1]=inbuffer[k];
83  }
84  inbuffer[offset+length_output-1]=0;
85  this->output = (char *)(inbuffer + offset-1);
86  offset += length_output;
87  return offset;
88  }
89 
90  const char * getType(){ return TEST; };
91  const char * getMD5(){ return "0825d95fdfa2c8f4bbb4e9c74bccd3fd"; };
92 
93  };
94 
95  class Test {
96  public:
99  };
100 
101 }
102 #endif
const char * getMD5()
Definition: Test.h:50
TestResponse()
Definition: Test.h:59
const char * getType()
Definition: Test.h:49
const char * getType()
Definition: Test.h:90
Definition: Test.h:95
const char * output
Definition: Test.h:57
static const char TEST[]
Definition: Test.h:11
virtual int deserialize(unsigned char *inbuffer)
Definition: Test.h:75
virtual int serialize(unsigned char *outbuffer) const
Definition: Test.h:23
const char * getMD5()
Definition: Test.h:91
const char * input
Definition: Test.h:16
virtual int serialize(unsigned char *outbuffer) const
Definition: Test.h:64
Definition: Test.h:13
TestRequest Request
Definition: Test.h:97
TestResponse Response
Definition: Test.h:98
TestRequest()
Definition: Test.h:18
Definition: Test.h:54
Definition: msg.h:43
virtual int deserialize(unsigned char *inbuffer)
Definition: Test.h:34