This is a fork from the original, including a small change in the buffer size of the hardware interface (increased to 2048) and decreasing the number of publishers and subscribers to 5. Besides, the library about the message Adc.h was modified so as to increase the number of available Adc channels to be read ( from 6 to 7 ) For this modification, a change in checksum was required

Dependencies:   BufferedSerial

Fork of ros_lib_kinetic by Gary Servin

Committer:
jacobepfl1692
Date:
Tue Oct 17 18:49:03 2017 +0000
Revision:
2:9114cc24ddcf
Parent:
0:9e9b7db60fd5
I increased the channels of the ADC to 6 (hence change in checksum) because my application needed it (STM32f407V6)

Who changed what in which revision?

UserRevisionLine numberNew contents of line
garyservin 0:9e9b7db60fd5 1 #ifndef _ROS_rosserial_mbed_Adc_h
garyservin 0:9e9b7db60fd5 2 #define _ROS_rosserial_mbed_Adc_h
garyservin 0:9e9b7db60fd5 3
jacobepfl1692 2:9114cc24ddcf 4 /*
jacobepfl1692 2:9114cc24ddcf 5 MODIFIED BY JACOB : ADDED AN EXTRA ADC CHANNEL
jacobepfl1692 2:9114cc24ddcf 6 */
jacobepfl1692 2:9114cc24ddcf 7
garyservin 0:9e9b7db60fd5 8 #include <stdint.h>
garyservin 0:9e9b7db60fd5 9 #include <string.h>
garyservin 0:9e9b7db60fd5 10 #include <stdlib.h>
garyservin 0:9e9b7db60fd5 11 #include "ros/msg.h"
garyservin 0:9e9b7db60fd5 12
jacobepfl1692 2:9114cc24ddcf 13
garyservin 0:9e9b7db60fd5 14 namespace rosserial_mbed
garyservin 0:9e9b7db60fd5 15 {
garyservin 0:9e9b7db60fd5 16
garyservin 0:9e9b7db60fd5 17 class Adc : public ros::Msg
garyservin 0:9e9b7db60fd5 18 {
garyservin 0:9e9b7db60fd5 19 public:
garyservin 0:9e9b7db60fd5 20 typedef uint16_t _adc0_type;
garyservin 0:9e9b7db60fd5 21 _adc0_type adc0;
garyservin 0:9e9b7db60fd5 22 typedef uint16_t _adc1_type;
garyservin 0:9e9b7db60fd5 23 _adc1_type adc1;
garyservin 0:9e9b7db60fd5 24 typedef uint16_t _adc2_type;
garyservin 0:9e9b7db60fd5 25 _adc2_type adc2;
garyservin 0:9e9b7db60fd5 26 typedef uint16_t _adc3_type;
garyservin 0:9e9b7db60fd5 27 _adc3_type adc3;
garyservin 0:9e9b7db60fd5 28 typedef uint16_t _adc4_type;
garyservin 0:9e9b7db60fd5 29 _adc4_type adc4;
garyservin 0:9e9b7db60fd5 30 typedef uint16_t _adc5_type;
garyservin 0:9e9b7db60fd5 31 _adc5_type adc5;
jacobepfl1692 2:9114cc24ddcf 32 typedef uint16_t _adc6_type;
jacobepfl1692 2:9114cc24ddcf 33 _adc6_type adc6;
garyservin 0:9e9b7db60fd5 34
garyservin 0:9e9b7db60fd5 35 Adc():
garyservin 0:9e9b7db60fd5 36 adc0(0),
garyservin 0:9e9b7db60fd5 37 adc1(0),
garyservin 0:9e9b7db60fd5 38 adc2(0),
garyservin 0:9e9b7db60fd5 39 adc3(0),
garyservin 0:9e9b7db60fd5 40 adc4(0),
jacobepfl1692 2:9114cc24ddcf 41 adc5(0),
jacobepfl1692 2:9114cc24ddcf 42 adc6(0)
garyservin 0:9e9b7db60fd5 43 {
garyservin 0:9e9b7db60fd5 44 }
garyservin 0:9e9b7db60fd5 45
garyservin 0:9e9b7db60fd5 46 virtual int serialize(unsigned char *outbuffer) const
garyservin 0:9e9b7db60fd5 47 {
garyservin 0:9e9b7db60fd5 48 int offset = 0;
garyservin 0:9e9b7db60fd5 49 *(outbuffer + offset + 0) = (this->adc0 >> (8 * 0)) & 0xFF;
garyservin 0:9e9b7db60fd5 50 *(outbuffer + offset + 1) = (this->adc0 >> (8 * 1)) & 0xFF;
garyservin 0:9e9b7db60fd5 51 offset += sizeof(this->adc0);
garyservin 0:9e9b7db60fd5 52 *(outbuffer + offset + 0) = (this->adc1 >> (8 * 0)) & 0xFF;
garyservin 0:9e9b7db60fd5 53 *(outbuffer + offset + 1) = (this->adc1 >> (8 * 1)) & 0xFF;
garyservin 0:9e9b7db60fd5 54 offset += sizeof(this->adc1);
garyservin 0:9e9b7db60fd5 55 *(outbuffer + offset + 0) = (this->adc2 >> (8 * 0)) & 0xFF;
garyservin 0:9e9b7db60fd5 56 *(outbuffer + offset + 1) = (this->adc2 >> (8 * 1)) & 0xFF;
garyservin 0:9e9b7db60fd5 57 offset += sizeof(this->adc2);
garyservin 0:9e9b7db60fd5 58 *(outbuffer + offset + 0) = (this->adc3 >> (8 * 0)) & 0xFF;
garyservin 0:9e9b7db60fd5 59 *(outbuffer + offset + 1) = (this->adc3 >> (8 * 1)) & 0xFF;
garyservin 0:9e9b7db60fd5 60 offset += sizeof(this->adc3);
garyservin 0:9e9b7db60fd5 61 *(outbuffer + offset + 0) = (this->adc4 >> (8 * 0)) & 0xFF;
garyservin 0:9e9b7db60fd5 62 *(outbuffer + offset + 1) = (this->adc4 >> (8 * 1)) & 0xFF;
garyservin 0:9e9b7db60fd5 63 offset += sizeof(this->adc4);
garyservin 0:9e9b7db60fd5 64 *(outbuffer + offset + 0) = (this->adc5 >> (8 * 0)) & 0xFF;
garyservin 0:9e9b7db60fd5 65 *(outbuffer + offset + 1) = (this->adc5 >> (8 * 1)) & 0xFF;
garyservin 0:9e9b7db60fd5 66 offset += sizeof(this->adc5);
jacobepfl1692 2:9114cc24ddcf 67 *(outbuffer + offset + 0) = (this->adc6 >> (8 * 0)) & 0xFF;
jacobepfl1692 2:9114cc24ddcf 68 *(outbuffer + offset + 1) = (this->adc6 >> (8 * 1)) & 0xFF;
jacobepfl1692 2:9114cc24ddcf 69 offset += sizeof(this->adc6);
garyservin 0:9e9b7db60fd5 70 return offset;
garyservin 0:9e9b7db60fd5 71 }
garyservin 0:9e9b7db60fd5 72
garyservin 0:9e9b7db60fd5 73 virtual int deserialize(unsigned char *inbuffer)
garyservin 0:9e9b7db60fd5 74 {
garyservin 0:9e9b7db60fd5 75 int offset = 0;
garyservin 0:9e9b7db60fd5 76 this->adc0 = ((uint16_t) (*(inbuffer + offset)));
garyservin 0:9e9b7db60fd5 77 this->adc0 |= ((uint16_t) (*(inbuffer + offset + 1))) << (8 * 1);
garyservin 0:9e9b7db60fd5 78 offset += sizeof(this->adc0);
garyservin 0:9e9b7db60fd5 79 this->adc1 = ((uint16_t) (*(inbuffer + offset)));
garyservin 0:9e9b7db60fd5 80 this->adc1 |= ((uint16_t) (*(inbuffer + offset + 1))) << (8 * 1);
garyservin 0:9e9b7db60fd5 81 offset += sizeof(this->adc1);
garyservin 0:9e9b7db60fd5 82 this->adc2 = ((uint16_t) (*(inbuffer + offset)));
garyservin 0:9e9b7db60fd5 83 this->adc2 |= ((uint16_t) (*(inbuffer + offset + 1))) << (8 * 1);
garyservin 0:9e9b7db60fd5 84 offset += sizeof(this->adc2);
garyservin 0:9e9b7db60fd5 85 this->adc3 = ((uint16_t) (*(inbuffer + offset)));
garyservin 0:9e9b7db60fd5 86 this->adc3 |= ((uint16_t) (*(inbuffer + offset + 1))) << (8 * 1);
garyservin 0:9e9b7db60fd5 87 offset += sizeof(this->adc3);
garyservin 0:9e9b7db60fd5 88 this->adc4 = ((uint16_t) (*(inbuffer + offset)));
garyservin 0:9e9b7db60fd5 89 this->adc4 |= ((uint16_t) (*(inbuffer + offset + 1))) << (8 * 1);
garyservin 0:9e9b7db60fd5 90 offset += sizeof(this->adc4);
garyservin 0:9e9b7db60fd5 91 this->adc5 = ((uint16_t) (*(inbuffer + offset)));
garyservin 0:9e9b7db60fd5 92 this->adc5 |= ((uint16_t) (*(inbuffer + offset + 1))) << (8 * 1);
garyservin 0:9e9b7db60fd5 93 offset += sizeof(this->adc5);
jacobepfl1692 2:9114cc24ddcf 94 this->adc6 = ((uint16_t) (*(inbuffer + offset)));
jacobepfl1692 2:9114cc24ddcf 95 this->adc6 |= ((uint16_t) (*(inbuffer + offset + 1))) << (8 * 1);
jacobepfl1692 2:9114cc24ddcf 96 offset += sizeof(this->adc6);
garyservin 0:9e9b7db60fd5 97 return offset;
garyservin 0:9e9b7db60fd5 98 }
garyservin 0:9e9b7db60fd5 99
garyservin 0:9e9b7db60fd5 100 const char * getType(){ return "rosserial_mbed/Adc"; };
jacobepfl1692 2:9114cc24ddcf 101 const char * getMD5(){ return "a1c93390d0a5d50b5be382174396ec0c"; };
jacobepfl1692 2:9114cc24ddcf 102 //const char * getMD5(){ return "6d7853a614e2e821319068311f2af25b"; };
garyservin 0:9e9b7db60fd5 103
garyservin 0:9e9b7db60fd5 104 };
garyservin 0:9e9b7db60fd5 105
garyservin 0:9e9b7db60fd5 106 }
garyservin 0:9e9b7db60fd5 107 #endif