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:
2026-07-16 14:54:06 +02:00
parent 87801c593c
commit 0a58afca9a
7 changed files with 119 additions and 20 deletions
+12 -11
View File
@@ -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;