modify for Hydro version
Fork of rosserial_mbed_lib by
rosserial_mbed/Adc.h@0:77afd7560544, 2011-08-19 (annotated)
- Committer:
- nucho
- Date:
- Fri Aug 19 09:06:30 2011 +0000
- Revision:
- 0:77afd7560544
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
nucho | 0:77afd7560544 | 1 | #ifndef ros_Adc_h |
nucho | 0:77afd7560544 | 2 | #define ros_Adc_h |
nucho | 0:77afd7560544 | 3 | |
nucho | 0:77afd7560544 | 4 | #include <stdint.h> |
nucho | 0:77afd7560544 | 5 | #include <string.h> |
nucho | 0:77afd7560544 | 6 | #include <stdlib.h> |
nucho | 0:77afd7560544 | 7 | #include "../ros/msg.h" |
nucho | 0:77afd7560544 | 8 | |
nucho | 0:77afd7560544 | 9 | namespace rosserial_mbed |
nucho | 0:77afd7560544 | 10 | { |
nucho | 0:77afd7560544 | 11 | |
nucho | 0:77afd7560544 | 12 | class Adc : public ros::Msg |
nucho | 0:77afd7560544 | 13 | { |
nucho | 0:77afd7560544 | 14 | public: |
nucho | 0:77afd7560544 | 15 | unsigned short adc0; |
nucho | 0:77afd7560544 | 16 | unsigned short adc1; |
nucho | 0:77afd7560544 | 17 | unsigned short adc2; |
nucho | 0:77afd7560544 | 18 | unsigned short adc3; |
nucho | 0:77afd7560544 | 19 | unsigned short adc4; |
nucho | 0:77afd7560544 | 20 | unsigned short adc5; |
nucho | 0:77afd7560544 | 21 | |
nucho | 0:77afd7560544 | 22 | virtual int serialize(unsigned char *outbuffer) |
nucho | 0:77afd7560544 | 23 | { |
nucho | 0:77afd7560544 | 24 | int offset = 0; |
nucho | 0:77afd7560544 | 25 | union { |
nucho | 0:77afd7560544 | 26 | unsigned short real; |
nucho | 0:77afd7560544 | 27 | unsigned short base; |
nucho | 0:77afd7560544 | 28 | } u_adc0; |
nucho | 0:77afd7560544 | 29 | u_adc0.real = this->adc0; |
nucho | 0:77afd7560544 | 30 | *(outbuffer + offset + 0) = (u_adc0.base >> (8 * 0)) & 0xFF; |
nucho | 0:77afd7560544 | 31 | *(outbuffer + offset + 1) = (u_adc0.base >> (8 * 1)) & 0xFF; |
nucho | 0:77afd7560544 | 32 | offset += sizeof(this->adc0); |
nucho | 0:77afd7560544 | 33 | union { |
nucho | 0:77afd7560544 | 34 | unsigned short real; |
nucho | 0:77afd7560544 | 35 | unsigned short base; |
nucho | 0:77afd7560544 | 36 | } u_adc1; |
nucho | 0:77afd7560544 | 37 | u_adc1.real = this->adc1; |
nucho | 0:77afd7560544 | 38 | *(outbuffer + offset + 0) = (u_adc1.base >> (8 * 0)) & 0xFF; |
nucho | 0:77afd7560544 | 39 | *(outbuffer + offset + 1) = (u_adc1.base >> (8 * 1)) & 0xFF; |
nucho | 0:77afd7560544 | 40 | offset += sizeof(this->adc1); |
nucho | 0:77afd7560544 | 41 | union { |
nucho | 0:77afd7560544 | 42 | unsigned short real; |
nucho | 0:77afd7560544 | 43 | unsigned short base; |
nucho | 0:77afd7560544 | 44 | } u_adc2; |
nucho | 0:77afd7560544 | 45 | u_adc2.real = this->adc2; |
nucho | 0:77afd7560544 | 46 | *(outbuffer + offset + 0) = (u_adc2.base >> (8 * 0)) & 0xFF; |
nucho | 0:77afd7560544 | 47 | *(outbuffer + offset + 1) = (u_adc2.base >> (8 * 1)) & 0xFF; |
nucho | 0:77afd7560544 | 48 | offset += sizeof(this->adc2); |
nucho | 0:77afd7560544 | 49 | union { |
nucho | 0:77afd7560544 | 50 | unsigned short real; |
nucho | 0:77afd7560544 | 51 | unsigned short base; |
nucho | 0:77afd7560544 | 52 | } u_adc3; |
nucho | 0:77afd7560544 | 53 | u_adc3.real = this->adc3; |
nucho | 0:77afd7560544 | 54 | *(outbuffer + offset + 0) = (u_adc3.base >> (8 * 0)) & 0xFF; |
nucho | 0:77afd7560544 | 55 | *(outbuffer + offset + 1) = (u_adc3.base >> (8 * 1)) & 0xFF; |
nucho | 0:77afd7560544 | 56 | offset += sizeof(this->adc3); |
nucho | 0:77afd7560544 | 57 | union { |
nucho | 0:77afd7560544 | 58 | unsigned short real; |
nucho | 0:77afd7560544 | 59 | unsigned short base; |
nucho | 0:77afd7560544 | 60 | } u_adc4; |
nucho | 0:77afd7560544 | 61 | u_adc4.real = this->adc4; |
nucho | 0:77afd7560544 | 62 | *(outbuffer + offset + 0) = (u_adc4.base >> (8 * 0)) & 0xFF; |
nucho | 0:77afd7560544 | 63 | *(outbuffer + offset + 1) = (u_adc4.base >> (8 * 1)) & 0xFF; |
nucho | 0:77afd7560544 | 64 | offset += sizeof(this->adc4); |
nucho | 0:77afd7560544 | 65 | union { |
nucho | 0:77afd7560544 | 66 | unsigned short real; |
nucho | 0:77afd7560544 | 67 | unsigned short base; |
nucho | 0:77afd7560544 | 68 | } u_adc5; |
nucho | 0:77afd7560544 | 69 | u_adc5.real = this->adc5; |
nucho | 0:77afd7560544 | 70 | *(outbuffer + offset + 0) = (u_adc5.base >> (8 * 0)) & 0xFF; |
nucho | 0:77afd7560544 | 71 | *(outbuffer + offset + 1) = (u_adc5.base >> (8 * 1)) & 0xFF; |
nucho | 0:77afd7560544 | 72 | offset += sizeof(this->adc5); |
nucho | 0:77afd7560544 | 73 | return offset; |
nucho | 0:77afd7560544 | 74 | } |
nucho | 0:77afd7560544 | 75 | |
nucho | 0:77afd7560544 | 76 | virtual int deserialize(unsigned char *inbuffer) |
nucho | 0:77afd7560544 | 77 | { |
nucho | 0:77afd7560544 | 78 | int offset = 0; |
nucho | 0:77afd7560544 | 79 | union { |
nucho | 0:77afd7560544 | 80 | unsigned short real; |
nucho | 0:77afd7560544 | 81 | unsigned short base; |
nucho | 0:77afd7560544 | 82 | } u_adc0; |
nucho | 0:77afd7560544 | 83 | u_adc0.base = 0; |
nucho | 0:77afd7560544 | 84 | u_adc0.base |= ((typeof(u_adc0.base)) (*(inbuffer + offset + 0))) << (8 * 0); |
nucho | 0:77afd7560544 | 85 | u_adc0.base |= ((typeof(u_adc0.base)) (*(inbuffer + offset + 1))) << (8 * 1); |
nucho | 0:77afd7560544 | 86 | this->adc0 = u_adc0.real; |
nucho | 0:77afd7560544 | 87 | offset += sizeof(this->adc0); |
nucho | 0:77afd7560544 | 88 | union { |
nucho | 0:77afd7560544 | 89 | unsigned short real; |
nucho | 0:77afd7560544 | 90 | unsigned short base; |
nucho | 0:77afd7560544 | 91 | } u_adc1; |
nucho | 0:77afd7560544 | 92 | u_adc1.base = 0; |
nucho | 0:77afd7560544 | 93 | u_adc1.base |= ((typeof(u_adc1.base)) (*(inbuffer + offset + 0))) << (8 * 0); |
nucho | 0:77afd7560544 | 94 | u_adc1.base |= ((typeof(u_adc1.base)) (*(inbuffer + offset + 1))) << (8 * 1); |
nucho | 0:77afd7560544 | 95 | this->adc1 = u_adc1.real; |
nucho | 0:77afd7560544 | 96 | offset += sizeof(this->adc1); |
nucho | 0:77afd7560544 | 97 | union { |
nucho | 0:77afd7560544 | 98 | unsigned short real; |
nucho | 0:77afd7560544 | 99 | unsigned short base; |
nucho | 0:77afd7560544 | 100 | } u_adc2; |
nucho | 0:77afd7560544 | 101 | u_adc2.base = 0; |
nucho | 0:77afd7560544 | 102 | u_adc2.base |= ((typeof(u_adc2.base)) (*(inbuffer + offset + 0))) << (8 * 0); |
nucho | 0:77afd7560544 | 103 | u_adc2.base |= ((typeof(u_adc2.base)) (*(inbuffer + offset + 1))) << (8 * 1); |
nucho | 0:77afd7560544 | 104 | this->adc2 = u_adc2.real; |
nucho | 0:77afd7560544 | 105 | offset += sizeof(this->adc2); |
nucho | 0:77afd7560544 | 106 | union { |
nucho | 0:77afd7560544 | 107 | unsigned short real; |
nucho | 0:77afd7560544 | 108 | unsigned short base; |
nucho | 0:77afd7560544 | 109 | } u_adc3; |
nucho | 0:77afd7560544 | 110 | u_adc3.base = 0; |
nucho | 0:77afd7560544 | 111 | u_adc3.base |= ((typeof(u_adc3.base)) (*(inbuffer + offset + 0))) << (8 * 0); |
nucho | 0:77afd7560544 | 112 | u_adc3.base |= ((typeof(u_adc3.base)) (*(inbuffer + offset + 1))) << (8 * 1); |
nucho | 0:77afd7560544 | 113 | this->adc3 = u_adc3.real; |
nucho | 0:77afd7560544 | 114 | offset += sizeof(this->adc3); |
nucho | 0:77afd7560544 | 115 | union { |
nucho | 0:77afd7560544 | 116 | unsigned short real; |
nucho | 0:77afd7560544 | 117 | unsigned short base; |
nucho | 0:77afd7560544 | 118 | } u_adc4; |
nucho | 0:77afd7560544 | 119 | u_adc4.base = 0; |
nucho | 0:77afd7560544 | 120 | u_adc4.base |= ((typeof(u_adc4.base)) (*(inbuffer + offset + 0))) << (8 * 0); |
nucho | 0:77afd7560544 | 121 | u_adc4.base |= ((typeof(u_adc4.base)) (*(inbuffer + offset + 1))) << (8 * 1); |
nucho | 0:77afd7560544 | 122 | this->adc4 = u_adc4.real; |
nucho | 0:77afd7560544 | 123 | offset += sizeof(this->adc4); |
nucho | 0:77afd7560544 | 124 | union { |
nucho | 0:77afd7560544 | 125 | unsigned short real; |
nucho | 0:77afd7560544 | 126 | unsigned short base; |
nucho | 0:77afd7560544 | 127 | } u_adc5; |
nucho | 0:77afd7560544 | 128 | u_adc5.base = 0; |
nucho | 0:77afd7560544 | 129 | u_adc5.base |= ((typeof(u_adc5.base)) (*(inbuffer + offset + 0))) << (8 * 0); |
nucho | 0:77afd7560544 | 130 | u_adc5.base |= ((typeof(u_adc5.base)) (*(inbuffer + offset + 1))) << (8 * 1); |
nucho | 0:77afd7560544 | 131 | this->adc5 = u_adc5.real; |
nucho | 0:77afd7560544 | 132 | offset += sizeof(this->adc5); |
nucho | 0:77afd7560544 | 133 | return offset; |
nucho | 0:77afd7560544 | 134 | } |
nucho | 0:77afd7560544 | 135 | |
nucho | 0:77afd7560544 | 136 | virtual const char * getType(){ return "rosserial_mbed/Adc"; }; |
nucho | 0:77afd7560544 | 137 | |
nucho | 0:77afd7560544 | 138 | }; |
nucho | 0:77afd7560544 | 139 | |
nucho | 0:77afd7560544 | 140 | } |
nucho | 0:77afd7560544 | 141 | #endif |