feat(sim): drive the brake vote from the DI's hardwired switch (DI_VC_SHARED) #18

Merged
outlandnish merged 1 commit from feat/sim-di-wired-brake-switch into main 2026-09-11 10:15:00 -05:00
Owner

Models the stock DI_VC_SHARED brake-switch topology so the DI's own hardwired brake switch drives DI_brakePedalState on the bench — the mechanism an add-on inverter controller uses over CAN (it doesn't change the DIR's vote logic; it bridges CAN signals).

Firmware basis (12803, gen-28 2022.45.15)
The DIR broadcasts its own wired brake switch (GPADAT bit1, active-low) on 0x1D6 bit 33 (TX-table builder FUN_000a70f4), and votes DI_brakePedalState on VCLEFT 0x3C2 + iBooster 0x39D + ESP 0x38D. GTW_brakeLineSwitchType (0=DI_VC_SHARED, 1=VC_ONLY) is a VC-side wiring-topology flag — the DIR itself never reads it.

Sim changes

  • DI node broadcasts 0x1D6 bit33 from a settable wired-switch state (the virtual-car case; a real DIR/PMR sources 0x1D6 itself on the bench and the peers react to it).
  • VCLEFT relays 0x1D6 → VCLEFT_brakeSwitchPressed (0x3C2) when GTW_brakeLineSwitchType == DI_VC_SHARED (read live from GTW_carConfig 0x7FF mux3); in VC_ONLY it sources its own switch and ignores the DI report.
  • ESP / IBST mirror 0x1D6 into their brake posture (0x145 / 0x39D), so all three vote sources agree and the DI's plausibility supervisor doesn't fault the state to INVALID.
  • The dashboard brake toggle also drives the virtual DI switch, keeping the toggle and the mirror consistent.
  • tesla_frames: DI_BRAKE_SWITCH_ID/DI_BRAKE_SWITCH_BIT + di_brake_switch_pressed().

Tests: DI 0x1D6 broadcast, VCLEFT relay (shared) vs ignore (vc_only), carconfig mux3 read, ESP/IBST mirror, facade→DI. Full suite green (3163), ruff clean on changed files.

🤖 Generated with Claude Code

Models the stock **DI_VC_SHARED** brake-switch topology so the DI's own hardwired brake switch drives `DI_brakePedalState` on the bench — the mechanism an add-on inverter controller uses over CAN (it doesn't change the DIR's vote logic; it bridges CAN signals). **Firmware basis (12803, gen-28 2022.45.15)** The DIR broadcasts its own wired brake switch (GPADAT bit1, active-low) on **0x1D6 bit 33** (TX-table builder `FUN_000a70f4`), and votes `DI_brakePedalState` on VCLEFT 0x3C2 + iBooster 0x39D + ESP 0x38D. `GTW_brakeLineSwitchType` (`0=DI_VC_SHARED, 1=VC_ONLY`) is a VC-side wiring-topology flag — the DIR itself never reads it. **Sim changes** - **DI node** broadcasts 0x1D6 bit33 from a settable wired-switch state (the virtual-car case; a real DIR/PMR sources 0x1D6 itself on the bench and the peers react to it). - **VCLEFT** relays 0x1D6 → `VCLEFT_brakeSwitchPressed` (0x3C2) when `GTW_brakeLineSwitchType == DI_VC_SHARED` (read live from `GTW_carConfig` 0x7FF mux3); in VC_ONLY it sources its own switch and ignores the DI report. - **ESP / IBST** mirror 0x1D6 into their brake posture (0x145 / 0x39D), so all three vote sources agree and the DI's plausibility supervisor doesn't fault the state to INVALID. - The dashboard brake toggle also drives the virtual DI switch, keeping the toggle and the mirror consistent. - `tesla_frames`: `DI_BRAKE_SWITCH_ID`/`DI_BRAKE_SWITCH_BIT` + `di_brake_switch_pressed()`. Tests: DI 0x1D6 broadcast, VCLEFT relay (shared) vs ignore (vc_only), carconfig mux3 read, ESP/IBST mirror, facade→DI. Full suite green (3163), ruff clean on changed files. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
feat(sim): drive the brake vote from the DI's hardwired switch (DI_VC_SHARED)
Some checks failed
Tests / test (pull_request) Has been cancelled
1cdd7bdb40
Model the stock DI_VC_SHARED brake-switch topology so the DI's own wired switch
drives DI_brakePedalState on the bench -- the way an add-on inverter controller
does it over CAN. The DIR broadcasts its wired switch on 0x1D6 bit33; the peers
mirror it into the three brake-vote sources:

- DI node broadcasts 0x1D6 bit33 from a settable wired-switch state (the virtual-car
  case; a real DIR/PMR sources 0x1D6 itself on the bench and the peers react to it).
- VCLEFT relays 0x1D6 onto VCLEFT_brakeSwitchPressed (0x3C2) when
  GTW_brakeLineSwitchType == DI_VC_SHARED (read live from GTW_carConfig 0x7FF mux3);
  in VC_ONLY it sources its own switch and ignores the DI report.
- ESP and IBST mirror 0x1D6 into their brake posture (0x145 / 0x39D), so all three
  vote sources agree and the DI's plausibility supervisor doesn't fault to INVALID.
- The dashboard brake toggle also drives the virtual DI switch, keeping the toggle
  and the mirror consistent.

tesla_frames gains DI_BRAKE_SWITCH_ID/BIT + di_brake_switch_pressed().

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Sign in to join this conversation.
No reviewers
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
outlandnish/tm3diag!18
No description provided.