Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Fork of rosserial_mbed_lib by
CompressedImage.h
00001 #ifndef _ROS_sensor_msgs_CompressedImage_h 00002 #define _ROS_sensor_msgs_CompressedImage_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 sensor_msgs 00011 { 00012 00013 class CompressedImage : public ros::Msg 00014 { 00015 public: 00016 std_msgs::Header header; 00017 char * format; 00018 uint8_t data_length; 00019 uint8_t st_data; 00020 uint8_t * data; 00021 00022 virtual int serialize(unsigned char *outbuffer) const 00023 { 00024 int offset = 0; 00025 offset += this->header.serialize(outbuffer + offset); 00026 uint32_t * length_format = (uint32_t *)(outbuffer + offset); 00027 *length_format = strlen( (const char*) this->format); 00028 offset += 4; 00029 memcpy(outbuffer + offset, this->format, *length_format); 00030 offset += *length_format; 00031 *(outbuffer + offset++) = data_length; 00032 *(outbuffer + offset++) = 0; 00033 *(outbuffer + offset++) = 0; 00034 *(outbuffer + offset++) = 0; 00035 for( uint8_t i = 0; i < data_length; i++){ 00036 *(outbuffer + offset + 0) = (this->data[i] >> (8 * 0)) & 0xFF; 00037 offset += sizeof(this->data[i]); 00038 } 00039 return offset; 00040 } 00041 00042 virtual int deserialize(unsigned char *inbuffer) 00043 { 00044 int offset = 0; 00045 offset += this->header.deserialize(inbuffer + offset); 00046 uint32_t length_format = *(uint32_t *)(inbuffer + offset); 00047 offset += 4; 00048 for(unsigned int k= offset; k< offset+length_format; ++k){ 00049 inbuffer[k-1]=inbuffer[k]; 00050 } 00051 inbuffer[offset+length_format-1]=0; 00052 this->format = (char *)(inbuffer + offset-1); 00053 offset += length_format; 00054 uint8_t data_lengthT = *(inbuffer + offset++); 00055 if(data_lengthT > data_length) 00056 this->data = (uint8_t*)realloc(this->data, data_lengthT * sizeof(uint8_t)); 00057 offset += 3; 00058 data_length = data_lengthT; 00059 for( uint8_t i = 0; i < data_length; i++){ 00060 this->st_data |= ((uint8_t) (*(inbuffer + offset + 0))) << (8 * 0); 00061 offset += sizeof(this->st_data); 00062 memcpy( &(this->data[i]), &(this->st_data), sizeof(uint8_t)); 00063 } 00064 return offset; 00065 } 00066 00067 virtual const char * getType(){ return "sensor_msgs/CompressedImage"; }; 00068 virtual const char * getMD5(){ return "8f7a12909da2c9d3332d540a0977563f"; }; 00069 00070 }; 00071 00072 } 00073 #endif
Generated on Tue Jul 12 2022 19:53:56 by
1.7.2
