CAN raw logger + toggle fix; wiki: first live capture confirms ID map
Firmware — make the board a working CAN sniffer and fix real bugs: - can_driver: add raw candump-style logger (CANRAW,<ts>,<id>,<extd>,<dlc>,<hex>), capturing every frame incl. unknown IDs for offline decoding. Single atomic write per frame. - serial_lock: new global serial mutex so concurrent task writes (CAN logger, UART 5Hz log, heartbeat) no longer splice mid-line. Corruption 3.2% -> 1.4%. - Fix CAN toggle: the switch had no event handler registered, so it never started CAN and reverted on screen change. Wire up onCANBusToggle. - platformio: route Serial to native USB-CDC (USB_MODE=1, CDC_ON_BOOT=1) so the ~486 frame/s stream isn't throttled by the 115200 UART ceiling; bump monitor baud to 921600. - tools/fix_toolchain_path.py: pre-build workaround for pioarduino nesting the Xtensa toolchain bin under a subdir that never reaches PATH. - Correct misleading "LISTEN_ONLY" log string (driver runs TWAI_MODE_NORMAL). Wiki — ingest the first live capture off the real swap bus: - raw/can-capture-2026-07-15-gearshift.csv (20,596 frames) + sources page. - Research map CONFIRMED: 0x1D0/0x1D2/0x0B5/0x3B4 all live; placeholder IDs (0x4F/0x55/0x201/0x1001/0x101F) verified absent; 0x130/0x304/0x192 absent. - 0x1D0 b0 coolant drifts up (37->40C, -48 holds); 0x1D0 b1 oil temp = 0xFF. - 0x1D2 gear encoding resolved: DLC 6, byte0 gear codes (E1=P, B4=N, 78=D live). - Corrected LISTEN_ONLY -> NORMAL/ACK across pages; documented non-isolated TJA1051 grounding requirement. Updated index + log. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
---
|
||||
type: concept
|
||||
tags: [can-bus, reverse-engineering]
|
||||
updated: 2026-07-15
|
||||
updated: 2026-07-16
|
||||
---
|
||||
|
||||
# CAN Bus Integration
|
||||
@@ -10,10 +10,14 @@ The core technical challenge of the project: reading real data from the [[bmw-m5
|
||||
|
||||
## Current firmware state (repo)
|
||||
|
||||
- ESP32-S3 TWAI peripheral, 500 kbps, **LISTEN_ONLY** mode (cannot disturb the bus — good).
|
||||
- ESP32-S3 TWAI peripheral, 500 kbps.
|
||||
- Falls back to dummy simulated data when CAN is off or failing.
|
||||
- **Raw frame logger (repo, added 2026-07-15):** every received frame is streamed over USB-CDC as `CANRAW,<ts_ms>,<id>,<extd>,<dlc>,<hex>`, serialized by a mutex so lines don't interleave. This is how [[can-capture-2026-07-15]] was taken — the board is now its own CAN sniffer. Logs are tethered-only (no onboard SD recording yet; the board has a microSD slot for a future "black box").
|
||||
- Configured message map:
|
||||
|
||||
> [!warning] The firmware is NOT in LISTEN_ONLY mode — it ACKs the bus
|
||||
> Despite older comments/docs saying "LISTEN_ONLY", the TWAI driver is installed in **`TWAI_MODE_NORMAL`** `(repo)` — a deliberate choice so it sends ACK bits and stops transmitters from flooding retries. Consequences: (1) the board is an **active bus participant**, not a passive sniffer — correct on a live multi-ECU bus, but do NOT power it in ACK mode on a bench with a single other node and no termination. (2) The onboard **TJA1051T/3 transceiver is non-isolated**, so its ground MUST be common with the vehicle (simplest: power the board from vehicle 12 V, whose negative *is* the reference). A flaky ground on an actively-ACKing node causes intermittent bus errors that look like data problems. → [[esp32-s3-touch-lcd-5b]]
|
||||
|
||||
| ID | Byte(s) | Mapped to |
|
||||
|--------|---------|-----------|
|
||||
| 0x4F | 0 | Coolant temp |
|
||||
@@ -25,14 +29,14 @@ The core technical challenge of the project: reading real data from the [[bmw-m5
|
||||
> [!warning] These IDs are almost certainly placeholders, not real BMW IDs.
|
||||
> Two red flags: (1) `0x1001` and `0x101F` exceed `0x7FF`, the maximum for standard 11-bit CAN identifiers — BMW E-series PT-CAN of the M57N era uses 11-bit frames `(unverified)`, so these would never match. (2) None of the five IDs appear in community BMW reverse-engineering documentation. The map needs to be rebuilt from real bus captures or a trustworthy source before any of the displayed data can be believed.
|
||||
|
||||
> [!info] Research done 2026-07-15
|
||||
> Web research produced a replacement candidate map — **0x1D0** (coolant + oil temp), **0x1D2** (gear), **0x0B5** (gearbox temp), **0x3B4** (battery voltage) — with confidence ratings and two layout disputes to settle on the bench. Full table and sources: [[can-id-candidates]]. Fault codes are NOT passively broadcast (diagnostic requests required) — the `fault_codes` field needs a design decision.
|
||||
> [!info] Research done 2026-07-15, then CONFIRMED live
|
||||
> Web research produced a replacement candidate map — **0x1D0** (coolant + oil temp), **0x1D2** (gear), **0x0B5** (gearbox temp), **0x3B4** (battery voltage) — with confidence ratings and two layout disputes to settle on the bench. Full table and sources: [[can-id-candidates]]. The first live capture ([[can-capture-2026-07-15]]) confirmed all four IDs are present and resolved the 0x1D2 gear encoding. Fault codes are NOT passively broadcast (diagnostic requests required) — the `fault_codes` field needs a design decision.
|
||||
|
||||
## Verification plan
|
||||
|
||||
1. Get a raw capture of the actual bus (candump / Savvy CAN / cheap USB-CAN dongle) with the engine running. File the log into `raw/`.
|
||||
2. Identify candidate IDs by watching which bytes track known physical behavior (rev the engine, warm it up, shift gears).
|
||||
3. Cross-check against community DBC files / reverse-engineering wikis for the donor vehicle.
|
||||
1. ~~Get a raw capture of the actual bus. File the log into `raw/`.~~ ✅ **Done** 2026-07-15 with the board's own logger → `raw/can-capture-2026-07-15-gearshift.csv`, summarized in [[can-capture-2026-07-15]]. **Still needed: a cold-start + confirmed-engine-running capture** to lock coolant/battery scaling (the first capture's engine state was unconfirmed and the battery/oil-temp bytes were dormant).
|
||||
2. Identify candidate IDs by watching which bytes track known physical behavior (rev the engine, warm it up, shift gears). *In progress:* gear (0x1D2) done; coolant drift seen; RPM/battery pending. Use a **differential capture** for gear (hold each position, diff steady states) rather than a continuous sweep.
|
||||
3. Cross-check against community DBC files / reverse-engineering wikis for the donor vehicle. ✅ done → [[can-id-candidates]].
|
||||
4. Update `automotive_data.h` `(repo)` and mark each mapping `(verified)` here only after it matches reality on the live bus.
|
||||
|
||||
## Signal-source caveat
|
||||
|
||||
@@ -1,13 +1,22 @@
|
||||
---
|
||||
type: synthesis
|
||||
tags: [can-bus, reverse-engineering, e60, research]
|
||||
updated: 2026-07-15
|
||||
updated: 2026-07-16
|
||||
---
|
||||
|
||||
# E60/E65 CAN ID Candidates (Research Results)
|
||||
|
||||
Findings from the 2026-07-15 deep-research run (95 claims extracted from ~15 sources, 30 adversarially verified against primary repos before the run was interrupted; synthesis done manually from the journal). These are the IDs to program into the firmware **for bench testing against a live capture** — none are `(verified)` until seen on the actual swap's bus.
|
||||
|
||||
> [!success] Live capture 2026-07-15 — the map is CONFIRMED on the real bus
|
||||
> First dump off the actual swap's bus ([[can-capture-2026-07-15]]) validates the research:
|
||||
> - **All four signal IDs are live**: `0x1D0`, `0x1D2`, `0x0B5`, `0x3B4` (+ bonus `0x0AA`, `0x0BA`). (verified: present)
|
||||
> - The firmware's placeholder IDs are **absent** — confirmed junk. (verified: absent)
|
||||
> - `0x1D0` byte0 drifts up `0x55→0x58` = coolant warming (−48 scaling holds). **Oil temp `0x1D0` byte1 = `0xFF`** (not populated here).
|
||||
> - `0x1D2` **encoding dispute resolved**: DLC 6, byte0 whole-byte gear codes — `0xE1`=P, `0xB4`=N, `0x78`=D seen live.
|
||||
> - Absent despite being researched: `0x130`, `0x304`, `0x192`.
|
||||
> - Still needs a **cold-start + confirmed-engine-running** capture to lock scaling on coolant/battery. See the source page for the full table.
|
||||
|
||||
## The map (replaces the firmware's placeholder IDs)
|
||||
|
||||
| Signal | CAN ID | Bytes | Scaling | Sender | Rate | Confidence |
|
||||
@@ -29,7 +38,7 @@ Findings from the 2026-07-15 deep-research run (95 claims extracted from ~15 sou
|
||||
|
||||
## Field checklist for the live capture session
|
||||
|
||||
Setup: 500 kbps, listen-only, board's 120 Ω termination switch **OFF**, tap CAN-H/CAN-L on the PT-CAN. **Log everything raw for the whole session** and save the dump into `wiki/raw/` — even IDs we don't care about yet.
|
||||
Setup: 500 kbps, board's 120 Ω termination switch **OFF**, common ground with the vehicle, tap CAN-H/CAN-L on the PT-CAN. (Note: the firmware runs `TWAI_MODE_NORMAL` and ACKs the bus — not listen-only — see [[can-bus-integration]].) **Log everything raw for the whole session** and save the dump into `wiki/raw/` — even IDs we don't care about yet.
|
||||
|
||||
| Test | Watch | Confirms |
|
||||
|------|-------|----------|
|
||||
@@ -73,8 +82,8 @@ Also useful: an E60 forum claim `(unverified)` that arbitration IDs are identica
|
||||
|
||||
- No source used an actual **E60 M57N diesel** end-to-end; the closest anchors are the E60 tool32 table (lists DDE1 as sender for 0x1D0/0x3B4), the E60 VFL spreadsheet (real pre-facelift E60, engine variant unknown), and the M57 dieslg8 project (different chassis generation). Engine-side layouts are inferred from petrol DME captures of the same bus generation.
|
||||
- **Oil temp and gearbox oil temp remain the weakest signals** — absent from both E60-specific sources; only the E9x DBC and E65 docs place oil temp at 0x1D0 byte 1, and only the E9x DBC has gearbox temp (0x0B5 byte 7, offset disputed).
|
||||
- Firmware's current IDs (`0x4F`, `0x55`, `0x201`, `0x1001`, `0x101F`) are contradicted by every source — confirmed placeholders. → [[can-bus-integration]]
|
||||
- Promotion to `(verified)` requires a live capture from the swap's bus: warm the engine and watch 0x1D0 byte 0 climb, shift through P/R/N/D and watch 0x1D2.
|
||||
- Firmware's current IDs (`0x4F`, `0x55`, `0x201`, `0x1001`, `0x101F`) are contradicted by every source AND **confirmed absent from the live bus** (verified, 2026-07-15) — definitively placeholders. → [[can-bus-integration]]
|
||||
- Promotion to `(verified)` requires a live capture from the swap's bus: warm the engine and watch 0x1D0 byte 0 climb, shift through P/R/N/D and watch 0x1D2. **Partially done** 2026-07-15 ([[can-capture-2026-07-15]]): IDs + 0x1D2 gear codes verified; coolant/battery scaling still needs a cold-start capture with confirmed engine state.
|
||||
|
||||
## Related
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
---
|
||||
type: entity
|
||||
tags: [hardware, waveshare, display]
|
||||
updated: 2026-07-15
|
||||
updated: 2026-07-16
|
||||
---
|
||||
|
||||
# Waveshare ESP32-S3-Touch-LCD-5B
|
||||
@@ -28,8 +28,10 @@ Controller A of the [[dual-controller-architecture]] — the main in-cabin displ
|
||||
## CAN interface (source: waveshare-wiki)
|
||||
|
||||
- **Onboard TJA1051T/3/1J transceiver**, CAN 2.0, on a 3.5 mm terminal block — wire CAN-H/L straight in. ✅ resolves the transceiver question
|
||||
- **Non-isolated** — its ground must be common with the vehicle. Simplest: power the board from vehicle 12 V (the 7–36 V input's negative *is* the CAN reference). Grounding-only + USB power also works, but keep the logging laptop **on battery** to avoid a mains-earth ↔ chassis ground loop.
|
||||
- **120 Ω termination switch, OFF by default — leave it off** when tapping an existing vehicle bus (the bus is already terminated at both ends).
|
||||
- Firmware drives it via TWAI on GPIO 15 TX / 16 RX, 500 kbps, LISTEN_ONLY `(repo)`.
|
||||
- Firmware drives it via TWAI on GPIO 15 TX / 16 RX, 500 kbps, **`TWAI_MODE_NORMAL`** `(repo)` — it **ACKs the bus** (active participant), *not* LISTEN_ONLY as older docs claimed. Deliberate, to stop transmitters retry-flooding. → [[can-bus-integration]]
|
||||
- **Raw CAN logger** `(repo, 2026-07-15)`: streams every frame as `CANRAW,...` over native USB-CDC (`Serial` remapped to USB-CDC, ~1 MB/s, so it keeps up with the ~486 frame/s bus). First capture: [[can-capture-2026-07-15]].
|
||||
|
||||
## Other interfaces
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
---
|
||||
type: synthesis
|
||||
tags: [meta, todo]
|
||||
updated: 2026-07-15
|
||||
updated: 2026-07-16
|
||||
---
|
||||
|
||||
# Open Questions
|
||||
@@ -10,7 +10,7 @@ The research frontier. Answering any of these should trigger updates across the
|
||||
|
||||
## Blocking
|
||||
|
||||
1. **What are the real CAN IDs for the E60/E65-generation M57N data we want?** The firmware's current map is placeholder-quality — two IDs aren't even valid 11-bit identifiers. Needs web research (in progress 2026-07-15) + a live bus capture to verify. → [[can-bus-integration]]
|
||||
1. **What are the real CAN IDs for the E60/E65-generation M57N data we want?** *Largely answered 2026-07-15.* Research produced the map and the **first live capture confirmed it** ([[can-capture-2026-07-15]]): `0x1D0` (coolant), `0x1D2` (gear, encoding resolved), `0x0B5`, `0x3B4` all live; placeholder IDs confirmed absent. **Remaining:** a cold-start + confirmed-engine-running capture to lock coolant/battery *scaling* (first capture's engine state was unconfirmed; battery + oil-temp bytes were dormant/`0xFF`). → [[can-bus-integration]]
|
||||
|
||||
## Project context
|
||||
|
||||
@@ -30,6 +30,8 @@ The research frontier. Answering any of these should trigger updates across the
|
||||
- ~~Is the EGS on the bus?~~ → **Yes — BMW auto with EGS wired in**; gearbox temp and gear position have a real source. (verified — user, 2026-07-15)
|
||||
- ~~Is the target a Nissan Patrol?~~ → **Yes.** (verified — user, 2026-07-15) → [[nissan-patrol-swap]]
|
||||
- ~~CAN transceiver?~~ → **Onboard TJA1051T/3/1J** on a terminal block; leave the 120 Ω termination switch OFF when tapping the vehicle bus. (source: waveshare-wiki, 2026-07-15) → [[esp32-s3-touch-lcd-5b]]
|
||||
- ~~Does passive-ish listening actually work on this bus?~~ → **Yes** — first live capture pulled 15 IDs cleanly at ~486 frame/s (verified, 2026-07-15). Note the firmware runs `TWAI_MODE_NORMAL` (ACKs), not LISTEN_ONLY. → [[can-capture-2026-07-15]]
|
||||
- ~~How to ground the board to the vehicle?~~ → TJA1051 is **non-isolated**; share ground with the vehicle (power from 12 V, or ground-wire + laptop on battery to avoid a ground loop). (verified, 2026-07-15) → [[esp32-s3-touch-lcd-5b]]
|
||||
- ~~12 V → 5 V power conversion?~~ → **Not needed**: board has a 7–36 V DC wide input. Residual transient concern moved to #6. (source: waveshare-wiki, 2026-07-15)
|
||||
|
||||
## Sourcing wishlist
|
||||
|
||||
Reference in New Issue
Block a user