Gear decode VERIFIED: real 0x1D2 map in firmware + wiki
The gear lever is fully decoded and confirmed on the actual swap bus (raw/gear_box_can_revealings.csv): 0x1D2 byte0 = P 0xE1 / R 0xD2 / N 0xB4 / D 0x78, matching the documented BMW codes exactly. Byte4 splits D vs S/M (0xF0 auto) and carries manual +/- shifts. Firmware: - automotive_data.h: replace placeholder gear map (0x1001) with CAN_ID_GEAR_LEVER 0x1D2, verified byte-0 codes, byte-4 mode define, and can_to_gear_lever(). - can_driver.cpp: decode 0x1D2 byte0 into gear_position via the enum; reject unrecognized codes instead of copying the raw byte. - Scope: P/R/N/D only (verified). S/M shows as D for now (no enum slot; engaged gear number needs a drive capture) — TODO'd, not faked. Coolant/oil/battery left as flagged placeholders pending a cold-start capture. Wiki: - New source page gear-box-can-revealings + raw CSV filed. - can-id-candidates: 0x1D2 gear row -> VERIFIED; encoding "dispute" section rewritten with the full lever+mode decode table. - Updated index + log. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -100,9 +100,18 @@ typedef struct __attribute__((packed)) {
|
||||
#define CAN_ID_GEARBOX_TEMP 0x201 // Gearbox oil temperature
|
||||
#define CAN_BYTE_GEARBOX_TEMP 3 // Byte 3
|
||||
|
||||
#define CAN_ID_GEARBOX_DATA 0x1001 // Gearbox position and current gear
|
||||
#define CAN_BYTE_GEAR_POS 0 // Byte 0 (P/R/N/D/S/M)
|
||||
#define CAN_BYTE_CURRENT_GEAR 1 // Byte 1 (1-8)
|
||||
// Gear lever position — EGS "TransmissionDataDisplay", DLC 6.
|
||||
// VERIFIED on the swap bus 2026-07-16 (see wiki/sources/gear-box-can-revealings.md).
|
||||
#define CAN_ID_GEAR_LEVER 0x1D2 // Gear lever position message
|
||||
#define CAN_BYTE_GEAR_LEVER 0 // Byte 0: lever code (see can_to_gear_lever)
|
||||
#define CAN_BYTE_GEAR_MODE 4 // Byte 4: 0xF0=Drive(auto), 0xF1=Sport/Manual, 0xF2=downshift(-)
|
||||
|
||||
// Raw byte-0 lever codes (whole-byte encoding, all verified against the live bus)
|
||||
#define GEAR_CODE_PARK 0xE1
|
||||
#define GEAR_CODE_REVERSE 0xD2
|
||||
#define GEAR_CODE_NEUTRAL 0xB4
|
||||
#define GEAR_CODE_DRIVE 0x78 // also S/M side-gate — split via CAN_BYTE_GEAR_MODE
|
||||
#define GEAR_MODE_DRIVE_AUTO 0xF0 // byte 4 value when in plain Drive (else Sport/Manual)
|
||||
|
||||
#define CAN_ID_BATTERY_VOLTAGE 0x101F // Battery voltage (16-bit)
|
||||
#define CAN_BYTE_BATTERY_VOLT_H 0 // Byte 0 (high byte)
|
||||
@@ -179,6 +188,24 @@ static inline uint16_t can_to_voltage(uint16_t can_value) {
|
||||
return can_value * 10; // Convert 0.1V to 0.01V units
|
||||
}
|
||||
|
||||
/**
|
||||
* Map a raw 0x1D2 byte-0 lever code to a gear_position_t.
|
||||
* D and S/M share code 0x78 — they're distinguished by byte 4 (CAN_BYTE_GEAR_MODE),
|
||||
* not surfaced here yet (no enum slot; the engaged manual gear number needs a drive
|
||||
* capture — see wiki/pages/open-questions.md).
|
||||
* @param d0 Byte 0 of a 0x1D2 frame
|
||||
* @return Gear position, or GEAR_UNKNOWN if the code isn't recognized
|
||||
*/
|
||||
static inline gear_position_t can_to_gear_lever(uint8_t d0) {
|
||||
switch (d0) {
|
||||
case GEAR_CODE_PARK: return GEAR_PARK;
|
||||
case GEAR_CODE_REVERSE: return GEAR_REVERSE;
|
||||
case GEAR_CODE_NEUTRAL: return GEAR_NEUTRAL;
|
||||
case GEAR_CODE_DRIVE: return GEAR_DRIVE; // D or S/M
|
||||
default: return GEAR_UNKNOWN;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get human-readable gear position string
|
||||
* @param gear Gear position enum value
|
||||
|
||||
+12
-11
@@ -89,17 +89,18 @@ static bool parseCANMessage(const twai_message_t& message) {
|
||||
}
|
||||
break;
|
||||
|
||||
case CAN_ID_GEARBOX_DATA:
|
||||
// Gearbox position and current gear (bytes 0 and 1)
|
||||
if (message.data_length_code > CAN_BYTE_CURRENT_GEAR) {
|
||||
// Byte 0: Gear position (P/R/N/D/S/M)
|
||||
g_automotive_data.gear_position = data[CAN_BYTE_GEAR_POS];
|
||||
|
||||
// Byte 1: Current gear number (1-8) - stored for future use
|
||||
// Could be displayed alongside position for manual modes
|
||||
|
||||
g_automotive_data.valid_flags |= VALID_FLAG_GEAR_POS;
|
||||
parsed = true;
|
||||
case CAN_ID_GEAR_LEVER:
|
||||
// Gear lever position from the EGS (0x1D2) — verified on the swap bus
|
||||
// 2026-07-16. Byte 0 is a whole-byte lever code (E1=P, D2=R, B4=N, 78=D/S-M).
|
||||
// Byte 4 (CAN_BYTE_GEAR_MODE) splits D vs S/M and carries manual +/- shifts;
|
||||
// not surfaced yet (no enum slot; the engaged gear number needs a drive capture).
|
||||
if (message.data_length_code > CAN_BYTE_GEAR_LEVER) {
|
||||
gear_position_t g = can_to_gear_lever(data[CAN_BYTE_GEAR_LEVER]);
|
||||
if (g != GEAR_UNKNOWN) {
|
||||
g_automotive_data.gear_position = (uint8_t)g;
|
||||
g_automotive_data.valid_flags |= VALID_FLAG_GEAR_POS;
|
||||
parsed = true;
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
|
||||
@@ -29,3 +29,4 @@ Catalog of every page in the wiki. Read this first when answering questions. Kee
|
||||
- [[e60-vfl-can-codes-xlsx]] — community E60 pre-facelift CAN table (ingested 2026-07-15); E60-specific confirmation of 0x1D0/0x3B4, new 0x304 gear-lever candidate
|
||||
- [[listen-and-send-pid-arduino]] — Arduino ELM327→E46-cluster sketch (ingested 2026-07-15); technique reference for a diagnostic-request fallback, not ID evidence
|
||||
- [[can-capture-2026-07-15]] — **first live CAN dump off the real swap bus** (captured with the board's own logger); confirms 15 IDs incl. all four signal IDs, resolves the 0x1D2 gear encoding, verifies placeholder IDs absent; raw at `raw/can-capture-2026-07-15-gearshift.csv`
|
||||
- [[gear-box-can-revealings]] — **gear lever fully decoded & VERIFIED** (2026-07-16): 0x1D2 byte0 = P/R/N/D codes, byte4 = D-vs-S/M + manual +/− shift; raw at `raw/gear_box_can_revealings.csv`
|
||||
|
||||
@@ -22,6 +22,10 @@ Deep-research workflow ran (interrupted twice by session task-loss on Windows; ~
|
||||
|
||||
User confirmed: donor chassis is **E60/E65 (2003+)**, transmission is a **BMW auto with EGS on the CAN bus**, target vehicle is a **Nissan Patrol**. Created [[nissan-patrol-swap]]; updated [[bmw-m57n-engine]] (E46-era candidate IDs flagged as probably wrong generation) and [[open-questions]] (three questions moved to Answered). Next: web research for E60-generation PT-CAN broadcast IDs.
|
||||
|
||||
## [2026-07-16] ingest | Gear lever fully decoded & VERIFIED (0x1D2)
|
||||
|
||||
User captured steady byte values per lever detent (`raw/gear_box_can_revealings.csv`) → [[gear-box-can-revealings]]. **0x1D2 verified as the gear source**: byte0 = P `0xE1` / R `0xD2` / N `0xB4` / D `0x78` (all match documented codes exactly); byte0 can't split D from S/M (shared `0x78`) so byte4 does it (`0xF0` auto / `0xF1` Sport-Manual / `0xF2` downshift −); byte1 is a drive-gate flag (`0x0F`→`0x5F`); byte3 = rolling counter (confirms prediction). 0x0BA also tracks the lever but is messier (D/S-M collide) — don't use. Promoted 0x1D2 gear row to VERIFIED and rewrote the encoding-dispute section in [[can-id-candidates]]; updated index. Still open: actual engaged gear number (needs a drive capture) and the manual up-shift (+) value. Next: rewrite firmware gear map to 0x1D2 byte0 (+byte4).
|
||||
|
||||
## [2026-07-16] ingest | First live CAN capture — research map CONFIRMED
|
||||
|
||||
First real dump off the swap's bus, taken with the board's **own new raw-frame logger** (`(repo)`; USB-CDC stream, serial mutex, ~486 frame/s, ~1.4% line loss). Raw filed at `raw/can-capture-2026-07-15-gearshift.csv` (20,596 frames) → [[can-capture-2026-07-15]]. Findings: 15 IDs live incl. **all four researched signal IDs** (0x1D0, 0x1D2, 0x0B5, 0x3B4) + bonus 0x0AA/0x0BA; firmware's placeholder IDs (0x4F/0x55/0x201/0x1001/0x101F) **verified absent**; researched-but-absent: 0x130/0x304/0x192. **0x1D0 b0** drifts 0x55→0x58 (coolant −48, ~37→40 °C); **0x1D0 b1 = 0xFF** (oil temp unpopulated). **0x1D2 gear encoding resolved**: DLC 6, byte0 whole-byte codes (0xE1=P, 0xB4=N, 0x78=D seen live). **0x3B4** at ~5 s rate but payload dormant (0xFF) — engine state unconfirmed. Updated [[can-id-candidates]], [[can-bus-integration]], [[esp32-s3-touch-lcd-5b]], [[open-questions]], index. Also corrected a firmware fact across pages: driver runs **`TWAI_MODE_NORMAL` (ACKs the bus), not LISTEN_ONLY**; TJA1051 is non-isolated → must share vehicle ground. Next: cold-start + confirmed-engine-running capture to lock coolant/battery scaling; use differential (per-position) captures for gear.
|
||||
|
||||
@@ -13,7 +13,7 @@ Findings from the 2026-07-15 deep-research run (95 claims extracted from ~15 sou
|
||||
> - **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.
|
||||
> - `0x1D2` **gear fully VERIFIED** (2026-07-16, [[gear-box-can-revealings]]): byte0 `0xE1`=P/`0xD2`=R/`0xB4`=N/`0x78`=D — all codes match; byte4 splits D vs S/M and carries manual +/− shifts.
|
||||
> - 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.
|
||||
|
||||
@@ -24,17 +24,26 @@ Findings from the 2026-07-15 deep-research run (95 claims extracted from ~15 sou
|
||||
| Coolant temp | **0x1D0** | byte 0 | °C = raw − 48 | DME/DDE | 100 ms | **Very high** — verified verbatim in E65 docs, present in E90-gen DBC, confirmed live on a real E60 545i, E60 tool32 table lists 0x1D0 "Motordaten" from DDE1 (diesel!), and the [[e60-vfl-can-codes-xlsx]] sheet shows 0x7A→74 °C on a real E60 VFL (raw−48 checks out) |
|
||||
| Engine oil temp | **0x1D0** | byte 1 | °C = raw − 48 | DME/DDE | 100 ms | **High** — same sources as coolant |
|
||||
| Gearbox oil temp | **0x0B5** ("Torque_request_EGS") | byte 7 | ⚠ disputed: raw + 0 vs raw + 40 | EGS | ? | **Medium** — in the E9x community DBC; absent from the E65 repo's decoded EGS messages. Offset must be settled on the bench (a ~40 °C error is dangerous — resolve before trusting) |
|
||||
| Gear lever position | **0x1D2** ("TransmissionDataDisplay") | byte 0 | ⚠ two encodings, see below | EGS | 200 ms | **High that the ID is right**, medium on layout |
|
||||
| Gear lever position | **0x1D2** ("TransmissionDataDisplay") | **byte 0** | `0xE1`=P `0xD2`=R `0xB4`=N `0x78`=D/(S/M); split D vs S/M with byte 4 (`0xF0` auto / `0xF1` S-M) | EGS | 200 ms | **✅ VERIFIED on the swap bus 2026-07-16** — every code matches. Full decode: [[gear-box-can-revealings]] |
|
||||
| Current gear number | **0x1D2** byte 1 upper nibble (GearAct, −4 offset) or **0x0BA** bits 0–3 (E65: values P/R/N…6th) | | | EGS | 20–200 ms | **Medium** — two candidate messages; also **0x304** "Gear lever" — the E60 VFL sheet shows a 2-byte lever message: P=0xE3, R=0xC2, N=0xD1, M=0xC9 (its D=0xC2 duplicates R — likely a sheet typo) |
|
||||
| Battery voltage | **0x3B4** ("Powermanagement Batteriespannung") | ⚠ disputed layout | 12-bit LE × 0.015 V (E65, verified: 0x3D9→14.775 V) vs 24-bit BE × 0.001 V (E90 DBC) | Power module / DDE | 5 s (E65) | **High on ID** (E60 tool32 table + E60 VFL sheet: `64 F3`→12.76 V, consistent with the 12-bit LE layout though implying factor ≈0.0147 vs 0.015). Bonus from the sheet: byte 3 = engine running flag (0x09 on / 0x00 off) |
|
||||
| Engine RPM (bonus) | **0x0AA** | bytes 4–5 | RPM = raw / 4 | DME/DDE | 10 ms | High — cross-generation (E65 + E90 comment) |
|
||||
| Ignition/terminal status (bonus) | **0x130** | byte 0 bitmasks | 0xD5/0xC5/0xC1 | CAS | 100 ms | Medium — used by an M57 project as its only passive decode |
|
||||
|
||||
### The 0x1D2 encoding dispute (must resolve on bench)
|
||||
### The 0x1D2 encoding dispute — ✅ RESOLVED on the swap bus (2026-07-16)
|
||||
|
||||
- **E90-generation DBC**: low nibble of byte 0 = 1=P, 2=R, 4=N, 8=D (bitmask style, XOR-inverted copy in high nibble); 2-bit ShiftLeverMode at bit 32 (0=Normal, 1=Sport, 2=Manual). DLC 6.
|
||||
- **E65 live capture** (damienmaguire, verified against code): whole byte 0 = 0xE1=P, 0xD2=R, 0xB4=N, 0x78=D; byte 3 is a rolling counter 0x0D→0xED in steps of 0x10. DLC **5**.
|
||||
- Same ID, different generation dialects — the E60 could speak either. Note the E65 byte-0 values are consistent with the E90 nibble scheme (0xE1 low nibble = 1 = P, 0xD2 → 2 = R, 0xB4 → 4 = N, 0x78 → 8 = D, high nibble = XOR-inverted copy!) — so the two sources may actually agree and the "dispute" is notation. Bench capture decides.
|
||||
The live lever capture ([[gear-box-can-revealings]]) settles it — **DLC 6**, whole-byte codes in byte 0, matching the documented table exactly:
|
||||
|
||||
| Byte | Meaning | Values |
|
||||
|------|---------|--------|
|
||||
| **0** | **Lever position** | `0xE1`=P, `0xD2`=R, `0xB4`=N, `0x78`=D **and** S/M |
|
||||
| 1 | Drive-gate flag | `0x0F` in P/R/N, `0x5F` in D + S/M |
|
||||
| 3 | Rolling counter | fluctuates — ignore (matches the predicted byte-3 counter) |
|
||||
| **4** | **Mode / manual shift** | `0xF0`=Drive(auto), `0xF1`=Sport/Manual, `0xF2`=downshift (−); up-shift (+) unconfirmed |
|
||||
|
||||
Byte 0 alone gives P/R/N/D; byte 4 splits **D vs S/M** (Steptronic side-gate) and carries the manual +/− nudges. The old "dispute" was just notation — the E65 whole-byte values and the E90 low-nibble scheme agree (`0xE1` low nibble = 1 = P, etc.), and this bus speaks the whole-byte/DLC-6 dialect.
|
||||
|
||||
> The firmware's `automotive_data.h` gear map should be rewritten to `0x1D2` byte 0 (+ byte 4 for S/M). → [[can-bus-integration]]
|
||||
|
||||
## Field checklist for the live capture session
|
||||
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
ADDR,LEN,D0,D1,D2,D3,D4,D5,D6,D7,Position
|
||||
0BA,8,3,255,15,0,0,,,239,P
|
||||
0BA,8,2,132,1,0,0,,,207,R
|
||||
0BA,8,1,255,15,0,0,,,223,N
|
||||
0BA,8,5,220,1,0,0,,,207,D
|
||||
0BA,8,5,220,1,0,0,,,207,M/S
|
||||
1D2,6,225,15,255,,240,255,,,P
|
||||
1D2,6,210,15,255,,240,255,,,R
|
||||
1D2,6,180,15,255,,240,255,,,N
|
||||
1D2,6,120,95,255,,240,255,,,D
|
||||
1D2,6,120,95,255,,241,255,,,M/S
|
||||
|
@@ -0,0 +1,46 @@
|
||||
---
|
||||
type: source
|
||||
tags: [can-bus, capture, verified, gear, egs, e60]
|
||||
updated: 2026-07-16
|
||||
---
|
||||
|
||||
# Gearbox Lever Decode — 2026-07-16 (VERIFIED)
|
||||
|
||||
Second, cleaner capture focused on the gear lever: the user moved the Steptronic selector through every detent and recorded the steady byte values per position. Raw table at `raw/gear_box_can_revealings.csv`. This **verifies `0x1D2` as the gear source on the actual swap bus** and fully decodes the lever, including the D-vs-S/M gate and the manual +/− shift signal.
|
||||
|
||||
Two IDs react to the lever: **`0x1D2`** (clean, use this) and **`0x0BA`** (secondary, messier).
|
||||
|
||||
## `0x1D2` (DLC 6) — the gear lever ✅ VERIFIED
|
||||
|
||||
| Lever | D0 | D1 | D4 |
|
||||
|-------|------|------|------|
|
||||
| P | `0xE1` | `0x0F` | `0xF0` |
|
||||
| R | `0xD2` | `0x0F` | `0xF0` |
|
||||
| N | `0xB4` | `0x0F` | `0xF0` |
|
||||
| D | `0x78` | `0x5F` | `0xF0` |
|
||||
| S/M | `0x78` | `0x5F` | `0xF1` |
|
||||
|
||||
- **D0 = lever position**, whole-byte code: `0xE1`=P, `0xD2`=R, `0xB4`=N, `0x78`=D. **Matches the documented E65/E90 codes exactly** — every value. (verified, 2026-07-16)
|
||||
- **D0 can't split D from S/M** (both `0x78`) — Steptronic's S/M is a side-gate off D, so fore/aft is identical. Two bytes disambiguate:
|
||||
- **D1** = drive-gate flag: `0x0F` in P/R/N, `0x5F` in D **and** S/M.
|
||||
- **D4** = mode / manual shift: `0xF0` = Drive (auto), `0xF1` = Sport/Manual engaged, **`0xF2` = downshift (−)** (user confirmed by pushing the lever forward). Up-nudge (+) likely `0xF3`/`0xF4` — **unconfirmed, one more capture**.
|
||||
- **D3 = rolling counter** (fluctuates, no meaning) — matches the research prediction of a byte-3 rolling counter. Ignore. D2/D5 = `0xFF` (unused).
|
||||
|
||||
### Recommended decode
|
||||
```
|
||||
gear = D0: 0xE1→P 0xD2→R 0xB4→N 0x78→D (if D0==0x78 && D4!=0xF0 → S/M)
|
||||
manual: D4 0xF0 auto · 0xF1 manual · 0xF2 downshift(−)
|
||||
```
|
||||
|
||||
## `0x0BA` (DLC 8) — secondary, do NOT use
|
||||
|
||||
D0 low bits also track the lever (P=3, R=2, N=1, D=5, S/M=5) but it's messier: D and S/M collide at 5, and D7 collides R=D=`0xCF` (P=`0xEF`, N=`0xDF`). D5/D6 fluctuate (counter/checksum). Prefer `0x1D2`.
|
||||
|
||||
## Still open
|
||||
|
||||
- **Actual engaged gear (1st…6th)** is a different signal — the lever position ≠ the gear the box is in. Needs a drive capture (watch `0x1D2` byte1 upper nibble / `0x0BA` while it shifts under load).
|
||||
- **Manual up-shift (+) value** on `0x1D2` D4 not captured.
|
||||
|
||||
## Related
|
||||
|
||||
[[can-id-candidates]] · [[can-capture-2026-07-15]] · [[can-bus-integration]] · [[bmw-m57n-engine]]
|
||||
Reference in New Issue
Block a user