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

Dependencies:   BufferedSerial

Committer:
Gary Servin
Date:
Fri Nov 08 14:38:09 2019 -0300
Revision:
0:04ac6be8229a
Initial commit, generated based on a clean melodic-desktop-full

Who changed what in which revision?

UserRevisionLine numberNew contents of line
Gary Servin 0:04ac6be8229a 1 #ifndef _ROS_sensor_msgs_TimeReference_h
Gary Servin 0:04ac6be8229a 2 #define _ROS_sensor_msgs_TimeReference_h
Gary Servin 0:04ac6be8229a 3
Gary Servin 0:04ac6be8229a 4 #include <stdint.h>
Gary Servin 0:04ac6be8229a 5 #include <string.h>
Gary Servin 0:04ac6be8229a 6 #include <stdlib.h>
Gary Servin 0:04ac6be8229a 7 #include "ros/msg.h"
Gary Servin 0:04ac6be8229a 8 #include "std_msgs/Header.h"
Gary Servin 0:04ac6be8229a 9 #include "ros/time.h"
Gary Servin 0:04ac6be8229a 10
Gary Servin 0:04ac6be8229a 11 namespace sensor_msgs
Gary Servin 0:04ac6be8229a 12 {
Gary Servin 0:04ac6be8229a 13
Gary Servin 0:04ac6be8229a 14 class TimeReference : public ros::Msg
Gary Servin 0:04ac6be8229a 15 {
Gary Servin 0:04ac6be8229a 16 public:
Gary Servin 0:04ac6be8229a 17 typedef std_msgs::Header _header_type;
Gary Servin 0:04ac6be8229a 18 _header_type header;
Gary Servin 0:04ac6be8229a 19 typedef ros::Time _time_ref_type;
Gary Servin 0:04ac6be8229a 20 _time_ref_type time_ref;
Gary Servin 0:04ac6be8229a 21 typedef const char* _source_type;
Gary Servin 0:04ac6be8229a 22 _source_type source;
Gary Servin 0:04ac6be8229a 23
Gary Servin 0:04ac6be8229a 24 TimeReference():
Gary Servin 0:04ac6be8229a 25 header(),
Gary Servin 0:04ac6be8229a 26 time_ref(),
Gary Servin 0:04ac6be8229a 27 source("")
Gary Servin 0:04ac6be8229a 28 {
Gary Servin 0:04ac6be8229a 29 }
Gary Servin 0:04ac6be8229a 30
Gary Servin 0:04ac6be8229a 31 virtual int serialize(unsigned char *outbuffer) const
Gary Servin 0:04ac6be8229a 32 {
Gary Servin 0:04ac6be8229a 33 int offset = 0;
Gary Servin 0:04ac6be8229a 34 offset += this->header.serialize(outbuffer + offset);
Gary Servin 0:04ac6be8229a 35 *(outbuffer + offset + 0) = (this->time_ref.sec >> (8 * 0)) & 0xFF;
Gary Servin 0:04ac6be8229a 36 *(outbuffer + offset + 1) = (this->time_ref.sec >> (8 * 1)) & 0xFF;
Gary Servin 0:04ac6be8229a 37 *(outbuffer + offset + 2) = (this->time_ref.sec >> (8 * 2)) & 0xFF;
Gary Servin 0:04ac6be8229a 38 *(outbuffer + offset + 3) = (this->time_ref.sec >> (8 * 3)) & 0xFF;
Gary Servin 0:04ac6be8229a 39 offset += sizeof(this->time_ref.sec);
Gary Servin 0:04ac6be8229a 40 *(outbuffer + offset + 0) = (this->time_ref.nsec >> (8 * 0)) & 0xFF;
Gary Servin 0:04ac6be8229a 41 *(outbuffer + offset + 1) = (this->time_ref.nsec >> (8 * 1)) & 0xFF;
Gary Servin 0:04ac6be8229a 42 *(outbuffer + offset + 2) = (this->time_ref.nsec >> (8 * 2)) & 0xFF;
Gary Servin 0:04ac6be8229a 43 *(outbuffer + offset + 3) = (this->time_ref.nsec >> (8 * 3)) & 0xFF;
Gary Servin 0:04ac6be8229a 44 offset += sizeof(this->time_ref.nsec);
Gary Servin 0:04ac6be8229a 45 uint32_t length_source = strlen(this->source);
Gary Servin 0:04ac6be8229a 46 varToArr(outbuffer + offset, length_source);
Gary Servin 0:04ac6be8229a 47 offset += 4;
Gary Servin 0:04ac6be8229a 48 memcpy(outbuffer + offset, this->source, length_source);
Gary Servin 0:04ac6be8229a 49 offset += length_source;
Gary Servin 0:04ac6be8229a 50 return offset;
Gary Servin 0:04ac6be8229a 51 }
Gary Servin 0:04ac6be8229a 52
Gary Servin 0:04ac6be8229a 53 virtual int deserialize(unsigned char *inbuffer)
Gary Servin 0:04ac6be8229a 54 {
Gary Servin 0:04ac6be8229a 55 int offset = 0;
Gary Servin 0:04ac6be8229a 56 offset += this->header.deserialize(inbuffer + offset);
Gary Servin 0:04ac6be8229a 57 this->time_ref.sec = ((uint32_t) (*(inbuffer + offset)));
Gary Servin 0:04ac6be8229a 58 this->time_ref.sec |= ((uint32_t) (*(inbuffer + offset + 1))) << (8 * 1);
Gary Servin 0:04ac6be8229a 59 this->time_ref.sec |= ((uint32_t) (*(inbuffer + offset + 2))) << (8 * 2);
Gary Servin 0:04ac6be8229a 60 this->time_ref.sec |= ((uint32_t) (*(inbuffer + offset + 3))) << (8 * 3);
Gary Servin 0:04ac6be8229a 61 offset += sizeof(this->time_ref.sec);
Gary Servin 0:04ac6be8229a 62 this->time_ref.nsec = ((uint32_t) (*(inbuffer + offset)));
Gary Servin 0:04ac6be8229a 63 this->time_ref.nsec |= ((uint32_t) (*(inbuffer + offset + 1))) << (8 * 1);
Gary Servin 0:04ac6be8229a 64 this->time_ref.nsec |= ((uint32_t) (*(inbuffer + offset + 2))) << (8 * 2);
Gary Servin 0:04ac6be8229a 65 this->time_ref.nsec |= ((uint32_t) (*(inbuffer + offset + 3))) << (8 * 3);
Gary Servin 0:04ac6be8229a 66 offset += sizeof(this->time_ref.nsec);
Gary Servin 0:04ac6be8229a 67 uint32_t length_source;
Gary Servin 0:04ac6be8229a 68 arrToVar(length_source, (inbuffer + offset));
Gary Servin 0:04ac6be8229a 69 offset += 4;
Gary Servin 0:04ac6be8229a 70 for(unsigned int k= offset; k< offset+length_source; ++k){
Gary Servin 0:04ac6be8229a 71 inbuffer[k-1]=inbuffer[k];
Gary Servin 0:04ac6be8229a 72 }
Gary Servin 0:04ac6be8229a 73 inbuffer[offset+length_source-1]=0;
Gary Servin 0:04ac6be8229a 74 this->source = (char *)(inbuffer + offset-1);
Gary Servin 0:04ac6be8229a 75 offset += length_source;
Gary Servin 0:04ac6be8229a 76 return offset;
Gary Servin 0:04ac6be8229a 77 }
Gary Servin 0:04ac6be8229a 78
Gary Servin 0:04ac6be8229a 79 const char * getType(){ return "sensor_msgs/TimeReference"; };
Gary Servin 0:04ac6be8229a 80 const char * getMD5(){ return "fded64a0265108ba86c3d38fb11c0c16"; };
Gary Servin 0:04ac6be8229a 81
Gary Servin 0:04ac6be8229a 82 };
Gary Servin 0:04ac6be8229a 83
Gary Servin 0:04ac6be8229a 84 }
Gary Servin 0:04ac6be8229a 85 #endif