From 8500535a8600a24a8a08e895d97ce3851e5fa01f Mon Sep 17 00:00:00 2001 From: wanckl Date: Tue, 26 May 2026 19:44:06 +0800 Subject: [PATCH] fix(driver_twai): fix driver assert fail when send frame Closes https://github.com/espressif/esp-idf/issues/18081 --- components/esp_driver_twai/esp_twai_onchip.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/components/esp_driver_twai/esp_twai_onchip.c b/components/esp_driver_twai/esp_twai_onchip.c index 4167cc5156f..e121157f467 100644 --- a/components/esp_driver_twai/esp_twai_onchip.c +++ b/components/esp_driver_twai/esp_twai_onchip.c @@ -275,8 +275,6 @@ static void _node_isr_main(void *arg) } // start a new TX if ((atomic_load(&twai_ctx->state) != TWAI_ERROR_BUS_OFF) && xQueueReceiveFromISR(twai_ctx->tx_mount_queue, &twai_ctx->p_curr_tx, &do_yield)) { - // Sanity check, must in `hw_busy` here, otherwise logic bug is somewhere - assert(twai_ctx->hw_busy); _node_start_trans(twai_ctx); } else { atomic_store(&twai_ctx->hw_busy, false); @@ -604,7 +602,8 @@ static esp_err_t _node_queue_tx(twai_node_handle_t node, const twai_frame_t *fra if (dequeue_result == pdTRUE) { _node_start_trans(twai_ctx); } else { - assert(false && "should always get frame at this moment"); + // any reason here means frame already taken and maybe finished by fast hardware, so back `hw_busy` to false + atomic_store(&twai_ctx->hw_busy, false); } }