Mavlink bridge for Mbed devices
Diff: uart_interface.h
- Revision:
- 6:48b46bcdd5cb
- Parent:
- 0:28183cc7963f
diff -r 4a5985e10a00 -r 48b46bcdd5cb uart_interface.h --- a/uart_interface.h Thu Feb 11 10:49:01 2016 +0000 +++ b/uart_interface.h Sat Feb 13 17:09:45 2016 +0000 @@ -2,6 +2,7 @@ #ifdef __MBED__ #include "mbed.h" +#include "BufferedSerial.h" #endif namespace ait { @@ -15,16 +16,15 @@ #ifdef __MBED__ class UART_Mbed : public UART_Interface { - Serial _serial; + BufferedSerial* serial_; public: - UART_Mbed(PinName tx, PinName rx, int baudrate = 115200) - : _serial(tx, rx) { - _serial.baud(baudrate); + UART_Mbed(BufferedSerial* serial) + : serial_(serial) { } virtual bool writeChar(uint8_t c) { - int ret = _serial.putc(c); + int ret = serial_->putc(c); if (ret == -1) { return false; //throw std::exception("Unable to write on serial port"); @@ -33,11 +33,11 @@ } virtual bool isCharAvailable() { - return _serial.readable(); + return serial_->readable(); } virtual uint8_t readChar(bool* err_flag = NULL) { - int c = _serial.getc(); + int c = serial_->getc(); if (err_flag != NULL) { if (c == -1) *err_flag = true;