Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Diff: serialBuffer.cpp
- Revision:
- 8:93d1469f3f6d
- Parent:
- 6:ca024bcee813
- Child:
- 9:8010dd8b4742
--- a/serialBuffer.cpp Wed Mar 08 11:12:20 2017 +0000 +++ b/serialBuffer.cpp Tue Mar 14 12:23:33 2017 +0000 @@ -1,30 +1,30 @@ #include "serialBuffer.h" -utils::SerialBuffer::SerialBuffer(PinName tx, PinName rx) : RawSerial(tx, rx), rx_buffer(255) { - RawSerial::attach(callback(this, &utils::SerialBuffer::rx_interrupt), Serial::RxIrq); +SerialBuffer::SerialBuffer(PinName tx, PinName rx) : RawSerial(tx, rx), rx_buffer(255, false) { + RawSerial::attach(callback(this, &SerialBuffer::rx_interrupt), Serial::RxIrq); return; } -utils::SerialBuffer::~SerialBuffer() { +SerialBuffer::~SerialBuffer() { RawSerial::attach(NULL, RawSerial::RxIrq); return; } -int utils::SerialBuffer::readable() { +int SerialBuffer::readable() { return rx_buffer.count() > 0; } -char utils::SerialBuffer::getc() { +char SerialBuffer::getc() { RawSerial::attach(NULL, RawSerial::RxIrq); char nextChar = rx_buffer.pop(); - RawSerial::attach(callback(this, &utils::SerialBuffer::rx_interrupt), Serial::RxIrq); + RawSerial::attach(callback(this, &SerialBuffer::rx_interrupt), Serial::RxIrq); return nextChar; } -void utils::SerialBuffer::rx_interrupt(void) { +void SerialBuffer::rx_interrupt(void) { if(serial_readable(&_serial) && !rx_buffer.full()) { rx_buffer.push(serial_getc(&_serial)); }