Skip to content

Fix: TWAI transmit hangs on empty bus - #6070

Open
bjoernQ wants to merge 2 commits into
esp-rs:mainfrom
bjoernQ:fix-twai-transmit-on-empty-bus
Open

Fix: TWAI transmit hangs on empty bus#6070
bjoernQ wants to merge 2 commits into
esp-rs:mainfrom
bjoernQ:fix-twai-transmit-on-empty-bus

Conversation

@bjoernQ

@bjoernQ bjoernQ commented Aug 7, 2026

Copy link
Copy Markdown
Contributor

Fixes #5307

We already had an (ignored) HIL test for this issue prepared.

This also restores the async TWAI example we had before - while having non-async and async examples seems redundant, in cases like this it's useful. (i.e. the non-async example didn't show the problem)

Happy to remove one of them if requested. (ideally the non-async)

Changelog

esp-hal

  • Fixed: TWAI transmit async hanging on an "empty" bus

@bjoernQ bjoernQ changed the title Fix twai transmit on empty bus Fix: TWAI transmit hangs on empty bus Aug 7, 2026
Comment thread esp-hal/src/twai/mod.rs
Comment on lines +1527 to +1531
#[cfg(any(esp32, esp32c3, esp32s2, esp32s3))]
let w = w.err_warn_int_ena().bit(enable);
#[cfg(any(esp32c6, esp32h2))]
let w = w.ext_err_warning_int_ena().bit(enable);
w

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:(

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes - we should align things

Comment thread esp-hal/src/twai/mod.rs
// status is still set. Gating on both ensures the bus-off state is
// signalled only once per entry, instead of on every error warning
// interrupt while the state persists.
if int_raw.bits() & 0b100 > 0 {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be a specific .bit_name().bit_is_set() IMO.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok - then I probably should align SVD/PACs first instead of unleash even more cfg hell here

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good idea

@bjoernQ

bjoernQ commented Aug 7, 2026

Copy link
Copy Markdown
Contributor Author

/hil full --test misc_drivers

@github-actions

github-actions Bot commented Aug 7, 2026

Copy link
Copy Markdown

Triggered full HIL run for #6070.

Run: https://github.com/esp-rs/esp-hal/actions/runs/31190456962

Status update: ✅ HIL (full) run succeeded.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

TWAI hangs when transmitting on an empty bus

2 participants