From 68540b1d6cfb3a8762fb61a86aa27fb59b8ec713 Mon Sep 17 00:00:00 2001 From: John Date: Sat, 17 Dec 2022 18:57:13 +0100 Subject: [PATCH] handle enhanced side data without bus signal as well --- src/lib/ebus/device.cpp | 9 +++++++++ src/lib/ebus/device.h | 8 ++++++++ 2 files changed, 17 insertions(+) diff --git a/src/lib/ebus/device.cpp b/src/lib/ebus/device.cpp index f2c3a4d7..3fc82402 100755 --- a/src/lib/ebus/device.cpp +++ b/src/lib/ebus/device.cpp @@ -567,6 +567,11 @@ bool Device::read(symbol_t* value, bool isAvailable, ArbitrationState* arbitrati #endif m_bufLen += size; } + if (m_enhancedProto) { + if (handleEnhancedBufferedData(value, arbitrationState)) { + return true; + } + } if (!available()) { if (incomplete) { *incomplete = m_enhancedProto && m_bufLen > 0; @@ -579,6 +584,10 @@ bool Device::read(symbol_t* value, bool isAvailable, ArbitrationState* arbitrati m_bufLen--; return true; } + return handleEnhancedBufferedData(value, arbitrationState); +} + +bool Device::handleEnhancedBufferedData(symbol_t* value, ArbitrationState* arbitrationState) { while (m_bufLen > 0) { symbol_t ch = m_buffer[m_bufPos]; if (!(ch&ENH_BYTE_FLAG)) { diff --git a/src/lib/ebus/device.h b/src/lib/ebus/device.h index 46c8d3a6..ff97472d 100755 --- a/src/lib/ebus/device.h +++ b/src/lib/ebus/device.h @@ -301,6 +301,14 @@ class Device { bool m_resetRequested; private: + /** + * Handle the already buffered enhanced data. + * @param value the reference in which the read byte value is stored. + * @param arbitrationState the variable in which to store the current/received arbitration state (mandatory for enhanced proto). + * @return true if the value was set, false otherwise. + */ + bool handleEnhancedBufferedData(symbol_t* value, ArbitrationState* arbitrationState); + /** the @a DeviceListener, or nullptr. */ DeviceListener* m_listener;