ROS Serial library for Mbed platforms for ROS Indigo Igloo. Check http://wiki.ros.org/rosserial_mbed/ for more information
Dependents: rosserial_mbed_hello_world_publisher rtos_base_control rosserial_mbed_F64MA ROS-RTOS ... more
Packet.h
00001 #ifndef _ROS_theora_image_transport_Packet_h 00002 #define _ROS_theora_image_transport_Packet_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 00010 namespace theora_image_transport 00011 { 00012 00013 class Packet : public ros::Msg 00014 { 00015 public: 00016 std_msgs::Header header; 00017 uint8_t data_length; 00018 uint8_t st_data; 00019 uint8_t * data; 00020 int32_t b_o_s; 00021 int32_t e_o_s; 00022 int64_t granulepos; 00023 int64_t packetno; 00024 00025 Packet(): 00026 header(), 00027 data_length(0), data(NULL), 00028 b_o_s(0), 00029 e_o_s(0), 00030 granulepos(0), 00031 packetno(0) 00032 { 00033 } 00034 00035 virtual int serialize(unsigned char *outbuffer) const 00036 { 00037 int offset = 0; 00038 offset += this->header.serialize(outbuffer + offset); 00039 *(outbuffer + offset++) = data_length; 00040 *(outbuffer + offset++) = 0; 00041 *(outbuffer + offset++) = 0; 00042 *(outbuffer + offset++) = 0; 00043 for( uint8_t i = 0; i < data_length; i++){ 00044 *(outbuffer + offset + 0) = (this->data[i] >> (8 * 0)) & 0xFF; 00045 offset += sizeof(this->data[i]); 00046 } 00047 union { 00048 int32_t real; 00049 uint32_t base; 00050 } u_b_o_s; 00051 u_b_o_s.real = this->b_o_s; 00052 *(outbuffer + offset + 0) = (u_b_o_s.base >> (8 * 0)) & 0xFF; 00053 *(outbuffer + offset + 1) = (u_b_o_s.base >> (8 * 1)) & 0xFF; 00054 *(outbuffer + offset + 2) = (u_b_o_s.base >> (8 * 2)) & 0xFF; 00055 *(outbuffer + offset + 3) = (u_b_o_s.base >> (8 * 3)) & 0xFF; 00056 offset += sizeof(this->b_o_s); 00057 union { 00058 int32_t real; 00059 uint32_t base; 00060 } u_e_o_s; 00061 u_e_o_s.real = this->e_o_s; 00062 *(outbuffer + offset + 0) = (u_e_o_s.base >> (8 * 0)) & 0xFF; 00063 *(outbuffer + offset + 1) = (u_e_o_s.base >> (8 * 1)) & 0xFF; 00064 *(outbuffer + offset + 2) = (u_e_o_s.base >> (8 * 2)) & 0xFF; 00065 *(outbuffer + offset + 3) = (u_e_o_s.base >> (8 * 3)) & 0xFF; 00066 offset += sizeof(this->e_o_s); 00067 union { 00068 int64_t real; 00069 uint64_t base; 00070 } u_granulepos; 00071 u_granulepos.real = this->granulepos; 00072 *(outbuffer + offset + 0) = (u_granulepos.base >> (8 * 0)) & 0xFF; 00073 *(outbuffer + offset + 1) = (u_granulepos.base >> (8 * 1)) & 0xFF; 00074 *(outbuffer + offset + 2) = (u_granulepos.base >> (8 * 2)) & 0xFF; 00075 *(outbuffer + offset + 3) = (u_granulepos.base >> (8 * 3)) & 0xFF; 00076 *(outbuffer + offset + 4) = (u_granulepos.base >> (8 * 4)) & 0xFF; 00077 *(outbuffer + offset + 5) = (u_granulepos.base >> (8 * 5)) & 0xFF; 00078 *(outbuffer + offset + 6) = (u_granulepos.base >> (8 * 6)) & 0xFF; 00079 *(outbuffer + offset + 7) = (u_granulepos.base >> (8 * 7)) & 0xFF; 00080 offset += sizeof(this->granulepos); 00081 union { 00082 int64_t real; 00083 uint64_t base; 00084 } u_packetno; 00085 u_packetno.real = this->packetno; 00086 *(outbuffer + offset + 0) = (u_packetno.base >> (8 * 0)) & 0xFF; 00087 *(outbuffer + offset + 1) = (u_packetno.base >> (8 * 1)) & 0xFF; 00088 *(outbuffer + offset + 2) = (u_packetno.base >> (8 * 2)) & 0xFF; 00089 *(outbuffer + offset + 3) = (u_packetno.base >> (8 * 3)) & 0xFF; 00090 *(outbuffer + offset + 4) = (u_packetno.base >> (8 * 4)) & 0xFF; 00091 *(outbuffer + offset + 5) = (u_packetno.base >> (8 * 5)) & 0xFF; 00092 *(outbuffer + offset + 6) = (u_packetno.base >> (8 * 6)) & 0xFF; 00093 *(outbuffer + offset + 7) = (u_packetno.base >> (8 * 7)) & 0xFF; 00094 offset += sizeof(this->packetno); 00095 return offset; 00096 } 00097 00098 virtual int deserialize(unsigned char *inbuffer) 00099 { 00100 int offset = 0; 00101 offset += this->header.deserialize(inbuffer + offset); 00102 uint8_t data_lengthT = *(inbuffer + offset++); 00103 if(data_lengthT > data_length) 00104 this->data = (uint8_t*)realloc(this->data, data_lengthT * sizeof(uint8_t)); 00105 offset += 3; 00106 data_length = data_lengthT; 00107 for( uint8_t i = 0; i < data_length; i++){ 00108 this->st_data = ((uint8_t) (*(inbuffer + offset))); 00109 offset += sizeof(this->st_data); 00110 memcpy( &(this->data[i]), &(this->st_data), sizeof(uint8_t)); 00111 } 00112 union { 00113 int32_t real; 00114 uint32_t base; 00115 } u_b_o_s; 00116 u_b_o_s.base = 0; 00117 u_b_o_s.base |= ((uint32_t) (*(inbuffer + offset + 0))) << (8 * 0); 00118 u_b_o_s.base |= ((uint32_t) (*(inbuffer + offset + 1))) << (8 * 1); 00119 u_b_o_s.base |= ((uint32_t) (*(inbuffer + offset + 2))) << (8 * 2); 00120 u_b_o_s.base |= ((uint32_t) (*(inbuffer + offset + 3))) << (8 * 3); 00121 this->b_o_s = u_b_o_s.real; 00122 offset += sizeof(this->b_o_s); 00123 union { 00124 int32_t real; 00125 uint32_t base; 00126 } u_e_o_s; 00127 u_e_o_s.base = 0; 00128 u_e_o_s.base |= ((uint32_t) (*(inbuffer + offset + 0))) << (8 * 0); 00129 u_e_o_s.base |= ((uint32_t) (*(inbuffer + offset + 1))) << (8 * 1); 00130 u_e_o_s.base |= ((uint32_t) (*(inbuffer + offset + 2))) << (8 * 2); 00131 u_e_o_s.base |= ((uint32_t) (*(inbuffer + offset + 3))) << (8 * 3); 00132 this->e_o_s = u_e_o_s.real; 00133 offset += sizeof(this->e_o_s); 00134 union { 00135 int64_t real; 00136 uint64_t base; 00137 } u_granulepos; 00138 u_granulepos.base = 0; 00139 u_granulepos.base |= ((uint64_t) (*(inbuffer + offset + 0))) << (8 * 0); 00140 u_granulepos.base |= ((uint64_t) (*(inbuffer + offset + 1))) << (8 * 1); 00141 u_granulepos.base |= ((uint64_t) (*(inbuffer + offset + 2))) << (8 * 2); 00142 u_granulepos.base |= ((uint64_t) (*(inbuffer + offset + 3))) << (8 * 3); 00143 u_granulepos.base |= ((uint64_t) (*(inbuffer + offset + 4))) << (8 * 4); 00144 u_granulepos.base |= ((uint64_t) (*(inbuffer + offset + 5))) << (8 * 5); 00145 u_granulepos.base |= ((uint64_t) (*(inbuffer + offset + 6))) << (8 * 6); 00146 u_granulepos.base |= ((uint64_t) (*(inbuffer + offset + 7))) << (8 * 7); 00147 this->granulepos = u_granulepos.real; 00148 offset += sizeof(this->granulepos); 00149 union { 00150 int64_t real; 00151 uint64_t base; 00152 } u_packetno; 00153 u_packetno.base = 0; 00154 u_packetno.base |= ((uint64_t) (*(inbuffer + offset + 0))) << (8 * 0); 00155 u_packetno.base |= ((uint64_t) (*(inbuffer + offset + 1))) << (8 * 1); 00156 u_packetno.base |= ((uint64_t) (*(inbuffer + offset + 2))) << (8 * 2); 00157 u_packetno.base |= ((uint64_t) (*(inbuffer + offset + 3))) << (8 * 3); 00158 u_packetno.base |= ((uint64_t) (*(inbuffer + offset + 4))) << (8 * 4); 00159 u_packetno.base |= ((uint64_t) (*(inbuffer + offset + 5))) << (8 * 5); 00160 u_packetno.base |= ((uint64_t) (*(inbuffer + offset + 6))) << (8 * 6); 00161 u_packetno.base |= ((uint64_t) (*(inbuffer + offset + 7))) << (8 * 7); 00162 this->packetno = u_packetno.real; 00163 offset += sizeof(this->packetno); 00164 return offset; 00165 } 00166 00167 const char * getType(){ return "theora_image_transport/Packet"; }; 00168 const char * getMD5(){ return "33ac4e14a7cff32e7e0d65f18bb410f3"; }; 00169 00170 }; 00171 00172 } 00173 #endif
Generated on Tue Jul 12 2022 18:39:40 by 1.7.2