diff --git a/libraries/AP_RPM/RPM_DroneCAN.cpp b/libraries/AP_RPM/RPM_DroneCAN.cpp index 4657ff7714..fffc87c0b1 100644 --- a/libraries/AP_RPM/RPM_DroneCAN.cpp +++ b/libraries/AP_RPM/RPM_DroneCAN.cpp @@ -34,15 +34,11 @@ AP_RPM_DroneCAN::AP_RPM_DroneCAN(AP_RPM &_ap_rpm, uint8_t instance, AP_RPM::RPM_ } // Subscribe to incoming rpm messages -void AP_RPM_DroneCAN::subscribe_msgs(AP_DroneCAN* ap_dronecan) +bool AP_RPM_DroneCAN::subscribe_msgs(AP_DroneCAN* ap_dronecan) { - if (ap_dronecan == nullptr) { - return; - } + const auto driver_index = ap_dronecan->get_driver_index(); - if (Canard::allocate_sub_arg_callback(ap_dronecan, &handle_rpm, ap_dronecan->get_driver_index()) == nullptr) { - AP_BoardConfig::allocation_error("rpm_sub"); - } + return (Canard::allocate_sub_arg_callback(ap_dronecan, &handle_rpm, driver_index) != nullptr); } // Receive new CAN message diff --git a/libraries/AP_RPM/RPM_DroneCAN.h b/libraries/AP_RPM/RPM_DroneCAN.h index c9d8e8c0c5..ae69240713 100644 --- a/libraries/AP_RPM/RPM_DroneCAN.h +++ b/libraries/AP_RPM/RPM_DroneCAN.h @@ -27,7 +27,7 @@ public: AP_RPM_DroneCAN(AP_RPM &_ap_rpm, uint8_t instance, AP_RPM::RPM_State &_state); // Subscribe to incoming rpm messages - static void subscribe_msgs(AP_DroneCAN* ap_dronecan); + static bool subscribe_msgs(AP_DroneCAN* ap_dronecan); // update state void update(void) override;