We noticed in some logs that we would sometimes drop an RBR sensor reading when it lined up with our periodic checking of the RBR type. In order to ensure we keep all valid sensor readings, this change reads from the RBR sensor in exactly one place in the code (rather than two different places previously). It correctly handles either a sensor reading or a command response no matter when they arrive.
The bulk of the changes are in rbr_sensor.cpp:
The function probeType is renamed maybeProbeType to encapsulate the timing and only writes the command, without reading a response. It also sets a flag to indicate we are now awaiting a response.
The boolean return value from getData still represents whether it received and successfully parsed a sensor reading, but command responses are also handled within that function.
The two types of lines we expect to receive from the sensor are each extracted into their own handler functions: handleOutputformat and handleDataString.
Logic marking a sensor being online with a known type is at the top of handleOutputFormat including resetting the "awaiting probe response" flag.
The handling of a timeout awaiting a probe response is moved to getData, including marking a sensor lost.
We noticed in some logs that we would sometimes drop an RBR sensor reading when it lined up with our periodic checking of the RBR type. In order to ensure we keep all valid sensor readings, this change reads from the RBR sensor in exactly one place in the code (rather than two different places previously). It correctly handles either a sensor reading or a command response no matter when they arrive.
The bulk of the changes are in
rbr_sensor.cpp
:probeType
is renamedmaybeProbeType
to encapsulate the timing and only writes the command, without reading a response. It also sets a flag to indicate we are now awaiting a response.getData
still represents whether it received and successfully parsed a sensor reading, but command responses are also handled within that function.handleOutputformat
andhandleDataString
.handleOutputFormat
including resetting the "awaiting probe response" flag.getData
, including marking a sensor lost.