This program is porting rosserial_arduino for mbed http://www.ros.org/wiki/rosserial_arduino This program supported the revision of 169 of rosserial.

Dependencies:  

Dependents:   rosserial_mbed robot_S2

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?

UserRevisionLine numberNew contents of line
nucho 0:77afd7560544 1 #ifndef ros_Int64_h
nucho 0:77afd7560544 2 #define ros_Int64_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 Int64 : public ros::Msg {
nucho 1:ff0ec969dad1 12 public:
nucho 1:ff0ec969dad1 13 int64_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 int64_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
nucho 1:ff0ec969dad1 31 offset += sizeof(this->data);
nucho 1:ff0ec969dad1 32 return offset;
nucho 0:77afd7560544 33 }
nucho 0:77afd7560544 34
nucho 1:ff0ec969dad1 35 virtual int deserialize(unsigned char *inbuffer) {
nucho 1:ff0ec969dad1 36 int offset = 0;
nucho 1:ff0ec969dad1 37 union {
nucho 1:ff0ec969dad1 38 int64_t real;
nucho 1:ff0ec969dad1 39 uint64_t base;
nucho 1:ff0ec969dad1 40 } u_data;
nucho 1:ff0ec969dad1 41 u_data.base = 0;
nucho 1:ff0ec969dad1 42 u_data.base |= ((typeof(u_data.base)) (*(inbuffer + offset + 0))) << (8 * 0);
nucho 1:ff0ec969dad1 43 u_data.base |= ((typeof(u_data.base)) (*(inbuffer + offset + 1))) << (8 * 1);
nucho 1:ff0ec969dad1 44 u_data.base |= ((typeof(u_data.base)) (*(inbuffer + offset + 2))) << (8 * 2);
nucho 1:ff0ec969dad1 45 u_data.base |= ((typeof(u_data.base)) (*(inbuffer + offset + 3))) << (8 * 3);
nucho 1:ff0ec969dad1 46 u_data.base |= ((typeof(u_data.base)) (*(inbuffer + offset + 4))) << (8 * 4);
nucho 1:ff0ec969dad1 47 u_data.base |= ((typeof(u_data.base)) (*(inbuffer + offset + 5))) << (8 * 5);
nucho 1:ff0ec969dad1 48 u_data.base |= ((typeof(u_data.base)) (*(inbuffer + offset + 6))) << (8 * 6);
nucho 1:ff0ec969dad1 49 u_data.base |= ((typeof(u_data.base)) (*(inbuffer + offset + 7))) << (8 * 7);
nucho 1:ff0ec969dad1 50
nucho 1:ff0ec969dad1 51 this->data = u_data.real;
nucho 1:ff0ec969dad1 52 offset += sizeof(this->data);
nucho 1:ff0ec969dad1 53 return offset;
nucho 0:77afd7560544 54 }
nucho 1:ff0ec969dad1 55 /*
nucho 1:ff0ec969dad1 56 public:
nucho 1:ff0ec969dad1 57 long data;
nucho 0:77afd7560544 58
nucho 1:ff0ec969dad1 59 virtual int serialize(unsigned char *outbuffer)
nucho 1:ff0ec969dad1 60 {
nucho 1:ff0ec969dad1 61 int offset = 0;
nucho 1:ff0ec969dad1 62 *(outbuffer + offset++) = (data >> (8 * 0)) & 0xFF;
nucho 1:ff0ec969dad1 63 *(outbuffer + offset++) = (data >> (8 * 1)) & 0xFF;
nucho 1:ff0ec969dad1 64 *(outbuffer + offset++) = (data >> (8 * 2)) & 0xFF;
nucho 1:ff0ec969dad1 65 *(outbuffer + offset++) = (data >> (8 * 3)) & 0xFF;
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 *(outbuffer + offset++) = (data > 0) ? 0: 255;
nucho 1:ff0ec969dad1 70 return offset;
nucho 1:ff0ec969dad1 71 }
nucho 0:77afd7560544 72
nucho 1:ff0ec969dad1 73 virtual int deserialize(unsigned char *inbuffer)
nucho 1:ff0ec969dad1 74 {
nucho 1:ff0ec969dad1 75 int offset = 0;
nucho 1:ff0ec969dad1 76 data = 0;
nucho 1:ff0ec969dad1 77 data += ((long)(*(inbuffer + offset++))) >> (8 * 0);
nucho 1:ff0ec969dad1 78 data += ((long)(*(inbuffer + offset++))) >> (8 * 1);
nucho 1:ff0ec969dad1 79 data += ((long)(*(inbuffer + offset++))) >> (8 * 2);
nucho 1:ff0ec969dad1 80 data += ((long)(*(inbuffer + offset++))) >> (8 * 3);
nucho 1:ff0ec969dad1 81 offset += 4;
nucho 1:ff0ec969dad1 82 return offset;
nucho 1:ff0ec969dad1 83 }
nucho 1:ff0ec969dad1 84 */
nucho 1:ff0ec969dad1 85
nucho 1:ff0ec969dad1 86 virtual const char * getType() {
nucho 1:ff0ec969dad1 87 return "std_msgs/Int64";
nucho 1:ff0ec969dad1 88 };
nucho 1:ff0ec969dad1 89
nucho 1:ff0ec969dad1 90 };
nucho 0:77afd7560544 91
nucho 0:77afd7560544 92 }
nucho 0:77afd7560544 93 #endif