Mavlink bridge for Mbed devices
Revision 10:bd4a08d39e94, committed 2016-04-04
- Comitter:
- bhepp
- Date:
- Mon Apr 04 11:18:57 2016 +0000
- Parent:
- 9:6f782c9f1850
- Commit message:
- nop
Changed in this revision
uart_interface.h | Show diff for this revision Revisions of this file |
diff -r 6f782c9f1850 -r bd4a08d39e94 uart_interface.h --- a/uart_interface.h Tue Mar 29 10:00:09 2016 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,52 +0,0 @@ -#pragma once - -#ifdef __MBED__ -#include "mbed.h" -#include "BufferedSerial.h" -#endif - -namespace ait { - -class UART_Interface { -public: - virtual bool writeChar(uint8_t c) = 0; - virtual bool isCharAvailable() = 0; - virtual uint8_t readChar(bool* err_flag = NULL) = 0; -}; - -#ifdef __MBED__ -class UART_Mbed : public UART_Interface { - BufferedSerial* serial_; - -public: - UART_Mbed(BufferedSerial* serial) - : serial_(serial) { - } - - virtual bool writeChar(uint8_t c) { - int ret = serial_->putc(c); - if (ret == -1) { - return false; - //throw std::exception("Unable to write on serial port"); - } - return true; - } - - virtual bool isCharAvailable() { - return serial_->readable(); - } - - virtual uint8_t readChar(bool* err_flag = NULL) { - int c = serial_->getc(); - if (err_flag != NULL) { - if (c == -1) - *err_flag = true; - else - *err_flag = false; - } - return static_cast<uint8_t>(c); - } -}; -#endif // __MBED__ - -}