Class that processes CAN messages. More...
#include <CANMessageProcessor.hpp>
Public Types | |
using | MessageHandler = std::function<void(const std::vector<uint8_t> &)> |
Public Member Functions | |
CANMessageProcessor () | |
Construct a new CANMessageProcessor::CANMessageProcessor object. | |
~CANMessageProcessor ()=default | |
void | registerHandler (uint16_t frameID, MessageHandler handler) |
Destroy the CANMessageProcessor::CANMessageProcessor object. | |
void | processMessage (uint16_t frameID, const std::vector< uint8_t > &data) |
Process a CAN message. | |
Private Attributes | |
std::unordered_map< uint16_t, MessageHandler > | handlers |
Map of frame IDs to message handlers. | |
Class that processes CAN messages.
Definition at line 29 of file CANMessageProcessor.hpp.
using CANMessageProcessor::MessageHandler = std::function<void(const std::vector<uint8_t> &)> |
Definition at line 31 of file CANMessageProcessor.hpp.
CANMessageProcessor::CANMessageProcessor | ( | ) |
Construct a new CANMessageProcessor::CANMessageProcessor object.
This constructor initializes the CANMessageProcessor object.
Definition at line 32 of file CANMessageProcessor.cpp.
|
default |
void CANMessageProcessor::processMessage | ( | uint16_t | frameID, |
const std::vector< uint8_t > & | data ) |
Process a CAN message.
frameID | The frame ID of the message. |
data | The data of the message. |
std::runtime_error | if no handler is registered for the frame ID. |
This method processes a CAN message by calling the appropriate handler for the frame ID.
Definition at line 59 of file CANMessageProcessor.cpp.
void CANMessageProcessor::registerHandler | ( | uint16_t | frameID, |
MessageHandler | handler ) |
Destroy the CANMessageProcessor::CANMessageProcessor object.
frameID | |
handler |
std::invalid_argument | if the handler is null |
This method registers a handler for a specific frame ID.
Definition at line 42 of file CANMessageProcessor.cpp.
|
private |
Map of frame IDs to message handlers.
Definition at line 40 of file CANMessageProcessor.hpp.