Working towards recieving twists

Dependencies:   BufferedSerial

Fork of ros_lib_kinetic by Gary Servin

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers Adc.h Source File

Adc.h

00001 #ifndef _ROS_rosserial_mbed_Adc_h
00002 #define _ROS_rosserial_mbed_Adc_h
00003 
00004 #include <stdint.h>
00005 #include <string.h>
00006 #include <stdlib.h>
00007 #include "ros/msg.h"
00008 
00009 namespace rosserial_mbed
00010 {
00011 
00012   class Adc : public ros::Msg
00013   {
00014     public:
00015       typedef uint16_t _adc0_type;
00016       _adc0_type adc0;
00017       typedef uint16_t _adc1_type;
00018       _adc1_type adc1;
00019       typedef uint16_t _adc2_type;
00020       _adc2_type adc2;
00021       typedef uint16_t _adc3_type;
00022       _adc3_type adc3;
00023       typedef uint16_t _adc4_type;
00024       _adc4_type adc4;
00025       typedef uint16_t _adc5_type;
00026       _adc5_type adc5;
00027 
00028     Adc():
00029       adc0(0),
00030       adc1(0),
00031       adc2(0),
00032       adc3(0),
00033       adc4(0),
00034       adc5(0)
00035     {
00036     }
00037 
00038     virtual int serialize(unsigned char *outbuffer) const
00039     {
00040       int offset = 0;
00041       *(outbuffer + offset + 0) = (this->adc0 >> (8 * 0)) & 0xFF;
00042       *(outbuffer + offset + 1) = (this->adc0 >> (8 * 1)) & 0xFF;
00043       offset += sizeof(this->adc0);
00044       *(outbuffer + offset + 0) = (this->adc1 >> (8 * 0)) & 0xFF;
00045       *(outbuffer + offset + 1) = (this->adc1 >> (8 * 1)) & 0xFF;
00046       offset += sizeof(this->adc1);
00047       *(outbuffer + offset + 0) = (this->adc2 >> (8 * 0)) & 0xFF;
00048       *(outbuffer + offset + 1) = (this->adc2 >> (8 * 1)) & 0xFF;
00049       offset += sizeof(this->adc2);
00050       *(outbuffer + offset + 0) = (this->adc3 >> (8 * 0)) & 0xFF;
00051       *(outbuffer + offset + 1) = (this->adc3 >> (8 * 1)) & 0xFF;
00052       offset += sizeof(this->adc3);
00053       *(outbuffer + offset + 0) = (this->adc4 >> (8 * 0)) & 0xFF;
00054       *(outbuffer + offset + 1) = (this->adc4 >> (8 * 1)) & 0xFF;
00055       offset += sizeof(this->adc4);
00056       *(outbuffer + offset + 0) = (this->adc5 >> (8 * 0)) & 0xFF;
00057       *(outbuffer + offset + 1) = (this->adc5 >> (8 * 1)) & 0xFF;
00058       offset += sizeof(this->adc5);
00059       return offset;
00060     }
00061 
00062     virtual int deserialize(unsigned char *inbuffer)
00063     {
00064       int offset = 0;
00065       this->adc0 =  ((uint16_t) (*(inbuffer + offset)));
00066       this->adc0 |= ((uint16_t) (*(inbuffer + offset + 1))) << (8 * 1);
00067       offset += sizeof(this->adc0);
00068       this->adc1 =  ((uint16_t) (*(inbuffer + offset)));
00069       this->adc1 |= ((uint16_t) (*(inbuffer + offset + 1))) << (8 * 1);
00070       offset += sizeof(this->adc1);
00071       this->adc2 =  ((uint16_t) (*(inbuffer + offset)));
00072       this->adc2 |= ((uint16_t) (*(inbuffer + offset + 1))) << (8 * 1);
00073       offset += sizeof(this->adc2);
00074       this->adc3 =  ((uint16_t) (*(inbuffer + offset)));
00075       this->adc3 |= ((uint16_t) (*(inbuffer + offset + 1))) << (8 * 1);
00076       offset += sizeof(this->adc3);
00077       this->adc4 =  ((uint16_t) (*(inbuffer + offset)));
00078       this->adc4 |= ((uint16_t) (*(inbuffer + offset + 1))) << (8 * 1);
00079       offset += sizeof(this->adc4);
00080       this->adc5 =  ((uint16_t) (*(inbuffer + offset)));
00081       this->adc5 |= ((uint16_t) (*(inbuffer + offset + 1))) << (8 * 1);
00082       offset += sizeof(this->adc5);
00083      return offset;
00084     }
00085 
00086     const char * getType(){ return "rosserial_mbed/Adc"; };
00087     const char * getMD5(){ return "6d7853a614e2e821319068311f2af25b"; };
00088 
00089   };
00090 
00091 }
00092 #endif