rosserial for Hydro
Fork of rosserial_mbed_lib by
std_msgs/MultiArrayLayout.h@3:1cf99502f396, 2011-11-12 (annotated)
- Committer:
- nucho
- Date:
- Sat Nov 12 23:54:45 2011 +0000
- Revision:
- 3:1cf99502f396
- Parent:
- 1:ff0ec969dad1
- Child:
- 5:c30c76e8c3f1
This program supported the revision of 167 of rosserial.
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
nucho | 3:1cf99502f396 | 1 | #ifndef _ROS_std_msgs_MultiArrayLayout_h |
nucho | 3:1cf99502f396 | 2 | #define _ROS_std_msgs_MultiArrayLayout_h |
nucho | 3:1cf99502f396 | 3 | |
nucho | 3:1cf99502f396 | 4 | #include <stdint.h> |
nucho | 3:1cf99502f396 | 5 | #include <string.h> |
nucho | 3:1cf99502f396 | 6 | #include <stdlib.h> |
nucho | 3:1cf99502f396 | 7 | #include "ros/msg.h" |
nucho | 3:1cf99502f396 | 8 | #include "std_msgs/MultiArrayDimension.h" |
nucho | 3:1cf99502f396 | 9 | |
nucho | 3:1cf99502f396 | 10 | namespace std_msgs |
nucho | 3:1cf99502f396 | 11 | { |
nucho | 3:1cf99502f396 | 12 | |
nucho | 3:1cf99502f396 | 13 | class MultiArrayLayout : public ros::Msg |
nucho | 3:1cf99502f396 | 14 | { |
nucho | 3:1cf99502f396 | 15 | public: |
nucho | 3:1cf99502f396 | 16 | uint8_t dim_length; |
nucho | 3:1cf99502f396 | 17 | std_msgs::MultiArrayDimension st_dim; |
nucho | 3:1cf99502f396 | 18 | std_msgs::MultiArrayDimension * dim; |
nucho | 3:1cf99502f396 | 19 | uint32_t data_offset; |
nucho | 3:1cf99502f396 | 20 | |
nucho | 3:1cf99502f396 | 21 | virtual int serialize(unsigned char *outbuffer) const |
nucho | 3:1cf99502f396 | 22 | { |
nucho | 3:1cf99502f396 | 23 | int offset = 0; |
nucho | 3:1cf99502f396 | 24 | *(outbuffer + offset++) = dim_length; |
nucho | 3:1cf99502f396 | 25 | *(outbuffer + offset++) = 0; |
nucho | 3:1cf99502f396 | 26 | *(outbuffer + offset++) = 0; |
nucho | 3:1cf99502f396 | 27 | *(outbuffer + offset++) = 0; |
nucho | 3:1cf99502f396 | 28 | for( uint8_t i = 0; i < dim_length; i++){ |
nucho | 3:1cf99502f396 | 29 | offset += this->dim[i].serialize(outbuffer + offset); |
nucho | 3:1cf99502f396 | 30 | } |
nucho | 3:1cf99502f396 | 31 | *(outbuffer + offset + 0) = (this->data_offset >> (8 * 0)) & 0xFF; |
nucho | 3:1cf99502f396 | 32 | *(outbuffer + offset + 1) = (this->data_offset >> (8 * 1)) & 0xFF; |
nucho | 3:1cf99502f396 | 33 | *(outbuffer + offset + 2) = (this->data_offset >> (8 * 2)) & 0xFF; |
nucho | 3:1cf99502f396 | 34 | *(outbuffer + offset + 3) = (this->data_offset >> (8 * 3)) & 0xFF; |
nucho | 3:1cf99502f396 | 35 | offset += sizeof(this->data_offset); |
nucho | 3:1cf99502f396 | 36 | return offset; |
nucho | 3:1cf99502f396 | 37 | } |
nucho | 3:1cf99502f396 | 38 | |
nucho | 3:1cf99502f396 | 39 | virtual int deserialize(unsigned char *inbuffer) |
nucho | 3:1cf99502f396 | 40 | { |
nucho | 3:1cf99502f396 | 41 | int offset = 0; |
nucho | 3:1cf99502f396 | 42 | uint8_t dim_lengthT = *(inbuffer + offset++); |
nucho | 3:1cf99502f396 | 43 | if(dim_lengthT > dim_length) |
nucho | 3:1cf99502f396 | 44 | this->dim = (std_msgs::MultiArrayDimension*)realloc(this->dim, dim_lengthT * sizeof(std_msgs::MultiArrayDimension)); |
nucho | 3:1cf99502f396 | 45 | offset += 3; |
nucho | 3:1cf99502f396 | 46 | dim_length = dim_lengthT; |
nucho | 3:1cf99502f396 | 47 | for( uint8_t i = 0; i < dim_length; i++){ |
nucho | 3:1cf99502f396 | 48 | offset += this->st_dim.deserialize(inbuffer + offset); |
nucho | 3:1cf99502f396 | 49 | memcpy( &(this->dim[i]), &(this->st_dim), sizeof(std_msgs::MultiArrayDimension)); |
nucho | 3:1cf99502f396 | 50 | } |
nucho | 3:1cf99502f396 | 51 | this->data_offset |= ((uint32_t) (*(inbuffer + offset + 0))) << (8 * 0); |
nucho | 3:1cf99502f396 | 52 | this->data_offset |= ((uint32_t) (*(inbuffer + offset + 1))) << (8 * 1); |
nucho | 3:1cf99502f396 | 53 | this->data_offset |= ((uint32_t) (*(inbuffer + offset + 2))) << (8 * 2); |
nucho | 3:1cf99502f396 | 54 | this->data_offset |= ((uint32_t) (*(inbuffer + offset + 3))) << (8 * 3); |
nucho | 3:1cf99502f396 | 55 | offset += sizeof(this->data_offset); |
nucho | 3:1cf99502f396 | 56 | return offset; |
nucho | 3:1cf99502f396 | 57 | } |
nucho | 3:1cf99502f396 | 58 | |
nucho | 3:1cf99502f396 | 59 | virtual const char * getType(){ return "std_msgs/MultiArrayLayout"; }; |
nucho | 3:1cf99502f396 | 60 | virtual const char * getMD5(){ return "0fed2a11c13e11c5571b4e2a995a91a3"; }; |
nucho | 3:1cf99502f396 | 61 | |
nucho | 3:1cf99502f396 | 62 | }; |
nucho | 3:1cf99502f396 | 63 | |
nucho | 3:1cf99502f396 | 64 | } |
nucho | 0:77afd7560544 | 65 | #endif |