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

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?

UserRevisionLine numberNew contents of line
nucho 0:06fc856e99ca 1 #ifndef ros_UInt64_h
nucho 0:06fc856e99ca 2 #define ros_UInt64_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 1:098e75fd5ad2 9 namespace std_msgs {
nucho 0:06fc856e99ca 10
nucho 1:098e75fd5ad2 11 class UInt64 : public ros::Msg {
nucho 1:098e75fd5ad2 12 public:
nucho 1:098e75fd5ad2 13 uint64_t data;
nucho 0:06fc856e99ca 14
nucho 1:098e75fd5ad2 15 virtual int serialize(unsigned char *outbuffer) {
nucho 1:098e75fd5ad2 16 int offset = 0;
nucho 1:098e75fd5ad2 17 union {
nucho 1:098e75fd5ad2 18 uint64_t real;
nucho 1:098e75fd5ad2 19 uint64_t base;
nucho 1:098e75fd5ad2 20 } u_data;
nucho 1:098e75fd5ad2 21 u_data.real = this->data;
nucho 1:098e75fd5ad2 22 *(outbuffer + offset + 0) = (u_data.base >> (8 * 0)) & 0xFF;
nucho 1:098e75fd5ad2 23 *(outbuffer + offset + 1) = (u_data.base >> (8 * 1)) & 0xFF;
nucho 1:098e75fd5ad2 24 *(outbuffer + offset + 2) = (u_data.base >> (8 * 2)) & 0xFF;
nucho 1:098e75fd5ad2 25 *(outbuffer + offset + 3) = (u_data.base >> (8 * 3)) & 0xFF;
nucho 1:098e75fd5ad2 26 *(outbuffer + offset + 4) = (u_data.base >> (8 * 4)) & 0xFF;
nucho 1:098e75fd5ad2 27 *(outbuffer + offset + 5) = (u_data.base >> (8 * 5)) & 0xFF;
nucho 1:098e75fd5ad2 28 *(outbuffer + offset + 6) = (u_data.base >> (8 * 6)) & 0xFF;
nucho 1:098e75fd5ad2 29 *(outbuffer + offset + 7) = (u_data.base >> (8 * 7)) & 0xFF;
nucho 1:098e75fd5ad2 30 offset += sizeof(this->data);
nucho 1:098e75fd5ad2 31 return offset;
nucho 0:06fc856e99ca 32 }
nucho 0:06fc856e99ca 33
nucho 1:098e75fd5ad2 34 virtual int deserialize(unsigned char *inbuffer) {
nucho 1:098e75fd5ad2 35 int offset = 0;
nucho 1:098e75fd5ad2 36 union {
nucho 1:098e75fd5ad2 37 uint64_t real;
nucho 1:098e75fd5ad2 38 uint64_t base;
nucho 1:098e75fd5ad2 39 } u_data;
nucho 1:098e75fd5ad2 40 u_data.base = 0;
nucho 1:098e75fd5ad2 41 u_data.base |= ((typeof(u_data.base)) (*(inbuffer + offset + 0))) << (8 * 0);
nucho 1:098e75fd5ad2 42 u_data.base |= ((typeof(u_data.base)) (*(inbuffer + offset + 1))) << (8 * 1);
nucho 1:098e75fd5ad2 43 u_data.base |= ((typeof(u_data.base)) (*(inbuffer + offset + 2))) << (8 * 2);
nucho 1:098e75fd5ad2 44 u_data.base |= ((typeof(u_data.base)) (*(inbuffer + offset + 3))) << (8 * 3);
nucho 1:098e75fd5ad2 45 u_data.base |= ((typeof(u_data.base)) (*(inbuffer + offset + 4))) << (8 * 4);
nucho 1:098e75fd5ad2 46 u_data.base |= ((typeof(u_data.base)) (*(inbuffer + offset + 5))) << (8 * 5);
nucho 1:098e75fd5ad2 47 u_data.base |= ((typeof(u_data.base)) (*(inbuffer + offset + 6))) << (8 * 6);
nucho 1:098e75fd5ad2 48 u_data.base |= ((typeof(u_data.base)) (*(inbuffer + offset + 7))) << (8 * 7);
nucho 1:098e75fd5ad2 49 this->data = u_data.real;
nucho 1:098e75fd5ad2 50 offset += sizeof(this->data);
nucho 1:098e75fd5ad2 51 return offset;
nucho 0:06fc856e99ca 52 }
nucho 0:06fc856e99ca 53
nucho 1:098e75fd5ad2 54 /*
nucho 1:098e75fd5ad2 55 public:
nucho 1:098e75fd5ad2 56 long data;
nucho 1:098e75fd5ad2 57
nucho 1:098e75fd5ad2 58 virtual int serialize(unsigned char *outbuffer)
nucho 1:098e75fd5ad2 59 {
nucho 1:098e75fd5ad2 60 int offset = 0;
nucho 1:098e75fd5ad2 61 *(outbuffer + offset++) = (data >> (8 * 0)) & 0xFF;
nucho 1:098e75fd5ad2 62 *(outbuffer + offset++) = (data >> (8 * 1)) & 0xFF;
nucho 1:098e75fd5ad2 63 *(outbuffer + offset++) = (data >> (8 * 2)) & 0xFF;
nucho 1:098e75fd5ad2 64 *(outbuffer + offset++) = (data >> (8 * 3)) & 0xFF;
nucho 1:098e75fd5ad2 65 *(outbuffer + offset++) = (data > 0) ? 0: 255;
nucho 1:098e75fd5ad2 66 *(outbuffer + offset++) = (data > 0) ? 0: 255;
nucho 1:098e75fd5ad2 67 *(outbuffer + offset++) = (data > 0) ? 0: 255;
nucho 1:098e75fd5ad2 68 *(outbuffer + offset++) = (data > 0) ? 0: 255;
nucho 1:098e75fd5ad2 69 return offset;
nucho 1:098e75fd5ad2 70 }
nucho 0:06fc856e99ca 71
nucho 1:098e75fd5ad2 72 virtual int deserialize(unsigned char *inbuffer)
nucho 1:098e75fd5ad2 73 {
nucho 1:098e75fd5ad2 74 int offset = 0;
nucho 1:098e75fd5ad2 75 data = 0;
nucho 1:098e75fd5ad2 76 data += ((long)(*(inbuffer + offset++))) >> (8 * 0);
nucho 1:098e75fd5ad2 77 data += ((long)(*(inbuffer + offset++))) >> (8 * 1);
nucho 1:098e75fd5ad2 78 data += ((long)(*(inbuffer + offset++))) >> (8 * 2);
nucho 1:098e75fd5ad2 79 data += ((long)(*(inbuffer + offset++))) >> (8 * 3);
nucho 1:098e75fd5ad2 80 offset += 4;
nucho 1:098e75fd5ad2 81 return offset;
nucho 1:098e75fd5ad2 82 }
nucho 1:098e75fd5ad2 83 */
nucho 1:098e75fd5ad2 84 virtual const char * getType() {
nucho 1:098e75fd5ad2 85 return "std_msgs/UInt64";
nucho 1:098e75fd5ad2 86 };
nucho 1:098e75fd5ad2 87
nucho 1:098e75fd5ad2 88 };
nucho 0:06fc856e99ca 89
nucho 0:06fc856e99ca 90 }
nucho 0:06fc856e99ca 91 #endif