ROS Serial library for Mbed platforms for ROS Jade Turtle. Check http://wiki.ros.org/rosserial_mbed/ for more information.

Dependencies:   BufferedSerial

Dependents:   rosserial_mbed_hello_world_publisher_jade

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers Header.h Source File

Header.h

00001 #ifndef _ROS_std_msgs_Header_h
00002 #define _ROS_std_msgs_Header_h
00003 
00004 #include <stdint.h>
00005 #include <string.h>
00006 #include <stdlib.h>
00007 #include "ros/msg.h"
00008 #include "ros/time.h"
00009 
00010 namespace std_msgs
00011 {
00012 
00013   class Header : public ros::Msg
00014   {
00015     public:
00016       uint32_t seq;
00017       ros::Time stamp;
00018       const char* frame_id;
00019 
00020     Header():
00021       seq(0),
00022       stamp(),
00023       frame_id("")
00024     {
00025     }
00026 
00027     virtual int serialize(unsigned char *outbuffer) const
00028     {
00029       int offset = 0;
00030       *(outbuffer + offset + 0) = (this->seq >> (8 * 0)) & 0xFF;
00031       *(outbuffer + offset + 1) = (this->seq >> (8 * 1)) & 0xFF;
00032       *(outbuffer + offset + 2) = (this->seq >> (8 * 2)) & 0xFF;
00033       *(outbuffer + offset + 3) = (this->seq >> (8 * 3)) & 0xFF;
00034       offset += sizeof(this->seq);
00035       *(outbuffer + offset + 0) = (this->stamp.sec >> (8 * 0)) & 0xFF;
00036       *(outbuffer + offset + 1) = (this->stamp.sec >> (8 * 1)) & 0xFF;
00037       *(outbuffer + offset + 2) = (this->stamp.sec >> (8 * 2)) & 0xFF;
00038       *(outbuffer + offset + 3) = (this->stamp.sec >> (8 * 3)) & 0xFF;
00039       offset += sizeof(this->stamp.sec);
00040       *(outbuffer + offset + 0) = (this->stamp.nsec >> (8 * 0)) & 0xFF;
00041       *(outbuffer + offset + 1) = (this->stamp.nsec >> (8 * 1)) & 0xFF;
00042       *(outbuffer + offset + 2) = (this->stamp.nsec >> (8 * 2)) & 0xFF;
00043       *(outbuffer + offset + 3) = (this->stamp.nsec >> (8 * 3)) & 0xFF;
00044       offset += sizeof(this->stamp.nsec);
00045       uint32_t length_frame_id = strlen(this->frame_id);
00046       memcpy(outbuffer + offset, &length_frame_id, sizeof(uint32_t));
00047       offset += 4;
00048       memcpy(outbuffer + offset, this->frame_id, length_frame_id);
00049       offset += length_frame_id;
00050       return offset;
00051     }
00052 
00053     virtual int deserialize(unsigned char *inbuffer)
00054     {
00055       int offset = 0;
00056       this->seq =  ((uint32_t) (*(inbuffer + offset)));
00057       this->seq |= ((uint32_t) (*(inbuffer + offset + 1))) << (8 * 1);
00058       this->seq |= ((uint32_t) (*(inbuffer + offset + 2))) << (8 * 2);
00059       this->seq |= ((uint32_t) (*(inbuffer + offset + 3))) << (8 * 3);
00060       offset += sizeof(this->seq);
00061       this->stamp.sec =  ((uint32_t) (*(inbuffer + offset)));
00062       this->stamp.sec |= ((uint32_t) (*(inbuffer + offset + 1))) << (8 * 1);
00063       this->stamp.sec |= ((uint32_t) (*(inbuffer + offset + 2))) << (8 * 2);
00064       this->stamp.sec |= ((uint32_t) (*(inbuffer + offset + 3))) << (8 * 3);
00065       offset += sizeof(this->stamp.sec);
00066       this->stamp.nsec =  ((uint32_t) (*(inbuffer + offset)));
00067       this->stamp.nsec |= ((uint32_t) (*(inbuffer + offset + 1))) << (8 * 1);
00068       this->stamp.nsec |= ((uint32_t) (*(inbuffer + offset + 2))) << (8 * 2);
00069       this->stamp.nsec |= ((uint32_t) (*(inbuffer + offset + 3))) << (8 * 3);
00070       offset += sizeof(this->stamp.nsec);
00071       uint32_t length_frame_id;
00072       memcpy(&length_frame_id, (inbuffer + offset), sizeof(uint32_t));
00073       offset += 4;
00074       for(unsigned int k= offset; k< offset+length_frame_id; ++k){
00075           inbuffer[k-1]=inbuffer[k];
00076       }
00077       inbuffer[offset+length_frame_id-1]=0;
00078       this->frame_id = (char *)(inbuffer + offset-1);
00079       offset += length_frame_id;
00080      return offset;
00081     }
00082 
00083     const char * getType(){ return "std_msgs/Header"; };
00084     const char * getMD5(){ return "2176decaecbce78abc3b96ef049fabed"; };
00085 
00086   };
00087 
00088 }
00089 #endif