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 /*
garyservin 0:9e9b7db60fd5 2 * MbedHardware
garyservin 0:9e9b7db60fd5 3 *
garyservin 0:9e9b7db60fd5 4 * Created on: Aug 17, 2011
garyservin 0:9e9b7db60fd5 5 * Author: nucho
garyservin 0:9e9b7db60fd5 6 */
garyservin 0:9e9b7db60fd5 7
garyservin 0:9e9b7db60fd5 8 #ifndef ROS_MBED_HARDWARE_H_
garyservin 0:9e9b7db60fd5 9 #define ROS_MBED_HARDWARE_H_
garyservin 0:9e9b7db60fd5 10
garyservin 0:9e9b7db60fd5 11 #include "mbed.h"
garyservin 0:9e9b7db60fd5 12
garyservin 0:9e9b7db60fd5 13 #include "BufferedSerial.h"
garyservin 0:9e9b7db60fd5 14
garyservin 0:9e9b7db60fd5 15 class MbedHardware {
garyservin 0:9e9b7db60fd5 16 public:
garyservin 0:9e9b7db60fd5 17 MbedHardware(PinName tx, PinName rx, long baud = 57600)
garyservin 0:9e9b7db60fd5 18 :iostream(tx, rx){
garyservin 0:9e9b7db60fd5 19 baud_ = baud;
garyservin 0:9e9b7db60fd5 20 t.start();
garyservin 0:9e9b7db60fd5 21 }
garyservin 0:9e9b7db60fd5 22
garyservin 0:9e9b7db60fd5 23 MbedHardware()
jacobepfl1692 2:9114cc24ddcf 24 //:iostream(USBTX, USBRX) {
jacobepfl1692 2:9114cc24ddcf 25 :iostream(PA_2, PA_3) { // Modification to be able to use USART2 from the STM32F407V6 connect PA2 to RXD and PA3 to TXD
jacobepfl1692 2:9114cc24ddcf 26 baud_ = 57600; //! 57600
garyservin 0:9e9b7db60fd5 27 t.start();
garyservin 0:9e9b7db60fd5 28 }
garyservin 0:9e9b7db60fd5 29
garyservin 0:9e9b7db60fd5 30 void setBaud(long baud){
garyservin 0:9e9b7db60fd5 31 this->baud_= baud;
garyservin 0:9e9b7db60fd5 32 }
garyservin 0:9e9b7db60fd5 33
garyservin 0:9e9b7db60fd5 34 int getBaud(){return baud_;}
garyservin 0:9e9b7db60fd5 35
garyservin 0:9e9b7db60fd5 36 void init(){
garyservin 0:9e9b7db60fd5 37 iostream.baud(baud_);
garyservin 0:9e9b7db60fd5 38 }
garyservin 0:9e9b7db60fd5 39
garyservin 0:9e9b7db60fd5 40 int read(){
garyservin 0:9e9b7db60fd5 41 if (iostream.readable()) {
garyservin 0:9e9b7db60fd5 42 return iostream.getc();
garyservin 0:9e9b7db60fd5 43 } else {
garyservin 0:9e9b7db60fd5 44 return -1;
garyservin 0:9e9b7db60fd5 45 }
garyservin 0:9e9b7db60fd5 46 };
garyservin 0:9e9b7db60fd5 47 void write(uint8_t* data, int length) {
garyservin 0:9e9b7db60fd5 48 for (int i=0; i<length; i++)
garyservin 0:9e9b7db60fd5 49 iostream.putc(data[i]);
garyservin 0:9e9b7db60fd5 50 }
garyservin 0:9e9b7db60fd5 51
garyservin 0:9e9b7db60fd5 52 unsigned long time(){return t.read_ms();}
garyservin 0:9e9b7db60fd5 53
garyservin 0:9e9b7db60fd5 54 protected:
garyservin 0:9e9b7db60fd5 55 BufferedSerial iostream;
garyservin 0:9e9b7db60fd5 56 long baud_;
garyservin 0:9e9b7db60fd5 57 Timer t;
garyservin 0:9e9b7db60fd5 58 };
garyservin 0:9e9b7db60fd5 59
garyservin 0:9e9b7db60fd5 60
garyservin 0:9e9b7db60fd5 61 #endif /* ROS_MBED_HARDWARE_H_ */