This program is porting rosserial_arduino for mbed http://www.ros.org/wiki/rosserial_arduino This program supported the revision of 169 of rosserial.

Dependencies:  

Dependents:   rosserial_mbed robot_S2

Committer:
nucho
Date:
Wed Feb 29 23:00:21 2012 +0000
Revision:
4:684f39d0c346
Parent:
3:1cf99502f396

        

Who changed what in which revision?

UserRevisionLine numberNew 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