![](/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/Time.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 | 1:098e75fd5ad2 | 1 | #ifndef ros_std_msgs_Time_h |
nucho | 1:098e75fd5ad2 | 2 | #define ros_std_msgs_Time_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 | #include "ros/time.h" |
nucho | 0:06fc856e99ca | 9 | |
nucho | 0:06fc856e99ca | 10 | namespace std_msgs |
nucho | 0:06fc856e99ca | 11 | { |
nucho | 0:06fc856e99ca | 12 | |
nucho | 0:06fc856e99ca | 13 | class Time : public ros::Msg |
nucho | 0:06fc856e99ca | 14 | { |
nucho | 0:06fc856e99ca | 15 | public: |
nucho | 0:06fc856e99ca | 16 | ros::Time data; |
nucho | 0:06fc856e99ca | 17 | |
nucho | 0:06fc856e99ca | 18 | virtual int serialize(unsigned char *outbuffer) |
nucho | 0:06fc856e99ca | 19 | { |
nucho | 0:06fc856e99ca | 20 | int offset = 0; |
nucho | 0:06fc856e99ca | 21 | union { |
nucho | 1:098e75fd5ad2 | 22 | uint32_t real; |
nucho | 1:098e75fd5ad2 | 23 | uint32_t base; |
nucho | 0:06fc856e99ca | 24 | } u_sec; |
nucho | 0:06fc856e99ca | 25 | u_sec.real = this->data.sec; |
nucho | 0:06fc856e99ca | 26 | *(outbuffer + offset + 0) = (u_sec.base >> (8 * 0)) & 0xFF; |
nucho | 0:06fc856e99ca | 27 | *(outbuffer + offset + 1) = (u_sec.base >> (8 * 1)) & 0xFF; |
nucho | 0:06fc856e99ca | 28 | *(outbuffer + offset + 2) = (u_sec.base >> (8 * 2)) & 0xFF; |
nucho | 0:06fc856e99ca | 29 | *(outbuffer + offset + 3) = (u_sec.base >> (8 * 3)) & 0xFF; |
nucho | 0:06fc856e99ca | 30 | offset += sizeof(this->data.sec); |
nucho | 0:06fc856e99ca | 31 | union { |
nucho | 1:098e75fd5ad2 | 32 | uint32_t real; |
nucho | 1:098e75fd5ad2 | 33 | uint32_t base; |
nucho | 0:06fc856e99ca | 34 | } u_nsec; |
nucho | 0:06fc856e99ca | 35 | u_nsec.real = this->data.nsec; |
nucho | 0:06fc856e99ca | 36 | *(outbuffer + offset + 0) = (u_nsec.base >> (8 * 0)) & 0xFF; |
nucho | 0:06fc856e99ca | 37 | *(outbuffer + offset + 1) = (u_nsec.base >> (8 * 1)) & 0xFF; |
nucho | 0:06fc856e99ca | 38 | *(outbuffer + offset + 2) = (u_nsec.base >> (8 * 2)) & 0xFF; |
nucho | 0:06fc856e99ca | 39 | *(outbuffer + offset + 3) = (u_nsec.base >> (8 * 3)) & 0xFF; |
nucho | 0:06fc856e99ca | 40 | offset += sizeof(this->data.nsec); |
nucho | 0:06fc856e99ca | 41 | return offset; |
nucho | 0:06fc856e99ca | 42 | } |
nucho | 0:06fc856e99ca | 43 | |
nucho | 0:06fc856e99ca | 44 | virtual int deserialize(unsigned char *inbuffer) |
nucho | 0:06fc856e99ca | 45 | { |
nucho | 0:06fc856e99ca | 46 | int offset = 0; |
nucho | 0:06fc856e99ca | 47 | union { |
nucho | 1:098e75fd5ad2 | 48 | uint32_t real; |
nucho | 1:098e75fd5ad2 | 49 | uint32_t base; |
nucho | 0:06fc856e99ca | 50 | } u_sec; |
nucho | 0:06fc856e99ca | 51 | u_sec.base = 0; |
nucho | 0:06fc856e99ca | 52 | u_sec.base |= ((typeof(u_sec.base)) (*(inbuffer + offset + 0))) << (8 * 0); |
nucho | 0:06fc856e99ca | 53 | u_sec.base |= ((typeof(u_sec.base)) (*(inbuffer + offset + 1))) << (8 * 1); |
nucho | 0:06fc856e99ca | 54 | u_sec.base |= ((typeof(u_sec.base)) (*(inbuffer + offset + 2))) << (8 * 2); |
nucho | 0:06fc856e99ca | 55 | u_sec.base |= ((typeof(u_sec.base)) (*(inbuffer + offset + 3))) << (8 * 3); |
nucho | 0:06fc856e99ca | 56 | this->data.sec = u_sec.real; |
nucho | 0:06fc856e99ca | 57 | offset += sizeof(this->data.sec); |
nucho | 0:06fc856e99ca | 58 | union { |
nucho | 1:098e75fd5ad2 | 59 | uint32_t real; |
nucho | 1:098e75fd5ad2 | 60 | uint32_t base; |
nucho | 0:06fc856e99ca | 61 | } u_nsec; |
nucho | 0:06fc856e99ca | 62 | u_nsec.base = 0; |
nucho | 0:06fc856e99ca | 63 | u_nsec.base |= ((typeof(u_nsec.base)) (*(inbuffer + offset + 0))) << (8 * 0); |
nucho | 0:06fc856e99ca | 64 | u_nsec.base |= ((typeof(u_nsec.base)) (*(inbuffer + offset + 1))) << (8 * 1); |
nucho | 0:06fc856e99ca | 65 | u_nsec.base |= ((typeof(u_nsec.base)) (*(inbuffer + offset + 2))) << (8 * 2); |
nucho | 0:06fc856e99ca | 66 | u_nsec.base |= ((typeof(u_nsec.base)) (*(inbuffer + offset + 3))) << (8 * 3); |
nucho | 0:06fc856e99ca | 67 | this->data.nsec = u_nsec.real; |
nucho | 0:06fc856e99ca | 68 | offset += sizeof(this->data.nsec); |
nucho | 0:06fc856e99ca | 69 | return offset; |
nucho | 0:06fc856e99ca | 70 | } |
nucho | 0:06fc856e99ca | 71 | |
nucho | 0:06fc856e99ca | 72 | virtual const char * getType(){ return "std_msgs/Time"; }; |
nucho | 0:06fc856e99ca | 73 | |
nucho | 0:06fc856e99ca | 74 | }; |
nucho | 0:06fc856e99ca | 75 | |
nucho | 0:06fc856e99ca | 76 | } |
nucho | 0:06fc856e99ca | 77 | #endif |