AP_Notify: UAVCAN_RGB_LED: don't init if no UAVCAN backends

This allows us to consider enabling UAVCAN_RGB_LED as a more general
default, as it won't consume one of our limited backend slots if UAVCAN
is not enabled.
This commit is contained in:
Michael du Breuil 2021-03-30 10:45:26 -07:00 committed by Andrew Tridgell
parent 240bfeb6bd
commit bde695d11f

View File

@ -45,7 +45,15 @@ UAVCAN_RGB_LED::UAVCAN_RGB_LED(uint8_t led_index, uint8_t led_off,
bool UAVCAN_RGB_LED::init()
{
const uint8_t can_num_drivers = AP::can().get_num_drivers();
for (uint8_t i = 0; i < can_num_drivers; i++) {
AP_UAVCAN *uavcan = AP_UAVCAN::get_uavcan(i);
if (uavcan != nullptr) {
return true;
}
}
// no UAVCAN drivers
return false;
}