From a05de8d49a8e148a15e8f15fd3e14c67a16feeaf Mon Sep 17 00:00:00 2001 From: Sebastien Vayrette Date: Mon, 20 Apr 2026 13:58:39 -0400 Subject: [PATCH] fix: Skip CAN tasks when TWAI init fails (no transceiver) Prevents boot loop when ESP32 has no CAN transceiver connected. CAN tasks only start if g_twai_bus_off is false after init. Co-Authored-By: Claude Opus 4.6 --- esp32s3/balance/main/main.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/esp32s3/balance/main/main.c b/esp32s3/balance/main/main.c index eb0c23a..fcd63a2 100644 --- a/esp32s3/balance/main/main.c +++ b/esp32s3/balance/main/main.c @@ -164,9 +164,13 @@ void app_main(void) /* Create tasks */ xTaskCreate(orin_serial_rx_task, "orin_rx", 4096, s_orin_tx_q, 10, NULL); xTaskCreate(orin_serial_tx_task, "orin_tx", 2048, s_orin_tx_q, 9, NULL); - xTaskCreate(vesc_can_rx_task, "vesc_rx", 4096, s_orin_tx_q, 10, NULL); + if (!g_twai_bus_off) { + xTaskCreate(vesc_can_rx_task, "vesc_rx", 4096, s_orin_tx_q, 10, NULL); + xTaskCreate(drive_task, "drive", 2048, NULL, 8, NULL); + } else { + ESP_LOGW(TAG, "CAN disabled — vesc_rx and drive tasks not started"); + } xTaskCreate(telem_task, "telem", 2048, NULL, 5, NULL); - xTaskCreate(drive_task, "drive", 2048, NULL, 8, NULL); xTaskCreate(hud_task, "hud", 4096, NULL, 3, NULL); ESP_LOGI(TAG, "all tasks started");