Closed Fuller97 closed 1 month ago
Just wanted to update you that I will add reply back here with an example asap.
Access data bytes in received frame.
CANFrame frame;
if (CAN.read(frame) == CANController::IOResult::OK) {
const uint8_t * data = frame.getData();
// now you can access each byte in data (data[0], data[1], ...)
}
You can also copy the data from the frame if required.
CANFrame frame;
uint8_t data[8];
if (CAN.read(frame) == CANController::IOResult::OK) {
frame.getData(data, sizeof(data));
// now you can access each byte in data (data[0], data[1], ...)
}
I will also add these getData()
methods as an additional example.
Hi I try to get data from frame by using a function:
frameRX.getData();
but I can't get separate bytes from frame like for example byte [3] from frame. I try something like this:CAN.read(adresrx, datarx, sizeof(datarx));
but i have error: `C:\Users\Fuller\Documents\Arduino\can_send\can_send.ino: In function 'void loop()': C:\Users\Fuller\Documents\Arduino\can_send\can_send.ino:58:45: error: no matching function for call to 'CANController::read(uint16_t&, uint8_t [8], unsigned int)' CAN.read(adresrx, datarx, sizeof(datarx)); ^ In file included from c:\Users\Fuller\Documents\Arduino\libraries\AA_MCP2515\src/AA_MCP2515.h:11:0, from C:\Users\Fuller\Documents\Arduino\can_send\can_send.ino:12: c:\Users\Fuller\Documents\Arduino\libraries\AA_MCP2515\src/CANController.h:46:14: note: candidate: CANController::IOResult CANController::read(CANFrame&) IOResult read(CANFrame &frame); ^~~~ c:\Users\Fuller\Documents\Arduino\libraries\AA_MCP2515\src/CANController.h:46:14: note: candidate expects 1 argument, 3 providedexit status 1
Compilation error: no matching function for call to 'CANController::read(uint16_t&, uint8_t [8], unsigned int)'` Maybe you gives examples how to get bytes from data frame?