Skip to content

Commit

Permalink
[HW]: Add a way to get each channel's assigned frame handler
Browse files Browse the repository at this point in the history
(cherry picked from commit 61482dc)
  • Loading branch information
ad3154 committed Dec 28, 2023
1 parent e978b85 commit 86219cf
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,11 @@ namespace isobus
/// @returns `true` if the driver was removed from the channel, otherwise `false`
static bool unassign_can_channel_frame_handler(std::uint8_t channelIndex);

/// @brief Gets the CAN driver assigned to a channel
/// @param[in] channelIndex The channel to get the driver from
/// @returns The driver assigned to the channel, or `nullptr` if the channel is not assigned
static std::shared_ptr<CANHardwarePlugin> get_assigned_can_channel_frame_handler(std::uint8_t channelIndex);

/// @brief Starts the threads for managing the CAN stack and CAN drivers
/// @returns `true` if the threads were started, otherwise false (perhaps they are already running)
static bool start();
Expand Down
11 changes: 11 additions & 0 deletions hardware_integration/src/can_hardware_interface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,17 @@ namespace isobus
return true;
}

std::shared_ptr<CANHardwarePlugin> CANHardwareInterface::get_assigned_can_channel_frame_handler(std::uint8_t channelIndex)
{
std::shared_ptr<CANHardwarePlugin> retVal;

if (channelIndex < hardwareChannels.size())
{
retVal = hardwareChannels.at(channelIndex)->frameHandler;
}
return retVal;
}

bool CANHardwareInterface::start()
{
std::lock_guard<std::mutex> lock(hardwareChannelsMutex);
Expand Down

0 comments on commit 86219cf

Please sign in to comment.