I'm trying to get mailboxes to work, but perhaps I don't understand them. I have a specific CAN ID that I want to receive, and the rest is junk.
Pseudocode:
Code:
// https://github.com/tonton81/FlexCAN_T4
#include <FlexCAN_T4.h>
FlexCAN_T4<CAN1, RX_SIZE_256, TX_SIZE_16> CanBus;
// CAN data to watch for (later needs to be in EEPROM)
#define CAN_SPEED_HEXID 0x589
#define CAN_SPEED_START_BYTE 6
void setup() {
// Initialize CAN1
CanBus.begin();
CanBus.setBaudRate(1000000);
CanBus.setMaxMB(16);
//CanBus.setMBFilter(REJECT_ALL);
//CanBus.setMBFilter(MB0, CAN_SPEED_HEXID);
//CanBus.enhanceFilter(MB0);
//CanBus.setMB(MB0, RX, STD);
//CanBus.onReceive(MB0, canSniff);
//CanBus.enableMBInterrupt(MB0);
CanBus.enableFIFO();
CanBus.enableFIFOInterrupt();
CanBus.onReceive(canSniff);
CanBus.mailboxStatus();
}
void loop() {
CanBus.events();
}
In FIFO mode, when I send a message from my CAN device, using the example canSniff function, I see output in the serial monitor:
Code:
MB 99 OVERRUN: 0 LEN: 8 EXT: 0 TS: 15520 ID: 589 Buffer: 0 0 2A 0 0 0 0 0
If I comment out the FIFO stuff and
UNcomment the MBfiltering, when my device sends a message on 0x589, nothing is output by canSniff.
Can you explain what I'm doing wrong with mailboxes here?
* I'm rejecting all messages with setMBFilter
* I'm telling MB0 which ID to filter (0x589)
* I'm turning on enhanced filtering on MB0
* I'm telling MB0 to receive standard frames
* I'm telling MB0 to call canSniff when it receives something
The goal:
I want to throw away any message that isn't 0x589