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

Dependencies:   BufferedSerial

Dependents:   rosserial_mbed_hello_world_publisher rtos_base_control rosserial_mbed_F64MA ROS-RTOS ... more

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers TimeReference.h Source File

TimeReference.h

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