Both bits of code on the nodes are just slightly modified from the object oriented examples.
Here is the receive node:
Code:
#include <FlexCAN.h>
class ExampleClass : public CANListener
{
public:
void printFrame(CAN_message_t &frame, int mailbox);
bool frameHandler(CAN_message_t &frame, int mailbox, uint8_t controller); //overrides the parent version so we can actually do something
};
void ExampleClass::printFrame(CAN_message_t &frame, int mailbox)
{
Serial.print("ID: ");
Serial.print(frame.id, HEX);
Serial.print(" Data: ");
for (int c = 0; c < frame.len; c++)
{
Serial.print(frame.buf[c], HEX);
Serial.write(' ');
}
Serial.write('\r');
Serial.write('\n');
}
bool ExampleClass::frameHandler(CAN_message_t &frame, int mailbox, uint8_t controller)
{
printFrame(frame, mailbox);
return true;
}
ExampleClass exampleClass;
// -------------------------------------------------------------
void setup(void)
{
delay(1000);
Serial.println(F("Hello Teensy Single CAN Receiving Example With Objects."));
Can0.begin(100000);
Can0.attachObj(&exampleClass);
exampleClass.attachGeneralHandler();
}
// -------------------------------------------------------------
void loop(void)
{
delay(1000);
Serial.write('.');
}
And here is the send node:
Code:
#include <FlexCAN.h>
#ifndef __MK66FX1M0__
#error "Teensy 3.6 runs this code"
#endif
CAN_message_t msg;
static uint8_t hex[17] = "0123456789abcdef";
class ExampleClass : public CANListener
{
public:
void printFrame(CAN_message_t &frame, int mailbox);
bool frameHandler(CAN_message_t &frame, int mailbox, uint8_t controller); //overrides the parent version so we can actually do something
};
void ExampleClass::printFrame(CAN_message_t &frame, int mailbox)
{
Serial.print("ID: ");
Serial.print(frame.id, HEX);
Serial.print(", MB: ");
Serial.print(mailbox);
Serial.print(" Data: ");
for (int c = 0; c < frame.len; c++)
{
Serial.print(frame.buf[c], HEX);
Serial.write(' ');
}
Serial.write('\r');
Serial.write('\n');
}
bool ExampleClass::frameHandler(CAN_message_t &frame, int mailbox, uint8_t controller)
{
printFrame(frame, mailbox);
return true;
}
ExampleClass exampleClass;
// -------------------------------------------------------------
void setup(void)
{
delay(1000);
Serial.println(F("Hello Teensy 3.6 dual CAN Test With Objects."));
Can0.begin(100000);
//if using enable pins on a transceiver they need to be set on
pinMode(2, OUTPUT);
pinMode(35, OUTPUT);
digitalWrite(2, HIGH);
digitalWrite(35, HIGH);
Can0.attachObj(&exampleClass);
exampleClass.attachGeneralHandler();
msg.ext = 0;
msg.id = 0x100;
msg.len = 8;
msg.buf[0] = 10;
msg.buf[1] = 20;
msg.buf[2] = 0;
msg.buf[3] = 100;
msg.buf[4] = 128;
msg.buf[5] = 64;
msg.buf[6] = 32;
msg.buf[7] = 16;
}
// -------------------------------------------------------------
void loop(void)
{
msg.buf[0]++;
int temp = Can0.write(msg);
Serial.println(temp);
delay(20);
}
Here is a picture of the setup:

Breadboard wires were too unstable so this is a modified PCB I found laying around. I am looking over it now and I think that I may of been off one pin in the socketing so the tx on the 3.6 was streaming directly to the rx pin on the 3.2, which would explain why I am seeing data on the 3.2, but I am still confused on why it is only receiving the first message.