Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Fork of rosserial_mbed_lib by
std_msgs/MultiArrayDimension.h@5:19c5437ed9fe, 2014-05-01 (annotated)
- Committer:
- garyservin
- Date:
- Thu May 01 06:01:31 2014 +0000
- Revision:
- 5:19c5437ed9fe
- Parent:
- 3:1cf99502f396
Updated to hydro
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
nucho | 3:1cf99502f396 | 1 | #ifndef _ROS_std_msgs_MultiArrayDimension_h |
nucho | 3:1cf99502f396 | 2 | #define _ROS_std_msgs_MultiArrayDimension_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 | |
nucho | 3:1cf99502f396 | 9 | namespace std_msgs |
nucho | 3:1cf99502f396 | 10 | { |
nucho | 3:1cf99502f396 | 11 | |
nucho | 3:1cf99502f396 | 12 | class MultiArrayDimension : public ros::Msg |
nucho | 3:1cf99502f396 | 13 | { |
nucho | 3:1cf99502f396 | 14 | public: |
nucho | 3:1cf99502f396 | 15 | char * label; |
nucho | 3:1cf99502f396 | 16 | uint32_t size; |
nucho | 3:1cf99502f396 | 17 | uint32_t stride; |
nucho | 3:1cf99502f396 | 18 | |
nucho | 3:1cf99502f396 | 19 | virtual int serialize(unsigned char *outbuffer) const |
nucho | 3:1cf99502f396 | 20 | { |
nucho | 3:1cf99502f396 | 21 | int offset = 0; |
nucho | 3:1cf99502f396 | 22 | uint32_t * length_label = (uint32_t *)(outbuffer + offset); |
nucho | 3:1cf99502f396 | 23 | *length_label = strlen( (const char*) this->label); |
nucho | 3:1cf99502f396 | 24 | offset += 4; |
nucho | 3:1cf99502f396 | 25 | memcpy(outbuffer + offset, this->label, *length_label); |
nucho | 3:1cf99502f396 | 26 | offset += *length_label; |
nucho | 3:1cf99502f396 | 27 | *(outbuffer + offset + 0) = (this->size >> (8 * 0)) & 0xFF; |
nucho | 3:1cf99502f396 | 28 | *(outbuffer + offset + 1) = (this->size >> (8 * 1)) & 0xFF; |
nucho | 3:1cf99502f396 | 29 | *(outbuffer + offset + 2) = (this->size >> (8 * 2)) & 0xFF; |
nucho | 3:1cf99502f396 | 30 | *(outbuffer + offset + 3) = (this->size >> (8 * 3)) & 0xFF; |
nucho | 3:1cf99502f396 | 31 | offset += sizeof(this->size); |
nucho | 3:1cf99502f396 | 32 | *(outbuffer + offset + 0) = (this->stride >> (8 * 0)) & 0xFF; |
nucho | 3:1cf99502f396 | 33 | *(outbuffer + offset + 1) = (this->stride >> (8 * 1)) & 0xFF; |
nucho | 3:1cf99502f396 | 34 | *(outbuffer + offset + 2) = (this->stride >> (8 * 2)) & 0xFF; |
nucho | 3:1cf99502f396 | 35 | *(outbuffer + offset + 3) = (this->stride >> (8 * 3)) & 0xFF; |
nucho | 3:1cf99502f396 | 36 | offset += sizeof(this->stride); |
nucho | 3:1cf99502f396 | 37 | return offset; |
nucho | 3:1cf99502f396 | 38 | } |
nucho | 3:1cf99502f396 | 39 | |
nucho | 3:1cf99502f396 | 40 | virtual int deserialize(unsigned char *inbuffer) |
nucho | 3:1cf99502f396 | 41 | { |
nucho | 3:1cf99502f396 | 42 | int offset = 0; |
nucho | 3:1cf99502f396 | 43 | uint32_t length_label = *(uint32_t *)(inbuffer + offset); |
nucho | 3:1cf99502f396 | 44 | offset += 4; |
nucho | 3:1cf99502f396 | 45 | for(unsigned int k= offset; k< offset+length_label; ++k){ |
nucho | 3:1cf99502f396 | 46 | inbuffer[k-1]=inbuffer[k]; |
nucho | 3:1cf99502f396 | 47 | } |
nucho | 3:1cf99502f396 | 48 | inbuffer[offset+length_label-1]=0; |
nucho | 3:1cf99502f396 | 49 | this->label = (char *)(inbuffer + offset-1); |
nucho | 3:1cf99502f396 | 50 | offset += length_label; |
nucho | 3:1cf99502f396 | 51 | this->size |= ((uint32_t) (*(inbuffer + offset + 0))) << (8 * 0); |
nucho | 3:1cf99502f396 | 52 | this->size |= ((uint32_t) (*(inbuffer + offset + 1))) << (8 * 1); |
nucho | 3:1cf99502f396 | 53 | this->size |= ((uint32_t) (*(inbuffer + offset + 2))) << (8 * 2); |
nucho | 3:1cf99502f396 | 54 | this->size |= ((uint32_t) (*(inbuffer + offset + 3))) << (8 * 3); |
nucho | 3:1cf99502f396 | 55 | offset += sizeof(this->size); |
nucho | 3:1cf99502f396 | 56 | this->stride |= ((uint32_t) (*(inbuffer + offset + 0))) << (8 * 0); |
nucho | 3:1cf99502f396 | 57 | this->stride |= ((uint32_t) (*(inbuffer + offset + 1))) << (8 * 1); |
nucho | 3:1cf99502f396 | 58 | this->stride |= ((uint32_t) (*(inbuffer + offset + 2))) << (8 * 2); |
nucho | 3:1cf99502f396 | 59 | this->stride |= ((uint32_t) (*(inbuffer + offset + 3))) << (8 * 3); |
nucho | 3:1cf99502f396 | 60 | offset += sizeof(this->stride); |
nucho | 3:1cf99502f396 | 61 | return offset; |
nucho | 3:1cf99502f396 | 62 | } |
nucho | 3:1cf99502f396 | 63 | |
nucho | 3:1cf99502f396 | 64 | virtual const char * getType(){ return "std_msgs/MultiArrayDimension"; }; |
nucho | 3:1cf99502f396 | 65 | virtual const char * getMD5(){ return "4cd0c83a8683deae40ecdac60e53bfa8"; }; |
nucho | 3:1cf99502f396 | 66 | |
nucho | 3:1cf99502f396 | 67 | }; |
nucho | 3:1cf99502f396 | 68 | |
nucho | 3:1cf99502f396 | 69 | } |
nucho | 0:77afd7560544 | 70 | #endif |