I really appreciate your help and thoughts on this.
So far nothing I've tried is working. I initially tried setMaxMB(9), normal callbacks, and no events() calls. That didn't work at all (no traffic to the DISPLAY). Here's the code:
Code:
#include <FlexCAN_T4.h>
FlexCAN_T4<CAN1, RX_SIZE_256, TX_SIZE_16> Can0;
FlexCAN_T4<CAN2, RX_SIZE_256, TX_SIZE_16> Can1;
void can0_got_frame_teensy(const CAN_message_t &frame) {
Serial.println("0->1");
Can1.write(frame);
}
void can1_got_frame_teensy(const CAN_message_t &frame) {
Serial.println("1->0");
Can0.write(frame);
}
void setup()
{
delay(5000);
Serial.begin(115200);
Serial.println("j1939 CAN bridge.");
//Teensy FlexCAN_T4 setup
Can0.begin();
Can0.setBaudRate(250000);
Can0.setMaxMB(9);
Can0.enableFIFO();
Can0.onReceive(can0_got_frame_teensy);
Can1.begin();
Can1.setBaudRate(250000);
Can1.setMaxMB(9);
Can1.enableFIFO();
Can1.onReceive(can1_got_frame_teensy);
Can0.enableFIFOInterrupt();
Can0.mailboxStatus();
Can1.enableFIFOInterrupt();
Can1.mailboxStatus();
}
void loop()
{
}
I think I must have misunderstood something you said above because without the calls to event(), the callback does not seem to get fired at all. Unless you were referring to using the ext_output callbacks, which I then went on to try:
Code:
void ext_output1(const CAN_message_t &msg)
{
if(msg.bus == 1) {
Can1.write(msg);
Serial.println("0->1");
}
if(msg.bus == 2) {
Can0.write(msg);
Serial.println("1->0");
}
}
That works kind of. Traffic is getting through but there seems to be a lot of missing frames. The OEM display starts complaining about lost communication. Button presses that interact with a device on the other side of the bus aren't seen half the time. So apparently using just one TX queue has now made the issues I'm seeing a lot worse.
I'm clearly missing something (probably simple). Oh and I tried setting seq to 1 without messing with setMaxMB, and that also seemed to make matters worse. I appreciate your patience!
Thanks again.