make changes on buffer serial

Dependencies:   BufferedSerial

Dependents:  

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_dynamic_reconfigure_ParamDescription_h
Gary Servin 0:04ac6be8229a 2 #define _ROS_dynamic_reconfigure_ParamDescription_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
Gary Servin 0:04ac6be8229a 9 namespace dynamic_reconfigure
Gary Servin 0:04ac6be8229a 10 {
Gary Servin 0:04ac6be8229a 11
Gary Servin 0:04ac6be8229a 12 class ParamDescription : public ros::Msg
Gary Servin 0:04ac6be8229a 13 {
Gary Servin 0:04ac6be8229a 14 public:
Gary Servin 0:04ac6be8229a 15 typedef const char* _name_type;
Gary Servin 0:04ac6be8229a 16 _name_type name;
Gary Servin 0:04ac6be8229a 17 typedef const char* _type_type;
Gary Servin 0:04ac6be8229a 18 _type_type type;
Gary Servin 0:04ac6be8229a 19 typedef uint32_t _level_type;
Gary Servin 0:04ac6be8229a 20 _level_type level;
Gary Servin 0:04ac6be8229a 21 typedef const char* _description_type;
Gary Servin 0:04ac6be8229a 22 _description_type description;
Gary Servin 0:04ac6be8229a 23 typedef const char* _edit_method_type;
Gary Servin 0:04ac6be8229a 24 _edit_method_type edit_method;
Gary Servin 0:04ac6be8229a 25
Gary Servin 0:04ac6be8229a 26 ParamDescription():
Gary Servin 0:04ac6be8229a 27 name(""),
Gary Servin 0:04ac6be8229a 28 type(""),
Gary Servin 0:04ac6be8229a 29 level(0),
Gary Servin 0:04ac6be8229a 30 description(""),
Gary Servin 0:04ac6be8229a 31 edit_method("")
Gary Servin 0:04ac6be8229a 32 {
Gary Servin 0:04ac6be8229a 33 }
Gary Servin 0:04ac6be8229a 34
Gary Servin 0:04ac6be8229a 35 virtual int serialize(unsigned char *outbuffer) const
Gary Servin 0:04ac6be8229a 36 {
Gary Servin 0:04ac6be8229a 37 int offset = 0;
Gary Servin 0:04ac6be8229a 38 uint32_t length_name = strlen(this->name);
Gary Servin 0:04ac6be8229a 39 varToArr(outbuffer + offset, length_name);
Gary Servin 0:04ac6be8229a 40 offset += 4;
Gary Servin 0:04ac6be8229a 41 memcpy(outbuffer + offset, this->name, length_name);
Gary Servin 0:04ac6be8229a 42 offset += length_name;
Gary Servin 0:04ac6be8229a 43 uint32_t length_type = strlen(this->type);
Gary Servin 0:04ac6be8229a 44 varToArr(outbuffer + offset, length_type);
Gary Servin 0:04ac6be8229a 45 offset += 4;
Gary Servin 0:04ac6be8229a 46 memcpy(outbuffer + offset, this->type, length_type);
Gary Servin 0:04ac6be8229a 47 offset += length_type;
Gary Servin 0:04ac6be8229a 48 *(outbuffer + offset + 0) = (this->level >> (8 * 0)) & 0xFF;
Gary Servin 0:04ac6be8229a 49 *(outbuffer + offset + 1) = (this->level >> (8 * 1)) & 0xFF;
Gary Servin 0:04ac6be8229a 50 *(outbuffer + offset + 2) = (this->level >> (8 * 2)) & 0xFF;
Gary Servin 0:04ac6be8229a 51 *(outbuffer + offset + 3) = (this->level >> (8 * 3)) & 0xFF;
Gary Servin 0:04ac6be8229a 52 offset += sizeof(this->level);
Gary Servin 0:04ac6be8229a 53 uint32_t length_description = strlen(this->description);
Gary Servin 0:04ac6be8229a 54 varToArr(outbuffer + offset, length_description);
Gary Servin 0:04ac6be8229a 55 offset += 4;
Gary Servin 0:04ac6be8229a 56 memcpy(outbuffer + offset, this->description, length_description);
Gary Servin 0:04ac6be8229a 57 offset += length_description;
Gary Servin 0:04ac6be8229a 58 uint32_t length_edit_method = strlen(this->edit_method);
Gary Servin 0:04ac6be8229a 59 varToArr(outbuffer + offset, length_edit_method);
Gary Servin 0:04ac6be8229a 60 offset += 4;
Gary Servin 0:04ac6be8229a 61 memcpy(outbuffer + offset, this->edit_method, length_edit_method);
Gary Servin 0:04ac6be8229a 62 offset += length_edit_method;
Gary Servin 0:04ac6be8229a 63 return offset;
Gary Servin 0:04ac6be8229a 64 }
Gary Servin 0:04ac6be8229a 65
Gary Servin 0:04ac6be8229a 66 virtual int deserialize(unsigned char *inbuffer)
Gary Servin 0:04ac6be8229a 67 {
Gary Servin 0:04ac6be8229a 68 int offset = 0;
Gary Servin 0:04ac6be8229a 69 uint32_t length_name;
Gary Servin 0:04ac6be8229a 70 arrToVar(length_name, (inbuffer + offset));
Gary Servin 0:04ac6be8229a 71 offset += 4;
Gary Servin 0:04ac6be8229a 72 for(unsigned int k= offset; k< offset+length_name; ++k){
Gary Servin 0:04ac6be8229a 73 inbuffer[k-1]=inbuffer[k];
Gary Servin 0:04ac6be8229a 74 }
Gary Servin 0:04ac6be8229a 75 inbuffer[offset+length_name-1]=0;
Gary Servin 0:04ac6be8229a 76 this->name = (char *)(inbuffer + offset-1);
Gary Servin 0:04ac6be8229a 77 offset += length_name;
Gary Servin 0:04ac6be8229a 78 uint32_t length_type;
Gary Servin 0:04ac6be8229a 79 arrToVar(length_type, (inbuffer + offset));
Gary Servin 0:04ac6be8229a 80 offset += 4;
Gary Servin 0:04ac6be8229a 81 for(unsigned int k= offset; k< offset+length_type; ++k){
Gary Servin 0:04ac6be8229a 82 inbuffer[k-1]=inbuffer[k];
Gary Servin 0:04ac6be8229a 83 }
Gary Servin 0:04ac6be8229a 84 inbuffer[offset+length_type-1]=0;
Gary Servin 0:04ac6be8229a 85 this->type = (char *)(inbuffer + offset-1);
Gary Servin 0:04ac6be8229a 86 offset += length_type;
Gary Servin 0:04ac6be8229a 87 this->level = ((uint32_t) (*(inbuffer + offset)));
Gary Servin 0:04ac6be8229a 88 this->level |= ((uint32_t) (*(inbuffer + offset + 1))) << (8 * 1);
Gary Servin 0:04ac6be8229a 89 this->level |= ((uint32_t) (*(inbuffer + offset + 2))) << (8 * 2);
Gary Servin 0:04ac6be8229a 90 this->level |= ((uint32_t) (*(inbuffer + offset + 3))) << (8 * 3);
Gary Servin 0:04ac6be8229a 91 offset += sizeof(this->level);
Gary Servin 0:04ac6be8229a 92 uint32_t length_description;
Gary Servin 0:04ac6be8229a 93 arrToVar(length_description, (inbuffer + offset));
Gary Servin 0:04ac6be8229a 94 offset += 4;
Gary Servin 0:04ac6be8229a 95 for(unsigned int k= offset; k< offset+length_description; ++k){
Gary Servin 0:04ac6be8229a 96 inbuffer[k-1]=inbuffer[k];
Gary Servin 0:04ac6be8229a 97 }
Gary Servin 0:04ac6be8229a 98 inbuffer[offset+length_description-1]=0;
Gary Servin 0:04ac6be8229a 99 this->description = (char *)(inbuffer + offset-1);
Gary Servin 0:04ac6be8229a 100 offset += length_description;
Gary Servin 0:04ac6be8229a 101 uint32_t length_edit_method;
Gary Servin 0:04ac6be8229a 102 arrToVar(length_edit_method, (inbuffer + offset));
Gary Servin 0:04ac6be8229a 103 offset += 4;
Gary Servin 0:04ac6be8229a 104 for(unsigned int k= offset; k< offset+length_edit_method; ++k){
Gary Servin 0:04ac6be8229a 105 inbuffer[k-1]=inbuffer[k];
Gary Servin 0:04ac6be8229a 106 }
Gary Servin 0:04ac6be8229a 107 inbuffer[offset+length_edit_method-1]=0;
Gary Servin 0:04ac6be8229a 108 this->edit_method = (char *)(inbuffer + offset-1);
Gary Servin 0:04ac6be8229a 109 offset += length_edit_method;
Gary Servin 0:04ac6be8229a 110 return offset;
Gary Servin 0:04ac6be8229a 111 }
Gary Servin 0:04ac6be8229a 112
Gary Servin 0:04ac6be8229a 113 const char * getType(){ return "dynamic_reconfigure/ParamDescription"; };
Gary Servin 0:04ac6be8229a 114 const char * getMD5(){ return "7434fcb9348c13054e0c3b267c8cb34d"; };
Gary Servin 0:04ac6be8229a 115
Gary Servin 0:04ac6be8229a 116 };
Gary Servin 0:04ac6be8229a 117
Gary Servin 0:04ac6be8229a 118 }
Gary Servin 0:04ac6be8229a 119 #endif