From b85e77a0d4362c59a2c1458c0192ed5a762e2738 Mon Sep 17 00:00:00 2001 From: Peter Barker Date: Mon, 18 Sep 2023 18:48:01 +1000 Subject: [PATCH] GCS_MAVLink: correct sensors when no baros found GCSs will know we have no baros on-board, as will the RC telemetry library --- libraries/GCS_MAVLink/GCS.cpp | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/libraries/GCS_MAVLink/GCS.cpp b/libraries/GCS_MAVLink/GCS.cpp index 7a887f2db7..bdf88403cb 100644 --- a/libraries/GCS_MAVLink/GCS.cpp +++ b/libraries/GCS_MAVLink/GCS.cpp @@ -177,10 +177,12 @@ void GCS::update_sensor_status_flags() #if !defined(HAL_BUILD_AP_PERIPH) || defined(HAL_PERIPH_ENABLE_BARO) const AP_Baro &barometer = AP::baro(); - control_sensors_present |= MAV_SYS_STATUS_SENSOR_ABSOLUTE_PRESSURE; - control_sensors_enabled |= MAV_SYS_STATUS_SENSOR_ABSOLUTE_PRESSURE; - if (barometer.all_healthy()) { - control_sensors_health |= MAV_SYS_STATUS_SENSOR_ABSOLUTE_PRESSURE; + if (barometer.num_instances() > 0) { + control_sensors_present |= MAV_SYS_STATUS_SENSOR_ABSOLUTE_PRESSURE; + control_sensors_enabled |= MAV_SYS_STATUS_SENSOR_ABSOLUTE_PRESSURE; + if (barometer.all_healthy()) { + control_sensors_health |= MAV_SYS_STATUS_SENSOR_ABSOLUTE_PRESSURE; + } } #endif