You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
ESP TWAI never counts RX bus errors, so a wrong bitrate looks silent #117
Seen on a WiCAN (ESP32-C3) in an E-GMP car with bus 0 built for 250 kbit/s on the 500 kbit/s M-CAN: every window read 0 frames, 0 RX errors, while the car was sending about 2,160 frames/s (#115 in-car test C).
Cause (esp-hal 1.1.2)
TwaiRx::receive_async only returns a frame, EspTwaiError::BusOff or Overrun. The Bit/Stuff/Crc/Form/Acknowledge kinds exist but are never returned.
handle_interrupt reads err_code_cap on a bus-error interrupt and discards it: "We might want to use the error code to gather statistics in the future."
receive_error_count() doesn't help in listen-only mode: esp-hal sets REC to 128 before leaving reset mode (errata workaround for ESP32/S2/S3/C3), and the counters stay frozen in listen-only mode.
Options
Upstream: have esp-hal count or expose bus errors (a counter in the async state, or an error-code callback), then count them in boards/esp/src/can.rs.
Local: patch esp-hal ([patch.crates-io]) the same way until upstream has it.
Check whether the bus-error interrupt still fires in listen-only mode on the C3 with REC frozen; if it doesn't, this can only work in normal mode.
Done when
A WiCAN at a wrong bitrate on a live bus reports RX errors with no frames: the serial line shows them, and the app shows "No valid frames".
Activity
feat(can): report each bus's frames per second
feat(can): report each bus's health to the app over BLE (#115)