Statistics
| Branch: | Revision:

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

History | View | Annotate | Download (1.6 KB)

1
#ifndef _ROS_std_msgs_ByteMultiArray_h
2
#define _ROS_std_msgs_ByteMultiArray_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
#include "std_msgs/byte.h"
10

    
11
namespace std_msgs
12
{
13

    
14
  class ByteMultiArray : public ros::Msg
15
  {
16
    public:
17
      std_msgs::MultiArrayLayout layout;
18
      uint8_t data_length;
19
      std_msgs::byte st_data;
20
      std_msgs::byte * data;
21

    
22
    virtual int serialize(unsigned char *outbuffer) const
23
    {
24
      int offset = 0;
25
      offset += this->layout.serialize(outbuffer + offset);
26
      *(outbuffer + offset++) = data_length;
27
      *(outbuffer + offset++) = 0;
28
      *(outbuffer + offset++) = 0;
29
      *(outbuffer + offset++) = 0;
30
      for( uint8_t i = 0; i < data_length; i++){
31
      offset += this->data[i].serialize(outbuffer + offset);
32
      }
33
      return offset;
34
    }
35

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

    
52
    const char * getType(){ return "std_msgs/ByteMultiArray"; };
53
    const char * getMD5(){ return "70ea476cbcfd65ac2f68f3cda1e891fe"; };
54

    
55
  };
56

    
57
}
58
#endif