Class hal::can_router
ClassList > hal > can_router
Route CAN messages received on the can bus to callbacks based on ID.
#include <can_router.hpp>
Classes
Type | Name |
---|---|
struct | route |
Public Types
Type | Name |
---|---|
typedef hal::callback< hal::can::handler > | message_handler |
typedef static_list< route >::item | route_item |
Public Static Attributes
Type | Name |
---|---|
constexpr auto | noop = = |
{} |
Public Functions
Type | Name |
---|---|
static_list< route >::item | add_message_callback (hal::can::id_t p_id) Add a message route without setting the callback. |
static_list< route >::item | add_message_callback (hal::can::id_t p_id, message_handler p_handler) Set a callback for when messages with a specific ID is received. |
hal::can & | bus () Get a reference to the can peripheral driver. |
can_router (hal::can & p_can) Construct a new can message router. |
|
can_router () = delete |
|
can_router (can_router & p_other) = delete |
|
can_router (can_router && p_other) noexcept |
|
const static_list< route > & | handlers () Get the list of handlers. |
void | operator() (const can::message_t & p_message) Message routing interrupt service handler. |
can_router & | operator= (can_router & p_other) = delete |
can_router & | operator= (can_router && p_other) noexcept |
~can_router () |
Public Static Functions
Type | Name |
---|---|
result< can_router > | create (hal::can & p_can) |
Public Types Documentation
typedef message_handler
using hal::can_router::message_handler = hal::callback<hal::can::handler>;
typedef route_item
using hal::can_router::route_item = static_list<route>::item;
Public Static Attributes Documentation
variable noop
constexpr auto hal::can_router::noop;
Public Functions Documentation
function add_message_callback [1/2]
Add a message route without setting the callback.
static_list < route >::item hal::can_router::add_message_callback (
hal::can::id_t p_id
)
The default callback will do nothing and will drop the message.
Parameters:
p_id
- Associated ID of messages to be stored.
Returns:
auto - route item from the linked list that must be stored stored in a variable
function add_message_callback [2/2]
Set a callback for when messages with a specific ID is received.
static_list < route >::item hal::can_router::add_message_callback (
hal::can::id_t p_id,
message_handler p_handler
)
Parameters:
p_id
- Associated ID of messages to be stored.p_handler
- callback to be executed when a p_id message is received.
Returns:
auto - route item from the linked list that must be stored stored in a variable
function bus
Get a reference to the can peripheral driver.
hal::can & hal::can_router::bus ()
Used to send can messages through the same port that the can_router is using.
Returns:
can& reference to the can peripheral driver
function can_router [1/4]
Construct a new can message router.
explicit hal::can_router::can_router (
hal::can & p_can
)
Parameters:
p_can
- can peripheral to route messages for
function can_router [2/4]
hal::can_router::can_router () = delete
function can_router [3/4]
hal::can_router::can_router (
can_router & p_other
) = delete
function can_router [4/4]
hal::can_router::can_router (
can_router && p_other
) noexcept
function handlers
Get the list of handlers.
const static_list < route > & hal::can_router::handlers ()
Meant for testing purposes or when direct inspection of the map is useful in userspace. Should not be used in by libraries.
Returns:
const auto& map of all of the can message handlers.
function operator()
Message routing interrupt service handler.
void hal::can_router::operator() (
const can::message_t & p_message
)
Searches the static list and finds the first ID associated with the message and run's that route's callback.
Parameters:
p_message
- message received from the bus
function operator=
can_router & hal::can_router::operator= (
can_router & p_other
) = delete
function operator=
can_router & hal::can_router::operator= (
can_router && p_other
) noexcept
function ~can_router
hal::can_router::~can_router ()
Public Static Functions Documentation
function create
static result< can_router > hal::can_router::create (
hal::can & p_can
)
The documentation for this class was generated from the following file libraries/include/libhal-canrouter/can_router.hpp