Hi all,
I've got a teensy 4.1 board and a dual canbus transceiver from tindie (https://www.tindie.com/products/fusion/dual-can-bus-adapter-for-teensy-40-41/)
For starters, I want to read the canbus stream from a vehicle through the obd2 port. I've got the necessary cables and adapter, and them hooked up as follows:
teensy CAN board can1 high = pin6 on OBD2 connector (CAN high)
teensy CAN board can1 low = pin 14 on OBD2 connector (CAN low)
teensy CAN board can1 ground = pin 5 on OBD2 connector (signal ground)
I've tried the base example that comes with flexcan_t4 included with teensyduino, code pasted below.
The can.read() functions don't seem to be firing, and I'm seeing no output.
Eventually I need to sniff and filter can messages from the vehicle to display on a display. For now I would just love to be able to get ANY sign that the teensy can 'see' data on the vehicle's canbus.
I'm pretty new to this, so any pointers on next steps to troubleshoot would be very much appreciated. Thank you
I've got a teensy 4.1 board and a dual canbus transceiver from tindie (https://www.tindie.com/products/fusion/dual-can-bus-adapter-for-teensy-40-41/)
For starters, I want to read the canbus stream from a vehicle through the obd2 port. I've got the necessary cables and adapter, and them hooked up as follows:
teensy CAN board can1 high = pin6 on OBD2 connector (CAN high)
teensy CAN board can1 low = pin 14 on OBD2 connector (CAN low)
teensy CAN board can1 ground = pin 5 on OBD2 connector (signal ground)
I've tried the base example that comes with flexcan_t4 included with teensyduino, code pasted below.
The can.read() functions don't seem to be firing, and I'm seeing no output.
Eventually I need to sniff and filter can messages from the vehicle to display on a display. For now I would just love to be able to get ANY sign that the teensy can 'see' data on the vehicle's canbus.
I'm pretty new to this, so any pointers on next steps to troubleshoot would be very much appreciated. Thank you
Code:
#include <FlexCAN_T4.h>
FlexCAN_T4<CAN1, RX_SIZE_256, TX_SIZE_16> can1;
FlexCAN_T4<CAN2, RX_SIZE_256, TX_SIZE_16> can2;
CAN_message_t msg;
void setup(void) {
can1.begin();
can1.setBaudRate(250000);
can2.begin();
can2.setBaudRate(250000);
}
void loop() {
if ( can1.read(msg) ) {
Serial.print("CAN1 ");
Serial.print("MB: "); Serial.print(msg.mb);
Serial.print(" ID: 0x"); Serial.print(msg.id, HEX );
Serial.print(" EXT: "); Serial.print(msg.flags.extended );
Serial.print(" LEN: "); Serial.print(msg.len);
Serial.print(" DATA: ");
for ( uint8_t i = 0; i < 8; i++ ) {
Serial.print(msg.buf[i]); Serial.print(" ");
}
Serial.print(" TS: "); Serial.println(msg.timestamp);
}
else if ( can2.read(msg) ) {
Serial.print("CAN2 ");
Serial.print("MB: "); Serial.print(msg.mb);
Serial.print(" ID: 0x"); Serial.print(msg.id, HEX );
Serial.print(" EXT: "); Serial.print(msg.flags.extended );
Serial.print(" LEN: "); Serial.print(msg.len);
Serial.print(" DATA: ");
for ( uint8_t i = 0; i < 8; i++ ) {
Serial.print(msg.buf[i]); Serial.print(" ");
}
Serial.print(" TS: "); Serial.println(msg.timestamp);
}
}