From 42805aa89246e897ba487926d9f3731f39c8f6f3 Mon Sep 17 00:00:00 2001 From: Peter Barker Date: Fri, 28 Jun 2024 13:10:32 +1000 Subject: [PATCH] AP_GPS: confine inter-instance DroneCAN state checks to DroneCAN GPSs stop these looking at parameters/state for all GPSs, focus on DroneCAN GPSs --- libraries/AP_GPS/AP_GPS_DroneCAN.cpp | 23 ++++++++--------------- libraries/AP_GPS/AP_GPS_DroneCAN.h | 9 +++++++++ 2 files changed, 17 insertions(+), 15 deletions(-) diff --git a/libraries/AP_GPS/AP_GPS_DroneCAN.cpp b/libraries/AP_GPS/AP_GPS_DroneCAN.cpp index a011e69c69..8bd8cb7e37 100644 --- a/libraries/AP_GPS/AP_GPS_DroneCAN.cpp +++ b/libraries/AP_GPS/AP_GPS_DroneCAN.cpp @@ -227,24 +227,13 @@ AP_GPS_Backend* AP_GPS_DroneCAN::probe(AP_GPS &_gps, AP_GPS::GPS_State &_state) bool AP_GPS_DroneCAN::inter_instance_pre_arm_checks(char failure_msg[], uint16_t failure_msg_len) { - // only do these checks if there is at least one DroneCAN GPS: - bool found_uavan_type = false; - for (uint8_t i = 0; i < GPS_MAX_RECEIVERS; i++) { - const auto type = AP::gps().params[i].type; - if (type != AP_GPS::GPS_TYPE_UAVCAN && - type != AP_GPS::GPS_TYPE_UAVCAN_RTK_BASE && - type != AP_GPS::GPS_TYPE_UAVCAN_RTK_ROVER) { - continue; - } - found_uavan_type = true; - } - if (!found_uavan_type) { - return true; - } - // lint parameters and detected node IDs: for (uint8_t i = 0; i < GPS_MAX_RECEIVERS; i++) { const auto ¶ms_i = AP::gps().params[i]; + // we are only interested in parameters for DroneCAN GPSs: + if (!is_dronecan_gps_type(params_i.type)) { + continue; + } bool overriden_node_found = false; bool bad_override_config = false; if (params_i.override_node_id == 0) { @@ -253,6 +242,10 @@ bool AP_GPS_DroneCAN::inter_instance_pre_arm_checks(char failure_msg[], uint16_t } for (uint8_t j = 0; j < GPS_MAX_RECEIVERS; j++) { const auto ¶ms_j = AP::gps().params[j]; + // we are only interested in parameters for DroneCAN GPSs: + if (!is_dronecan_gps_type(params_j.type)) { + continue; + } if (params_i.override_node_id == params_j.override_node_id && (i != j)) { bad_override_config = true; break; diff --git a/libraries/AP_GPS/AP_GPS_DroneCAN.h b/libraries/AP_GPS/AP_GPS_DroneCAN.h index f422c983fe..1de0b6b8f4 100644 --- a/libraries/AP_GPS/AP_GPS_DroneCAN.h +++ b/libraries/AP_GPS/AP_GPS_DroneCAN.h @@ -149,6 +149,15 @@ private: uint32_t last_send_ms; ByteBuffer *buf; } _rtcm_stream; + + // returns true if the supplied GPS_Type is a DroneCAN GPS type + static bool is_dronecan_gps_type(AP_GPS::GPS_Type type) { + return ( + type == AP_GPS::GPS_TYPE_UAVCAN || + type == AP_GPS::GPS_TYPE_UAVCAN_RTK_BASE || + type == AP_GPS::GPS_TYPE_UAVCAN_RTK_ROVER + ); + } }; #endif // AP_GPS_DRONECAN_ENABLED