VE.Direct: make state machine timeout robust against overflow

This commit is contained in:
Bernhard Kirchen 2024-03-29 21:20:03 +01:00 committed by Bernhard Kirchen
parent 43f553d2d4
commit 8c6e925ca4

View File

@ -118,7 +118,7 @@ void VeDirectFrameHandler<T>::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(); }
reset();