Class that controls the MCP2515 CAN controller. IMCP2515Controller. More...
#include <MCP2515Controller.hpp>
Public Member Functions | |
MCP2515Controller (const std::string &spiDevice) | |
Construct a new MCP2515Controller::MCP2515Controller object. | |
MCP2515Controller (const std::string &spiDevice, ISPIController &spiController) | |
Construct a new MCP2515Controller::MCP2515Controller object. | |
~MCP2515Controller () override | |
Destroy the MCP2515Controller::MCP2515Controller object. | |
bool | init () override |
Initialize the MCP2515 controller. | |
void | processReading () override |
Start reading CAN messages. | |
void | stopReading () override |
Stop reading CAN messages. | |
CANMessageProcessor & | getMessageProcessor () |
bool | isStopReadingFlagSet () const override |
Check if the stop reading flag is set. | |
![]() | |
virtual | ~IMCP2515Controller ()=default |
Private Member Functions | |
void | setupHandlers () |
Send a CAN message. | |
Private Attributes | |
ISPIController * | spiController |
Pointer to the ISPIController object. | |
MCP2515Configurator | configurator |
MCP2515Configurator object. | |
CANMessageProcessor | messageProcessor |
CANMessageProcessor object. | |
bool | stopReadingFlag = false |
Flag to indicate if the reading process should stop. | |
bool | ownsSPIController = false |
Flag to indicate if the SPI controller is owned by the MCP2515Controller. | |
Additional Inherited Members | |
![]() | |
void | speedUpdated (float newSpeed) |
Signal emitted when the speed is updated. | |
void | rpmUpdated (int newRpm) |
Signal emitted when the RPM is updated. | |
Class that controls the MCP2515 CAN controller. IMCP2515Controller.
Definition at line 31 of file MCP2515Controller.hpp.
|
explicit |
Construct a new MCP2515Controller::MCP2515Controller object.
spiDevice | The SPI device to use for communication. |
std::runtime_error | if the SPI device cannot be opened. |
This constructor initializes the MCP2515Controller object with the specified SPI device.
Definition at line 39 of file MCP2515Controller.cpp.
MCP2515Controller::MCP2515Controller | ( | const std::string & | spiDevice, |
ISPIController & | spiController ) |
Construct a new MCP2515Controller::MCP2515Controller object.
spiDevice | The SPI device to use for communication. |
spiController | The SPI controller to use for communication. |
std::runtime_error | if the SPI device cannot be opened. |
This constructor initializes the MCP2515Controller object with the specified SPI device and SPI controller.
Definition at line 56 of file MCP2515Controller.cpp.
|
override |
Destroy the MCP2515Controller::MCP2515Controller object.
This destructor closes the SPI device and deletes the SPI controller if it was created by the MCP2515Controller.
Definition at line 71 of file MCP2515Controller.cpp.
|
inline |
|
overridevirtual |
Initialize the MCP2515 controller.
std::runtime_error | if the MCP2515 cannot be reset. |
This function initializes the MCP2515 controller by resetting the chip and configuring it.
Implements IMCP2515Controller.
Definition at line 85 of file MCP2515Controller.cpp.
|
overridevirtual |
Check if the stop reading flag is set.
This function checks if the stop reading flag is set.
Implements IMCP2515Controller.
Definition at line 167 of file MCP2515Controller.cpp.
|
overridevirtual |
Start reading CAN messages.
This function starts reading CAN messages from the MCP2515.
Implements IMCP2515Controller.
Definition at line 108 of file MCP2515Controller.cpp.
|
private |
Send a CAN message.
frameID | The frame ID of the message. |
data | The data of the message. |
This function sends a CAN message with the specified frame ID and data.
Definition at line 143 of file MCP2515Controller.cpp.
|
overridevirtual |
Stop reading CAN messages.
This function stops reading CAN messages from the MCP2515.
Implements IMCP2515Controller.
Definition at line 134 of file MCP2515Controller.cpp.
|
private |
MCP2515Configurator object.
Definition at line 51 of file MCP2515Controller.hpp.
|
private |
CANMessageProcessor object.
Definition at line 53 of file MCP2515Controller.hpp.
|
private |
Flag to indicate if the SPI controller is owned by the MCP2515Controller.
Definition at line 58 of file MCP2515Controller.hpp.
|
private |
Pointer to the ISPIController object.
Definition at line 49 of file MCP2515Controller.hpp.
|
private |
Flag to indicate if the reading process should stop.
Definition at line 55 of file MCP2515Controller.hpp.