Packet.h
Go to the documentation of this file.
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     virtual int serialize(unsigned char *outbuffer) const
00026     {
00027       int offset = 0;
00028       offset += this->header.serialize(outbuffer + offset);
00029       *(outbuffer + offset++) = data_length;
00030       *(outbuffer + offset++) = 0;
00031       *(outbuffer + offset++) = 0;
00032       *(outbuffer + offset++) = 0;
00033       for( uint8_t i = 0; i < data_length; i++){
00034       *(outbuffer + offset + 0) = (this->data[i] >> (8 * 0)) & 0xFF;
00035       offset += sizeof(this->data[i]);
00036       }
00037       union {
00038         int32_t real;
00039         uint32_t base;
00040       } u_b_o_s;
00041       u_b_o_s.real = this->b_o_s;
00042       *(outbuffer + offset + 0) = (u_b_o_s.base >> (8 * 0)) & 0xFF;
00043       *(outbuffer + offset + 1) = (u_b_o_s.base >> (8 * 1)) & 0xFF;
00044       *(outbuffer + offset + 2) = (u_b_o_s.base >> (8 * 2)) & 0xFF;
00045       *(outbuffer + offset + 3) = (u_b_o_s.base >> (8 * 3)) & 0xFF;
00046       offset += sizeof(this->b_o_s);
00047       union {
00048         int32_t real;
00049         uint32_t base;
00050       } u_e_o_s;
00051       u_e_o_s.real = this->e_o_s;
00052       *(outbuffer + offset + 0) = (u_e_o_s.base >> (8 * 0)) & 0xFF;
00053       *(outbuffer + offset + 1) = (u_e_o_s.base >> (8 * 1)) & 0xFF;
00054       *(outbuffer + offset + 2) = (u_e_o_s.base >> (8 * 2)) & 0xFF;
00055       *(outbuffer + offset + 3) = (u_e_o_s.base >> (8 * 3)) & 0xFF;
00056       offset += sizeof(this->e_o_s);
00057       union {
00058         int64_t real;
00059         uint64_t base;
00060       } u_granulepos;
00061       u_granulepos.real = this->granulepos;
00062       *(outbuffer + offset + 0) = (u_granulepos.base >> (8 * 0)) & 0xFF;
00063       *(outbuffer + offset + 1) = (u_granulepos.base >> (8 * 1)) & 0xFF;
00064       *(outbuffer + offset + 2) = (u_granulepos.base >> (8 * 2)) & 0xFF;
00065       *(outbuffer + offset + 3) = (u_granulepos.base >> (8 * 3)) & 0xFF;
00066       *(outbuffer + offset + 4) = (u_granulepos.base >> (8 * 4)) & 0xFF;
00067       *(outbuffer + offset + 5) = (u_granulepos.base >> (8 * 5)) & 0xFF;
00068       *(outbuffer + offset + 6) = (u_granulepos.base >> (8 * 6)) & 0xFF;
00069       *(outbuffer + offset + 7) = (u_granulepos.base >> (8 * 7)) & 0xFF;
00070       offset += sizeof(this->granulepos);
00071       union {
00072         int64_t real;
00073         uint64_t base;
00074       } u_packetno;
00075       u_packetno.real = this->packetno;
00076       *(outbuffer + offset + 0) = (u_packetno.base >> (8 * 0)) & 0xFF;
00077       *(outbuffer + offset + 1) = (u_packetno.base >> (8 * 1)) & 0xFF;
00078       *(outbuffer + offset + 2) = (u_packetno.base >> (8 * 2)) & 0xFF;
00079       *(outbuffer + offset + 3) = (u_packetno.base >> (8 * 3)) & 0xFF;
00080       *(outbuffer + offset + 4) = (u_packetno.base >> (8 * 4)) & 0xFF;
00081       *(outbuffer + offset + 5) = (u_packetno.base >> (8 * 5)) & 0xFF;
00082       *(outbuffer + offset + 6) = (u_packetno.base >> (8 * 6)) & 0xFF;
00083       *(outbuffer + offset + 7) = (u_packetno.base >> (8 * 7)) & 0xFF;
00084       offset += sizeof(this->packetno);
00085       return offset;
00086     }
00087 
00088     virtual int deserialize(unsigned char *inbuffer)
00089     {
00090       int offset = 0;
00091       offset += this->header.deserialize(inbuffer + offset);
00092       uint8_t data_lengthT = *(inbuffer + offset++);
00093       if(data_lengthT > data_length)
00094         this->data = (uint8_t*)realloc(this->data, data_lengthT * sizeof(uint8_t));
00095       offset += 3;
00096       data_length = data_lengthT;
00097       for( uint8_t i = 0; i < data_length; i++){
00098       this->st_data =  ((uint8_t) (*(inbuffer + offset)));
00099       offset += sizeof(this->st_data);
00100         memcpy( &(this->data[i]), &(this->st_data), sizeof(uint8_t));
00101       }
00102       union {
00103         int32_t real;
00104         uint32_t base;
00105       } u_b_o_s;
00106       u_b_o_s.base = 0;
00107       u_b_o_s.base |= ((uint32_t) (*(inbuffer + offset + 0))) << (8 * 0);
00108       u_b_o_s.base |= ((uint32_t) (*(inbuffer + offset + 1))) << (8 * 1);
00109       u_b_o_s.base |= ((uint32_t) (*(inbuffer + offset + 2))) << (8 * 2);
00110       u_b_o_s.base |= ((uint32_t) (*(inbuffer + offset + 3))) << (8 * 3);
00111       this->b_o_s = u_b_o_s.real;
00112       offset += sizeof(this->b_o_s);
00113       union {
00114         int32_t real;
00115         uint32_t base;
00116       } u_e_o_s;
00117       u_e_o_s.base = 0;
00118       u_e_o_s.base |= ((uint32_t) (*(inbuffer + offset + 0))) << (8 * 0);
00119       u_e_o_s.base |= ((uint32_t) (*(inbuffer + offset + 1))) << (8 * 1);
00120       u_e_o_s.base |= ((uint32_t) (*(inbuffer + offset + 2))) << (8 * 2);
00121       u_e_o_s.base |= ((uint32_t) (*(inbuffer + offset + 3))) << (8 * 3);
00122       this->e_o_s = u_e_o_s.real;
00123       offset += sizeof(this->e_o_s);
00124       union {
00125         int64_t real;
00126         uint64_t base;
00127       } u_granulepos;
00128       u_granulepos.base = 0;
00129       u_granulepos.base |= ((uint64_t) (*(inbuffer + offset + 0))) << (8 * 0);
00130       u_granulepos.base |= ((uint64_t) (*(inbuffer + offset + 1))) << (8 * 1);
00131       u_granulepos.base |= ((uint64_t) (*(inbuffer + offset + 2))) << (8 * 2);
00132       u_granulepos.base |= ((uint64_t) (*(inbuffer + offset + 3))) << (8 * 3);
00133       u_granulepos.base |= ((uint64_t) (*(inbuffer + offset + 4))) << (8 * 4);
00134       u_granulepos.base |= ((uint64_t) (*(inbuffer + offset + 5))) << (8 * 5);
00135       u_granulepos.base |= ((uint64_t) (*(inbuffer + offset + 6))) << (8 * 6);
00136       u_granulepos.base |= ((uint64_t) (*(inbuffer + offset + 7))) << (8 * 7);
00137       this->granulepos = u_granulepos.real;
00138       offset += sizeof(this->granulepos);
00139       union {
00140         int64_t real;
00141         uint64_t base;
00142       } u_packetno;
00143       u_packetno.base = 0;
00144       u_packetno.base |= ((uint64_t) (*(inbuffer + offset + 0))) << (8 * 0);
00145       u_packetno.base |= ((uint64_t) (*(inbuffer + offset + 1))) << (8 * 1);
00146       u_packetno.base |= ((uint64_t) (*(inbuffer + offset + 2))) << (8 * 2);
00147       u_packetno.base |= ((uint64_t) (*(inbuffer + offset + 3))) << (8 * 3);
00148       u_packetno.base |= ((uint64_t) (*(inbuffer + offset + 4))) << (8 * 4);
00149       u_packetno.base |= ((uint64_t) (*(inbuffer + offset + 5))) << (8 * 5);
00150       u_packetno.base |= ((uint64_t) (*(inbuffer + offset + 6))) << (8 * 6);
00151       u_packetno.base |= ((uint64_t) (*(inbuffer + offset + 7))) << (8 * 7);
00152       this->packetno = u_packetno.real;
00153       offset += sizeof(this->packetno);
00154      return offset;
00155     }
00156 
00157     const char * getType(){ return "theora_image_transport/Packet"; };
00158     const char * getMD5(){ return "33ac4e14a7cff32e7e0d65f18bb410f3"; };
00159 
00160   };
00161 
00162 }
00163 #endif


lizi_arduino
Author(s): RoboTiCan
autogenerated on Wed Aug 26 2015 12:24:22