The Amphenol T6615 has a built-in calibration system which means that
the sensor could go away for a couple of seconds to figure itself out.
While this is happening, commands are silently dropped.
This caused the previous version of this code to lock up completely,
since there was no way for the command_ state machine to tick back to
the NONE state.
Instead of just breaking the state machine, which might be harmful on
a multi-core or multi-threaded device, add a timestamp and only break
the lock if it's been more than a second since the command was issued.
The command usually doesn't take more than a few milliseconds to
complete, so this should not affect things unduly.
While we're at it, rewrite the rx side to be more robust against
bytes going missing.
Instead of reading in the data essentially inline, read into a buffer
and process it when enough has been read to make progress.
If data stops coming when we expect it to, or the data is malformed,
have a timeout that sends a new command.
Co-authored-by: jas <jas@asspa.in>
* Add macros header with more usable Arduino version defines
* Change Arduino version checking to use our version defines
* Add missing ESP8266 check
* Rename Arduino version macro to ARDUINO_VERSION_CODE
* Upgrade clang-tidy to use Arduino 3
* Fix clang-tidy warnings
* Upgrade NeoPixelBus to upstream 2.6.7
* Use Arduino-version-appropriate API to set redirect flags
* Remove now unnecessary CLANG_TIDY ifdefs
* Add preprocessor hackery to avoid including pgmspace.h
* Bump base image to 4.1.1 and update lint
* Fix nfctag
* Fix make_unique ambiguous
* Fix ignore name
* Fix ambiguous v2
* Remove unused begin
* Cast time_t to prevent issues on platforms where time_t is 32bit
Co-authored-by: Otto winter <otto@otto-winter.com>
The Amphenol T6615 has a built-in calibration system which means that
the sensor could go away for a couple of seconds to figure itself out.
While this is happening, commands are silently dropped.
This caused the previous version of this code to lock up completely,
since there was no way for the command_ state machine to tick back to
the NONE state.
Instead of just breaking the state machine, which might be harmful on
a multi-core or multi-threaded device, add a timestamp and only break
the lock if it's been more than a second since the command was issued.
The command usually doesn't take more than a few milliseconds to
complete, so this should not affect things unduly.
While we're at it, rewrite the rx side to be more robust against
bytes going missing.
Instead of reading in the data essentially inline, read into a buffer
and process it when enough has been read to make progress.
If data stops coming when we expect it to, or the data is malformed,
have a timeout that sends a new command.
Co-authored-by: jas <jas@asspa.in>