esphome/esphome/components/t6615
Jas Strong 460a144ca8
t6615: tolerate sensor dropping commands (#2255)
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>
2021-09-14 23:06:13 +12:00
..
__init__.py Add T6615 (#1170) 2021-07-29 11:24:36 +02:00
sensor.py Convert sensor_schema to use kwargs (#2094) 2021-08-01 12:21:32 +02:00
t6615.cpp t6615: tolerate sensor dropping commands (#2255) 2021-09-14 23:06:13 +12:00
t6615.h t6615: tolerate sensor dropping commands (#2255) 2021-09-14 23:06:13 +12:00