Statistics
| Branch: | Revision:

root / quad2 / arduino / src / ros_lib / rosserial_arduino / Adc.h @ c1426757

History | View | Annotate | Download (2.76 KB)

1
#ifndef _ROS_rosserial_arduino_Adc_h
2
#define _ROS_rosserial_arduino_Adc_h
3

    
4
#include <stdint.h>
5
#include <string.h>
6
#include <stdlib.h>
7
#include "ros/msg.h"
8

    
9
namespace rosserial_arduino
10
{
11

    
12
  class Adc : public ros::Msg
13
  {
14
    public:
15
      uint16_t adc0;
16
      uint16_t adc1;
17
      uint16_t adc2;
18
      uint16_t adc3;
19
      uint16_t adc4;
20
      uint16_t adc5;
21

    
22
    virtual int serialize(unsigned char *outbuffer) const
23
    {
24
      int offset = 0;
25
      *(outbuffer + offset + 0) = (this->adc0 >> (8 * 0)) & 0xFF;
26
      *(outbuffer + offset + 1) = (this->adc0 >> (8 * 1)) & 0xFF;
27
      offset += sizeof(this->adc0);
28
      *(outbuffer + offset + 0) = (this->adc1 >> (8 * 0)) & 0xFF;
29
      *(outbuffer + offset + 1) = (this->adc1 >> (8 * 1)) & 0xFF;
30
      offset += sizeof(this->adc1);
31
      *(outbuffer + offset + 0) = (this->adc2 >> (8 * 0)) & 0xFF;
32
      *(outbuffer + offset + 1) = (this->adc2 >> (8 * 1)) & 0xFF;
33
      offset += sizeof(this->adc2);
34
      *(outbuffer + offset + 0) = (this->adc3 >> (8 * 0)) & 0xFF;
35
      *(outbuffer + offset + 1) = (this->adc3 >> (8 * 1)) & 0xFF;
36
      offset += sizeof(this->adc3);
37
      *(outbuffer + offset + 0) = (this->adc4 >> (8 * 0)) & 0xFF;
38
      *(outbuffer + offset + 1) = (this->adc4 >> (8 * 1)) & 0xFF;
39
      offset += sizeof(this->adc4);
40
      *(outbuffer + offset + 0) = (this->adc5 >> (8 * 0)) & 0xFF;
41
      *(outbuffer + offset + 1) = (this->adc5 >> (8 * 1)) & 0xFF;
42
      offset += sizeof(this->adc5);
43
      return offset;
44
    }
45

    
46
    virtual int deserialize(unsigned char *inbuffer)
47
    {
48
      int offset = 0;
49
      this->adc0 |= ((uint16_t) (*(inbuffer + offset + 0))) << (8 * 0);
50
      this->adc0 |= ((uint16_t) (*(inbuffer + offset + 1))) << (8 * 1);
51
      offset += sizeof(this->adc0);
52
      this->adc1 |= ((uint16_t) (*(inbuffer + offset + 0))) << (8 * 0);
53
      this->adc1 |= ((uint16_t) (*(inbuffer + offset + 1))) << (8 * 1);
54
      offset += sizeof(this->adc1);
55
      this->adc2 |= ((uint16_t) (*(inbuffer + offset + 0))) << (8 * 0);
56
      this->adc2 |= ((uint16_t) (*(inbuffer + offset + 1))) << (8 * 1);
57
      offset += sizeof(this->adc2);
58
      this->adc3 |= ((uint16_t) (*(inbuffer + offset + 0))) << (8 * 0);
59
      this->adc3 |= ((uint16_t) (*(inbuffer + offset + 1))) << (8 * 1);
60
      offset += sizeof(this->adc3);
61
      this->adc4 |= ((uint16_t) (*(inbuffer + offset + 0))) << (8 * 0);
62
      this->adc4 |= ((uint16_t) (*(inbuffer + offset + 1))) << (8 * 1);
63
      offset += sizeof(this->adc4);
64
      this->adc5 |= ((uint16_t) (*(inbuffer + offset + 0))) << (8 * 0);
65
      this->adc5 |= ((uint16_t) (*(inbuffer + offset + 1))) << (8 * 1);
66
      offset += sizeof(this->adc5);
67
     return offset;
68
    }
69

    
70
    const char * getType(){ return "rosserial_arduino/Adc"; };
71
    const char * getMD5(){ return "6d7853a614e2e821319068311f2af25b"; };
72

    
73
  };
74

    
75
}
76
#endif