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 <noreply@anthropic.com>
This commit is contained in:
Sebastien Vayrette 2026-04-20 13:58:39 -04:00
parent 2622696772
commit a05de8d49a

View File

@ -164,9 +164,13 @@ void app_main(void)
/* Create tasks */ /* Create tasks */
xTaskCreate(orin_serial_rx_task, "orin_rx", 4096, s_orin_tx_q, 10, NULL); 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(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(telem_task, "telem", 2048, NULL, 5, NULL);
xTaskCreate(drive_task, "drive", 2048, NULL, 8, NULL);
xTaskCreate(hud_task, "hud", 4096, NULL, 3, NULL); xTaskCreate(hud_task, "hud", 4096, NULL, 3, NULL);
ESP_LOGI(TAG, "all tasks started"); ESP_LOGI(TAG, "all tasks started");