Skip to content

Commit

Permalink
VE.Direct: make state machine timeout robust against overflow
Browse files Browse the repository at this point in the history
  • Loading branch information
schlimmchen committed Mar 30, 2024
1 parent 994c155 commit 5fa04f9
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion lib/VeDirectFrameHandler/VeDirectFrameHandler.cpp
Original file line number Diff line number Diff line change
@@ -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();

0 comments on commit 5fa04f9

Please sign in to comment.