make changes on buffer serial
visualization_msgs/InteractiveMarkerInit.h@0:04ac6be8229a, 2019-11-08 (annotated)
- 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?
User | Revision | Line number | New contents of line |
---|---|---|---|
Gary Servin |
0:04ac6be8229a | 1 | #ifndef _ROS_visualization_msgs_InteractiveMarkerInit_h |
Gary Servin |
0:04ac6be8229a | 2 | #define _ROS_visualization_msgs_InteractiveMarkerInit_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 | #include "visualization_msgs/InteractiveMarker.h" |
Gary Servin |
0:04ac6be8229a | 9 | |
Gary Servin |
0:04ac6be8229a | 10 | namespace visualization_msgs |
Gary Servin |
0:04ac6be8229a | 11 | { |
Gary Servin |
0:04ac6be8229a | 12 | |
Gary Servin |
0:04ac6be8229a | 13 | class InteractiveMarkerInit : public ros::Msg |
Gary Servin |
0:04ac6be8229a | 14 | { |
Gary Servin |
0:04ac6be8229a | 15 | public: |
Gary Servin |
0:04ac6be8229a | 16 | typedef const char* _server_id_type; |
Gary Servin |
0:04ac6be8229a | 17 | _server_id_type server_id; |
Gary Servin |
0:04ac6be8229a | 18 | typedef uint64_t _seq_num_type; |
Gary Servin |
0:04ac6be8229a | 19 | _seq_num_type seq_num; |
Gary Servin |
0:04ac6be8229a | 20 | uint32_t markers_length; |
Gary Servin |
0:04ac6be8229a | 21 | typedef visualization_msgs::InteractiveMarker _markers_type; |
Gary Servin |
0:04ac6be8229a | 22 | _markers_type st_markers; |
Gary Servin |
0:04ac6be8229a | 23 | _markers_type * markers; |
Gary Servin |
0:04ac6be8229a | 24 | |
Gary Servin |
0:04ac6be8229a | 25 | InteractiveMarkerInit(): |
Gary Servin |
0:04ac6be8229a | 26 | server_id(""), |
Gary Servin |
0:04ac6be8229a | 27 | seq_num(0), |
Gary Servin |
0:04ac6be8229a | 28 | markers_length(0), markers(NULL) |
Gary Servin |
0:04ac6be8229a | 29 | { |
Gary Servin |
0:04ac6be8229a | 30 | } |
Gary Servin |
0:04ac6be8229a | 31 | |
Gary Servin |
0:04ac6be8229a | 32 | virtual int serialize(unsigned char *outbuffer) const |
Gary Servin |
0:04ac6be8229a | 33 | { |
Gary Servin |
0:04ac6be8229a | 34 | int offset = 0; |
Gary Servin |
0:04ac6be8229a | 35 | uint32_t length_server_id = strlen(this->server_id); |
Gary Servin |
0:04ac6be8229a | 36 | varToArr(outbuffer + offset, length_server_id); |
Gary Servin |
0:04ac6be8229a | 37 | offset += 4; |
Gary Servin |
0:04ac6be8229a | 38 | memcpy(outbuffer + offset, this->server_id, length_server_id); |
Gary Servin |
0:04ac6be8229a | 39 | offset += length_server_id; |
Gary Servin |
0:04ac6be8229a | 40 | union { |
Gary Servin |
0:04ac6be8229a | 41 | uint64_t real; |
Gary Servin |
0:04ac6be8229a | 42 | uint32_t base; |
Gary Servin |
0:04ac6be8229a | 43 | } u_seq_num; |
Gary Servin |
0:04ac6be8229a | 44 | u_seq_num.real = this->seq_num; |
Gary Servin |
0:04ac6be8229a | 45 | *(outbuffer + offset + 0) = (u_seq_num.base >> (8 * 0)) & 0xFF; |
Gary Servin |
0:04ac6be8229a | 46 | *(outbuffer + offset + 1) = (u_seq_num.base >> (8 * 1)) & 0xFF; |
Gary Servin |
0:04ac6be8229a | 47 | *(outbuffer + offset + 2) = (u_seq_num.base >> (8 * 2)) & 0xFF; |
Gary Servin |
0:04ac6be8229a | 48 | *(outbuffer + offset + 3) = (u_seq_num.base >> (8 * 3)) & 0xFF; |
Gary Servin |
0:04ac6be8229a | 49 | offset += sizeof(this->seq_num); |
Gary Servin |
0:04ac6be8229a | 50 | *(outbuffer + offset + 0) = (this->markers_length >> (8 * 0)) & 0xFF; |
Gary Servin |
0:04ac6be8229a | 51 | *(outbuffer + offset + 1) = (this->markers_length >> (8 * 1)) & 0xFF; |
Gary Servin |
0:04ac6be8229a | 52 | *(outbuffer + offset + 2) = (this->markers_length >> (8 * 2)) & 0xFF; |
Gary Servin |
0:04ac6be8229a | 53 | *(outbuffer + offset + 3) = (this->markers_length >> (8 * 3)) & 0xFF; |
Gary Servin |
0:04ac6be8229a | 54 | offset += sizeof(this->markers_length); |
Gary Servin |
0:04ac6be8229a | 55 | for( uint32_t i = 0; i < markers_length; i++){ |
Gary Servin |
0:04ac6be8229a | 56 | offset += this->markers[i].serialize(outbuffer + offset); |
Gary Servin |
0:04ac6be8229a | 57 | } |
Gary Servin |
0:04ac6be8229a | 58 | return offset; |
Gary Servin |
0:04ac6be8229a | 59 | } |
Gary Servin |
0:04ac6be8229a | 60 | |
Gary Servin |
0:04ac6be8229a | 61 | virtual int deserialize(unsigned char *inbuffer) |
Gary Servin |
0:04ac6be8229a | 62 | { |
Gary Servin |
0:04ac6be8229a | 63 | int offset = 0; |
Gary Servin |
0:04ac6be8229a | 64 | uint32_t length_server_id; |
Gary Servin |
0:04ac6be8229a | 65 | arrToVar(length_server_id, (inbuffer + offset)); |
Gary Servin |
0:04ac6be8229a | 66 | offset += 4; |
Gary Servin |
0:04ac6be8229a | 67 | for(unsigned int k= offset; k< offset+length_server_id; ++k){ |
Gary Servin |
0:04ac6be8229a | 68 | inbuffer[k-1]=inbuffer[k]; |
Gary Servin |
0:04ac6be8229a | 69 | } |
Gary Servin |
0:04ac6be8229a | 70 | inbuffer[offset+length_server_id-1]=0; |
Gary Servin |
0:04ac6be8229a | 71 | this->server_id = (char *)(inbuffer + offset-1); |
Gary Servin |
0:04ac6be8229a | 72 | offset += length_server_id; |
Gary Servin |
0:04ac6be8229a | 73 | union { |
Gary Servin |
0:04ac6be8229a | 74 | uint64_t real; |
Gary Servin |
0:04ac6be8229a | 75 | uint32_t base; |
Gary Servin |
0:04ac6be8229a | 76 | } u_seq_num; |
Gary Servin |
0:04ac6be8229a | 77 | u_seq_num.base = 0; |
Gary Servin |
0:04ac6be8229a | 78 | u_seq_num.base |= ((uint32_t) (*(inbuffer + offset + 0))) << (8 * 0); |
Gary Servin |
0:04ac6be8229a | 79 | u_seq_num.base |= ((uint32_t) (*(inbuffer + offset + 1))) << (8 * 1); |
Gary Servin |
0:04ac6be8229a | 80 | u_seq_num.base |= ((uint32_t) (*(inbuffer + offset + 2))) << (8 * 2); |
Gary Servin |
0:04ac6be8229a | 81 | u_seq_num.base |= ((uint32_t) (*(inbuffer + offset + 3))) << (8 * 3); |
Gary Servin |
0:04ac6be8229a | 82 | this->seq_num = u_seq_num.real; |
Gary Servin |
0:04ac6be8229a | 83 | offset += sizeof(this->seq_num); |
Gary Servin |
0:04ac6be8229a | 84 | uint32_t markers_lengthT = ((uint32_t) (*(inbuffer + offset))); |
Gary Servin |
0:04ac6be8229a | 85 | markers_lengthT |= ((uint32_t) (*(inbuffer + offset + 1))) << (8 * 1); |
Gary Servin |
0:04ac6be8229a | 86 | markers_lengthT |= ((uint32_t) (*(inbuffer + offset + 2))) << (8 * 2); |
Gary Servin |
0:04ac6be8229a | 87 | markers_lengthT |= ((uint32_t) (*(inbuffer + offset + 3))) << (8 * 3); |
Gary Servin |
0:04ac6be8229a | 88 | offset += sizeof(this->markers_length); |
Gary Servin |
0:04ac6be8229a | 89 | if(markers_lengthT > markers_length) |
Gary Servin |
0:04ac6be8229a | 90 | this->markers = (visualization_msgs::InteractiveMarker*)realloc(this->markers, markers_lengthT * sizeof(visualization_msgs::InteractiveMarker)); |
Gary Servin |
0:04ac6be8229a | 91 | markers_length = markers_lengthT; |
Gary Servin |
0:04ac6be8229a | 92 | for( uint32_t i = 0; i < markers_length; i++){ |
Gary Servin |
0:04ac6be8229a | 93 | offset += this->st_markers.deserialize(inbuffer + offset); |
Gary Servin |
0:04ac6be8229a | 94 | memcpy( &(this->markers[i]), &(this->st_markers), sizeof(visualization_msgs::InteractiveMarker)); |
Gary Servin |
0:04ac6be8229a | 95 | } |
Gary Servin |
0:04ac6be8229a | 96 | return offset; |
Gary Servin |
0:04ac6be8229a | 97 | } |
Gary Servin |
0:04ac6be8229a | 98 | |
Gary Servin |
0:04ac6be8229a | 99 | const char * getType(){ return "visualization_msgs/InteractiveMarkerInit"; }; |
Gary Servin |
0:04ac6be8229a | 100 | const char * getMD5(){ return "d5f2c5045a72456d228676ab91048734"; }; |
Gary Servin |
0:04ac6be8229a | 101 | |
Gary Servin |
0:04ac6be8229a | 102 | }; |
Gary Servin |
0:04ac6be8229a | 103 | |
Gary Servin |
0:04ac6be8229a | 104 | } |
Gary Servin |
0:04ac6be8229a | 105 | #endif |