rosserial library for mbed Inspired by nucho's rosserial library This library is still under development
Dependents: mbed_roshydro_test
Library still under development!
visualization_msgs/MenuEntry.h@0:30537dec6e0b, 2015-02-15 (annotated)
- Committer:
- akashvibhute
- Date:
- Sun Feb 15 10:53:43 2015 +0000
- Revision:
- 0:30537dec6e0b
First commit; Library still need to be debugged, compilation issues with new mbed and modserial updates.
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
akashvibhute | 0:30537dec6e0b | 1 | #ifndef _ROS_visualization_msgs_MenuEntry_h |
akashvibhute | 0:30537dec6e0b | 2 | #define _ROS_visualization_msgs_MenuEntry_h |
akashvibhute | 0:30537dec6e0b | 3 | |
akashvibhute | 0:30537dec6e0b | 4 | #include <stdint.h> |
akashvibhute | 0:30537dec6e0b | 5 | #include <string.h> |
akashvibhute | 0:30537dec6e0b | 6 | #include <stdlib.h> |
akashvibhute | 0:30537dec6e0b | 7 | #include "ros/msg.h" |
akashvibhute | 0:30537dec6e0b | 8 | |
akashvibhute | 0:30537dec6e0b | 9 | namespace visualization_msgs |
akashvibhute | 0:30537dec6e0b | 10 | { |
akashvibhute | 0:30537dec6e0b | 11 | |
akashvibhute | 0:30537dec6e0b | 12 | class MenuEntry : public ros::Msg |
akashvibhute | 0:30537dec6e0b | 13 | { |
akashvibhute | 0:30537dec6e0b | 14 | public: |
akashvibhute | 0:30537dec6e0b | 15 | uint32_t id; |
akashvibhute | 0:30537dec6e0b | 16 | uint32_t parent_id; |
akashvibhute | 0:30537dec6e0b | 17 | const char* title; |
akashvibhute | 0:30537dec6e0b | 18 | const char* command; |
akashvibhute | 0:30537dec6e0b | 19 | uint8_t command_type; |
akashvibhute | 0:30537dec6e0b | 20 | enum { FEEDBACK = 0 }; |
akashvibhute | 0:30537dec6e0b | 21 | enum { ROSRUN = 1 }; |
akashvibhute | 0:30537dec6e0b | 22 | enum { ROSLAUNCH = 2 }; |
akashvibhute | 0:30537dec6e0b | 23 | |
akashvibhute | 0:30537dec6e0b | 24 | MenuEntry(): |
akashvibhute | 0:30537dec6e0b | 25 | id(0), |
akashvibhute | 0:30537dec6e0b | 26 | parent_id(0), |
akashvibhute | 0:30537dec6e0b | 27 | title(""), |
akashvibhute | 0:30537dec6e0b | 28 | command(""), |
akashvibhute | 0:30537dec6e0b | 29 | command_type(0) |
akashvibhute | 0:30537dec6e0b | 30 | { |
akashvibhute | 0:30537dec6e0b | 31 | } |
akashvibhute | 0:30537dec6e0b | 32 | |
akashvibhute | 0:30537dec6e0b | 33 | virtual int serialize(unsigned char *outbuffer) const |
akashvibhute | 0:30537dec6e0b | 34 | { |
akashvibhute | 0:30537dec6e0b | 35 | int offset = 0; |
akashvibhute | 0:30537dec6e0b | 36 | *(outbuffer + offset + 0) = (this->id >> (8 * 0)) & 0xFF; |
akashvibhute | 0:30537dec6e0b | 37 | *(outbuffer + offset + 1) = (this->id >> (8 * 1)) & 0xFF; |
akashvibhute | 0:30537dec6e0b | 38 | *(outbuffer + offset + 2) = (this->id >> (8 * 2)) & 0xFF; |
akashvibhute | 0:30537dec6e0b | 39 | *(outbuffer + offset + 3) = (this->id >> (8 * 3)) & 0xFF; |
akashvibhute | 0:30537dec6e0b | 40 | offset += sizeof(this->id); |
akashvibhute | 0:30537dec6e0b | 41 | *(outbuffer + offset + 0) = (this->parent_id >> (8 * 0)) & 0xFF; |
akashvibhute | 0:30537dec6e0b | 42 | *(outbuffer + offset + 1) = (this->parent_id >> (8 * 1)) & 0xFF; |
akashvibhute | 0:30537dec6e0b | 43 | *(outbuffer + offset + 2) = (this->parent_id >> (8 * 2)) & 0xFF; |
akashvibhute | 0:30537dec6e0b | 44 | *(outbuffer + offset + 3) = (this->parent_id >> (8 * 3)) & 0xFF; |
akashvibhute | 0:30537dec6e0b | 45 | offset += sizeof(this->parent_id); |
akashvibhute | 0:30537dec6e0b | 46 | uint32_t length_title = strlen(this->title); |
akashvibhute | 0:30537dec6e0b | 47 | memcpy(outbuffer + offset, &length_title, sizeof(uint32_t)); |
akashvibhute | 0:30537dec6e0b | 48 | offset += 4; |
akashvibhute | 0:30537dec6e0b | 49 | memcpy(outbuffer + offset, this->title, length_title); |
akashvibhute | 0:30537dec6e0b | 50 | offset += length_title; |
akashvibhute | 0:30537dec6e0b | 51 | uint32_t length_command = strlen(this->command); |
akashvibhute | 0:30537dec6e0b | 52 | memcpy(outbuffer + offset, &length_command, sizeof(uint32_t)); |
akashvibhute | 0:30537dec6e0b | 53 | offset += 4; |
akashvibhute | 0:30537dec6e0b | 54 | memcpy(outbuffer + offset, this->command, length_command); |
akashvibhute | 0:30537dec6e0b | 55 | offset += length_command; |
akashvibhute | 0:30537dec6e0b | 56 | *(outbuffer + offset + 0) = (this->command_type >> (8 * 0)) & 0xFF; |
akashvibhute | 0:30537dec6e0b | 57 | offset += sizeof(this->command_type); |
akashvibhute | 0:30537dec6e0b | 58 | return offset; |
akashvibhute | 0:30537dec6e0b | 59 | } |
akashvibhute | 0:30537dec6e0b | 60 | |
akashvibhute | 0:30537dec6e0b | 61 | virtual int deserialize(unsigned char *inbuffer) |
akashvibhute | 0:30537dec6e0b | 62 | { |
akashvibhute | 0:30537dec6e0b | 63 | int offset = 0; |
akashvibhute | 0:30537dec6e0b | 64 | this->id = ((uint32_t) (*(inbuffer + offset))); |
akashvibhute | 0:30537dec6e0b | 65 | this->id |= ((uint32_t) (*(inbuffer + offset + 1))) << (8 * 1); |
akashvibhute | 0:30537dec6e0b | 66 | this->id |= ((uint32_t) (*(inbuffer + offset + 2))) << (8 * 2); |
akashvibhute | 0:30537dec6e0b | 67 | this->id |= ((uint32_t) (*(inbuffer + offset + 3))) << (8 * 3); |
akashvibhute | 0:30537dec6e0b | 68 | offset += sizeof(this->id); |
akashvibhute | 0:30537dec6e0b | 69 | this->parent_id = ((uint32_t) (*(inbuffer + offset))); |
akashvibhute | 0:30537dec6e0b | 70 | this->parent_id |= ((uint32_t) (*(inbuffer + offset + 1))) << (8 * 1); |
akashvibhute | 0:30537dec6e0b | 71 | this->parent_id |= ((uint32_t) (*(inbuffer + offset + 2))) << (8 * 2); |
akashvibhute | 0:30537dec6e0b | 72 | this->parent_id |= ((uint32_t) (*(inbuffer + offset + 3))) << (8 * 3); |
akashvibhute | 0:30537dec6e0b | 73 | offset += sizeof(this->parent_id); |
akashvibhute | 0:30537dec6e0b | 74 | uint32_t length_title; |
akashvibhute | 0:30537dec6e0b | 75 | memcpy(&length_title, (inbuffer + offset), sizeof(uint32_t)); |
akashvibhute | 0:30537dec6e0b | 76 | offset += 4; |
akashvibhute | 0:30537dec6e0b | 77 | for(unsigned int k= offset; k< offset+length_title; ++k){ |
akashvibhute | 0:30537dec6e0b | 78 | inbuffer[k-1]=inbuffer[k]; |
akashvibhute | 0:30537dec6e0b | 79 | } |
akashvibhute | 0:30537dec6e0b | 80 | inbuffer[offset+length_title-1]=0; |
akashvibhute | 0:30537dec6e0b | 81 | this->title = (char *)(inbuffer + offset-1); |
akashvibhute | 0:30537dec6e0b | 82 | offset += length_title; |
akashvibhute | 0:30537dec6e0b | 83 | uint32_t length_command; |
akashvibhute | 0:30537dec6e0b | 84 | memcpy(&length_command, (inbuffer + offset), sizeof(uint32_t)); |
akashvibhute | 0:30537dec6e0b | 85 | offset += 4; |
akashvibhute | 0:30537dec6e0b | 86 | for(unsigned int k= offset; k< offset+length_command; ++k){ |
akashvibhute | 0:30537dec6e0b | 87 | inbuffer[k-1]=inbuffer[k]; |
akashvibhute | 0:30537dec6e0b | 88 | } |
akashvibhute | 0:30537dec6e0b | 89 | inbuffer[offset+length_command-1]=0; |
akashvibhute | 0:30537dec6e0b | 90 | this->command = (char *)(inbuffer + offset-1); |
akashvibhute | 0:30537dec6e0b | 91 | offset += length_command; |
akashvibhute | 0:30537dec6e0b | 92 | this->command_type = ((uint8_t) (*(inbuffer + offset))); |
akashvibhute | 0:30537dec6e0b | 93 | offset += sizeof(this->command_type); |
akashvibhute | 0:30537dec6e0b | 94 | return offset; |
akashvibhute | 0:30537dec6e0b | 95 | } |
akashvibhute | 0:30537dec6e0b | 96 | |
akashvibhute | 0:30537dec6e0b | 97 | const char * getType(){ return "visualization_msgs/MenuEntry"; }; |
akashvibhute | 0:30537dec6e0b | 98 | const char * getMD5(){ return "b90ec63024573de83b57aa93eb39be2d"; }; |
akashvibhute | 0:30537dec6e0b | 99 | |
akashvibhute | 0:30537dec6e0b | 100 | }; |
akashvibhute | 0:30537dec6e0b | 101 | |
akashvibhute | 0:30537dec6e0b | 102 | } |
akashvibhute | 0:30537dec6e0b | 103 | #endif |