AP_UAVCAN: add can driver getter

This commit is contained in:
Lucas De Marchi 2018-03-09 14:00:16 -08:00 committed by Tom Pittenger
parent 80cb2e343c
commit 1dd14a8aed
2 changed files with 11 additions and 0 deletions

View File

@ -1347,4 +1347,12 @@ bool AP_UAVCAN::led_write(uint8_t led_index, uint8_t red, uint8_t green, uint8_t
return true; return true;
} }
AP_UAVCAN *AP_UAVCAN::get_uavcan(uint8_t iface)
{
if (iface >= MAX_NUMBER_OF_CAN_INTERFACES || !hal.can_mgr[iface]) {
return nullptr;
}
return hal.can_mgr[iface]->get_UAVCAN();
}
#endif // HAL_WITH_UAVCAN #endif // HAL_WITH_UAVCAN

View File

@ -54,6 +54,9 @@ public:
static const struct AP_Param::GroupInfo var_info[]; static const struct AP_Param::GroupInfo var_info[];
// Return uavcan from @iface or nullptr if it's not ready or doesn't exist
static AP_UAVCAN *get_uavcan(uint8_t iface);
// this function will register the listening class on a first free channel or on the specified channel // this function will register the listening class on a first free channel or on the specified channel
// if preferred_channel = 0 then free channel will be searched for // if preferred_channel = 0 then free channel will be searched for
// if preferred_channel > 0 then listener will be added to specific channel // if preferred_channel > 0 then listener will be added to specific channel