Repository navigation
feat: show each CAN bus's health in the settings - #127
Conversation
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01XkZEiX4By1AMegtzFhVwNo
A new "CAN buses" settings section, Bluetooth only, lists every bus the device reports in SystemState.can_bus_health: its status (OK, Silent, Errors, No valid frames, Bus-off) with what it means, whether it is listen-only, and its counters since the device started. canBusHealthProvider follows the current connection only, like the CAN access state, and replaces each reported bus's entry. Closes #30. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01XkZEiX4By1AMegtzFhVwNo
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01XkZEiX4By1AMegtzFhVwNo
The provider only started listening when the settings first showed the CAN buses section, so it missed the report sent when the app subscribes and showed "Waiting for the device" for up to 5 s. Seen on the WiCAN. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Hardware test: WiCAN (ESP32-C3) + virtual-carTested together with OpenCarControls/contracts#43 and OpenCarControls/firmware#115. Test 2 found a gap in this PR; the fix is pushed here as Setup
The PRs list no manual checks, so all tests come from reading the diffs. 1. [Analysis] The CAN buses row appears: passSettings → CAN buses shows "Bus 0 (listen-only) · Silent", "0 frames · 0 errors · 0 overruns · 0 bus-offs". This matches the serial log.
2. [Analysis] Bus health shown when Settings first opens: fail as submitted, pass with
|
| Time (UTC) | Event |
|---|---|
| 18:41:12.3 | Window report: listen-only |
| 18:41:14.8 | Write lock off: TWAI started in normal mode |
| 18:41:17.3 | Window report: (normal); the app updates, 2.5 s after the switch |
| 18:41:23.4 | Write lock on: TWAI started in listen-only mode |
| 18:41:27.3 | Window report: (listen-only); the app updates, 3.9 s after the switch |
Note on firmware#115:
- When the mode changes,
run_twai_sessionreturns without ending the RX window. The new mode reaches the app only when that window ends, up to 5 s later, rather than "right away". - The window that spans the switch is reported under the new mode.
- Neither blocks the PR. Ending the window on a mode change, as is done on bus-off, would make the update immediate.
4. [Analysis] No regression on the BLE link: pass
- About 20 minutes of serial log, including the extra bus health message every 5 s: no
BLE GATT TX dropped, queue-full or panic lines. - Car access and the dashboard kept updating.
5. [Analysis] Board reset with the app connected: pass
A watchdog reset while the app was on Settings. The row came back as soon as the app reconnected.
| Time (UTC) | Event |
|---|---|
| 18:43:21.8 | Boot: 1 bond, bus 0 in listen-only mode |
| 18:43:26.9 → | Bus 0 window reports every 5 s while the app is away |
| 18:43:56.3 | Phone reconnected (the app's 30 s retry gap) |
| 18:43:56.6 | Link encrypted |
| 18:43:57.6 | Subscribed; latest state resent and the row shows at once |
Unrelated observation
After adb install -r of the new APK, the BLE link seems to have stayed up. The log shows only a new subscribe at 18:38:44, with no new connect or encryption line.
Not tested
- The OK, Errors (degraded), No valid frames and Bus-off statuses, overruns, and the early report on bus-off. These need a live CAN bus; an in-car test with the E-GMP firmware is planned next.
- The PC SocketCAN path (no vcan here).
- MCP2515 (not implemented in this PR).
- The section being hidden over MQTT.
- iOS, a second phone, and ESP32-S3 (Xtensa) builds.
Hardware test in the car: WiCAN (ESP32-C3) + egmpTested together with OpenCarControls/contracts#43 and OpenCarControls/firmware#115. Setup
A. [Analysis] Car awake → OK: passThe app showed "Bus 0 (listen-only) · OK", "151409 frames · 0 errors · 0 overruns · 0 bus-offs" at 20:06:43 UTC. That matches the serial log's window sum exactly, up to the window that ended at 20:06:38.
About 2,160 frames/s, with 0 RX errors and 0 overruns. There were no B. [Analysis] Car going to sleep → Silent: skippedSkipped because the phone had to stay on USB in the car. The desk tests already showed Silent rendering correctly. C. [Analysis] Wrong bitrate (250 kbit/s, still listen-only) → No valid frames: failThe car was awake: about 10,800 frames per 5 s just before and just after the test. Bus 0 still reported Cause: the ESP TWAI driver never counts bus errors (bit, stuff, form, CRC, ACK). esp-hal 1.1.2's Follow-ups, in progress on this PR set:
Not tested in the car: bus-off (shouldn't be provoked on a car, and a listen-only controller can't go bus-off) and overruns (none seen). The WiCAN was flashed back to the 500 kbit/s build afterwards. |
A frame total only grows, and would saturate after a few weeks of a busy bus being awake, so the row shows the device's rate over the last few seconds instead. The No valid frames hint no longer points at configuration: firmwares are built per platform. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Frames per second: changes and in-car retestTogether with OpenCarControls/contracts#43 and OpenCarControls/firmware#115. Changes after the in-car test
Checks: Retest in the car: pass
Before merging: the firmware and app pins point at the contracts PR branch ( |
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01XkZEiX4By1AMegtzFhVwNo
What and why
Shows CAN bus health, part of OpenCarControls/firmware#12. Closes #30. The wire format is in OpenCarControls/contracts#43; the firmware side is OpenCarControls/firmware#115.
canBusHealthProvider: holdsSystemState.can_bus_healthfrom the current connection only, likecanAccessStateProvider:docs/architecture.mdanddocs/ui-screens.mdupdated. The HTML mockup indocs/ui/mockups/is not updated.The dev read-only toggle that #30 also mentions is already there: it's the developer write lock switch in
CanAccessSection.The contracts submodule bump is its own commit. It points at the contracts PR's branch commit, so it needs re-pinning once that PR merges.
How it was tested
test/can_bus_health_test.dart: the provider (live only, per-bus merge, other platform, MQTT), the wording, and a widget test of the section.dart format,flutter analyze --fatal-infos,flutter testand the Android APK build. Flutter isn't installed where I worked, so these were only run in CI.Checklist
dart format,flutter analyze --fatal-infosandflutter testpass (in CI)config.tomlor credentials committed; generated files not hand-editedSafety