![](/media/cache/profiles/94aef38441efa3380a3bed3faf1f9d5d.50x50_q85.jpg)
This program is porting rosserial_arduino for mbed http://www.ros.org/wiki/rosserial_arduino This program supported the revision of 169 of rosserial. This program contains an example.
Dependencies: rosserial_mbed_lib mbed Servo
std_msgs/UInt16.h@1:098e75fd5ad2, 2011-10-16 (annotated)
- Committer:
- nucho
- Date:
- Sun Oct 16 07:17:43 2011 +0000
- Revision:
- 1:098e75fd5ad2
- Parent:
- 0:06fc856e99ca
- Child:
- 3:dff241b66f84
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:06fc856e99ca | 1 | #ifndef ros_UInt16_h |
nucho | 0:06fc856e99ca | 2 | #define ros_UInt16_h |
nucho | 0:06fc856e99ca | 3 | |
nucho | 0:06fc856e99ca | 4 | #include <stdint.h> |
nucho | 0:06fc856e99ca | 5 | #include <string.h> |
nucho | 0:06fc856e99ca | 6 | #include <stdlib.h> |
nucho | 0:06fc856e99ca | 7 | #include "../ros/msg.h" |
nucho | 0:06fc856e99ca | 8 | |
nucho | 0:06fc856e99ca | 9 | namespace std_msgs |
nucho | 0:06fc856e99ca | 10 | { |
nucho | 0:06fc856e99ca | 11 | |
nucho | 0:06fc856e99ca | 12 | class UInt16 : public ros::Msg |
nucho | 0:06fc856e99ca | 13 | { |
nucho | 0:06fc856e99ca | 14 | public: |
nucho | 1:098e75fd5ad2 | 15 | uint16_t data; |
nucho | 0:06fc856e99ca | 16 | |
nucho | 0:06fc856e99ca | 17 | virtual int serialize(unsigned char *outbuffer) |
nucho | 0:06fc856e99ca | 18 | { |
nucho | 0:06fc856e99ca | 19 | int offset = 0; |
nucho | 0:06fc856e99ca | 20 | union { |
nucho | 1:098e75fd5ad2 | 21 | uint16_t real; |
nucho | 1:098e75fd5ad2 | 22 | uint16_t base; |
nucho | 0:06fc856e99ca | 23 | } u_data; |
nucho | 0:06fc856e99ca | 24 | u_data.real = this->data; |
nucho | 0:06fc856e99ca | 25 | *(outbuffer + offset + 0) = (u_data.base >> (8 * 0)) & 0xFF; |
nucho | 0:06fc856e99ca | 26 | *(outbuffer + offset + 1) = (u_data.base >> (8 * 1)) & 0xFF; |
nucho | 0:06fc856e99ca | 27 | offset += sizeof(this->data); |
nucho | 0:06fc856e99ca | 28 | return offset; |
nucho | 0:06fc856e99ca | 29 | } |
nucho | 0:06fc856e99ca | 30 | |
nucho | 0:06fc856e99ca | 31 | virtual int deserialize(unsigned char *inbuffer) |
nucho | 0:06fc856e99ca | 32 | { |
nucho | 0:06fc856e99ca | 33 | int offset = 0; |
nucho | 0:06fc856e99ca | 34 | union { |
nucho | 1:098e75fd5ad2 | 35 | uint16_t real; |
nucho | 1:098e75fd5ad2 | 36 | uint16_t base; |
nucho | 0:06fc856e99ca | 37 | } u_data; |
nucho | 0:06fc856e99ca | 38 | u_data.base = 0; |
nucho | 0:06fc856e99ca | 39 | u_data.base |= ((typeof(u_data.base)) (*(inbuffer + offset + 0))) << (8 * 0); |
nucho | 0:06fc856e99ca | 40 | u_data.base |= ((typeof(u_data.base)) (*(inbuffer + offset + 1))) << (8 * 1); |
nucho | 0:06fc856e99ca | 41 | this->data = u_data.real; |
nucho | 0:06fc856e99ca | 42 | offset += sizeof(this->data); |
nucho | 0:06fc856e99ca | 43 | return offset; |
nucho | 0:06fc856e99ca | 44 | } |
nucho | 0:06fc856e99ca | 45 | |
nucho | 0:06fc856e99ca | 46 | virtual const char * getType(){ return "std_msgs/UInt16"; }; |
nucho | 0:06fc856e99ca | 47 | |
nucho | 0:06fc856e99ca | 48 | }; |
nucho | 0:06fc856e99ca | 49 | |
nucho | 0:06fc856e99ca | 50 | } |
nucho | 0:06fc856e99ca | 51 | #endif |