Skip to content

Conversation

@NeoHylde
Copy link

@NeoHylde NeoHylde commented Jan 13, 2026

Changes:

  • curr_error doesn't read PSR.BO/EW/EP.

Problem:
When awaiting can::read() / try_read(), if the CAN controller enters ErrorWarning or ErrorPassive, the future resolves immediately if the RxFifo's are empty and the CAN controller is in ErrorPassive or ErrorWarning.

For async functions this can result in tight polling loops that:

  • hog cpu
  • starve other async tasks

Root cause is treating a bus error state (BusPassive, BusWarning, BusOff) as an error. Error states reflect the TEC or REC registers exceeding certain numbers, while the LEC is the error last detected on the bus. Additionally, LEC may be "reset" on read, EW, EP, and BO do not.

Fix:
Read no longer reads BO, EW, EP registers in PSR registers.

Possible Future Changes
I would recommend seperating the error checks from the can read function, and creating a dedicated error checking function that is exposed through properties.

Meaning you can detect errors outside of reads, giving a bit more versatility.

@NeoHylde NeoHylde changed the title BusOFF, BusPassive, BusWarning removed from bus error BusOFF, BusPassive, BusWarning removed from curr_error in FDCAN and BXCAN Jan 13, 2026
@NeoHylde NeoHylde changed the title BusOFF, BusPassive, BusWarning removed from curr_error in FDCAN and BXCAN stm32: BusOFF, BusPassive, BusWarning removed from curr_error in FDCAN and BXCAN Jan 13, 2026
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.

1 participant