RTOS safe buffered serial driver
Fork of SerialDriver by
Diff: SerialDriver.h
- Revision:
- 3:ea9719695b6a
- Parent:
- 0:cd0d79be0c1a
- Child:
- 4:3c0d0c37ad75
--- a/SerialDriver.h Thu Jan 15 09:53:09 2015 +0000 +++ b/SerialDriver.h Mon Jan 26 19:21:56 2015 +0000 @@ -46,6 +46,8 @@ Semaphore semTxBufferFull; // used by putc to wait Semaphore semRxBufferEmpty; // used by getc to wait + // drop counters + volatile int numTxDrops, numRxDrops; public: /// @brief Prepares ring buffer and irq @@ -170,4 +172,13 @@ /// For compatibility with mbed Serial. /// @return true - RX buffer is readable, false - else inline bool readable() { return !isRxBufferEmpty(); } + + + /// @brief Returns number of dropped bytes that did not fit into TX buffer + /// @return number of dropped tx bytes + inline int getNumTxDrops() { return numTxDrops; } + + /// @brief Returns number of dropped bytes that did not fit into RX buffer + /// @return number of dropped rx bytes + inline int getNumRxDrops() { return numRxDrops; } };