rosserial library for mbed Inspired by nucho's rosserial library This library is still under development
Dependents: mbed_roshydro_test
Library still under development!
ur_msgs/SetIO.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_SERVICE_SetIO_h |
akashvibhute | 0:30537dec6e0b | 2 | #define _ROS_SERVICE_SetIO_h |
akashvibhute | 0:30537dec6e0b | 3 | #include <stdint.h> |
akashvibhute | 0:30537dec6e0b | 4 | #include <string.h> |
akashvibhute | 0:30537dec6e0b | 5 | #include <stdlib.h> |
akashvibhute | 0:30537dec6e0b | 6 | #include "ros/msg.h" |
akashvibhute | 0:30537dec6e0b | 7 | |
akashvibhute | 0:30537dec6e0b | 8 | namespace ur_msgs |
akashvibhute | 0:30537dec6e0b | 9 | { |
akashvibhute | 0:30537dec6e0b | 10 | |
akashvibhute | 0:30537dec6e0b | 11 | static const char SETIO[] = "ur_msgs/SetIO"; |
akashvibhute | 0:30537dec6e0b | 12 | |
akashvibhute | 0:30537dec6e0b | 13 | class SetIORequest : public ros::Msg |
akashvibhute | 0:30537dec6e0b | 14 | { |
akashvibhute | 0:30537dec6e0b | 15 | public: |
akashvibhute | 0:30537dec6e0b | 16 | int8_t fun; |
akashvibhute | 0:30537dec6e0b | 17 | int8_t pin; |
akashvibhute | 0:30537dec6e0b | 18 | float state; |
akashvibhute | 0:30537dec6e0b | 19 | |
akashvibhute | 0:30537dec6e0b | 20 | SetIORequest(): |
akashvibhute | 0:30537dec6e0b | 21 | fun(0), |
akashvibhute | 0:30537dec6e0b | 22 | pin(0), |
akashvibhute | 0:30537dec6e0b | 23 | state(0) |
akashvibhute | 0:30537dec6e0b | 24 | { |
akashvibhute | 0:30537dec6e0b | 25 | } |
akashvibhute | 0:30537dec6e0b | 26 | |
akashvibhute | 0:30537dec6e0b | 27 | virtual int serialize(unsigned char *outbuffer) const |
akashvibhute | 0:30537dec6e0b | 28 | { |
akashvibhute | 0:30537dec6e0b | 29 | int offset = 0; |
akashvibhute | 0:30537dec6e0b | 30 | union { |
akashvibhute | 0:30537dec6e0b | 31 | int8_t real; |
akashvibhute | 0:30537dec6e0b | 32 | uint8_t base; |
akashvibhute | 0:30537dec6e0b | 33 | } u_fun; |
akashvibhute | 0:30537dec6e0b | 34 | u_fun.real = this->fun; |
akashvibhute | 0:30537dec6e0b | 35 | *(outbuffer + offset + 0) = (u_fun.base >> (8 * 0)) & 0xFF; |
akashvibhute | 0:30537dec6e0b | 36 | offset += sizeof(this->fun); |
akashvibhute | 0:30537dec6e0b | 37 | union { |
akashvibhute | 0:30537dec6e0b | 38 | int8_t real; |
akashvibhute | 0:30537dec6e0b | 39 | uint8_t base; |
akashvibhute | 0:30537dec6e0b | 40 | } u_pin; |
akashvibhute | 0:30537dec6e0b | 41 | u_pin.real = this->pin; |
akashvibhute | 0:30537dec6e0b | 42 | *(outbuffer + offset + 0) = (u_pin.base >> (8 * 0)) & 0xFF; |
akashvibhute | 0:30537dec6e0b | 43 | offset += sizeof(this->pin); |
akashvibhute | 0:30537dec6e0b | 44 | union { |
akashvibhute | 0:30537dec6e0b | 45 | float real; |
akashvibhute | 0:30537dec6e0b | 46 | uint32_t base; |
akashvibhute | 0:30537dec6e0b | 47 | } u_state; |
akashvibhute | 0:30537dec6e0b | 48 | u_state.real = this->state; |
akashvibhute | 0:30537dec6e0b | 49 | *(outbuffer + offset + 0) = (u_state.base >> (8 * 0)) & 0xFF; |
akashvibhute | 0:30537dec6e0b | 50 | *(outbuffer + offset + 1) = (u_state.base >> (8 * 1)) & 0xFF; |
akashvibhute | 0:30537dec6e0b | 51 | *(outbuffer + offset + 2) = (u_state.base >> (8 * 2)) & 0xFF; |
akashvibhute | 0:30537dec6e0b | 52 | *(outbuffer + offset + 3) = (u_state.base >> (8 * 3)) & 0xFF; |
akashvibhute | 0:30537dec6e0b | 53 | offset += sizeof(this->state); |
akashvibhute | 0:30537dec6e0b | 54 | return offset; |
akashvibhute | 0:30537dec6e0b | 55 | } |
akashvibhute | 0:30537dec6e0b | 56 | |
akashvibhute | 0:30537dec6e0b | 57 | virtual int deserialize(unsigned char *inbuffer) |
akashvibhute | 0:30537dec6e0b | 58 | { |
akashvibhute | 0:30537dec6e0b | 59 | int offset = 0; |
akashvibhute | 0:30537dec6e0b | 60 | union { |
akashvibhute | 0:30537dec6e0b | 61 | int8_t real; |
akashvibhute | 0:30537dec6e0b | 62 | uint8_t base; |
akashvibhute | 0:30537dec6e0b | 63 | } u_fun; |
akashvibhute | 0:30537dec6e0b | 64 | u_fun.base = 0; |
akashvibhute | 0:30537dec6e0b | 65 | u_fun.base |= ((uint8_t) (*(inbuffer + offset + 0))) << (8 * 0); |
akashvibhute | 0:30537dec6e0b | 66 | this->fun = u_fun.real; |
akashvibhute | 0:30537dec6e0b | 67 | offset += sizeof(this->fun); |
akashvibhute | 0:30537dec6e0b | 68 | union { |
akashvibhute | 0:30537dec6e0b | 69 | int8_t real; |
akashvibhute | 0:30537dec6e0b | 70 | uint8_t base; |
akashvibhute | 0:30537dec6e0b | 71 | } u_pin; |
akashvibhute | 0:30537dec6e0b | 72 | u_pin.base = 0; |
akashvibhute | 0:30537dec6e0b | 73 | u_pin.base |= ((uint8_t) (*(inbuffer + offset + 0))) << (8 * 0); |
akashvibhute | 0:30537dec6e0b | 74 | this->pin = u_pin.real; |
akashvibhute | 0:30537dec6e0b | 75 | offset += sizeof(this->pin); |
akashvibhute | 0:30537dec6e0b | 76 | union { |
akashvibhute | 0:30537dec6e0b | 77 | float real; |
akashvibhute | 0:30537dec6e0b | 78 | uint32_t base; |
akashvibhute | 0:30537dec6e0b | 79 | } u_state; |
akashvibhute | 0:30537dec6e0b | 80 | u_state.base = 0; |
akashvibhute | 0:30537dec6e0b | 81 | u_state.base |= ((uint32_t) (*(inbuffer + offset + 0))) << (8 * 0); |
akashvibhute | 0:30537dec6e0b | 82 | u_state.base |= ((uint32_t) (*(inbuffer + offset + 1))) << (8 * 1); |
akashvibhute | 0:30537dec6e0b | 83 | u_state.base |= ((uint32_t) (*(inbuffer + offset + 2))) << (8 * 2); |
akashvibhute | 0:30537dec6e0b | 84 | u_state.base |= ((uint32_t) (*(inbuffer + offset + 3))) << (8 * 3); |
akashvibhute | 0:30537dec6e0b | 85 | this->state = u_state.real; |
akashvibhute | 0:30537dec6e0b | 86 | offset += sizeof(this->state); |
akashvibhute | 0:30537dec6e0b | 87 | return offset; |
akashvibhute | 0:30537dec6e0b | 88 | } |
akashvibhute | 0:30537dec6e0b | 89 | |
akashvibhute | 0:30537dec6e0b | 90 | const char * getType(){ return SETIO; }; |
akashvibhute | 0:30537dec6e0b | 91 | const char * getMD5(){ return "cbb7d56b1142033251cb8df226edd774"; }; |
akashvibhute | 0:30537dec6e0b | 92 | |
akashvibhute | 0:30537dec6e0b | 93 | }; |
akashvibhute | 0:30537dec6e0b | 94 | |
akashvibhute | 0:30537dec6e0b | 95 | class SetIOResponse : public ros::Msg |
akashvibhute | 0:30537dec6e0b | 96 | { |
akashvibhute | 0:30537dec6e0b | 97 | public: |
akashvibhute | 0:30537dec6e0b | 98 | bool success; |
akashvibhute | 0:30537dec6e0b | 99 | |
akashvibhute | 0:30537dec6e0b | 100 | SetIOResponse(): |
akashvibhute | 0:30537dec6e0b | 101 | success(0) |
akashvibhute | 0:30537dec6e0b | 102 | { |
akashvibhute | 0:30537dec6e0b | 103 | } |
akashvibhute | 0:30537dec6e0b | 104 | |
akashvibhute | 0:30537dec6e0b | 105 | virtual int serialize(unsigned char *outbuffer) const |
akashvibhute | 0:30537dec6e0b | 106 | { |
akashvibhute | 0:30537dec6e0b | 107 | int offset = 0; |
akashvibhute | 0:30537dec6e0b | 108 | union { |
akashvibhute | 0:30537dec6e0b | 109 | bool real; |
akashvibhute | 0:30537dec6e0b | 110 | uint8_t base; |
akashvibhute | 0:30537dec6e0b | 111 | } u_success; |
akashvibhute | 0:30537dec6e0b | 112 | u_success.real = this->success; |
akashvibhute | 0:30537dec6e0b | 113 | *(outbuffer + offset + 0) = (u_success.base >> (8 * 0)) & 0xFF; |
akashvibhute | 0:30537dec6e0b | 114 | offset += sizeof(this->success); |
akashvibhute | 0:30537dec6e0b | 115 | return offset; |
akashvibhute | 0:30537dec6e0b | 116 | } |
akashvibhute | 0:30537dec6e0b | 117 | |
akashvibhute | 0:30537dec6e0b | 118 | virtual int deserialize(unsigned char *inbuffer) |
akashvibhute | 0:30537dec6e0b | 119 | { |
akashvibhute | 0:30537dec6e0b | 120 | int offset = 0; |
akashvibhute | 0:30537dec6e0b | 121 | union { |
akashvibhute | 0:30537dec6e0b | 122 | bool real; |
akashvibhute | 0:30537dec6e0b | 123 | uint8_t base; |
akashvibhute | 0:30537dec6e0b | 124 | } u_success; |
akashvibhute | 0:30537dec6e0b | 125 | u_success.base = 0; |
akashvibhute | 0:30537dec6e0b | 126 | u_success.base |= ((uint8_t) (*(inbuffer + offset + 0))) << (8 * 0); |
akashvibhute | 0:30537dec6e0b | 127 | this->success = u_success.real; |
akashvibhute | 0:30537dec6e0b | 128 | offset += sizeof(this->success); |
akashvibhute | 0:30537dec6e0b | 129 | return offset; |
akashvibhute | 0:30537dec6e0b | 130 | } |
akashvibhute | 0:30537dec6e0b | 131 | |
akashvibhute | 0:30537dec6e0b | 132 | const char * getType(){ return SETIO; }; |
akashvibhute | 0:30537dec6e0b | 133 | const char * getMD5(){ return "358e233cde0c8a8bcfea4ce193f8fc15"; }; |
akashvibhute | 0:30537dec6e0b | 134 | |
akashvibhute | 0:30537dec6e0b | 135 | }; |
akashvibhute | 0:30537dec6e0b | 136 | |
akashvibhute | 0:30537dec6e0b | 137 | class SetIO { |
akashvibhute | 0:30537dec6e0b | 138 | public: |
akashvibhute | 0:30537dec6e0b | 139 | typedef SetIORequest Request; |
akashvibhute | 0:30537dec6e0b | 140 | typedef SetIOResponse Response; |
akashvibhute | 0:30537dec6e0b | 141 | }; |
akashvibhute | 0:30537dec6e0b | 142 | |
akashvibhute | 0:30537dec6e0b | 143 | } |
akashvibhute | 0:30537dec6e0b | 144 | #endif |
akashvibhute | 0:30537dec6e0b | 145 |