rosserial library for mbed Inspired by nucho's rosserial library This library is still under development

Dependencies:   MODSERIAL mbed

Dependents:   mbed_roshydro_test

Library still under development!

Committer:
akashvibhute
Date:
Sun Feb 15 10:53:43 2015 +0000
Revision:
0:30537dec6e0b
First commit; Library still need to be debugged, compilation issues with new mbed and modserial updates.

Who changed what in which revision?

UserRevisionLine numberNew contents of line
akashvibhute 0:30537dec6e0b 1 #ifndef _ROS_SERVICE_TwoInts_h
akashvibhute 0:30537dec6e0b 2 #define _ROS_SERVICE_TwoInts_h
akashvibhute 0:30537dec6e0b 3 #include <stdint.h>
akashvibhute 0:30537dec6e0b 4 #include <string.h>
akashvibhute 0:30537dec6e0b 5 #include <stdlib.h>
akashvibhute 0:30537dec6e0b 6 #include "ros/msg.h"
akashvibhute 0:30537dec6e0b 7
akashvibhute 0:30537dec6e0b 8 namespace roscpp_tutorials
akashvibhute 0:30537dec6e0b 9 {
akashvibhute 0:30537dec6e0b 10
akashvibhute 0:30537dec6e0b 11 static const char TWOINTS[] = "roscpp_tutorials/TwoInts";
akashvibhute 0:30537dec6e0b 12
akashvibhute 0:30537dec6e0b 13 class TwoIntsRequest : public ros::Msg
akashvibhute 0:30537dec6e0b 14 {
akashvibhute 0:30537dec6e0b 15 public:
akashvibhute 0:30537dec6e0b 16 int64_t a;
akashvibhute 0:30537dec6e0b 17 int64_t b;
akashvibhute 0:30537dec6e0b 18
akashvibhute 0:30537dec6e0b 19 TwoIntsRequest():
akashvibhute 0:30537dec6e0b 20 a(0),
akashvibhute 0:30537dec6e0b 21 b(0)
akashvibhute 0:30537dec6e0b 22 {
akashvibhute 0:30537dec6e0b 23 }
akashvibhute 0:30537dec6e0b 24
akashvibhute 0:30537dec6e0b 25 virtual int serialize(unsigned char *outbuffer) const
akashvibhute 0:30537dec6e0b 26 {
akashvibhute 0:30537dec6e0b 27 int offset = 0;
akashvibhute 0:30537dec6e0b 28 union {
akashvibhute 0:30537dec6e0b 29 int64_t real;
akashvibhute 0:30537dec6e0b 30 uint64_t base;
akashvibhute 0:30537dec6e0b 31 } u_a;
akashvibhute 0:30537dec6e0b 32 u_a.real = this->a;
akashvibhute 0:30537dec6e0b 33 *(outbuffer + offset + 0) = (u_a.base >> (8 * 0)) & 0xFF;
akashvibhute 0:30537dec6e0b 34 *(outbuffer + offset + 1) = (u_a.base >> (8 * 1)) & 0xFF;
akashvibhute 0:30537dec6e0b 35 *(outbuffer + offset + 2) = (u_a.base >> (8 * 2)) & 0xFF;
akashvibhute 0:30537dec6e0b 36 *(outbuffer + offset + 3) = (u_a.base >> (8 * 3)) & 0xFF;
akashvibhute 0:30537dec6e0b 37 *(outbuffer + offset + 4) = (u_a.base >> (8 * 4)) & 0xFF;
akashvibhute 0:30537dec6e0b 38 *(outbuffer + offset + 5) = (u_a.base >> (8 * 5)) & 0xFF;
akashvibhute 0:30537dec6e0b 39 *(outbuffer + offset + 6) = (u_a.base >> (8 * 6)) & 0xFF;
akashvibhute 0:30537dec6e0b 40 *(outbuffer + offset + 7) = (u_a.base >> (8 * 7)) & 0xFF;
akashvibhute 0:30537dec6e0b 41 offset += sizeof(this->a);
akashvibhute 0:30537dec6e0b 42 union {
akashvibhute 0:30537dec6e0b 43 int64_t real;
akashvibhute 0:30537dec6e0b 44 uint64_t base;
akashvibhute 0:30537dec6e0b 45 } u_b;
akashvibhute 0:30537dec6e0b 46 u_b.real = this->b;
akashvibhute 0:30537dec6e0b 47 *(outbuffer + offset + 0) = (u_b.base >> (8 * 0)) & 0xFF;
akashvibhute 0:30537dec6e0b 48 *(outbuffer + offset + 1) = (u_b.base >> (8 * 1)) & 0xFF;
akashvibhute 0:30537dec6e0b 49 *(outbuffer + offset + 2) = (u_b.base >> (8 * 2)) & 0xFF;
akashvibhute 0:30537dec6e0b 50 *(outbuffer + offset + 3) = (u_b.base >> (8 * 3)) & 0xFF;
akashvibhute 0:30537dec6e0b 51 *(outbuffer + offset + 4) = (u_b.base >> (8 * 4)) & 0xFF;
akashvibhute 0:30537dec6e0b 52 *(outbuffer + offset + 5) = (u_b.base >> (8 * 5)) & 0xFF;
akashvibhute 0:30537dec6e0b 53 *(outbuffer + offset + 6) = (u_b.base >> (8 * 6)) & 0xFF;
akashvibhute 0:30537dec6e0b 54 *(outbuffer + offset + 7) = (u_b.base >> (8 * 7)) & 0xFF;
akashvibhute 0:30537dec6e0b 55 offset += sizeof(this->b);
akashvibhute 0:30537dec6e0b 56 return offset;
akashvibhute 0:30537dec6e0b 57 }
akashvibhute 0:30537dec6e0b 58
akashvibhute 0:30537dec6e0b 59 virtual int deserialize(unsigned char *inbuffer)
akashvibhute 0:30537dec6e0b 60 {
akashvibhute 0:30537dec6e0b 61 int offset = 0;
akashvibhute 0:30537dec6e0b 62 union {
akashvibhute 0:30537dec6e0b 63 int64_t real;
akashvibhute 0:30537dec6e0b 64 uint64_t base;
akashvibhute 0:30537dec6e0b 65 } u_a;
akashvibhute 0:30537dec6e0b 66 u_a.base = 0;
akashvibhute 0:30537dec6e0b 67 u_a.base |= ((uint64_t) (*(inbuffer + offset + 0))) << (8 * 0);
akashvibhute 0:30537dec6e0b 68 u_a.base |= ((uint64_t) (*(inbuffer + offset + 1))) << (8 * 1);
akashvibhute 0:30537dec6e0b 69 u_a.base |= ((uint64_t) (*(inbuffer + offset + 2))) << (8 * 2);
akashvibhute 0:30537dec6e0b 70 u_a.base |= ((uint64_t) (*(inbuffer + offset + 3))) << (8 * 3);
akashvibhute 0:30537dec6e0b 71 u_a.base |= ((uint64_t) (*(inbuffer + offset + 4))) << (8 * 4);
akashvibhute 0:30537dec6e0b 72 u_a.base |= ((uint64_t) (*(inbuffer + offset + 5))) << (8 * 5);
akashvibhute 0:30537dec6e0b 73 u_a.base |= ((uint64_t) (*(inbuffer + offset + 6))) << (8 * 6);
akashvibhute 0:30537dec6e0b 74 u_a.base |= ((uint64_t) (*(inbuffer + offset + 7))) << (8 * 7);
akashvibhute 0:30537dec6e0b 75 this->a = u_a.real;
akashvibhute 0:30537dec6e0b 76 offset += sizeof(this->a);
akashvibhute 0:30537dec6e0b 77 union {
akashvibhute 0:30537dec6e0b 78 int64_t real;
akashvibhute 0:30537dec6e0b 79 uint64_t base;
akashvibhute 0:30537dec6e0b 80 } u_b;
akashvibhute 0:30537dec6e0b 81 u_b.base = 0;
akashvibhute 0:30537dec6e0b 82 u_b.base |= ((uint64_t) (*(inbuffer + offset + 0))) << (8 * 0);
akashvibhute 0:30537dec6e0b 83 u_b.base |= ((uint64_t) (*(inbuffer + offset + 1))) << (8 * 1);
akashvibhute 0:30537dec6e0b 84 u_b.base |= ((uint64_t) (*(inbuffer + offset + 2))) << (8 * 2);
akashvibhute 0:30537dec6e0b 85 u_b.base |= ((uint64_t) (*(inbuffer + offset + 3))) << (8 * 3);
akashvibhute 0:30537dec6e0b 86 u_b.base |= ((uint64_t) (*(inbuffer + offset + 4))) << (8 * 4);
akashvibhute 0:30537dec6e0b 87 u_b.base |= ((uint64_t) (*(inbuffer + offset + 5))) << (8 * 5);
akashvibhute 0:30537dec6e0b 88 u_b.base |= ((uint64_t) (*(inbuffer + offset + 6))) << (8 * 6);
akashvibhute 0:30537dec6e0b 89 u_b.base |= ((uint64_t) (*(inbuffer + offset + 7))) << (8 * 7);
akashvibhute 0:30537dec6e0b 90 this->b = u_b.real;
akashvibhute 0:30537dec6e0b 91 offset += sizeof(this->b);
akashvibhute 0:30537dec6e0b 92 return offset;
akashvibhute 0:30537dec6e0b 93 }
akashvibhute 0:30537dec6e0b 94
akashvibhute 0:30537dec6e0b 95 const char * getType(){ return TWOINTS; };
akashvibhute 0:30537dec6e0b 96 const char * getMD5(){ return "36d09b846be0b371c5f190354dd3153e"; };
akashvibhute 0:30537dec6e0b 97
akashvibhute 0:30537dec6e0b 98 };
akashvibhute 0:30537dec6e0b 99
akashvibhute 0:30537dec6e0b 100 class TwoIntsResponse : public ros::Msg
akashvibhute 0:30537dec6e0b 101 {
akashvibhute 0:30537dec6e0b 102 public:
akashvibhute 0:30537dec6e0b 103 int64_t sum;
akashvibhute 0:30537dec6e0b 104
akashvibhute 0:30537dec6e0b 105 TwoIntsResponse():
akashvibhute 0:30537dec6e0b 106 sum(0)
akashvibhute 0:30537dec6e0b 107 {
akashvibhute 0:30537dec6e0b 108 }
akashvibhute 0:30537dec6e0b 109
akashvibhute 0:30537dec6e0b 110 virtual int serialize(unsigned char *outbuffer) const
akashvibhute 0:30537dec6e0b 111 {
akashvibhute 0:30537dec6e0b 112 int offset = 0;
akashvibhute 0:30537dec6e0b 113 union {
akashvibhute 0:30537dec6e0b 114 int64_t real;
akashvibhute 0:30537dec6e0b 115 uint64_t base;
akashvibhute 0:30537dec6e0b 116 } u_sum;
akashvibhute 0:30537dec6e0b 117 u_sum.real = this->sum;
akashvibhute 0:30537dec6e0b 118 *(outbuffer + offset + 0) = (u_sum.base >> (8 * 0)) & 0xFF;
akashvibhute 0:30537dec6e0b 119 *(outbuffer + offset + 1) = (u_sum.base >> (8 * 1)) & 0xFF;
akashvibhute 0:30537dec6e0b 120 *(outbuffer + offset + 2) = (u_sum.base >> (8 * 2)) & 0xFF;
akashvibhute 0:30537dec6e0b 121 *(outbuffer + offset + 3) = (u_sum.base >> (8 * 3)) & 0xFF;
akashvibhute 0:30537dec6e0b 122 *(outbuffer + offset + 4) = (u_sum.base >> (8 * 4)) & 0xFF;
akashvibhute 0:30537dec6e0b 123 *(outbuffer + offset + 5) = (u_sum.base >> (8 * 5)) & 0xFF;
akashvibhute 0:30537dec6e0b 124 *(outbuffer + offset + 6) = (u_sum.base >> (8 * 6)) & 0xFF;
akashvibhute 0:30537dec6e0b 125 *(outbuffer + offset + 7) = (u_sum.base >> (8 * 7)) & 0xFF;
akashvibhute 0:30537dec6e0b 126 offset += sizeof(this->sum);
akashvibhute 0:30537dec6e0b 127 return offset;
akashvibhute 0:30537dec6e0b 128 }
akashvibhute 0:30537dec6e0b 129
akashvibhute 0:30537dec6e0b 130 virtual int deserialize(unsigned char *inbuffer)
akashvibhute 0:30537dec6e0b 131 {
akashvibhute 0:30537dec6e0b 132 int offset = 0;
akashvibhute 0:30537dec6e0b 133 union {
akashvibhute 0:30537dec6e0b 134 int64_t real;
akashvibhute 0:30537dec6e0b 135 uint64_t base;
akashvibhute 0:30537dec6e0b 136 } u_sum;
akashvibhute 0:30537dec6e0b 137 u_sum.base = 0;
akashvibhute 0:30537dec6e0b 138 u_sum.base |= ((uint64_t) (*(inbuffer + offset + 0))) << (8 * 0);
akashvibhute 0:30537dec6e0b 139 u_sum.base |= ((uint64_t) (*(inbuffer + offset + 1))) << (8 * 1);
akashvibhute 0:30537dec6e0b 140 u_sum.base |= ((uint64_t) (*(inbuffer + offset + 2))) << (8 * 2);
akashvibhute 0:30537dec6e0b 141 u_sum.base |= ((uint64_t) (*(inbuffer + offset + 3))) << (8 * 3);
akashvibhute 0:30537dec6e0b 142 u_sum.base |= ((uint64_t) (*(inbuffer + offset + 4))) << (8 * 4);
akashvibhute 0:30537dec6e0b 143 u_sum.base |= ((uint64_t) (*(inbuffer + offset + 5))) << (8 * 5);
akashvibhute 0:30537dec6e0b 144 u_sum.base |= ((uint64_t) (*(inbuffer + offset + 6))) << (8 * 6);
akashvibhute 0:30537dec6e0b 145 u_sum.base |= ((uint64_t) (*(inbuffer + offset + 7))) << (8 * 7);
akashvibhute 0:30537dec6e0b 146 this->sum = u_sum.real;
akashvibhute 0:30537dec6e0b 147 offset += sizeof(this->sum);
akashvibhute 0:30537dec6e0b 148 return offset;
akashvibhute 0:30537dec6e0b 149 }
akashvibhute 0:30537dec6e0b 150
akashvibhute 0:30537dec6e0b 151 const char * getType(){ return TWOINTS; };
akashvibhute 0:30537dec6e0b 152 const char * getMD5(){ return "b88405221c77b1878a3cbbfff53428d7"; };
akashvibhute 0:30537dec6e0b 153
akashvibhute 0:30537dec6e0b 154 };
akashvibhute 0:30537dec6e0b 155
akashvibhute 0:30537dec6e0b 156 class TwoInts {
akashvibhute 0:30537dec6e0b 157 public:
akashvibhute 0:30537dec6e0b 158 typedef TwoIntsRequest Request;
akashvibhute 0:30537dec6e0b 159 typedef TwoIntsResponse Response;
akashvibhute 0:30537dec6e0b 160 };
akashvibhute 0:30537dec6e0b 161
akashvibhute 0:30537dec6e0b 162 }
akashvibhute 0:30537dec6e0b 163 #endif
akashvibhute 0:30537dec6e0b 164