Statistics
| Branch: | Revision:

root / quad2 / arduino / src / ros_lib / std_msgs / Int8MultiArray.h @ c1426757

History | View | Annotate | Download (1.87 KB)

1
#ifndef _ROS_std_msgs_Int8MultiArray_h
2
#define _ROS_std_msgs_Int8MultiArray_h
3

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

    
10
namespace std_msgs
11
{
12

    
13
  class Int8MultiArray : public ros::Msg
14
  {
15
    public:
16
      std_msgs::MultiArrayLayout layout;
17
      uint8_t data_length;
18
      int8_t st_data;
19
      int8_t * data;
20

    
21
    virtual int serialize(unsigned char *outbuffer) const
22
    {
23
      int offset = 0;
24
      offset += this->layout.serialize(outbuffer + offset);
25
      *(outbuffer + offset++) = data_length;
26
      *(outbuffer + offset++) = 0;
27
      *(outbuffer + offset++) = 0;
28
      *(outbuffer + offset++) = 0;
29
      for( uint8_t i = 0; i < data_length; i++){
30
      union {
31
        int8_t real;
32
        uint8_t base;
33
      } u_datai;
34
      u_datai.real = this->data[i];
35
      *(outbuffer + offset + 0) = (u_datai.base >> (8 * 0)) & 0xFF;
36
      offset += sizeof(this->data[i]);
37
      }
38
      return offset;
39
    }
40

    
41
    virtual int deserialize(unsigned char *inbuffer)
42
    {
43
      int offset = 0;
44
      offset += this->layout.deserialize(inbuffer + offset);
45
      uint8_t data_lengthT = *(inbuffer + offset++);
46
      if(data_lengthT > data_length)
47
        this->data = (int8_t*)realloc(this->data, data_lengthT * sizeof(int8_t));
48
      offset += 3;
49
      data_length = data_lengthT;
50
      for( uint8_t i = 0; i < data_length; i++){
51
      union {
52
        int8_t real;
53
        uint8_t base;
54
      } u_st_data;
55
      u_st_data.base = 0;
56
      u_st_data.base |= ((uint8_t) (*(inbuffer + offset + 0))) << (8 * 0);
57
      this->st_data = u_st_data.real;
58
      offset += sizeof(this->st_data);
59
        memcpy( &(this->data[i]), &(this->st_data), sizeof(int8_t));
60
      }
61
     return offset;
62
    }
63

    
64
    const char * getType(){ return "std_msgs/Int8MultiArray"; };
65
    const char * getMD5(){ return "d7c1af35a1b4781bbe79e03dd94b7c13"; };
66

    
67
  };
68

    
69
}
70
#endif