Hotwheels-Cluster 1.2
Creation of Cluster APP for SEA:ME project.
 
Loading...
Searching...
No Matches
CANMessageProcessor Class Reference

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, MessageHandlerhandlers
 Map of frame IDs to message handlers.
 

Detailed Description

Class that processes CAN messages.

Definition at line 29 of file CANMessageProcessor.hpp.

Member Typedef Documentation

◆ MessageHandler

using CANMessageProcessor::MessageHandler = std::function<void(const std::vector<uint8_t> &)>

Definition at line 31 of file CANMessageProcessor.hpp.

Constructor & Destructor Documentation

◆ CANMessageProcessor()

CANMessageProcessor::CANMessageProcessor ( )

Construct a new CANMessageProcessor::CANMessageProcessor object.

This constructor initializes the CANMessageProcessor object.

Definition at line 32 of file CANMessageProcessor.cpp.

◆ ~CANMessageProcessor()

CANMessageProcessor::~CANMessageProcessor ( )
default

Member Function Documentation

◆ processMessage()

void CANMessageProcessor::processMessage ( uint16_t frameID,
const std::vector< uint8_t > & data )

Process a CAN message.

Parameters
frameIDThe frame ID of the message.
dataThe data of the message.
Exceptions
std::runtime_errorif 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.

Here is the caller graph for this function:

◆ registerHandler()

void CANMessageProcessor::registerHandler ( uint16_t frameID,
MessageHandler handler )

Destroy the CANMessageProcessor::CANMessageProcessor object.

Parameters
frameID
handler
Exceptions
std::invalid_argumentif the handler is null

This method registers a handler for a specific frame ID.

Definition at line 42 of file CANMessageProcessor.cpp.

Field Documentation

◆ handlers

std::unordered_map<uint16_t, MessageHandler> CANMessageProcessor::handlers
private

Map of frame IDs to message handlers.

Definition at line 40 of file CANMessageProcessor.hpp.


The documentation for this class was generated from the following files: