From 4a29a57d8d1ba42c0996e05bd063d5efe96f8b77 Mon Sep 17 00:00:00 2001 From: Peter Barker Date: Thu, 6 Apr 2023 08:56:53 +1000 Subject: [PATCH] AP_Proximity: fix fallthrough in proximity switch in the case that cygbot was selected but not compiled in we would try to insantiate a DroneCAN backend --- libraries/AP_Proximity/AP_Proximity.cpp | 2 +- libraries/AP_Proximity/AP_Proximity.h | 2 ++ libraries/AP_Proximity/AP_Proximity_Cygbot_D1.h | 4 ---- libraries/AP_Proximity/AP_Proximity_config.h | 4 ++++ 4 files changed, 7 insertions(+), 5 deletions(-) diff --git a/libraries/AP_Proximity/AP_Proximity.cpp b/libraries/AP_Proximity/AP_Proximity.cpp index 2a1f9d95bd..866e5b3460 100644 --- a/libraries/AP_Proximity/AP_Proximity.cpp +++ b/libraries/AP_Proximity/AP_Proximity.cpp @@ -173,8 +173,8 @@ void AP_Proximity::init() } break; - case Type::CYGBOT_D1: #if AP_PROXIMITY_CYGBOT_ENABLED + case Type::CYGBOT_D1: if (AP_Proximity_Cygbot_D1::detect(serial_instance)) { state[instance].instance = instance; drivers[instance] = new AP_Proximity_Cygbot_D1(*this, state[instance], params[instance], serial_instance); diff --git a/libraries/AP_Proximity/AP_Proximity.h b/libraries/AP_Proximity/AP_Proximity.h index d521d87359..e5ebb32a33 100644 --- a/libraries/AP_Proximity/AP_Proximity.h +++ b/libraries/AP_Proximity/AP_Proximity.h @@ -59,7 +59,9 @@ public: SITL = 10, AirSimSITL = 12, #endif +#if AP_PROXIMITY_CYGBOT_ENABLED CYGBOT_D1 = 13, +#endif DroneCAN = 14, }; diff --git a/libraries/AP_Proximity/AP_Proximity_Cygbot_D1.h b/libraries/AP_Proximity/AP_Proximity_Cygbot_D1.h index 3e844732f9..aaa1de91c8 100644 --- a/libraries/AP_Proximity/AP_Proximity_Cygbot_D1.h +++ b/libraries/AP_Proximity/AP_Proximity_Cygbot_D1.h @@ -2,10 +2,6 @@ #include "AP_Proximity.h" -#ifndef AP_PROXIMITY_CYGBOT_ENABLED -#define AP_PROXIMITY_CYGBOT_ENABLED HAL_PROXIMITY_ENABLED -#endif - #if (HAL_PROXIMITY_ENABLED && AP_PROXIMITY_CYGBOT_ENABLED) #include "AP_Proximity_Backend_Serial.h" diff --git a/libraries/AP_Proximity/AP_Proximity_config.h b/libraries/AP_Proximity/AP_Proximity_config.h index 92e87818bd..c6ca9e0291 100644 --- a/libraries/AP_Proximity/AP_Proximity_config.h +++ b/libraries/AP_Proximity/AP_Proximity_config.h @@ -5,3 +5,7 @@ #ifndef HAL_PROXIMITY_ENABLED #define HAL_PROXIMITY_ENABLED (!HAL_MINIMIZE_FEATURES && BOARD_FLASH_SIZE > 1024) #endif + +#ifndef AP_PROXIMITY_CYGBOT_ENABLED +#define AP_PROXIMITY_CYGBOT_ENABLED HAL_PROXIMITY_ENABLED +#endif