Here are both sketches. Both are unmodified code I got from here: https://learn.adafruit.com/adafruit-fea ... n-examples
Send:
Code: Select all
// Copyright (c) Sandeep Mistry. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
#include <CAN.h>
void setup() {
Serial.begin(9600);
while (!Serial);
Serial.println("CAN Sender");
pinMode(PIN_CAN_STANDBY, OUTPUT);
digitalWrite(PIN_CAN_STANDBY, false); // turn off STANDBY
pinMode(PIN_CAN_BOOSTEN, OUTPUT);
digitalWrite(PIN_CAN_BOOSTEN, true); // turn on booster
// start the CAN bus at 250 kbps
if (!CAN.begin(250000)) {
Serial.println("Starting CAN failed!");
while (1);
}
}
void loop() {
// send packet: id is 11 bits, packet can contain up to 8 bytes of data
Serial.print("Sending packet ... ");
CAN.beginPacket(0x12);
CAN.write('h');
CAN.write('e');
CAN.write('l');
CAN.write('l');
CAN.write('o');
CAN.endPacket();
Serial.println("done");
delay(1000);
// send extended packet: id is 29 bits, packet can contain up to 8 bytes of data
Serial.print("Sending extended packet ... ");
CAN.beginExtendedPacket(0xabcdef);
CAN.write('w');
CAN.write('o');
CAN.write('r');
CAN.write('l');
CAN.write('d');
CAN.endPacket();
Serial.println("done");
delay(1000);
}
Receive:
Code: Select all
// Copyright (c) Sandeep Mistry. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
#include <CAN.h>
void setup() {
Serial.begin(9600);
while (!Serial);
Serial.println("CAN Receiver");
pinMode(PIN_CAN_STANDBY, OUTPUT);
digitalWrite(PIN_CAN_STANDBY, false); // turn off STANDBY
pinMode(PIN_CAN_BOOSTEN, OUTPUT);
digitalWrite(PIN_CAN_BOOSTEN, true); // turn on booster
// start the CAN bus at 250 kbps
if (!CAN.begin(250000)) {
Serial.println("Starting CAN failed!");
while (1);
}
}
void loop() {
// try to parse packet
int packetSize = CAN.parsePacket();
if (packetSize) {
// received a packet
Serial.print("Received ");
if (CAN.packetExtended()) {
Serial.print("extended ");
}
if (CAN.packetRtr()) {
// Remote transmission request, packet contains no data
Serial.print("RTR ");
}
Serial.print("packet with id 0x");
Serial.print(CAN.packetId(), HEX);
if (CAN.packetRtr()) {
Serial.print(" and requested length ");
Serial.println(CAN.packetDlc());
} else {
Serial.print(" and length ");
Serial.println(packetSize);
// only print packet data for non-RTR packets
while (CAN.available()) {
Serial.print((char)CAN.read());
}
Serial.println();
}
Serial.println();
}
}
Here's a picture of my system: https://drive.google.com/file/d/1Aahk9c ... sp=sharing
In Arduino IDE's library files, I moved the original CAN library to a folder titled "!Depreciated" and imported Adafruit's provided CAN library. I checked for continuity of the CAN High and CAN Low lines and both seem to have continuity with the respective line.
I tried writing Send to Feather M4 CAN "A" and Receive to Feather M4 CAN "B", as well as writing Feather M4 CAN "B" and Receive to Feather M4 CAN "A", but the same behavior persists.
Current behavior:
Sender tells me in serial monitor:
CAN Sender
Sending packet ... done
Sending extended packet ... done
Receiver tells me "CAN Receiver" in the serial monitor and nothing else
Expected Behavior:
Sender tells me in serial monitor:
CAN Sender
Sending packet ... done
Sending extended packet ... done
Receiver tells me "CAN Receiver" in the serial monitor and "hello" "world" in addresses 0x12 and 0xabcdef respectively
Again, I was able to get them to successfully talk to one another a few days ago in the duration I tested them with the correct messages being sent from the sender and seen in the serial monitor of the receiver. Is it possible that I burned something out? How would I be able to test that? Are both of mine defective?