43 throw std::runtime_error(
"Failed to open SPI device : " + spiDevice);
61 throw std::runtime_error(
"Failed to open SPI device : " + spiDevice);
87 throw std::runtime_error(
"Failed to reset MCP2515");
98 throw std::runtime_error(
"Failed to set MCP2515 to normal mode");
111 std::vector<uint8_t> data;
118 }
catch (
const std::exception &e) {
119 qDebug() <<
"Error while processing CAN message:" << e.what();
145 0x100, [
this](
const std::vector<uint8_t> &data) {
146 if (data.size() ==
sizeof(
float)) {
148 memcpy(&speed, data.data(),
sizeof(
float));
154 [
this](
const std::vector<uint8_t> &data) {
155 if (data.size() == 2) {
156 uint16_t rpm = (data[0] << 8) | data[1];
Definition of the MCP2515Controller class.
Definition of the SPIController class.
void rpmUpdated(int newRpm)
Signal emitted when the RPM is updated.
void speedUpdated(float newSpeed)
Signal emitted when the speed is updated.
Interface for the SPI controller.
bool isStopReadingFlagSet() const override
Check if the stop reading flag is set.
void processReading() override
Start reading CAN messages.
~MCP2515Controller() override
Destroy the MCP2515Controller::MCP2515Controller object.
bool stopReadingFlag
Flag to indicate if the reading process should stop.
bool init() override
Initialize the MCP2515 controller.
bool ownsSPIController
Flag to indicate if the SPI controller is owned by the MCP2515Controller.
void stopReading() override
Stop reading CAN messages.
MCP2515Configurator configurator
MCP2515Configurator object.
CANMessageProcessor messageProcessor
CANMessageProcessor object.
void setupHandlers()
Send a CAN message.
MCP2515Controller(const std::string &spiDevice)
Construct a new MCP2515Controller::MCP2515Controller object.
ISPIController * spiController
Pointer to the ISPIController object.
Class that controls the SPI communication. ISPIController.