diff --git a/libraries/AP_Airspeed/AP_Airspeed_DroneCAN.cpp b/libraries/AP_Airspeed/AP_Airspeed_DroneCAN.cpp index 4f0b3da42f..8d3dff897a 100644 --- a/libraries/AP_Airspeed/AP_Airspeed_DroneCAN.cpp +++ b/libraries/AP_Airspeed/AP_Airspeed_DroneCAN.cpp @@ -13,21 +13,15 @@ extern const AP_HAL::HAL& hal; AP_Airspeed_DroneCAN::DetectedModules AP_Airspeed_DroneCAN::_detected_modules[]; HAL_Semaphore AP_Airspeed_DroneCAN::_sem_registry; -void AP_Airspeed_DroneCAN::subscribe_msgs(AP_DroneCAN* ap_dronecan) +bool AP_Airspeed_DroneCAN::subscribe_msgs(AP_DroneCAN* ap_dronecan) { - if (ap_dronecan == nullptr) { - return; - } - - if (Canard::allocate_sub_arg_callback(ap_dronecan, &handle_airspeed, ap_dronecan->get_driver_index()) == nullptr) { - AP_BoardConfig::allocation_error("airspeed_sub"); - } + const auto driver_index = ap_dronecan->get_driver_index(); + return (Canard::allocate_sub_arg_callback(ap_dronecan, &handle_airspeed, driver_index) != nullptr) #if AP_AIRSPEED_HYGROMETER_ENABLE - if (Canard::allocate_sub_arg_callback(ap_dronecan, &handle_hygrometer, ap_dronecan->get_driver_index()) == nullptr) { - AP_BoardConfig::allocation_error("hygrometer_sub"); - } + && (Canard::allocate_sub_arg_callback(ap_dronecan, &handle_hygrometer, driver_index) != nullptr) #endif + ; } AP_Airspeed_Backend* AP_Airspeed_DroneCAN::probe(AP_Airspeed &_frontend, uint8_t _instance, uint32_t previous_devid) diff --git a/libraries/AP_Airspeed/AP_Airspeed_DroneCAN.h b/libraries/AP_Airspeed/AP_Airspeed_DroneCAN.h index 2167f9f061..7d92c27f95 100644 --- a/libraries/AP_Airspeed/AP_Airspeed_DroneCAN.h +++ b/libraries/AP_Airspeed/AP_Airspeed_DroneCAN.h @@ -26,7 +26,7 @@ public: bool get_hygrometer(uint32_t &last_sample_ms, float &temperature, float &humidity) override; #endif - static void subscribe_msgs(AP_DroneCAN* ap_dronecan); + static bool subscribe_msgs(AP_DroneCAN* ap_dronecan); static AP_Airspeed_Backend* probe(AP_Airspeed &_frontend, uint8_t _instance, uint32_t previous_devid);