Statistics
| Branch: | Revision:

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

History | View | Annotate | Download (1.79 KB)

1
#ifndef _ROS_std_msgs_UInt16MultiArray_h
2
#define _ROS_std_msgs_UInt16MultiArray_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 UInt16MultiArray : public ros::Msg
14
  {
15
    public:
16
      std_msgs::MultiArrayLayout layout;
17
      uint8_t data_length;
18
      uint16_t st_data;
19
      uint16_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
      *(outbuffer + offset + 0) = (this->data[i] >> (8 * 0)) & 0xFF;
31
      *(outbuffer + offset + 1) = (this->data[i] >> (8 * 1)) & 0xFF;
32
      offset += sizeof(this->data[i]);
33
      }
34
      return offset;
35
    }
36

    
37
    virtual int deserialize(unsigned char *inbuffer)
38
    {
39
      int offset = 0;
40
      offset += this->layout.deserialize(inbuffer + offset);
41
      uint8_t data_lengthT = *(inbuffer + offset++);
42
      if(data_lengthT > data_length)
43
        this->data = (uint16_t*)realloc(this->data, data_lengthT * sizeof(uint16_t));
44
      offset += 3;
45
      data_length = data_lengthT;
46
      for( uint8_t i = 0; i < data_length; i++){
47
      this->st_data |= ((uint16_t) (*(inbuffer + offset + 0))) << (8 * 0);
48
      this->st_data |= ((uint16_t) (*(inbuffer + offset + 1))) << (8 * 1);
49
      offset += sizeof(this->st_data);
50
        memcpy( &(this->data[i]), &(this->st_data), sizeof(uint16_t));
51
      }
52
     return offset;
53
    }
54

    
55
    const char * getType(){ return "std_msgs/UInt16MultiArray"; };
56
    const char * getMD5(){ return "52f264f1c973c4b73790d384c6cb4484"; };
57

    
58
  };
59

    
60
}
61
#endif