ros melodic library with custom message
Dependents: Robot_team1_QEI_Douglas Robot_team1
ros_lib/rosserial_arduino/Adc.h@3:b964e3f71102, 2019-12-03 (annotated)
- Committer:
- florine_van
- Date:
- Tue Dec 03 09:39:29 2019 +0000
- Revision:
- 3:b964e3f71102
- Parent:
- 0:020db18a476d
Clean code and remove unused lines
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
scarter1 | 0:020db18a476d | 1 | #ifndef _ROS_rosserial_arduino_Adc_h |
scarter1 | 0:020db18a476d | 2 | #define _ROS_rosserial_arduino_Adc_h |
scarter1 | 0:020db18a476d | 3 | |
scarter1 | 0:020db18a476d | 4 | #include <stdint.h> |
scarter1 | 0:020db18a476d | 5 | #include <string.h> |
scarter1 | 0:020db18a476d | 6 | #include <stdlib.h> |
scarter1 | 0:020db18a476d | 7 | #include "ros/msg.h" |
scarter1 | 0:020db18a476d | 8 | |
scarter1 | 0:020db18a476d | 9 | namespace rosserial_arduino |
scarter1 | 0:020db18a476d | 10 | { |
scarter1 | 0:020db18a476d | 11 | |
scarter1 | 0:020db18a476d | 12 | class Adc : public ros::Msg |
scarter1 | 0:020db18a476d | 13 | { |
scarter1 | 0:020db18a476d | 14 | public: |
scarter1 | 0:020db18a476d | 15 | typedef uint16_t _adc0_type; |
scarter1 | 0:020db18a476d | 16 | _adc0_type adc0; |
scarter1 | 0:020db18a476d | 17 | typedef uint16_t _adc1_type; |
scarter1 | 0:020db18a476d | 18 | _adc1_type adc1; |
scarter1 | 0:020db18a476d | 19 | typedef uint16_t _adc2_type; |
scarter1 | 0:020db18a476d | 20 | _adc2_type adc2; |
scarter1 | 0:020db18a476d | 21 | typedef uint16_t _adc3_type; |
scarter1 | 0:020db18a476d | 22 | _adc3_type adc3; |
scarter1 | 0:020db18a476d | 23 | typedef uint16_t _adc4_type; |
scarter1 | 0:020db18a476d | 24 | _adc4_type adc4; |
scarter1 | 0:020db18a476d | 25 | typedef uint16_t _adc5_type; |
scarter1 | 0:020db18a476d | 26 | _adc5_type adc5; |
scarter1 | 0:020db18a476d | 27 | |
scarter1 | 0:020db18a476d | 28 | Adc(): |
scarter1 | 0:020db18a476d | 29 | adc0(0), |
scarter1 | 0:020db18a476d | 30 | adc1(0), |
scarter1 | 0:020db18a476d | 31 | adc2(0), |
scarter1 | 0:020db18a476d | 32 | adc3(0), |
scarter1 | 0:020db18a476d | 33 | adc4(0), |
scarter1 | 0:020db18a476d | 34 | adc5(0) |
scarter1 | 0:020db18a476d | 35 | { |
scarter1 | 0:020db18a476d | 36 | } |
scarter1 | 0:020db18a476d | 37 | |
scarter1 | 0:020db18a476d | 38 | virtual int serialize(unsigned char *outbuffer) const |
scarter1 | 0:020db18a476d | 39 | { |
scarter1 | 0:020db18a476d | 40 | int offset = 0; |
scarter1 | 0:020db18a476d | 41 | *(outbuffer + offset + 0) = (this->adc0 >> (8 * 0)) & 0xFF; |
scarter1 | 0:020db18a476d | 42 | *(outbuffer + offset + 1) = (this->adc0 >> (8 * 1)) & 0xFF; |
scarter1 | 0:020db18a476d | 43 | offset += sizeof(this->adc0); |
scarter1 | 0:020db18a476d | 44 | *(outbuffer + offset + 0) = (this->adc1 >> (8 * 0)) & 0xFF; |
scarter1 | 0:020db18a476d | 45 | *(outbuffer + offset + 1) = (this->adc1 >> (8 * 1)) & 0xFF; |
scarter1 | 0:020db18a476d | 46 | offset += sizeof(this->adc1); |
scarter1 | 0:020db18a476d | 47 | *(outbuffer + offset + 0) = (this->adc2 >> (8 * 0)) & 0xFF; |
scarter1 | 0:020db18a476d | 48 | *(outbuffer + offset + 1) = (this->adc2 >> (8 * 1)) & 0xFF; |
scarter1 | 0:020db18a476d | 49 | offset += sizeof(this->adc2); |
scarter1 | 0:020db18a476d | 50 | *(outbuffer + offset + 0) = (this->adc3 >> (8 * 0)) & 0xFF; |
scarter1 | 0:020db18a476d | 51 | *(outbuffer + offset + 1) = (this->adc3 >> (8 * 1)) & 0xFF; |
scarter1 | 0:020db18a476d | 52 | offset += sizeof(this->adc3); |
scarter1 | 0:020db18a476d | 53 | *(outbuffer + offset + 0) = (this->adc4 >> (8 * 0)) & 0xFF; |
scarter1 | 0:020db18a476d | 54 | *(outbuffer + offset + 1) = (this->adc4 >> (8 * 1)) & 0xFF; |
scarter1 | 0:020db18a476d | 55 | offset += sizeof(this->adc4); |
scarter1 | 0:020db18a476d | 56 | *(outbuffer + offset + 0) = (this->adc5 >> (8 * 0)) & 0xFF; |
scarter1 | 0:020db18a476d | 57 | *(outbuffer + offset + 1) = (this->adc5 >> (8 * 1)) & 0xFF; |
scarter1 | 0:020db18a476d | 58 | offset += sizeof(this->adc5); |
scarter1 | 0:020db18a476d | 59 | return offset; |
scarter1 | 0:020db18a476d | 60 | } |
scarter1 | 0:020db18a476d | 61 | |
scarter1 | 0:020db18a476d | 62 | virtual int deserialize(unsigned char *inbuffer) |
scarter1 | 0:020db18a476d | 63 | { |
scarter1 | 0:020db18a476d | 64 | int offset = 0; |
scarter1 | 0:020db18a476d | 65 | this->adc0 = ((uint16_t) (*(inbuffer + offset))); |
scarter1 | 0:020db18a476d | 66 | this->adc0 |= ((uint16_t) (*(inbuffer + offset + 1))) << (8 * 1); |
scarter1 | 0:020db18a476d | 67 | offset += sizeof(this->adc0); |
scarter1 | 0:020db18a476d | 68 | this->adc1 = ((uint16_t) (*(inbuffer + offset))); |
scarter1 | 0:020db18a476d | 69 | this->adc1 |= ((uint16_t) (*(inbuffer + offset + 1))) << (8 * 1); |
scarter1 | 0:020db18a476d | 70 | offset += sizeof(this->adc1); |
scarter1 | 0:020db18a476d | 71 | this->adc2 = ((uint16_t) (*(inbuffer + offset))); |
scarter1 | 0:020db18a476d | 72 | this->adc2 |= ((uint16_t) (*(inbuffer + offset + 1))) << (8 * 1); |
scarter1 | 0:020db18a476d | 73 | offset += sizeof(this->adc2); |
scarter1 | 0:020db18a476d | 74 | this->adc3 = ((uint16_t) (*(inbuffer + offset))); |
scarter1 | 0:020db18a476d | 75 | this->adc3 |= ((uint16_t) (*(inbuffer + offset + 1))) << (8 * 1); |
scarter1 | 0:020db18a476d | 76 | offset += sizeof(this->adc3); |
scarter1 | 0:020db18a476d | 77 | this->adc4 = ((uint16_t) (*(inbuffer + offset))); |
scarter1 | 0:020db18a476d | 78 | this->adc4 |= ((uint16_t) (*(inbuffer + offset + 1))) << (8 * 1); |
scarter1 | 0:020db18a476d | 79 | offset += sizeof(this->adc4); |
scarter1 | 0:020db18a476d | 80 | this->adc5 = ((uint16_t) (*(inbuffer + offset))); |
scarter1 | 0:020db18a476d | 81 | this->adc5 |= ((uint16_t) (*(inbuffer + offset + 1))) << (8 * 1); |
scarter1 | 0:020db18a476d | 82 | offset += sizeof(this->adc5); |
scarter1 | 0:020db18a476d | 83 | return offset; |
scarter1 | 0:020db18a476d | 84 | } |
scarter1 | 0:020db18a476d | 85 | |
scarter1 | 0:020db18a476d | 86 | const char * getType(){ return "rosserial_arduino/Adc"; }; |
scarter1 | 0:020db18a476d | 87 | const char * getMD5(){ return "6d7853a614e2e821319068311f2af25b"; }; |
scarter1 | 0:020db18a476d | 88 | |
scarter1 | 0:020db18a476d | 89 | }; |
scarter1 | 0:020db18a476d | 90 | |
scarter1 | 0:020db18a476d | 91 | } |
scarter1 | 0:020db18a476d | 92 | #endif |