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 Apr 2, 2024
1 parent 43f553d commit 8c6e925
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
Expand Up @@ -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();
Expand Down

0 comments on commit 8c6e925

Please sign in to comment.