root / quad2 / arduino / src / ros_lib / std_msgs / UInt32MultiArray.h @ c1426757
History | View | Annotate | Download (2.07 KB)
1 | c1426757 | Tom Mullins | #ifndef _ROS_std_msgs_UInt32MultiArray_h
|
---|---|---|---|
2 | #define _ROS_std_msgs_UInt32MultiArray_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 UInt32MultiArray : public ros::Msg |
||
14 | { |
||
15 | public:
|
||
16 | std_msgs::MultiArrayLayout layout; |
||
17 | uint8_t data_length; |
||
18 | uint32_t st_data; |
||
19 | uint32_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 | *(outbuffer + offset + 2) = (this->data[i] >> (8 * 2)) & 0xFF; |
||
33 | *(outbuffer + offset + 3) = (this->data[i] >> (8 * 3)) & 0xFF; |
||
34 | offset += sizeof(this->data[i]);
|
||
35 | } |
||
36 | return offset;
|
||
37 | } |
||
38 | |||
39 | virtual int deserialize(unsigned char *inbuffer) |
||
40 | { |
||
41 | int offset = 0; |
||
42 | offset += this->layout.deserialize(inbuffer + offset); |
||
43 | uint8_t data_lengthT = *(inbuffer + offset++); |
||
44 | if(data_lengthT > data_length)
|
||
45 | this->data = (uint32_t*)realloc(this->data, data_lengthT * sizeof(uint32_t));
|
||
46 | offset += 3;
|
||
47 | data_length = data_lengthT; |
||
48 | for( uint8_t i = 0; i < data_length; i++){ |
||
49 | this->st_data |= ((uint32_t) (*(inbuffer + offset + 0))) << (8 * 0); |
||
50 | this->st_data |= ((uint32_t) (*(inbuffer + offset + 1))) << (8 * 1); |
||
51 | this->st_data |= ((uint32_t) (*(inbuffer + offset + 2))) << (8 * 2); |
||
52 | this->st_data |= ((uint32_t) (*(inbuffer + offset + 3))) << (8 * 3); |
||
53 | offset += sizeof(this->st_data);
|
||
54 | memcpy( &(this->data[i]), &(this->st_data), sizeof(uint32_t));
|
||
55 | } |
||
56 | return offset;
|
||
57 | } |
||
58 | |||
59 | const char * getType(){ return "std_msgs/UInt32MultiArray"; }; |
||
60 | const char * getMD5(){ return "4d6a180abc9be191b96a7eda6c8a233d"; }; |
||
61 | |||
62 | }; |
||
63 | |||
64 | } |
||
65 | #endif |