kitt_platform
 All Classes Namespaces Files Functions Variables Typedefs Enumerator Macros
SelfTest.h
Go to the documentation of this file.
1 #ifndef _ROS_SERVICE_SelfTest_h
2 #define _ROS_SERVICE_SelfTest_h
3 #include <stdint.h>
4 #include <string.h>
5 #include <stdlib.h>
6 #include "ros/msg.h"
8 
9 namespace diagnostic_msgs
10 {
11 
12 static const char SELFTEST[] = "diagnostic_msgs/SelfTest";
13 
14  class SelfTestRequest : public ros::Msg
15  {
16  public:
17 
19  {
20  }
21 
22  virtual int serialize(unsigned char *outbuffer) const
23  {
24  int offset = 0;
25  return offset;
26  }
27 
28  virtual int deserialize(unsigned char *inbuffer)
29  {
30  int offset = 0;
31  return offset;
32  }
33 
34  const char * getType(){ return SELFTEST; };
35  const char * getMD5(){ return "d41d8cd98f00b204e9800998ecf8427e"; };
36 
37  };
38 
39  class SelfTestResponse : public ros::Msg
40  {
41  public:
42  const char* id;
43  int8_t passed;
44  uint8_t status_length;
47 
49  id(""),
50  passed(0),
51  status_length(0), status(NULL)
52  {
53  }
54 
55  virtual int serialize(unsigned char *outbuffer) const
56  {
57  int offset = 0;
58  uint32_t length_id = strlen(this->id);
59  memcpy(outbuffer + offset, &length_id, sizeof(uint32_t));
60  offset += 4;
61  memcpy(outbuffer + offset, this->id, length_id);
62  offset += length_id;
63  union {
64  int8_t real;
65  uint8_t base;
66  } u_passed;
67  u_passed.real = this->passed;
68  *(outbuffer + offset + 0) = (u_passed.base >> (8 * 0)) & 0xFF;
69  offset += sizeof(this->passed);
70  *(outbuffer + offset++) = status_length;
71  *(outbuffer + offset++) = 0;
72  *(outbuffer + offset++) = 0;
73  *(outbuffer + offset++) = 0;
74  for( uint8_t i = 0; i < status_length; i++){
75  offset += this->status[i].serialize(outbuffer + offset);
76  }
77  return offset;
78  }
79 
80  virtual int deserialize(unsigned char *inbuffer)
81  {
82  int offset = 0;
83  uint32_t length_id;
84  memcpy(&length_id, (inbuffer + offset), sizeof(uint32_t));
85  offset += 4;
86  for(unsigned int k= offset; k< offset+length_id; ++k){
87  inbuffer[k-1]=inbuffer[k];
88  }
89  inbuffer[offset+length_id-1]=0;
90  this->id = (char *)(inbuffer + offset-1);
91  offset += length_id;
92  union {
93  int8_t real;
94  uint8_t base;
95  } u_passed;
96  u_passed.base = 0;
97  u_passed.base |= ((uint8_t) (*(inbuffer + offset + 0))) << (8 * 0);
98  this->passed = u_passed.real;
99  offset += sizeof(this->passed);
100  uint8_t status_lengthT = *(inbuffer + offset++);
101  if(status_lengthT > status_length)
102  this->status = (diagnostic_msgs::DiagnosticStatus*)realloc(this->status, status_lengthT * sizeof(diagnostic_msgs::DiagnosticStatus));
103  offset += 3;
104  status_length = status_lengthT;
105  for( uint8_t i = 0; i < status_length; i++){
106  offset += this->st_status.deserialize(inbuffer + offset);
107  memcpy( &(this->status[i]), &(this->st_status), sizeof(diagnostic_msgs::DiagnosticStatus));
108  }
109  return offset;
110  }
111 
112  const char * getType(){ return SELFTEST; };
113  const char * getMD5(){ return "ac21b1bab7ab17546986536c22eb34e9"; };
114 
115  };
116 
117  class SelfTest {
118  public:
121  };
122 
123 }
124 #endif
const char * getMD5()
Definition: SelfTest.h:113
Definition: DiagnosticStatus.h:13
Definition: SelfTest.h:14
const char * getType()
Definition: SelfTest.h:34
virtual int deserialize(unsigned char *inbuffer)
Definition: SelfTest.h:28
const char * getMD5()
Definition: SelfTest.h:35
virtual int deserialize(unsigned char *inbuffer)
Definition: SelfTest.h:80
static const char SELFTEST[]
Definition: SelfTest.h:12
int8_t passed
Definition: SelfTest.h:43
diagnostic_msgs::DiagnosticStatus st_status
Definition: SelfTest.h:45
uint8_t status_length
Definition: SelfTest.h:44
virtual int serialize(unsigned char *outbuffer) const
Definition: SelfTest.h:22
virtual int serialize(unsigned char *outbuffer) const
Definition: SelfTest.h:55
virtual int serialize(unsigned char *outbuffer) const
Definition: DiagnosticStatus.h:37
SelfTestRequest Request
Definition: SelfTest.h:119
virtual int deserialize(unsigned char *inbuffer)
Definition: DiagnosticStatus.h:72
SelfTestResponse()
Definition: SelfTest.h:48
const char * getType()
Definition: SelfTest.h:112
SelfTestResponse Response
Definition: SelfTest.h:120
diagnostic_msgs::DiagnosticStatus * status
Definition: SelfTest.h:46
SelfTestRequest()
Definition: SelfTest.h:18
Definition: SelfTest.h:117
Definition: msg.h:43
Definition: SelfTest.h:39
const char * id
Definition: SelfTest.h:42