Anyone get any further on this? Tried the code below, which compiles and downloads, however I don't get any CANbus signals coming through. Not sure what else to check?
#include <M5Core2.h>
#include "CAN_config.h"
#include "ESP32CAN.h"
CAN_device_t CAN_cfg; // CAN Config
unsigned long previousMillis = 0; // will store last time a CAN Message was send
const int interval = 1000; // interval at which send CAN Messages (milliseconds)
const int rx_queue_size = 10; // Receive Queue size
uint8_t count = 0;
void setup() {
M5.begin(false,false,true,false); //(LCDEnable, SDEnable, SerialEnable, I2CEnable)
CAN_cfg.speed = CAN_SPEED_250KBPS;
CAN_cfg.tx_pin_id = GPIO_NUM_32;
CAN_cfg.rx_pin_id = GPIO_NUM_33;
CAN_cfg.rx_queue = xQueueCreate(rx_queue_size, sizeof(CAN_frame_t));
ESP32Can.CANInit();
}
void loop() {
CAN_frame_t rx_frame;
unsigned long currentMillis = millis();
// Receive next CAN frame from queue
if (xQueueReceive(CAN_cfg.rx_queue, &rx_frame, 3 * portTICK_PERIOD_MS) == pdTRUE) {
if (rx_frame.FIR.B.RTR == CAN_RTR) {
Serial.printf("RTR from 0x%08X, DLC %d\r\n", rx_frame.MsgID, rx_frame.FIR.B.DLC);
}
else {
Serial.printf("from 0x%08X, DLC %d, Data \r\n", rx_frame.MsgID, rx_frame.FIR.B.DLC);
for (int i = 0; i < rx_frame.FIR.B.DLC; i++) {
Serial.printf("0x%02X ", rx_frame.data.u8[i]);
}
Serial.println("\n");
}
}
}