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:
Wed Feb 29 23:02:12 2012 +0000
Revision:
4:2cbca0ac2569
Parent:
3:dff241b66f84

        

Who changed what in which revision?

UserRevisionLine numberNew contents of line
nucho 3:dff241b66f84 1 #ifndef _ROS_rosserial_arduino_Adc_h
nucho 3:dff241b66f84 2 #define _ROS_rosserial_arduino_Adc_h
nucho 3:dff241b66f84 3
nucho 3:dff241b66f84 4 #include <stdint.h>
nucho 3:dff241b66f84 5 #include <string.h>
nucho 3:dff241b66f84 6 #include <stdlib.h>
nucho 3:dff241b66f84 7 #include "ros/msg.h"
nucho 3:dff241b66f84 8
nucho 3:dff241b66f84 9 namespace rosserial_arduino
nucho 3:dff241b66f84 10 {
nucho 3:dff241b66f84 11
nucho 3:dff241b66f84 12 class Adc : public ros::Msg
nucho 3:dff241b66f84 13 {
nucho 3:dff241b66f84 14 public:
nucho 3:dff241b66f84 15 uint16_t adc0;
nucho 3:dff241b66f84 16 uint16_t adc1;
nucho 3:dff241b66f84 17 uint16_t adc2;
nucho 3:dff241b66f84 18 uint16_t adc3;
nucho 3:dff241b66f84 19 uint16_t adc4;
nucho 3:dff241b66f84 20 uint16_t adc5;
nucho 3:dff241b66f84 21
nucho 3:dff241b66f84 22 virtual int serialize(unsigned char *outbuffer) const
nucho 3:dff241b66f84 23 {
nucho 3:dff241b66f84 24 int offset = 0;
nucho 3:dff241b66f84 25 *(outbuffer + offset + 0) = (this->adc0 >> (8 * 0)) & 0xFF;
nucho 3:dff241b66f84 26 *(outbuffer + offset + 1) = (this->adc0 >> (8 * 1)) & 0xFF;
nucho 3:dff241b66f84 27 offset += sizeof(this->adc0);
nucho 3:dff241b66f84 28 *(outbuffer + offset + 0) = (this->adc1 >> (8 * 0)) & 0xFF;
nucho 3:dff241b66f84 29 *(outbuffer + offset + 1) = (this->adc1 >> (8 * 1)) & 0xFF;
nucho 3:dff241b66f84 30 offset += sizeof(this->adc1);
nucho 3:dff241b66f84 31 *(outbuffer + offset + 0) = (this->adc2 >> (8 * 0)) & 0xFF;
nucho 3:dff241b66f84 32 *(outbuffer + offset + 1) = (this->adc2 >> (8 * 1)) & 0xFF;
nucho 3:dff241b66f84 33 offset += sizeof(this->adc2);
nucho 3:dff241b66f84 34 *(outbuffer + offset + 0) = (this->adc3 >> (8 * 0)) & 0xFF;
nucho 3:dff241b66f84 35 *(outbuffer + offset + 1) = (this->adc3 >> (8 * 1)) & 0xFF;
nucho 3:dff241b66f84 36 offset += sizeof(this->adc3);
nucho 3:dff241b66f84 37 *(outbuffer + offset + 0) = (this->adc4 >> (8 * 0)) & 0xFF;
nucho 3:dff241b66f84 38 *(outbuffer + offset + 1) = (this->adc4 >> (8 * 1)) & 0xFF;
nucho 3:dff241b66f84 39 offset += sizeof(this->adc4);
nucho 3:dff241b66f84 40 *(outbuffer + offset + 0) = (this->adc5 >> (8 * 0)) & 0xFF;
nucho 3:dff241b66f84 41 *(outbuffer + offset + 1) = (this->adc5 >> (8 * 1)) & 0xFF;
nucho 3:dff241b66f84 42 offset += sizeof(this->adc5);
nucho 3:dff241b66f84 43 return offset;
nucho 3:dff241b66f84 44 }
nucho 3:dff241b66f84 45
nucho 3:dff241b66f84 46 virtual int deserialize(unsigned char *inbuffer)
nucho 3:dff241b66f84 47 {
nucho 3:dff241b66f84 48 int offset = 0;
nucho 3:dff241b66f84 49 this->adc0 |= ((uint16_t) (*(inbuffer + offset + 0))) << (8 * 0);
nucho 3:dff241b66f84 50 this->adc0 |= ((uint16_t) (*(inbuffer + offset + 1))) << (8 * 1);
nucho 3:dff241b66f84 51 offset += sizeof(this->adc0);
nucho 3:dff241b66f84 52 this->adc1 |= ((uint16_t) (*(inbuffer + offset + 0))) << (8 * 0);
nucho 3:dff241b66f84 53 this->adc1 |= ((uint16_t) (*(inbuffer + offset + 1))) << (8 * 1);
nucho 3:dff241b66f84 54 offset += sizeof(this->adc1);
nucho 3:dff241b66f84 55 this->adc2 |= ((uint16_t) (*(inbuffer + offset + 0))) << (8 * 0);
nucho 3:dff241b66f84 56 this->adc2 |= ((uint16_t) (*(inbuffer + offset + 1))) << (8 * 1);
nucho 3:dff241b66f84 57 offset += sizeof(this->adc2);
nucho 3:dff241b66f84 58 this->adc3 |= ((uint16_t) (*(inbuffer + offset + 0))) << (8 * 0);
nucho 3:dff241b66f84 59 this->adc3 |= ((uint16_t) (*(inbuffer + offset + 1))) << (8 * 1);
nucho 3:dff241b66f84 60 offset += sizeof(this->adc3);
nucho 3:dff241b66f84 61 this->adc4 |= ((uint16_t) (*(inbuffer + offset + 0))) << (8 * 0);
nucho 3:dff241b66f84 62 this->adc4 |= ((uint16_t) (*(inbuffer + offset + 1))) << (8 * 1);
nucho 3:dff241b66f84 63 offset += sizeof(this->adc4);
nucho 3:dff241b66f84 64 this->adc5 |= ((uint16_t) (*(inbuffer + offset + 0))) << (8 * 0);
nucho 3:dff241b66f84 65 this->adc5 |= ((uint16_t) (*(inbuffer + offset + 1))) << (8 * 1);
nucho 3:dff241b66f84 66 offset += sizeof(this->adc5);
nucho 3:dff241b66f84 67 return offset;
nucho 3:dff241b66f84 68 }
nucho 3:dff241b66f84 69
nucho 3:dff241b66f84 70 const char * getType(){ return "rosserial_mbed/Adc"; };
nucho 3:dff241b66f84 71 const char * getMD5(){ return "6d7853a614e2e821319068311f2af25b"; };
nucho 3:dff241b66f84 72
nucho 3:dff241b66f84 73 };
nucho 3:dff241b66f84 74
nucho 3:dff241b66f84 75 }
nucho 3:dff241b66f84 76 #endif