diff --git a/keywords.txt b/keywords.txt index cbc45aae..9c8e6dca 100644 --- a/keywords.txt +++ b/keywords.txt @@ -244,6 +244,9 @@ sendMicE KEYWORD2 # Pager sendTone KEYWORD2 +# PhysicalLayer +dropSync KEYWORD2 + ####################################### # Constants (LITERAL1) ####################################### diff --git a/src/protocols/PhysicalLayer/PhysicalLayer.cpp b/src/protocols/PhysicalLayer/PhysicalLayer.cpp index e0fad08d..1d414ac4 100644 --- a/src/protocols/PhysicalLayer/PhysicalLayer.cpp +++ b/src/protocols/PhysicalLayer/PhysicalLayer.cpp @@ -195,11 +195,17 @@ int16_t PhysicalLayer::available() { return(_bufferWritePos); } -uint8_t PhysicalLayer::read() { +void PhysicalLayer::dropSync() { if(_directSyncWordLen > 0) { _gotSync = false; _syncBuffer = 0; } +} + +uint8_t PhysicalLayer::read(bool drop) { + if(drop) { + dropSync(); + } _bufferWritePos--; return(_buffer[_bufferReadPos++]); } diff --git a/src/protocols/PhysicalLayer/PhysicalLayer.h b/src/protocols/PhysicalLayer/PhysicalLayer.h index a8b011f7..941181b1 100644 --- a/src/protocols/PhysicalLayer/PhysicalLayer.h +++ b/src/protocols/PhysicalLayer/PhysicalLayer.h @@ -318,12 +318,19 @@ class PhysicalLayer { */ int16_t available(); + /*! + \brief Forcefully drop synchronization. + */ + void dropSync(); + /*! \brief Get data from direct mode buffer. + \param drop Drop synchronization on read - next reading will require waiting for the sync word again. Defautls to true. + \returns Byte from direct mode buffer. */ - uint8_t read(); + uint8_t read(bool drop = true); #endif /*!