rosserial library for mbed Inspired by nucho's rosserial library This library is still under development
Dependents: mbed_roshydro_test
Library still under development!
smach_msgs/SmachContainerInitialStatusCmd.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_smach_msgs_SmachContainerInitialStatusCmd_h |
akashvibhute | 0:30537dec6e0b | 2 | #define _ROS_smach_msgs_SmachContainerInitialStatusCmd_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 smach_msgs |
akashvibhute | 0:30537dec6e0b | 10 | { |
akashvibhute | 0:30537dec6e0b | 11 | |
akashvibhute | 0:30537dec6e0b | 12 | class SmachContainerInitialStatusCmd : public ros::Msg |
akashvibhute | 0:30537dec6e0b | 13 | { |
akashvibhute | 0:30537dec6e0b | 14 | public: |
akashvibhute | 0:30537dec6e0b | 15 | const char* path; |
akashvibhute | 0:30537dec6e0b | 16 | uint8_t initial_states_length; |
akashvibhute | 0:30537dec6e0b | 17 | char* st_initial_states; |
akashvibhute | 0:30537dec6e0b | 18 | char* * initial_states; |
akashvibhute | 0:30537dec6e0b | 19 | const char* local_data; |
akashvibhute | 0:30537dec6e0b | 20 | |
akashvibhute | 0:30537dec6e0b | 21 | SmachContainerInitialStatusCmd(): |
akashvibhute | 0:30537dec6e0b | 22 | path(""), |
akashvibhute | 0:30537dec6e0b | 23 | initial_states_length(0), initial_states(NULL), |
akashvibhute | 0:30537dec6e0b | 24 | local_data("") |
akashvibhute | 0:30537dec6e0b | 25 | { |
akashvibhute | 0:30537dec6e0b | 26 | } |
akashvibhute | 0:30537dec6e0b | 27 | |
akashvibhute | 0:30537dec6e0b | 28 | virtual int serialize(unsigned char *outbuffer) const |
akashvibhute | 0:30537dec6e0b | 29 | { |
akashvibhute | 0:30537dec6e0b | 30 | int offset = 0; |
akashvibhute | 0:30537dec6e0b | 31 | uint32_t length_path = strlen(this->path); |
akashvibhute | 0:30537dec6e0b | 32 | memcpy(outbuffer + offset, &length_path, sizeof(uint32_t)); |
akashvibhute | 0:30537dec6e0b | 33 | offset += 4; |
akashvibhute | 0:30537dec6e0b | 34 | memcpy(outbuffer + offset, this->path, length_path); |
akashvibhute | 0:30537dec6e0b | 35 | offset += length_path; |
akashvibhute | 0:30537dec6e0b | 36 | *(outbuffer + offset++) = initial_states_length; |
akashvibhute | 0:30537dec6e0b | 37 | *(outbuffer + offset++) = 0; |
akashvibhute | 0:30537dec6e0b | 38 | *(outbuffer + offset++) = 0; |
akashvibhute | 0:30537dec6e0b | 39 | *(outbuffer + offset++) = 0; |
akashvibhute | 0:30537dec6e0b | 40 | for( uint8_t i = 0; i < initial_states_length; i++){ |
akashvibhute | 0:30537dec6e0b | 41 | uint32_t length_initial_statesi = strlen(this->initial_states[i]); |
akashvibhute | 0:30537dec6e0b | 42 | memcpy(outbuffer + offset, &length_initial_statesi, sizeof(uint32_t)); |
akashvibhute | 0:30537dec6e0b | 43 | offset += 4; |
akashvibhute | 0:30537dec6e0b | 44 | memcpy(outbuffer + offset, this->initial_states[i], length_initial_statesi); |
akashvibhute | 0:30537dec6e0b | 45 | offset += length_initial_statesi; |
akashvibhute | 0:30537dec6e0b | 46 | } |
akashvibhute | 0:30537dec6e0b | 47 | uint32_t length_local_data = strlen(this->local_data); |
akashvibhute | 0:30537dec6e0b | 48 | memcpy(outbuffer + offset, &length_local_data, sizeof(uint32_t)); |
akashvibhute | 0:30537dec6e0b | 49 | offset += 4; |
akashvibhute | 0:30537dec6e0b | 50 | memcpy(outbuffer + offset, this->local_data, length_local_data); |
akashvibhute | 0:30537dec6e0b | 51 | offset += length_local_data; |
akashvibhute | 0:30537dec6e0b | 52 | return offset; |
akashvibhute | 0:30537dec6e0b | 53 | } |
akashvibhute | 0:30537dec6e0b | 54 | |
akashvibhute | 0:30537dec6e0b | 55 | virtual int deserialize(unsigned char *inbuffer) |
akashvibhute | 0:30537dec6e0b | 56 | { |
akashvibhute | 0:30537dec6e0b | 57 | int offset = 0; |
akashvibhute | 0:30537dec6e0b | 58 | uint32_t length_path; |
akashvibhute | 0:30537dec6e0b | 59 | memcpy(&length_path, (inbuffer + offset), sizeof(uint32_t)); |
akashvibhute | 0:30537dec6e0b | 60 | offset += 4; |
akashvibhute | 0:30537dec6e0b | 61 | for(unsigned int k= offset; k< offset+length_path; ++k){ |
akashvibhute | 0:30537dec6e0b | 62 | inbuffer[k-1]=inbuffer[k]; |
akashvibhute | 0:30537dec6e0b | 63 | } |
akashvibhute | 0:30537dec6e0b | 64 | inbuffer[offset+length_path-1]=0; |
akashvibhute | 0:30537dec6e0b | 65 | this->path = (char *)(inbuffer + offset-1); |
akashvibhute | 0:30537dec6e0b | 66 | offset += length_path; |
akashvibhute | 0:30537dec6e0b | 67 | uint8_t initial_states_lengthT = *(inbuffer + offset++); |
akashvibhute | 0:30537dec6e0b | 68 | if(initial_states_lengthT > initial_states_length) |
akashvibhute | 0:30537dec6e0b | 69 | this->initial_states = (char**)realloc(this->initial_states, initial_states_lengthT * sizeof(char*)); |
akashvibhute | 0:30537dec6e0b | 70 | offset += 3; |
akashvibhute | 0:30537dec6e0b | 71 | initial_states_length = initial_states_lengthT; |
akashvibhute | 0:30537dec6e0b | 72 | for( uint8_t i = 0; i < initial_states_length; i++){ |
akashvibhute | 0:30537dec6e0b | 73 | uint32_t length_st_initial_states; |
akashvibhute | 0:30537dec6e0b | 74 | memcpy(&length_st_initial_states, (inbuffer + offset), sizeof(uint32_t)); |
akashvibhute | 0:30537dec6e0b | 75 | offset += 4; |
akashvibhute | 0:30537dec6e0b | 76 | for(unsigned int k= offset; k< offset+length_st_initial_states; ++k){ |
akashvibhute | 0:30537dec6e0b | 77 | inbuffer[k-1]=inbuffer[k]; |
akashvibhute | 0:30537dec6e0b | 78 | } |
akashvibhute | 0:30537dec6e0b | 79 | inbuffer[offset+length_st_initial_states-1]=0; |
akashvibhute | 0:30537dec6e0b | 80 | this->st_initial_states = (char *)(inbuffer + offset-1); |
akashvibhute | 0:30537dec6e0b | 81 | offset += length_st_initial_states; |
akashvibhute | 0:30537dec6e0b | 82 | memcpy( &(this->initial_states[i]), &(this->st_initial_states), sizeof(char*)); |
akashvibhute | 0:30537dec6e0b | 83 | } |
akashvibhute | 0:30537dec6e0b | 84 | uint32_t length_local_data; |
akashvibhute | 0:30537dec6e0b | 85 | memcpy(&length_local_data, (inbuffer + offset), sizeof(uint32_t)); |
akashvibhute | 0:30537dec6e0b | 86 | offset += 4; |
akashvibhute | 0:30537dec6e0b | 87 | for(unsigned int k= offset; k< offset+length_local_data; ++k){ |
akashvibhute | 0:30537dec6e0b | 88 | inbuffer[k-1]=inbuffer[k]; |
akashvibhute | 0:30537dec6e0b | 89 | } |
akashvibhute | 0:30537dec6e0b | 90 | inbuffer[offset+length_local_data-1]=0; |
akashvibhute | 0:30537dec6e0b | 91 | this->local_data = (char *)(inbuffer + offset-1); |
akashvibhute | 0:30537dec6e0b | 92 | offset += length_local_data; |
akashvibhute | 0:30537dec6e0b | 93 | return offset; |
akashvibhute | 0:30537dec6e0b | 94 | } |
akashvibhute | 0:30537dec6e0b | 95 | |
akashvibhute | 0:30537dec6e0b | 96 | const char * getType(){ return "smach_msgs/SmachContainerInitialStatusCmd"; }; |
akashvibhute | 0:30537dec6e0b | 97 | const char * getMD5(){ return "45f8cf31fc29b829db77f23001f788d6"; }; |
akashvibhute | 0:30537dec6e0b | 98 | |
akashvibhute | 0:30537dec6e0b | 99 | }; |
akashvibhute | 0:30537dec6e0b | 100 | |
akashvibhute | 0:30537dec6e0b | 101 | } |
akashvibhute | 0:30537dec6e0b | 102 | #endif |