Skip to content

Commit

Permalink
AP_UAVCAN: add can driver getter
Browse files Browse the repository at this point in the history
  • Loading branch information
lucasdemarchi authored and magicrub committed Mar 11, 2018
1 parent 80cb2e3 commit 1dd14a8
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
8 changes: 8 additions & 0 deletions libraries/AP_UAVCAN/AP_UAVCAN.cpp
Expand Up @@ -1347,4 +1347,12 @@ bool AP_UAVCAN::led_write(uint8_t led_index, uint8_t red, uint8_t green, uint8_t
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
3 changes: 3 additions & 0 deletions libraries/AP_UAVCAN/AP_UAVCAN.h
Expand Up @@ -54,6 +54,9 @@ class AP_UAVCAN {

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
// if preferred_channel = 0 then free channel will be searched for
// if preferred_channel > 0 then listener will be added to specific channel
Expand Down

0 comments on commit 1dd14a8

Please sign in to comment.