From dbbf235c50bfc09cdc0b44c9e170f1b477c5dcf3 Mon Sep 17 00:00:00 2001 From: John Date: Fri, 10 Nov 2023 19:06:30 +0100 Subject: [PATCH] fix syn generator timing --- src/lib/ebus/protocol.h | 3 +++ src/lib/ebus/protocol_direct.cpp | 6 +++--- src/lib/ebus/protocol_direct.h | 2 +- 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/src/lib/ebus/protocol.h b/src/lib/ebus/protocol.h index 12476aa1..1936d3ec 100755 --- a/src/lib/ebus/protocol.h +++ b/src/lib/ebus/protocol.h @@ -35,6 +35,9 @@ namespace ebusd { /** the default time [ms] for retrieving a symbol from an addressed slave. */ #define SLAVE_RECV_TIMEOUT 15 +/** the desired delay time [ms] for sending the AUTO-SYN symbol after last seen symbol. */ +#define SYN_INTERVAL 40 + /** the maximum allowed time [ms] for retrieving the AUTO-SYN symbol (45ms + 2*1,2% + 1 Symbol). */ #define SYN_TIMEOUT 51 diff --git a/src/lib/ebus/protocol_direct.cpp b/src/lib/ebus/protocol_direct.cpp index c66bd1cc..28fe84ab 100644 --- a/src/lib/ebus/protocol_direct.cpp +++ b/src/lib/ebus/protocol_direct.cpp @@ -281,9 +281,9 @@ result_t DirectProtocolHandler::handleSymbol() { return setState(bs_noSignal, result); } measureLatency(&sentTime, &recvTime); - if (m_generateSynInterval != SYN_TIMEOUT) { + if (m_generateSynInterval != SYN_INTERVAL) { // received own AUTO-SYN symbol back again: act as AUTO-SYN generator now - m_generateSynInterval = SYN_TIMEOUT; + m_generateSynInterval = SYN_INTERVAL; logNotice(lf_bus, "acting as AUTO-SYN generator"); } m_remainLockCount = 0; @@ -344,7 +344,7 @@ result_t DirectProtocolHandler::handleSymbol() { time_t now; time(&now); if (result != RESULT_OK) { - if ((m_generateSynInterval != SYN_TIMEOUT && difftime(now, m_lastReceive) > 1) + if ((m_generateSynInterval != SYN_INTERVAL && difftime(now, m_lastReceive) > 1) // at least one full second has passed since last received symbol || m_state == bs_noSignal) { return setState(bs_noSignal, result); diff --git a/src/lib/ebus/protocol_direct.h b/src/lib/ebus/protocol_direct.h index 46f0842b..872d37d3 100755 --- a/src/lib/ebus/protocol_direct.h +++ b/src/lib/ebus/protocol_direct.h @@ -69,7 +69,7 @@ class DirectProtocolHandler : public ProtocolHandler { : ProtocolHandler(config, device, listener), m_lockCount(config.lockCount <= 3 ? 3 : config.lockCount), m_remainLockCount(config.lockCount == 0 ? 1 : 0), - m_generateSynInterval(config.generateSyn ? SYN_TIMEOUT*getMasterNumber(config.ownAddress)+SYMBOL_DURATION : 0), + m_generateSynInterval(config.generateSyn ? 10*getMasterNumber(config.ownAddress)+SYN_TIMEOUT : 0), m_currentRequest(nullptr), m_currentAnswering(false), m_nextSendPos(0), m_state(bs_noSignal), m_escape(0), m_crc(0), m_crcValid(false), m_repeat(false) { m_lastSynReceiveTime.tv_sec = 0;