This program is porting rosserial_arduino for mbed http://www.ros.org/wiki/rosserial_arduino This program supported the revision of 169 of rosserial.
Dependents: rosserial_mbed robot_S2
std_msgs/UInt64.h@1:ff0ec969dad1, 2011-10-16 (annotated)
- Committer:
- nucho
- Date:
- Sun Oct 16 07:19:36 2011 +0000
- Revision:
- 1:ff0ec969dad1
- Parent:
- 0:77afd7560544
- Child:
- 3:1cf99502f396
This program supported the revision of 143 of rosserial.
And the bug fix of receive of array data.
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
nucho | 0:77afd7560544 | 1 | #ifndef ros_UInt64_h |
nucho | 0:77afd7560544 | 2 | #define ros_UInt64_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 | 1:ff0ec969dad1 | 9 | namespace std_msgs { |
nucho | 0:77afd7560544 | 10 | |
nucho | 1:ff0ec969dad1 | 11 | class UInt64 : public ros::Msg { |
nucho | 1:ff0ec969dad1 | 12 | public: |
nucho | 1:ff0ec969dad1 | 13 | uint64_t data; |
nucho | 0:77afd7560544 | 14 | |
nucho | 1:ff0ec969dad1 | 15 | virtual int serialize(unsigned char *outbuffer) { |
nucho | 1:ff0ec969dad1 | 16 | int offset = 0; |
nucho | 1:ff0ec969dad1 | 17 | union { |
nucho | 1:ff0ec969dad1 | 18 | uint64_t real; |
nucho | 1:ff0ec969dad1 | 19 | uint64_t base; |
nucho | 1:ff0ec969dad1 | 20 | } u_data; |
nucho | 1:ff0ec969dad1 | 21 | u_data.real = this->data; |
nucho | 1:ff0ec969dad1 | 22 | *(outbuffer + offset + 0) = (u_data.base >> (8 * 0)) & 0xFF; |
nucho | 1:ff0ec969dad1 | 23 | *(outbuffer + offset + 1) = (u_data.base >> (8 * 1)) & 0xFF; |
nucho | 1:ff0ec969dad1 | 24 | *(outbuffer + offset + 2) = (u_data.base >> (8 * 2)) & 0xFF; |
nucho | 1:ff0ec969dad1 | 25 | *(outbuffer + offset + 3) = (u_data.base >> (8 * 3)) & 0xFF; |
nucho | 1:ff0ec969dad1 | 26 | *(outbuffer + offset + 4) = (u_data.base >> (8 * 4)) & 0xFF; |
nucho | 1:ff0ec969dad1 | 27 | *(outbuffer + offset + 5) = (u_data.base >> (8 * 5)) & 0xFF; |
nucho | 1:ff0ec969dad1 | 28 | *(outbuffer + offset + 6) = (u_data.base >> (8 * 6)) & 0xFF; |
nucho | 1:ff0ec969dad1 | 29 | *(outbuffer + offset + 7) = (u_data.base >> (8 * 7)) & 0xFF; |
nucho | 1:ff0ec969dad1 | 30 | offset += sizeof(this->data); |
nucho | 1:ff0ec969dad1 | 31 | return offset; |
nucho | 0:77afd7560544 | 32 | } |
nucho | 0:77afd7560544 | 33 | |
nucho | 1:ff0ec969dad1 | 34 | virtual int deserialize(unsigned char *inbuffer) { |
nucho | 1:ff0ec969dad1 | 35 | int offset = 0; |
nucho | 1:ff0ec969dad1 | 36 | union { |
nucho | 1:ff0ec969dad1 | 37 | uint64_t real; |
nucho | 1:ff0ec969dad1 | 38 | uint64_t base; |
nucho | 1:ff0ec969dad1 | 39 | } u_data; |
nucho | 1:ff0ec969dad1 | 40 | u_data.base = 0; |
nucho | 1:ff0ec969dad1 | 41 | u_data.base |= ((typeof(u_data.base)) (*(inbuffer + offset + 0))) << (8 * 0); |
nucho | 1:ff0ec969dad1 | 42 | u_data.base |= ((typeof(u_data.base)) (*(inbuffer + offset + 1))) << (8 * 1); |
nucho | 1:ff0ec969dad1 | 43 | u_data.base |= ((typeof(u_data.base)) (*(inbuffer + offset + 2))) << (8 * 2); |
nucho | 1:ff0ec969dad1 | 44 | u_data.base |= ((typeof(u_data.base)) (*(inbuffer + offset + 3))) << (8 * 3); |
nucho | 1:ff0ec969dad1 | 45 | u_data.base |= ((typeof(u_data.base)) (*(inbuffer + offset + 4))) << (8 * 4); |
nucho | 1:ff0ec969dad1 | 46 | u_data.base |= ((typeof(u_data.base)) (*(inbuffer + offset + 5))) << (8 * 5); |
nucho | 1:ff0ec969dad1 | 47 | u_data.base |= ((typeof(u_data.base)) (*(inbuffer + offset + 6))) << (8 * 6); |
nucho | 1:ff0ec969dad1 | 48 | u_data.base |= ((typeof(u_data.base)) (*(inbuffer + offset + 7))) << (8 * 7); |
nucho | 1:ff0ec969dad1 | 49 | this->data = u_data.real; |
nucho | 1:ff0ec969dad1 | 50 | offset += sizeof(this->data); |
nucho | 1:ff0ec969dad1 | 51 | return offset; |
nucho | 0:77afd7560544 | 52 | } |
nucho | 0:77afd7560544 | 53 | |
nucho | 1:ff0ec969dad1 | 54 | /* |
nucho | 1:ff0ec969dad1 | 55 | public: |
nucho | 1:ff0ec969dad1 | 56 | long data; |
nucho | 1:ff0ec969dad1 | 57 | |
nucho | 1:ff0ec969dad1 | 58 | virtual int serialize(unsigned char *outbuffer) |
nucho | 1:ff0ec969dad1 | 59 | { |
nucho | 1:ff0ec969dad1 | 60 | int offset = 0; |
nucho | 1:ff0ec969dad1 | 61 | *(outbuffer + offset++) = (data >> (8 * 0)) & 0xFF; |
nucho | 1:ff0ec969dad1 | 62 | *(outbuffer + offset++) = (data >> (8 * 1)) & 0xFF; |
nucho | 1:ff0ec969dad1 | 63 | *(outbuffer + offset++) = (data >> (8 * 2)) & 0xFF; |
nucho | 1:ff0ec969dad1 | 64 | *(outbuffer + offset++) = (data >> (8 * 3)) & 0xFF; |
nucho | 1:ff0ec969dad1 | 65 | *(outbuffer + offset++) = (data > 0) ? 0: 255; |
nucho | 1:ff0ec969dad1 | 66 | *(outbuffer + offset++) = (data > 0) ? 0: 255; |
nucho | 1:ff0ec969dad1 | 67 | *(outbuffer + offset++) = (data > 0) ? 0: 255; |
nucho | 1:ff0ec969dad1 | 68 | *(outbuffer + offset++) = (data > 0) ? 0: 255; |
nucho | 1:ff0ec969dad1 | 69 | return offset; |
nucho | 1:ff0ec969dad1 | 70 | } |
nucho | 0:77afd7560544 | 71 | |
nucho | 1:ff0ec969dad1 | 72 | virtual int deserialize(unsigned char *inbuffer) |
nucho | 1:ff0ec969dad1 | 73 | { |
nucho | 1:ff0ec969dad1 | 74 | int offset = 0; |
nucho | 1:ff0ec969dad1 | 75 | data = 0; |
nucho | 1:ff0ec969dad1 | 76 | data += ((long)(*(inbuffer + offset++))) >> (8 * 0); |
nucho | 1:ff0ec969dad1 | 77 | data += ((long)(*(inbuffer + offset++))) >> (8 * 1); |
nucho | 1:ff0ec969dad1 | 78 | data += ((long)(*(inbuffer + offset++))) >> (8 * 2); |
nucho | 1:ff0ec969dad1 | 79 | data += ((long)(*(inbuffer + offset++))) >> (8 * 3); |
nucho | 1:ff0ec969dad1 | 80 | offset += 4; |
nucho | 1:ff0ec969dad1 | 81 | return offset; |
nucho | 1:ff0ec969dad1 | 82 | } |
nucho | 1:ff0ec969dad1 | 83 | */ |
nucho | 1:ff0ec969dad1 | 84 | virtual const char * getType() { |
nucho | 1:ff0ec969dad1 | 85 | return "std_msgs/UInt64"; |
nucho | 1:ff0ec969dad1 | 86 | }; |
nucho | 1:ff0ec969dad1 | 87 | |
nucho | 1:ff0ec969dad1 | 88 | }; |
nucho | 0:77afd7560544 | 89 | |
nucho | 0:77afd7560544 | 90 | } |
nucho | 0:77afd7560544 | 91 | #endif |