Browse Source

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.
c415-sdk
Michael du Breuil 4 years ago committed by Andrew Tridgell
parent
commit
bde695d11f
  1. 10
      libraries/AP_Notify/UAVCAN_RGB_LED.cpp

10
libraries/AP_Notify/UAVCAN_RGB_LED.cpp

@ -45,7 +45,15 @@ UAVCAN_RGB_LED::UAVCAN_RGB_LED(uint8_t led_index, uint8_t led_off, @@ -45,7 +45,15 @@ UAVCAN_RGB_LED::UAVCAN_RGB_LED(uint8_t led_index, uint8_t led_off,
bool UAVCAN_RGB_LED::init()
{
return true;
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;
}

Loading…
Cancel
Save