Many thanks, that did it! I did test similar code earlier but never figured it out all the way.
Your advise on how to filter into mailboxes will come to use, appreciate it!
Attached is my code for other to use.
Your advise on how to filter into mailboxes will come to use, appreciate it!
Attached is my code for other to use.
Code:
#include <FlexCAN_T4.h>
FlexCAN_T4<CAN1, RX_SIZE_256, TX_SIZE_16> Can0;
CAN_message_t msg, rxmsg;
void setup(void) {
Serial.begin(115200);
delay(500);
Can0.begin();
Can0.setBaudRate(100000);
Can0.enableMBInterrupts();
}
void canSniff(const CAN_message_t &msg) { // global callback
Serial.print("T4: ");
Serial.print("MB ");
Serial.print(msg.mb);
Serial.print(" OVERRUN: ");
Serial.print(msg.flags.overrun);
Serial.print(" BUS ");
Serial.print(msg.bus);
Serial.print(" LEN: ");
Serial.print(msg.len);
Serial.print(" EXT: ");
Serial.print(msg.flags.extended);
Serial.print(" REMOTE: ");
Serial.print(msg.flags.remote);
Serial.print(" TS: ");
Serial.print(msg.timestamp);
Serial.print(" ID: ");
Serial.print(msg.id, HEX);
Serial.print(" IDHIT: ");
Serial.print(msg.idhit);
Serial.print(" Buffer: ");
for ( uint8_t i = 0; i < msg.len; i++ ) {
Serial.print(msg.buf[i], HEX);
Serial.print(" ");
}
Serial.println();
}
void loop() {
while(Can0.events() > 0){
Can0.onReceive(canSniff);
}
}