From 49f7e22c722770b8925f299ccf9d029279b796f7 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Wed, 31 Jul 2019 12:55:07 +1000 Subject: [PATCH] AP_Baro: consider a baro unhealthy when outside of -200 to 200 C this helps detects unhealthy baros on SPI where we can't detect comms failure --- libraries/AP_Baro/AP_Baro_Backend.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/libraries/AP_Baro/AP_Baro_Backend.cpp b/libraries/AP_Baro/AP_Baro_Backend.cpp index 8d0071d4a1..dd8aedb7a4 100644 --- a/libraries/AP_Baro/AP_Baro_Backend.cpp +++ b/libraries/AP_Baro/AP_Baro_Backend.cpp @@ -27,6 +27,15 @@ void AP_Baro_Backend::update_healthy_flag(uint8_t instance) (now - _frontend.sensors[instance].last_change_ms < BARO_DATA_CHANGE_TIMEOUT_MS) && !is_zero(_frontend.sensors[instance].pressure); + if (_frontend.sensors[instance].temperature < -200 || + _frontend.sensors[instance].temperature > 200) { + // if temperature is way out of range then we likely have bad + // data from the sensor, treat is as unhealthy. This is done + // so SPI sensors which have no data validity checking can + // mark a sensor unhealthy + _frontend.sensors[instance].healthy = false; + } + _sem->give(); }