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/Header.h@3:1cf99502f396, 2011-11-12 (annotated)
- Committer:
- nucho
- Date:
- Sat Nov 12 23:54:45 2011 +0000
- Revision:
- 3:1cf99502f396
- Parent:
- 1:ff0ec969dad1
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_Header_h |
| nucho | 3:1cf99502f396 | 2 | #define _ROS_std_msgs_Header_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 "ros/time.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 Header : public ros::Msg |
| nucho | 3:1cf99502f396 | 14 | { |
| nucho | 3:1cf99502f396 | 15 | public: |
| nucho | 3:1cf99502f396 | 16 | uint32_t seq; |
| nucho | 3:1cf99502f396 | 17 | ros::Time stamp; |
| nucho | 3:1cf99502f396 | 18 | char * frame_id; |
| nucho | 3:1cf99502f396 | 19 | |
| nucho | 3:1cf99502f396 | 20 | virtual int serialize(unsigned char *outbuffer) const |
| nucho | 3:1cf99502f396 | 21 | { |
| nucho | 3:1cf99502f396 | 22 | int offset = 0; |
| nucho | 3:1cf99502f396 | 23 | *(outbuffer + offset + 0) = (this->seq >> (8 * 0)) & 0xFF; |
| nucho | 3:1cf99502f396 | 24 | *(outbuffer + offset + 1) = (this->seq >> (8 * 1)) & 0xFF; |
| nucho | 3:1cf99502f396 | 25 | *(outbuffer + offset + 2) = (this->seq >> (8 * 2)) & 0xFF; |
| nucho | 3:1cf99502f396 | 26 | *(outbuffer + offset + 3) = (this->seq >> (8 * 3)) & 0xFF; |
| nucho | 3:1cf99502f396 | 27 | offset += sizeof(this->seq); |
| nucho | 3:1cf99502f396 | 28 | *(outbuffer + offset + 0) = (this->stamp.sec >> (8 * 0)) & 0xFF; |
| nucho | 3:1cf99502f396 | 29 | *(outbuffer + offset + 1) = (this->stamp.sec >> (8 * 1)) & 0xFF; |
| nucho | 3:1cf99502f396 | 30 | *(outbuffer + offset + 2) = (this->stamp.sec >> (8 * 2)) & 0xFF; |
| nucho | 3:1cf99502f396 | 31 | *(outbuffer + offset + 3) = (this->stamp.sec >> (8 * 3)) & 0xFF; |
| nucho | 3:1cf99502f396 | 32 | offset += sizeof(this->stamp.sec); |
| nucho | 3:1cf99502f396 | 33 | *(outbuffer + offset + 0) = (this->stamp.nsec >> (8 * 0)) & 0xFF; |
| nucho | 3:1cf99502f396 | 34 | *(outbuffer + offset + 1) = (this->stamp.nsec >> (8 * 1)) & 0xFF; |
| nucho | 3:1cf99502f396 | 35 | *(outbuffer + offset + 2) = (this->stamp.nsec >> (8 * 2)) & 0xFF; |
| nucho | 3:1cf99502f396 | 36 | *(outbuffer + offset + 3) = (this->stamp.nsec >> (8 * 3)) & 0xFF; |
| nucho | 3:1cf99502f396 | 37 | offset += sizeof(this->stamp.nsec); |
| nucho | 3:1cf99502f396 | 38 | uint32_t * length_frame_id = (uint32_t *)(outbuffer + offset); |
| nucho | 3:1cf99502f396 | 39 | *length_frame_id = strlen( (const char*) this->frame_id); |
| nucho | 3:1cf99502f396 | 40 | offset += 4; |
| nucho | 3:1cf99502f396 | 41 | memcpy(outbuffer + offset, this->frame_id, *length_frame_id); |
| nucho | 3:1cf99502f396 | 42 | offset += *length_frame_id; |
| nucho | 3:1cf99502f396 | 43 | return offset; |
| nucho | 3:1cf99502f396 | 44 | } |
| nucho | 3:1cf99502f396 | 45 | |
| nucho | 3:1cf99502f396 | 46 | virtual int deserialize(unsigned char *inbuffer) |
| nucho | 3:1cf99502f396 | 47 | { |
| nucho | 3:1cf99502f396 | 48 | int offset = 0; |
| nucho | 3:1cf99502f396 | 49 | this->seq |= ((uint32_t) (*(inbuffer + offset + 0))) << (8 * 0); |
| nucho | 3:1cf99502f396 | 50 | this->seq |= ((uint32_t) (*(inbuffer + offset + 1))) << (8 * 1); |
| nucho | 3:1cf99502f396 | 51 | this->seq |= ((uint32_t) (*(inbuffer + offset + 2))) << (8 * 2); |
| nucho | 3:1cf99502f396 | 52 | this->seq |= ((uint32_t) (*(inbuffer + offset + 3))) << (8 * 3); |
| nucho | 3:1cf99502f396 | 53 | offset += sizeof(this->seq); |
| nucho | 3:1cf99502f396 | 54 | this->stamp.sec |= ((uint32_t) (*(inbuffer + offset + 0))) << (8 * 0); |
| nucho | 3:1cf99502f396 | 55 | this->stamp.sec |= ((uint32_t) (*(inbuffer + offset + 1))) << (8 * 1); |
| nucho | 3:1cf99502f396 | 56 | this->stamp.sec |= ((uint32_t) (*(inbuffer + offset + 2))) << (8 * 2); |
| nucho | 3:1cf99502f396 | 57 | this->stamp.sec |= ((uint32_t) (*(inbuffer + offset + 3))) << (8 * 3); |
| nucho | 3:1cf99502f396 | 58 | offset += sizeof(this->stamp.sec); |
| nucho | 3:1cf99502f396 | 59 | this->stamp.nsec |= ((uint32_t) (*(inbuffer + offset + 0))) << (8 * 0); |
| nucho | 3:1cf99502f396 | 60 | this->stamp.nsec |= ((uint32_t) (*(inbuffer + offset + 1))) << (8 * 1); |
| nucho | 3:1cf99502f396 | 61 | this->stamp.nsec |= ((uint32_t) (*(inbuffer + offset + 2))) << (8 * 2); |
| nucho | 3:1cf99502f396 | 62 | this->stamp.nsec |= ((uint32_t) (*(inbuffer + offset + 3))) << (8 * 3); |
| nucho | 3:1cf99502f396 | 63 | offset += sizeof(this->stamp.nsec); |
| nucho | 3:1cf99502f396 | 64 | uint32_t length_frame_id = *(uint32_t *)(inbuffer + offset); |
| nucho | 3:1cf99502f396 | 65 | offset += 4; |
| nucho | 3:1cf99502f396 | 66 | for(unsigned int k= offset; k< offset+length_frame_id; ++k){ |
| nucho | 3:1cf99502f396 | 67 | inbuffer[k-1]=inbuffer[k]; |
| nucho | 3:1cf99502f396 | 68 | } |
| nucho | 3:1cf99502f396 | 69 | inbuffer[offset+length_frame_id-1]=0; |
| nucho | 3:1cf99502f396 | 70 | this->frame_id = (char *)(inbuffer + offset-1); |
| nucho | 3:1cf99502f396 | 71 | offset += length_frame_id; |
| nucho | 3:1cf99502f396 | 72 | return offset; |
| nucho | 3:1cf99502f396 | 73 | } |
| nucho | 3:1cf99502f396 | 74 | |
| nucho | 3:1cf99502f396 | 75 | virtual const char * getType(){ return "std_msgs/Header"; }; |
| nucho | 3:1cf99502f396 | 76 | virtual const char * getMD5(){ return "2176decaecbce78abc3b96ef049fabed"; }; |
| nucho | 3:1cf99502f396 | 77 | |
| nucho | 3:1cf99502f396 | 78 | }; |
| nucho | 3:1cf99502f396 | 79 | |
| nucho | 3:1cf99502f396 | 80 | } |
| nucho | 0:77afd7560544 | 81 | #endif |
