rosserial library for mbed Inspired by nucho's rosserial library This library is still under development
Dependents: mbed_roshydro_test
Library still under development!
industrial_msgs/DeviceInfo.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_industrial_msgs_DeviceInfo_h |
akashvibhute | 0:30537dec6e0b | 2 | #define _ROS_industrial_msgs_DeviceInfo_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 industrial_msgs |
akashvibhute | 0:30537dec6e0b | 10 | { |
akashvibhute | 0:30537dec6e0b | 11 | |
akashvibhute | 0:30537dec6e0b | 12 | class DeviceInfo : public ros::Msg |
akashvibhute | 0:30537dec6e0b | 13 | { |
akashvibhute | 0:30537dec6e0b | 14 | public: |
akashvibhute | 0:30537dec6e0b | 15 | const char* model; |
akashvibhute | 0:30537dec6e0b | 16 | const char* serial_number; |
akashvibhute | 0:30537dec6e0b | 17 | const char* hw_version; |
akashvibhute | 0:30537dec6e0b | 18 | const char* sw_version; |
akashvibhute | 0:30537dec6e0b | 19 | const char* address; |
akashvibhute | 0:30537dec6e0b | 20 | |
akashvibhute | 0:30537dec6e0b | 21 | DeviceInfo(): |
akashvibhute | 0:30537dec6e0b | 22 | model(""), |
akashvibhute | 0:30537dec6e0b | 23 | serial_number(""), |
akashvibhute | 0:30537dec6e0b | 24 | hw_version(""), |
akashvibhute | 0:30537dec6e0b | 25 | sw_version(""), |
akashvibhute | 0:30537dec6e0b | 26 | address("") |
akashvibhute | 0:30537dec6e0b | 27 | { |
akashvibhute | 0:30537dec6e0b | 28 | } |
akashvibhute | 0:30537dec6e0b | 29 | |
akashvibhute | 0:30537dec6e0b | 30 | virtual int serialize(unsigned char *outbuffer) const |
akashvibhute | 0:30537dec6e0b | 31 | { |
akashvibhute | 0:30537dec6e0b | 32 | int offset = 0; |
akashvibhute | 0:30537dec6e0b | 33 | uint32_t length_model = strlen(this->model); |
akashvibhute | 0:30537dec6e0b | 34 | memcpy(outbuffer + offset, &length_model, sizeof(uint32_t)); |
akashvibhute | 0:30537dec6e0b | 35 | offset += 4; |
akashvibhute | 0:30537dec6e0b | 36 | memcpy(outbuffer + offset, this->model, length_model); |
akashvibhute | 0:30537dec6e0b | 37 | offset += length_model; |
akashvibhute | 0:30537dec6e0b | 38 | uint32_t length_serial_number = strlen(this->serial_number); |
akashvibhute | 0:30537dec6e0b | 39 | memcpy(outbuffer + offset, &length_serial_number, sizeof(uint32_t)); |
akashvibhute | 0:30537dec6e0b | 40 | offset += 4; |
akashvibhute | 0:30537dec6e0b | 41 | memcpy(outbuffer + offset, this->serial_number, length_serial_number); |
akashvibhute | 0:30537dec6e0b | 42 | offset += length_serial_number; |
akashvibhute | 0:30537dec6e0b | 43 | uint32_t length_hw_version = strlen(this->hw_version); |
akashvibhute | 0:30537dec6e0b | 44 | memcpy(outbuffer + offset, &length_hw_version, sizeof(uint32_t)); |
akashvibhute | 0:30537dec6e0b | 45 | offset += 4; |
akashvibhute | 0:30537dec6e0b | 46 | memcpy(outbuffer + offset, this->hw_version, length_hw_version); |
akashvibhute | 0:30537dec6e0b | 47 | offset += length_hw_version; |
akashvibhute | 0:30537dec6e0b | 48 | uint32_t length_sw_version = strlen(this->sw_version); |
akashvibhute | 0:30537dec6e0b | 49 | memcpy(outbuffer + offset, &length_sw_version, sizeof(uint32_t)); |
akashvibhute | 0:30537dec6e0b | 50 | offset += 4; |
akashvibhute | 0:30537dec6e0b | 51 | memcpy(outbuffer + offset, this->sw_version, length_sw_version); |
akashvibhute | 0:30537dec6e0b | 52 | offset += length_sw_version; |
akashvibhute | 0:30537dec6e0b | 53 | uint32_t length_address = strlen(this->address); |
akashvibhute | 0:30537dec6e0b | 54 | memcpy(outbuffer + offset, &length_address, sizeof(uint32_t)); |
akashvibhute | 0:30537dec6e0b | 55 | offset += 4; |
akashvibhute | 0:30537dec6e0b | 56 | memcpy(outbuffer + offset, this->address, length_address); |
akashvibhute | 0:30537dec6e0b | 57 | offset += length_address; |
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 | uint32_t length_model; |
akashvibhute | 0:30537dec6e0b | 65 | memcpy(&length_model, (inbuffer + offset), sizeof(uint32_t)); |
akashvibhute | 0:30537dec6e0b | 66 | offset += 4; |
akashvibhute | 0:30537dec6e0b | 67 | for(unsigned int k= offset; k< offset+length_model; ++k){ |
akashvibhute | 0:30537dec6e0b | 68 | inbuffer[k-1]=inbuffer[k]; |
akashvibhute | 0:30537dec6e0b | 69 | } |
akashvibhute | 0:30537dec6e0b | 70 | inbuffer[offset+length_model-1]=0; |
akashvibhute | 0:30537dec6e0b | 71 | this->model = (char *)(inbuffer + offset-1); |
akashvibhute | 0:30537dec6e0b | 72 | offset += length_model; |
akashvibhute | 0:30537dec6e0b | 73 | uint32_t length_serial_number; |
akashvibhute | 0:30537dec6e0b | 74 | memcpy(&length_serial_number, (inbuffer + offset), sizeof(uint32_t)); |
akashvibhute | 0:30537dec6e0b | 75 | offset += 4; |
akashvibhute | 0:30537dec6e0b | 76 | for(unsigned int k= offset; k< offset+length_serial_number; ++k){ |
akashvibhute | 0:30537dec6e0b | 77 | inbuffer[k-1]=inbuffer[k]; |
akashvibhute | 0:30537dec6e0b | 78 | } |
akashvibhute | 0:30537dec6e0b | 79 | inbuffer[offset+length_serial_number-1]=0; |
akashvibhute | 0:30537dec6e0b | 80 | this->serial_number = (char *)(inbuffer + offset-1); |
akashvibhute | 0:30537dec6e0b | 81 | offset += length_serial_number; |
akashvibhute | 0:30537dec6e0b | 82 | uint32_t length_hw_version; |
akashvibhute | 0:30537dec6e0b | 83 | memcpy(&length_hw_version, (inbuffer + offset), sizeof(uint32_t)); |
akashvibhute | 0:30537dec6e0b | 84 | offset += 4; |
akashvibhute | 0:30537dec6e0b | 85 | for(unsigned int k= offset; k< offset+length_hw_version; ++k){ |
akashvibhute | 0:30537dec6e0b | 86 | inbuffer[k-1]=inbuffer[k]; |
akashvibhute | 0:30537dec6e0b | 87 | } |
akashvibhute | 0:30537dec6e0b | 88 | inbuffer[offset+length_hw_version-1]=0; |
akashvibhute | 0:30537dec6e0b | 89 | this->hw_version = (char *)(inbuffer + offset-1); |
akashvibhute | 0:30537dec6e0b | 90 | offset += length_hw_version; |
akashvibhute | 0:30537dec6e0b | 91 | uint32_t length_sw_version; |
akashvibhute | 0:30537dec6e0b | 92 | memcpy(&length_sw_version, (inbuffer + offset), sizeof(uint32_t)); |
akashvibhute | 0:30537dec6e0b | 93 | offset += 4; |
akashvibhute | 0:30537dec6e0b | 94 | for(unsigned int k= offset; k< offset+length_sw_version; ++k){ |
akashvibhute | 0:30537dec6e0b | 95 | inbuffer[k-1]=inbuffer[k]; |
akashvibhute | 0:30537dec6e0b | 96 | } |
akashvibhute | 0:30537dec6e0b | 97 | inbuffer[offset+length_sw_version-1]=0; |
akashvibhute | 0:30537dec6e0b | 98 | this->sw_version = (char *)(inbuffer + offset-1); |
akashvibhute | 0:30537dec6e0b | 99 | offset += length_sw_version; |
akashvibhute | 0:30537dec6e0b | 100 | uint32_t length_address; |
akashvibhute | 0:30537dec6e0b | 101 | memcpy(&length_address, (inbuffer + offset), sizeof(uint32_t)); |
akashvibhute | 0:30537dec6e0b | 102 | offset += 4; |
akashvibhute | 0:30537dec6e0b | 103 | for(unsigned int k= offset; k< offset+length_address; ++k){ |
akashvibhute | 0:30537dec6e0b | 104 | inbuffer[k-1]=inbuffer[k]; |
akashvibhute | 0:30537dec6e0b | 105 | } |
akashvibhute | 0:30537dec6e0b | 106 | inbuffer[offset+length_address-1]=0; |
akashvibhute | 0:30537dec6e0b | 107 | this->address = (char *)(inbuffer + offset-1); |
akashvibhute | 0:30537dec6e0b | 108 | offset += length_address; |
akashvibhute | 0:30537dec6e0b | 109 | return offset; |
akashvibhute | 0:30537dec6e0b | 110 | } |
akashvibhute | 0:30537dec6e0b | 111 | |
akashvibhute | 0:30537dec6e0b | 112 | const char * getType(){ return "industrial_msgs/DeviceInfo"; }; |
akashvibhute | 0:30537dec6e0b | 113 | const char * getMD5(){ return "373ed7fa0fac92d443be9cd5198e80f0"; }; |
akashvibhute | 0:30537dec6e0b | 114 | |
akashvibhute | 0:30537dec6e0b | 115 | }; |
akashvibhute | 0:30537dec6e0b | 116 | |
akashvibhute | 0:30537dec6e0b | 117 | } |
akashvibhute | 0:30537dec6e0b | 118 | #endif |