From 07fb33a0834cd6f719aacb7768214b7289738305 Mon Sep 17 00:00:00 2001 From: Bernhard Kirchen Date: Fri, 29 Mar 2024 21:20:03 +0100 Subject: [PATCH] VE.Direct: make state machine timeout robust against overflow --- lib/VeDirectFrameHandler/VeDirectFrameHandler.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/VeDirectFrameHandler/VeDirectFrameHandler.cpp b/lib/VeDirectFrameHandler/VeDirectFrameHandler.cpp index 14dfa129b..af45919fb 100644 --- a/lib/VeDirectFrameHandler/VeDirectFrameHandler.cpp +++ b/lib/VeDirectFrameHandler/VeDirectFrameHandler.cpp @@ -110,7 +110,7 @@ void VeDirectFrameHandler::loop() // there will never be a large gap between two bytes of the same frame. // if such a large gap is observed, reset the state machine so it tries // to decode a new frame once more data arrives. - if (IDLE != _state && _lastByteMillis + 500 < millis()) { + if (IDLE != _state && (millis() - _lastByteMillis) > 500) { _msgOut->printf("%s Resetting state machine (was %d) after timeout\r\n", _logId, _state); if (_verboseLogging) { dumpDebugBuffer(); } _checksum = 0;