Statistics
| Branch: | Revision:

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

History | View | Annotate | Download (2.03 KB)

1
#ifndef _ROS_std_msgs_Int16MultiArray_h
2
#define _ROS_std_msgs_Int16MultiArray_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 Int16MultiArray : public ros::Msg
14
  {
15
    public:
16
      std_msgs::MultiArrayLayout layout;
17
      uint8_t data_length;
18
      int16_t st_data;
19
      int16_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
        int16_t real;
32
        uint16_t base;
33
      } u_datai;
34
      u_datai.real = this->data[i];
35
      *(outbuffer + offset + 0) = (u_datai.base >> (8 * 0)) & 0xFF;
36
      *(outbuffer + offset + 1) = (u_datai.base >> (8 * 1)) & 0xFF;
37
      offset += sizeof(this->data[i]);
38
      }
39
      return offset;
40
    }
41

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

    
66
    const char * getType(){ return "std_msgs/Int16MultiArray"; };
67
    const char * getMD5(){ return "d9338d7f523fcb692fae9d0a0e9f067c"; };
68

    
69
  };
70

    
71
}
72
#endif