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.
ros_lib/mavros_msgs/FileEntry.h@0:8f3710bfd298, 2020-09-02 (annotated)
- Committer:
- irfantitok
- Date:
- Wed Sep 02 13:51:31 2020 +0000
- Revision:
- 0:8f3710bfd298
Resolved round not found
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
irfantitok | 0:8f3710bfd298 | 1 | #ifndef _ROS_mavros_msgs_FileEntry_h |
irfantitok | 0:8f3710bfd298 | 2 | #define _ROS_mavros_msgs_FileEntry_h |
irfantitok | 0:8f3710bfd298 | 3 | |
irfantitok | 0:8f3710bfd298 | 4 | #include <stdint.h> |
irfantitok | 0:8f3710bfd298 | 5 | #include <string.h> |
irfantitok | 0:8f3710bfd298 | 6 | #include <stdlib.h> |
irfantitok | 0:8f3710bfd298 | 7 | #include "ros/msg.h" |
irfantitok | 0:8f3710bfd298 | 8 | |
irfantitok | 0:8f3710bfd298 | 9 | namespace mavros_msgs |
irfantitok | 0:8f3710bfd298 | 10 | { |
irfantitok | 0:8f3710bfd298 | 11 | |
irfantitok | 0:8f3710bfd298 | 12 | class FileEntry : public ros::Msg |
irfantitok | 0:8f3710bfd298 | 13 | { |
irfantitok | 0:8f3710bfd298 | 14 | public: |
irfantitok | 0:8f3710bfd298 | 15 | typedef const char* _name_type; |
irfantitok | 0:8f3710bfd298 | 16 | _name_type name; |
irfantitok | 0:8f3710bfd298 | 17 | typedef uint8_t _type_type; |
irfantitok | 0:8f3710bfd298 | 18 | _type_type type; |
irfantitok | 0:8f3710bfd298 | 19 | typedef uint64_t _size_type; |
irfantitok | 0:8f3710bfd298 | 20 | _size_type size; |
irfantitok | 0:8f3710bfd298 | 21 | enum { TYPE_FILE = 0 }; |
irfantitok | 0:8f3710bfd298 | 22 | enum { TYPE_DIRECTORY = 1 }; |
irfantitok | 0:8f3710bfd298 | 23 | |
irfantitok | 0:8f3710bfd298 | 24 | FileEntry(): |
irfantitok | 0:8f3710bfd298 | 25 | name(""), |
irfantitok | 0:8f3710bfd298 | 26 | type(0), |
irfantitok | 0:8f3710bfd298 | 27 | size(0) |
irfantitok | 0:8f3710bfd298 | 28 | { |
irfantitok | 0:8f3710bfd298 | 29 | } |
irfantitok | 0:8f3710bfd298 | 30 | |
irfantitok | 0:8f3710bfd298 | 31 | virtual int serialize(unsigned char *outbuffer) const |
irfantitok | 0:8f3710bfd298 | 32 | { |
irfantitok | 0:8f3710bfd298 | 33 | int offset = 0; |
irfantitok | 0:8f3710bfd298 | 34 | uint32_t length_name = strlen(this->name); |
irfantitok | 0:8f3710bfd298 | 35 | varToArr(outbuffer + offset, length_name); |
irfantitok | 0:8f3710bfd298 | 36 | offset += 4; |
irfantitok | 0:8f3710bfd298 | 37 | memcpy(outbuffer + offset, this->name, length_name); |
irfantitok | 0:8f3710bfd298 | 38 | offset += length_name; |
irfantitok | 0:8f3710bfd298 | 39 | *(outbuffer + offset + 0) = (this->type >> (8 * 0)) & 0xFF; |
irfantitok | 0:8f3710bfd298 | 40 | offset += sizeof(this->type); |
irfantitok | 0:8f3710bfd298 | 41 | union { |
irfantitok | 0:8f3710bfd298 | 42 | uint64_t real; |
irfantitok | 0:8f3710bfd298 | 43 | uint32_t base; |
irfantitok | 0:8f3710bfd298 | 44 | } u_size; |
irfantitok | 0:8f3710bfd298 | 45 | u_size.real = this->size; |
irfantitok | 0:8f3710bfd298 | 46 | *(outbuffer + offset + 0) = (u_size.base >> (8 * 0)) & 0xFF; |
irfantitok | 0:8f3710bfd298 | 47 | *(outbuffer + offset + 1) = (u_size.base >> (8 * 1)) & 0xFF; |
irfantitok | 0:8f3710bfd298 | 48 | *(outbuffer + offset + 2) = (u_size.base >> (8 * 2)) & 0xFF; |
irfantitok | 0:8f3710bfd298 | 49 | *(outbuffer + offset + 3) = (u_size.base >> (8 * 3)) & 0xFF; |
irfantitok | 0:8f3710bfd298 | 50 | offset += sizeof(this->size); |
irfantitok | 0:8f3710bfd298 | 51 | return offset; |
irfantitok | 0:8f3710bfd298 | 52 | } |
irfantitok | 0:8f3710bfd298 | 53 | |
irfantitok | 0:8f3710bfd298 | 54 | virtual int deserialize(unsigned char *inbuffer) |
irfantitok | 0:8f3710bfd298 | 55 | { |
irfantitok | 0:8f3710bfd298 | 56 | int offset = 0; |
irfantitok | 0:8f3710bfd298 | 57 | uint32_t length_name; |
irfantitok | 0:8f3710bfd298 | 58 | arrToVar(length_name, (inbuffer + offset)); |
irfantitok | 0:8f3710bfd298 | 59 | offset += 4; |
irfantitok | 0:8f3710bfd298 | 60 | for(unsigned int k= offset; k< offset+length_name; ++k){ |
irfantitok | 0:8f3710bfd298 | 61 | inbuffer[k-1]=inbuffer[k]; |
irfantitok | 0:8f3710bfd298 | 62 | } |
irfantitok | 0:8f3710bfd298 | 63 | inbuffer[offset+length_name-1]=0; |
irfantitok | 0:8f3710bfd298 | 64 | this->name = (char *)(inbuffer + offset-1); |
irfantitok | 0:8f3710bfd298 | 65 | offset += length_name; |
irfantitok | 0:8f3710bfd298 | 66 | this->type = ((uint8_t) (*(inbuffer + offset))); |
irfantitok | 0:8f3710bfd298 | 67 | offset += sizeof(this->type); |
irfantitok | 0:8f3710bfd298 | 68 | union { |
irfantitok | 0:8f3710bfd298 | 69 | uint64_t real; |
irfantitok | 0:8f3710bfd298 | 70 | uint32_t base; |
irfantitok | 0:8f3710bfd298 | 71 | } u_size; |
irfantitok | 0:8f3710bfd298 | 72 | u_size.base = 0; |
irfantitok | 0:8f3710bfd298 | 73 | u_size.base |= ((uint32_t) (*(inbuffer + offset + 0))) << (8 * 0); |
irfantitok | 0:8f3710bfd298 | 74 | u_size.base |= ((uint32_t) (*(inbuffer + offset + 1))) << (8 * 1); |
irfantitok | 0:8f3710bfd298 | 75 | u_size.base |= ((uint32_t) (*(inbuffer + offset + 2))) << (8 * 2); |
irfantitok | 0:8f3710bfd298 | 76 | u_size.base |= ((uint32_t) (*(inbuffer + offset + 3))) << (8 * 3); |
irfantitok | 0:8f3710bfd298 | 77 | this->size = u_size.real; |
irfantitok | 0:8f3710bfd298 | 78 | offset += sizeof(this->size); |
irfantitok | 0:8f3710bfd298 | 79 | return offset; |
irfantitok | 0:8f3710bfd298 | 80 | } |
irfantitok | 0:8f3710bfd298 | 81 | |
irfantitok | 0:8f3710bfd298 | 82 | const char * getType(){ return "mavros_msgs/FileEntry"; }; |
irfantitok | 0:8f3710bfd298 | 83 | const char * getMD5(){ return "5ed706bccb946c5b3a5087569cc53ac3"; }; |
irfantitok | 0:8f3710bfd298 | 84 | |
irfantitok | 0:8f3710bfd298 | 85 | }; |
irfantitok | 0:8f3710bfd298 | 86 | |
irfantitok | 0:8f3710bfd298 | 87 | } |
irfantitok | 0:8f3710bfd298 | 88 | #endif |