From d9f605ed369d030b2d727076315be8ed3ae19aef Mon Sep 17 00:00:00 2001 From: Peter Barker Date: Wed, 27 Apr 2022 20:57:42 +1000 Subject: [PATCH] AP_Baro: move error logging of sensor health into AP_Baro --- libraries/AP_Baro/AP_Baro.cpp | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/libraries/AP_Baro/AP_Baro.cpp b/libraries/AP_Baro/AP_Baro.cpp index 0447cae0bd..fee8cfa727 100644 --- a/libraries/AP_Baro/AP_Baro.cpp +++ b/libraries/AP_Baro/AP_Baro.cpp @@ -851,6 +851,10 @@ void AP_Baro::update(void) _alt_offset_active = _alt_offset; } +#if HAL_LOGGING_ENABLED + bool old_primary_healthy = sensors[_primary].healthy; +#endif + for (uint8_t i=0; i<_num_drivers; i++) { drivers[i]->backend_update(i); } @@ -905,6 +909,16 @@ void AP_Baro::update(void) if (should_log()) { Write_Baro(); } + +#define MASK_LOG_ANY 0xFFFF + + // log sensor healthy state change: + if (sensors[_primary].healthy != old_primary_healthy) { + if (AP::logger().should_log(MASK_LOG_ANY)) { + const LogErrorCode code = sensors[_primary].healthy ? LogErrorCode::ERROR_RESOLVED : LogErrorCode::UNHEALTHY; + AP::logger().Write_Error(LogErrorSubsystem::BARO, code); + } + } #endif }