Decode the real CAN map: gear, temps, battery, driveline speeds

Ingest HeinrichG-V12/E65_ReverseEngineering (per-ID DBC-style docs with
worked examples) and re-analyse our own 2026-07-15 capture against it.
Resolves both outstanding scaling disputes, closes the engine-state
question, and adds the driveline speeds.

Resolved:
- Gearbox oil temp = raw - 40 (not offset 0, not +40). Source's worked
  example plus our own cross-check: the box read 31 C while coolant was
  at 37 C and climbing; offset 0 would have the transmission warming
  faster than the engine.
- Battery = 12-bit LE * 0.015 (0x3B4 U_BT); the E90 24-bit BE reading is
  wrong for us. The high nibble of byte 1 is ST_BTSW, not voltage.
- Engine was running during the 2026-07-15 capture (ST_ENGINE_RUN = 2 in
  397/397 frames), so its coolant trace is genuine warm-up data and the
  planned cold-start capture is unnecessary.
- Engaged gear = 0x1D2 byte 1, gear = (D1>>4)-4. No drive capture needed.

New signals (0x1A2 turbine, 0x0BA output shaft, 0x0AA RPM/pedal). Turbine
speed physically proves engagement: it free-spins at ~engine speed in P/N
and collapses to ~0 when the box loads up. Output shaft is the only
road-speed source on this bus - there is no DSC module - so it is the
feedback variable any future cruise-control work would need. Scaling is
uncalibrated; it is carried as raw counts with no physical unit.

Corrects three of my own earlier claims:
- 0x1D2 D1 is the engaged gear, not a "drive-gate flag" (it only ever
  showed two values because the car was stationary in 1st).
- 0x1D2 D4 0xF2 is a persistent Manual mode, not a "downshift event" - it
  holds across gears 2-6.
- 0x0BA was dismissed on the strength of D7, which is an alive counter.
  The gear is in D0's low nibble, and it is the only source of engaged
  reverse: 0x1D2 D1 stays 0x0F in R.

Firmware: real IDs replace the placeholder map (all 11-bit standard now,
so the extended-ID assumption is gone), full gear decode incl. Sport vs
Manual, and a debounced lever-vs-gearbox mismatch fault - the "lever says
R but the box never took it" case. Engine oil temp reads 0xFF here (sensor
not populated), so its valid flag is left clear rather than publishing
-207 C. Driveline speeds are kept out of automotive_data_t deliberately:
that struct is the UART wire format and widening it would break
Controller B.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
2026-07-17 12:33:31 +02:00
parent 0a58afca9a
commit bb87b3d6da
13 changed files with 428331 additions and 132 deletions
+39 -2
View File
@@ -2,10 +2,13 @@
* can_driver.h * can_driver.h
* *
* CAN Bus driver for ESP32-S3-Touch-LCD-5B using TWAI (Two-Wire Automotive Interface) * CAN Bus driver for ESP32-S3-Touch-LCD-5B using TWAI (Two-Wire Automotive Interface)
* Reads BMW CAN messages at 500 Kbps in LISTEN_ONLY mode * Reads BMW E60/E65 PT-CAN messages at 500 Kbps.
* *
* Hardware: GPIO 15 (TX), GPIO 16 (RX) * Hardware: GPIO 15 (TX), GPIO 16 (RX)
* Mode: LISTEN_ONLY (safe, won't transmit on vehicle bus) * Mode: TWAI_MODE_NORMAL — the board ACKs the bus (LISTEN_ONLY can't ACK, which
* makes transmitters flood it with retries). We never call twai_transmit(),
* so behaviour is read-only in practice, but note this is a policy, not a
* hardware guarantee: nothing but discipline prevents a write.
* Baud: 500 Kbps * Baud: 500 Kbps
*/ */
@@ -57,6 +60,33 @@ typedef struct {
uint32_t last_receive_time; uint32_t last_receive_time;
} can_stats_t; } can_stats_t;
// ============================================================================
// DRIVELINE STATE
// ============================================================================
/**
* Decoded driveline speeds. Deliberately NOT part of automotive_data_t: that
* struct is the wire format for the UART link to Controller B, and widening it
* would break the receiver. These live here until there's a reason to spend a
* protocol version bump on them.
*
* See wiki/pages/driveline-speed-signals.md for the physics and the calibration
* that output_shaft_raw still needs.
*/
typedef struct {
uint16_t engine_rpm; // 0x0AA RPM_ENG (verified)
uint16_t turbine_rpm; // 0x1A2 RPM_GRB_TURB (verified). ~engine speed in
// P/N; collapses toward 0 when the box engages.
uint16_t output_shaft_raw; // 0x0BA bytes 3-4, RAW COUNTS — scaling unknown.
// Zero when the output is held, non-zero when the
// wheels turn. The only road-speed signal we have.
uint8_t pedal_percent; // 0x0AA ANG_ACPD
uint8_t engine_run_state; // 0x1D0 ST_ENGINE_RUN (ENGINE_RUN_* constants)
uint8_t gearbox_cooling; // 0x0B5 ST_OTMP_GRB (GEARBOX_COOL_* constants)
bool gear_mismatch; // lever (0x1D2) vs gearbox (0x0BA) disagree,
// sustained past the debounce window
} driveline_t;
// ============================================================================ // ============================================================================
// PUBLIC API // PUBLIC API
// ============================================================================ // ============================================================================
@@ -84,6 +114,13 @@ namespace CANDriver {
*/ */
can_stats_t getStats(); can_stats_t getStats();
/**
* Get the decoded driveline speeds (engine / turbine / output shaft).
* Not carried over the UART link — see driveline_t.
* @return Snapshot of the current driveline state
*/
driveline_t getDriveline();
/** /**
* Check if CAN is currently active * Check if CAN is currently active
* @return true if CAN is receiving messages * @return true if CAN is receiving messages
+188 -32
View File
@@ -86,39 +86,114 @@ typedef struct __attribute__((packed)) {
#define VALID_FLAG_BATTERY_VOLT (1 << 4) #define VALID_FLAG_BATTERY_VOLT (1 << 4)
#define VALID_FLAG_FAULT_CODES (1 << 5) #define VALID_FLAG_FAULT_CODES (1 << 5)
// Fault code bitmap (fault_codes field). NOTE: these are OUR derived faults, not
// DDE DTCs — real fault codes are not broadcast on this bus and would require
// diagnostic request/response (see wiki/pages/can-id-candidates.md).
#define FAULT_GEAR_MISMATCH (1 << 0) // lever (0x1D2) and gearbox (0x0BA) disagree
// ============================================================================ // ============================================================================
// CAN BUS ID MAPPINGS (BMW-Specific) // CAN BUS ID MAPPINGS (BMW-Specific)
// ============================================================================ // ============================================================================
// BMW CAN message IDs and byte positions // BMW E60/E65 PT-CAN, 500 kbps. Every ID below is an 11-bit STANDARD frame and
#define CAN_ID_COOLANT_TEMP 0x4F // Engine coolant temperature // has been seen live on the actual swap bus. Decodes cross-checked against
#define CAN_BYTE_COOLANT_TEMP 0 // Byte 0 // HeinrichG-V12/E65_ReverseEngineering (per-ID DBC docs) AND our own captures.
// Full evidence + confidence labels: wiki/pages/can-id-candidates.md
//
// The original map (0x4F/0x55/0x201/0x1001/0x101F) was placeholder junk — those
// IDs were verified ABSENT from the bus 2026-07-15. Do not resurrect them.
#define CAN_ID_ENGINE_OIL_TEMP 0x55 // Engine oil temperature // --- 0x1D0 "Engine Data" (DME/DDE, DLC 8, 100 ms) --------------------------
#define CAN_BYTE_ENGINE_OIL_TEMP 7 // Byte 7 #define CAN_ID_ENGINE_DATA 0x1D0
#define CAN_BYTE_COOLANT_TEMP 0 // TEMP_ENG: °C = raw - 48 (verified)
#define CAN_BYTE_ENGINE_OIL_TEMP 1 // TEMP_EOI: °C = raw - 48 (reads 0xFF here — sensor not populated on this M57N)
#define CAN_BYTE_ENGINE_STATUS 2 // bits 4-5 = ST_ENGINE_RUN
#define ENGINE_TEMP_OFFSET 48 // subtract from raw
#define CAN_ID_GEARBOX_TEMP 0x201 // Gearbox oil temperature // ST_ENGINE_RUN (byte 2, bits 4-5)
#define CAN_BYTE_GEARBOX_TEMP 3 // Byte 3 #define ENGINE_RUN_OFF 0
#define ENGINE_RUN_STARTING 1
#define ENGINE_RUN_RUNNING 2
#define ENGINE_RUN_INVALID 3
// Gear lever position — EGS "TransmissionDataDisplay", DLC 6. // --- 0x0B5 "Torque Request EGS" (EGS, DLC 8, 10 ms) ------------------------
// VERIFIED on the swap bus 2026-07-16 (see wiki/sources/gear-box-can-revealings.md). #define CAN_ID_TORQUE_EGS 0x0B5
#define CAN_ID_GEAR_LEVER 0x1D2 // Gear lever position message #define CAN_BYTE_GEARBOX_TEMP 7 // TEMP_GRB: °C = raw - 40 (verified two ways)
#define CAN_BYTE_GEAR_LEVER 0 // Byte 0: lever code (see can_to_gear_lever) #define GEARBOX_TEMP_OFFSET 40 // NOT 0, NOT +40 — see wiki; a 40 °C error either way
#define CAN_BYTE_GEAR_MODE 4 // Byte 4: 0xF0=Drive(auto), 0xF1=Sport/Manual, 0xF2=downshift(-) #define CAN_BYTE_GEARBOX_COOL 4 // bits 38-39 = ST_OTMP_GRB (cooling demand)
// Raw byte-0 lever codes (whole-byte encoding, all verified against the live bus) // ST_OTMP_GRB — the box's own overheat opinion (better than thresholding temp)
#define GEARBOX_COOL_NONE 0
#define GEARBOX_COOL_STAGE1 1
#define GEARBOX_COOL_STAGE2 2
#define GEARBOX_COOL_INVALID 3
// --- 0x1D2 "Display Gearbox Data" (EGS, DLC 6, 200 ms) ---------------------
// Our decode is AHEAD of the published source here: the E65 repo lists this ID
// with an empty signal table. Byte 1 and byte 4 are our own work.
#define CAN_ID_GEAR_DISPLAY 0x1D2
#define CAN_BYTE_GEAR_LEVER 0 // whole-byte lever code
#define CAN_BYTE_GEAR_ENGAGED 1 // (raw >> 4) - 4 = gear 1..6; 0x0F = none
#define CAN_BYTE_GEAR_MODE 4 // 0xF0 auto / 0xF1 Sport / 0xF2 Manual
// Byte 0 lever codes (verified — every code matches the documented table)
#define GEAR_CODE_PARK 0xE1 #define GEAR_CODE_PARK 0xE1
#define GEAR_CODE_REVERSE 0xD2 #define GEAR_CODE_REVERSE 0xD2
#define GEAR_CODE_NEUTRAL 0xB4 #define GEAR_CODE_NEUTRAL 0xB4
#define GEAR_CODE_DRIVE 0x78 // also S/M side-gate — split via CAN_BYTE_GEAR_MODE #define GEAR_CODE_DRIVE 0x78 // D *and* S/M — the side-gate is physically the same detent
#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) // Byte 4 mode codes. NOTE: 0xF2 is a PERSISTENT mode, not a downshift event —
#define CAN_BYTE_BATTERY_VOLT_H 0 // Byte 0 (high byte) // it holds across gears 2..6. The +/- nudges have no distinct code; the first
#define CAN_BYTE_BATTERY_VOLT_L 1 // Byte 1 (low byte) // tap simply promotes Sport -> Manual.
#define GEAR_MODE_DRIVE_AUTO 0xF0
#define GEAR_MODE_SPORT 0xF1
#define GEAR_MODE_MANUAL 0xF2
// CAN ID type: Mix of standard (0x4F, 0x55, 0x201) and extended (0x1001, 0x101F) #define GEAR_ENGAGED_NONE 0x0F // byte 1 value in P/R/N — and in R even when engaged
#define USE_EXTENDED_CAN_IDS true // Using 29-bit extended IDs for some messages
// --- 0x0BA gearbox state (EGS, DLC 8, 20 ms) -------------------------------
// The ONLY source of engaged reverse: 0x1D2 byte 1 stays 0x0F in R.
#define CAN_ID_GEARBOX_STATE 0x0BA
#define CAN_BYTE_GEARBOX_TARGET 0 // low nibble = ST_GR_GRB
// ST_GR_GRB (byte 0, low nibble). 1/2/3/5 verified live; 6..0xA inferred from
// the identical ladder in 0x1D2 byte 1. Value 4 unaccounted for.
#define GRB_TARGET_NEUTRAL 1
#define GRB_TARGET_REVERSE 2
#define GRB_TARGET_PARK 3
#define GRB_TARGET_GEAR1 5 // ..0xA = 6th
#define GRB_TARGET_INVALID 0xF
// Bytes 3-4: output shaft speed. UNDOCUMENTED in every source; zero in every
// stationary frame (including engaged-in-D), non-zero once the wheels turn.
// This is the project's only road-speed signal — there is no DSC/wheel-speed
// module on this bus. SCALING IS NOT CALIBRATED — do not convert to a physical
// unit yet. See wiki/pages/driveline-speed-signals.md
#define CAN_BYTE_OUTPUT_SHAFT_L 3
#define CAN_BYTE_OUTPUT_SHAFT_H 4
// --- 0x1A2 turbine speed (EGS, DLC 4, 20 ms) -------------------------------
// Gearbox INPUT speed. Physically proves engagement: free-spins at ~engine
// speed in P/N, collapses to ~0 when the box engages against a held output.
#define CAN_ID_TURBINE_SPEED 0x1A2
#define CAN_BYTE_TURBINE_L 0
#define CAN_BYTE_TURBINE_H 1
// --- 0x0AA "Torque 3" (DME/DDE, DLC 8, 10 ms) ------------------------------
#define CAN_ID_TORQUE_3 0x0AA
#define CAN_BYTE_PEDAL_POS 3 // ANG_ACPD: % = raw * 0.39063
#define CAN_BYTE_RPM_L 4 // RPM_ENG: 1/min = raw16 * 0.25
#define CAN_BYTE_RPM_H 5
#define CAN_BYTE_CRUISE_STATE 6 // low nibble = ST_CLCTR_V
// --- 0x3B4 "Power Management Battery Voltage" (DLC 8, 5 s) -----------------
#define CAN_ID_BATTERY_VOLTAGE 0x3B4
#define CAN_BYTE_BATTERY_VOLT_L 0 // U_BT: 12-bit little-endian, V = raw * 0.015
#define CAN_BYTE_BATTERY_VOLT_H 1 // low nibble only (high nibble = ST_BTSW)
// All IDs are 11-bit standard frames — the extended-ID assumption came from the
// bogus 0x1001/0x101F placeholders and is dead.
#define USE_EXTENDED_CAN_IDS false
// ============================================================================ // ============================================================================
// PACKET STRUCTURE FOR UART TRANSMISSION // PACKET STRUCTURE FOR UART TRANSMISSION
@@ -172,40 +247,121 @@ static inline bool validate_packet(const uart_packet_t* packet) {
/** /**
* Convert temperature from CAN format to internal format * Convert temperature from CAN format to internal format
* @param can_value Raw CAN bus value * @param can_value Raw CAN bus value
* @param offset Temperature offset (usually -40 for automotive) * @param offset Value to SUBTRACT from raw (48 for 0x1D0 engine temps, 40 for 0x0B5)
* @return Temperature in 0.1°C units * @return Temperature in 0.1°C units
*/ */
static inline int16_t can_to_temperature(uint8_t can_value, int16_t offset = -40) { static inline int16_t can_to_temperature(uint8_t can_value, int16_t offset) {
return (int16_t)((can_value + offset) * 10); // Convert to 0.1°C units return (int16_t)(((int16_t)can_value - offset) * 10);
} }
/** /**
* Convert voltage from CAN format to internal format * Decode battery voltage from a 0x3B4 frame.
* @param can_value Raw CAN bus value (typically in 0.1V) * U_BT is 12-bit little-endian, factor 0.015 V — i.e. 0.01 V units = raw * 1.5.
* (Verified: raw 0x3D9 = 985 -> 14.775 V.) The high nibble of byte 1 is ST_BTSW,
* NOT voltage — mask it off or you'll read ~4x too high.
* @param d Payload of a 0x3B4 frame (needs DLC >= 2)
* @return Voltage in 0.01V units * @return Voltage in 0.01V units
*/ */
static inline uint16_t can_to_voltage(uint16_t can_value) { static inline uint16_t can_to_voltage(const uint8_t* d) {
return can_value * 10; // Convert 0.1V to 0.01V units uint16_t raw12 = (uint16_t)(((d[CAN_BYTE_BATTERY_VOLT_H] & 0x0F) << 8) | d[CAN_BYTE_BATTERY_VOLT_L]);
return (uint16_t)((raw12 * 3) / 2); // raw * 0.015 V -> 0.01 V units
}
/**
* Decode engine RPM from a 0x0AA frame. RPM_ENG = raw16 (Intel) * 0.25.
* @param d Payload of a 0x0AA frame (needs DLC >= 6)
*/
static inline uint16_t can_to_rpm(const uint8_t* d) {
uint16_t raw = (uint16_t)((d[CAN_BYTE_RPM_H] << 8) | d[CAN_BYTE_RPM_L]);
return (uint16_t)(raw / 4);
}
/**
* Decode gearbox turbine (input) speed from a 0x1A2 frame.
* RPM_GRB_TURB = raw16 (Intel) * 0.125 + 6.
* @param d Payload of a 0x1A2 frame (needs DLC >= 2)
*/
static inline uint16_t can_to_turbine_rpm(const uint8_t* d) {
uint16_t raw = (uint16_t)((d[CAN_BYTE_TURBINE_H] << 8) | d[CAN_BYTE_TURBINE_L]);
return (uint16_t)(raw / 8 + 6);
} }
/** /**
* Map a raw 0x1D2 byte-0 lever code to a gear_position_t. * 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), * D and S/M share code 0x78 — use decode_gear() to resolve them.
* 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 * @param d0 Byte 0 of a 0x1D2 frame
* @return Gear position, or GEAR_UNKNOWN if the code isn't recognized * @return Lever position, or GEAR_UNKNOWN if the code isn't recognized
*/ */
static inline gear_position_t can_to_gear_lever(uint8_t d0) { static inline gear_position_t can_to_gear_lever(uint8_t d0) {
switch (d0) { switch (d0) {
case GEAR_CODE_PARK: return GEAR_PARK; case GEAR_CODE_PARK: return GEAR_PARK;
case GEAR_CODE_REVERSE: return GEAR_REVERSE; case GEAR_CODE_REVERSE: return GEAR_REVERSE;
case GEAR_CODE_NEUTRAL: return GEAR_NEUTRAL; case GEAR_CODE_NEUTRAL: return GEAR_NEUTRAL;
case GEAR_CODE_DRIVE: return GEAR_DRIVE; // D or S/M case GEAR_CODE_DRIVE: return GEAR_DRIVE; // D or S/M — see decode_gear()
default: return GEAR_UNKNOWN; default: return GEAR_UNKNOWN;
} }
} }
/**
* Extract the engaged gear number from 0x1D2 byte 1.
* High nibble is a +16 ladder: 0x5F=1st .. 0xAF=6th. 0x0F = no numbered gear.
* @param d1 Byte 1 of a 0x1D2 frame
* @return 1..6, or 0 if no gear is engaged / value out of range.
* Always 0 in REVERSE — reverse is unnumbered here; use 0x0BA instead.
*/
static inline uint8_t can_to_engaged_gear(uint8_t d1) {
if (d1 == GEAR_ENGAGED_NONE) return 0;
uint8_t n = (uint8_t)((d1 >> 4) - 4);
return (n >= 1 && n <= 6) ? n : 0;
}
/**
* Resolve the full 0x1D2 frame into a single displayable gear_position_t.
*
* P/R/N come straight from the lever. In the D detent, byte 4 splits plain Drive
* from the Sport/Manual side-gate; when in S/M we surface the engaged gear number
* (GEAR_MANUAL_1..6) because that's what a driver in the side-gate wants to read.
*
* @param d Payload of a 0x1D2 frame
* @param dlc Frame DLC (must be >= 5 to reach the mode byte)
* @return Gear to display, or GEAR_UNKNOWN if the lever code isn't recognized
*/
static inline gear_position_t decode_gear(const uint8_t* d, uint8_t dlc) {
if (dlc <= CAN_BYTE_GEAR_LEVER) return GEAR_UNKNOWN;
gear_position_t lever = can_to_gear_lever(d[CAN_BYTE_GEAR_LEVER]);
if (lever != GEAR_DRIVE) return lever; // P/R/N (or UNKNOWN) need no further work
// In the D detent. Without the mode byte we can't tell D from S/M — report D.
if (dlc <= CAN_BYTE_GEAR_MODE) return GEAR_DRIVE;
if (d[CAN_BYTE_GEAR_MODE] == GEAR_MODE_DRIVE_AUTO) return GEAR_DRIVE;
// Sport or Manual: show the engaged gear if the box has told us one.
if (dlc > CAN_BYTE_GEAR_ENGAGED) {
uint8_t n = can_to_engaged_gear(d[CAN_BYTE_GEAR_ENGAGED]);
if (n >= 1 && n <= 6) return (gear_position_t)(GEAR_MANUAL_1 + (n - 1));
}
return GEAR_DRIVE;
}
/**
* Map a 0x0BA ST_GR_GRB nibble (the gearbox's own target gear) to a
* gear_position_t, for cross-checking against the lever.
* @param nibble Low nibble of 0x0BA byte 0
* @return Target gear, or GEAR_UNKNOWN if invalid/unrecognized
*/
static inline gear_position_t can_to_target_gear(uint8_t nibble) {
switch (nibble) {
case GRB_TARGET_PARK: return GEAR_PARK;
case GRB_TARGET_REVERSE: return GEAR_REVERSE;
case GRB_TARGET_NEUTRAL: return GEAR_NEUTRAL;
default: break;
}
// 5..0xA = forward gears 1..6 (same ladder as 0x1D2 byte 1)
if (nibble >= GRB_TARGET_GEAR1 && nibble <= 0xA) return GEAR_DRIVE;
return GEAR_UNKNOWN;
}
/** /**
* Get human-readable gear position string * Get human-readable gear position string
* @param gear Gear position enum value * @param gear Gear position enum value
+157 -39
View File
@@ -24,6 +24,12 @@ namespace CANDriver {
// CAN timeout threshold - stop UART if no messages received for this duration // CAN timeout threshold - stop UART if no messages received for this duration
#define CAN_TIMEOUT_MS 2000 // 2 seconds (for 5Hz expected rate, this is 10 missed messages) #define CAN_TIMEOUT_MS 2000 // 2 seconds (for 5Hz expected rate, this is 10 missed messages)
// How long the lever (0x1D2) and the gearbox (0x0BA) must disagree before we call
// it a fault. They legitimately differ for a moment during every shift — 0x1D2 is
// a 200ms message and 0x0BA a 20ms one, so they are never perfectly in step.
// Without this window the flag would strobe on every gear change.
#define GEAR_MISMATCH_DEBOUNCE_MS 500
// ============================================================================ // ============================================================================
// MODULE STATE // MODULE STATE
// ============================================================================ // ============================================================================
@@ -41,10 +47,60 @@ static bool g_raw_logging = true;
// (and would drown) the raw capture stream. Enable only for quick eyeballing. // (and would drown) the raw capture stream. Enable only for quick eyeballing.
static bool g_verbose_decode = false; static bool g_verbose_decode = false;
// Driveline speeds — decoded but NOT sent over UART (see driveline_t in the header).
// Guarded by g_data_mutex along with g_automotive_data.
static driveline_t g_driveline = {0};
// Last gear LEVER code seen on 0x1D2, for the lever-vs-gearbox cross-check.
static gear_position_t g_last_lever = GEAR_UNKNOWN;
// When the current disagreement started (0 = currently in agreement).
static uint32_t g_mismatch_since = 0;
// ============================================================================ // ============================================================================
// PRIVATE FUNCTIONS // PRIVATE FUNCTIONS
// ============================================================================ // ============================================================================
/**
* @brief Cross-check the driver's lever selection against the gearbox's own
* target gear and raise a fault if they disagree for long enough.
*
* This is the "lever says R but the car isn't moving" detector: if the box never
* took the request, 0x0BA reports a different gear than the lever shows.
*
* Note this compares INTENT, not mechanical engagement — 0x0BA is a target gear.
* Proving the box physically caught requires the turbine/engine speed ratio, which
* needs output-shaft calibration to gate correctly (it reads "not engaged" whenever
* the wheels are free, e.g. on a lift). Not attempted here on purpose.
* See wiki/pages/driveline-speed-signals.md
*
* Caller must hold g_data_mutex.
* @param target Gear the gearbox reports as its target
*/
static void updateGearMismatch(gear_position_t target) {
// Ignore frames we can't interpret rather than guessing a mismatch from them.
if (target == GEAR_UNKNOWN || g_last_lever == GEAR_UNKNOWN) return;
// The lever's D detent covers D/S/M; can_to_target_gear() maps every forward
// gear to GEAR_DRIVE, so both sides are directly comparable.
bool disagrees = (target != g_last_lever);
if (!disagrees) {
g_mismatch_since = 0;
g_driveline.gear_mismatch = false;
g_automotive_data.fault_codes &= ~FAULT_GEAR_MISMATCH;
return;
}
uint32_t now = millis();
if (g_mismatch_since == 0) {
g_mismatch_since = now; // start the clock, don't fault yet
} else if ((now - g_mismatch_since) >= GEAR_MISMATCH_DEBOUNCE_MS) {
g_driveline.gear_mismatch = true;
g_automotive_data.fault_codes |= FAULT_GEAR_MISMATCH;
g_automotive_data.valid_flags |= VALID_FLAG_FAULT_CODES;
}
}
/** /**
* @brief Parse BMW-specific CAN message and update automotive data * @brief Parse BMW-specific CAN message and update automotive data
* @param message Received TWAI message * @param message Received TWAI message
@@ -61,59 +117,101 @@ static bool parseCANMessage(const twai_message_t& message) {
return false; return false;
} }
uint8_t dlc = message.data_length_code;
switch (id) { switch (id) {
case CAN_ID_COOLANT_TEMP: case CAN_ID_ENGINE_DATA:
// Engine coolant temperature (byte 0) // 0x1D0: coolant (byte 0), engine oil (byte 1), engine run state (byte 2).
if (message.data_length_code > CAN_BYTE_COOLANT_TEMP) { if (dlc > CAN_BYTE_COOLANT_TEMP) {
g_automotive_data.coolant_temp = can_to_temperature(data[CAN_BYTE_COOLANT_TEMP]); g_automotive_data.coolant_temp =
can_to_temperature(data[CAN_BYTE_COOLANT_TEMP], ENGINE_TEMP_OFFSET);
g_automotive_data.valid_flags |= VALID_FLAG_COOLANT_TEMP; g_automotive_data.valid_flags |= VALID_FLAG_COOLANT_TEMP;
parsed = true; parsed = true;
} }
break; // Oil temp reads 0xFF on this M57N — the sensor isn't populated. Leave
// the valid flag clear rather than publishing -207 C as if it were real.
case CAN_ID_ENGINE_OIL_TEMP: if (dlc > CAN_BYTE_ENGINE_OIL_TEMP && data[CAN_BYTE_ENGINE_OIL_TEMP] != 0xFF) {
// Engine oil temperature (byte 7) g_automotive_data.engine_oil_temp =
if (message.data_length_code > CAN_BYTE_ENGINE_OIL_TEMP) { can_to_temperature(data[CAN_BYTE_ENGINE_OIL_TEMP], ENGINE_TEMP_OFFSET);
g_automotive_data.engine_oil_temp = can_to_temperature(data[CAN_BYTE_ENGINE_OIL_TEMP]);
g_automotive_data.valid_flags |= VALID_FLAG_ENGINE_TEMP; g_automotive_data.valid_flags |= VALID_FLAG_ENGINE_TEMP;
parsed = true; }
if (dlc > CAN_BYTE_ENGINE_STATUS) {
g_driveline.engine_run_state = (data[CAN_BYTE_ENGINE_STATUS] >> 4) & 0x03;
} }
break; break;
case CAN_ID_GEARBOX_TEMP: case CAN_ID_TORQUE_EGS:
// Gearbox oil temperature (byte 3) // 0x0B5: gearbox oil temp (byte 7) + the box's own cooling demand.
if (message.data_length_code > CAN_BYTE_GEARBOX_TEMP) { if (dlc > CAN_BYTE_GEARBOX_TEMP) {
g_automotive_data.gearbox_oil_temp = can_to_temperature(data[CAN_BYTE_GEARBOX_TEMP]); g_automotive_data.gearbox_oil_temp =
can_to_temperature(data[CAN_BYTE_GEARBOX_TEMP], GEARBOX_TEMP_OFFSET);
g_automotive_data.valid_flags |= VALID_FLAG_GEARBOX_TEMP; g_automotive_data.valid_flags |= VALID_FLAG_GEARBOX_TEMP;
parsed = true; parsed = true;
} }
if (dlc > CAN_BYTE_GEARBOX_COOL) {
// ST_OTMP_GRB = bits 38-39 = byte 4, bits 6-7
g_driveline.gearbox_cooling = (data[CAN_BYTE_GEARBOX_COOL] >> 6) & 0x03;
}
break; break;
case CAN_ID_GEAR_LEVER: case CAN_ID_GEAR_DISPLAY: {
// Gear lever position from the EGS (0x1D2) — verified on the swap bus // 0x1D2: the EGS publishing its whole state — byte 0 is what the driver
// 2026-07-16. Byte 0 is a whole-byte lever code (E1=P, D2=R, B4=N, 78=D/S-M). // selected, byte 1 is what's actually engaged, byte 4 is the mode.
// Byte 4 (CAN_BYTE_GEAR_MODE) splits D vs S/M and carries manual +/- shifts; gear_position_t g = decode_gear(data, dlc);
// not surfaced yet (no enum slot; the engaged gear number needs a drive capture). if (g != GEAR_UNKNOWN) {
if (message.data_length_code > CAN_BYTE_GEAR_LEVER) { g_automotive_data.gear_position = (uint8_t)g;
gear_position_t g = can_to_gear_lever(data[CAN_BYTE_GEAR_LEVER]); g_automotive_data.valid_flags |= VALID_FLAG_GEAR_POS;
if (g != GEAR_UNKNOWN) { parsed = true;
g_automotive_data.gear_position = (uint8_t)g; }
g_automotive_data.valid_flags |= VALID_FLAG_GEAR_POS; // Keep the bare lever (not the resolved display value) for the
parsed = true; // cross-check below: 0x0BA reports a gear, never a mode.
} if (dlc > CAN_BYTE_GEAR_LEVER) {
g_last_lever = can_to_gear_lever(data[CAN_BYTE_GEAR_LEVER]);
}
break;
}
case CAN_ID_GEARBOX_STATE: {
// 0x0BA: the gearbox's own target gear — the ONLY source of engaged
// reverse (0x1D2 byte 1 stays 0x0F in R) — plus the output shaft.
if (dlc > CAN_BYTE_GEARBOX_TARGET) {
gear_position_t target =
can_to_target_gear(data[CAN_BYTE_GEARBOX_TARGET] & 0x0F);
updateGearMismatch(target);
parsed = true;
}
if (dlc > CAN_BYTE_OUTPUT_SHAFT_H) {
// Raw counts only — scaling uncalibrated, so no physical unit.
g_driveline.output_shaft_raw =
(uint16_t)((data[CAN_BYTE_OUTPUT_SHAFT_H] << 8) | data[CAN_BYTE_OUTPUT_SHAFT_L]);
}
break;
}
case CAN_ID_TURBINE_SPEED:
// 0x1A2: gearbox input speed — the physical engagement signal.
if (dlc > CAN_BYTE_TURBINE_H) {
g_driveline.turbine_rpm = can_to_turbine_rpm(data);
parsed = true;
}
break;
case CAN_ID_TORQUE_3:
// 0x0AA: engine RPM + accelerator pedal.
if (dlc > CAN_BYTE_RPM_H) {
g_driveline.engine_rpm = can_to_rpm(data);
parsed = true;
}
if (dlc > CAN_BYTE_PEDAL_POS) {
// ANG_ACPD: % = raw * 0.39063 (i.e. raw * 100 / 256)
g_driveline.pedal_percent = (uint8_t)((data[CAN_BYTE_PEDAL_POS] * 100) / 256);
} }
break; break;
case CAN_ID_BATTERY_VOLTAGE: case CAN_ID_BATTERY_VOLTAGE:
// Battery voltage (bytes 0-1, 16-bit value) // 0x3B4: U_BT, 12-bit little-endian x 0.015 V.
if (message.data_length_code > CAN_BYTE_BATTERY_VOLT_L) { if (dlc > CAN_BYTE_BATTERY_VOLT_H) {
// Combine high and low bytes (assuming big-endian) g_automotive_data.battery_voltage = can_to_voltage(data);
uint16_t raw_voltage = (data[CAN_BYTE_BATTERY_VOLT_H] << 8) | data[CAN_BYTE_BATTERY_VOLT_L];
// Convert to internal format (0.01V units)
// Assuming CAN sends in 0.1V units, multiply by 10
g_automotive_data.battery_voltage = raw_voltage * 10;
g_automotive_data.valid_flags |= VALID_FLAG_BATTERY_VOLT; g_automotive_data.valid_flags |= VALID_FLAG_BATTERY_VOLT;
parsed = true; parsed = true;
} }
@@ -193,13 +291,16 @@ static void handleRxMessage(twai_message_t& message) {
// Per-frame decoded prose — off by default (redundant with raw capture) // Per-frame decoded prose — off by default (redundant with raw capture)
if (g_verbose_decode && xSemaphoreTake(g_data_mutex, pdMS_TO_TICKS(10)) == pdTRUE) { if (g_verbose_decode && xSemaphoreTake(g_data_mutex, pdMS_TO_TICKS(10)) == pdTRUE) {
ESP_LOGI("CANDrv", "✓ RX CAN ID=0x%X → Coolant:%d.%d°C, Oil:%d.%d°C, Gearbox:%d.%d°C, Batt:%d.%02dV, Gear:%d [%d/%d]", ESP_LOGI("CANDrv", "✓ RX 0x%X → Gear:%s%s Coolant:%d.%d°C Gearbox:%d.%d°C Batt:%d.%02dV | RPM:%u Turb:%u Shaft:%u [%d/%d]",
message.identifier, message.identifier,
gear_to_string((gear_position_t)g_automotive_data.gear_position),
g_driveline.gear_mismatch ? " !MISMATCH" : "",
g_automotive_data.coolant_temp / 10, abs(g_automotive_data.coolant_temp % 10), g_automotive_data.coolant_temp / 10, abs(g_automotive_data.coolant_temp % 10),
g_automotive_data.engine_oil_temp / 10, abs(g_automotive_data.engine_oil_temp % 10),
g_automotive_data.gearbox_oil_temp / 10, abs(g_automotive_data.gearbox_oil_temp % 10), g_automotive_data.gearbox_oil_temp / 10, abs(g_automotive_data.gearbox_oil_temp % 10),
g_automotive_data.battery_voltage / 100, g_automotive_data.battery_voltage % 100, g_automotive_data.battery_voltage / 100, g_automotive_data.battery_voltage % 100,
g_automotive_data.gear_position, g_driveline.engine_rpm,
g_driveline.turbine_rpm,
g_driveline.output_shaft_raw,
g_can_stats.messages_parsed, g_can_stats.messages_parsed,
g_can_stats.messages_received); g_can_stats.messages_received);
xSemaphoreGive(g_data_mutex); xSemaphoreGive(g_data_mutex);
@@ -295,6 +396,10 @@ static void canTask(void* parameter) {
if (initTWAI()) { if (initTWAI()) {
g_can_active = true; g_can_active = true;
memset(&g_can_stats, 0, sizeof(g_can_stats)); memset(&g_can_stats, 0, sizeof(g_can_stats));
// Drop stale driveline/gear state from a previous session
memset(&g_driveline, 0, sizeof(g_driveline));
g_last_lever = GEAR_UNKNOWN;
g_mismatch_since = 0;
ESP_LOGI("CANTask", "CAN reception active"); ESP_LOGI("CANTask", "CAN reception active");
// Auto-start UART transmission (CAN drives UART) // Auto-start UART transmission (CAN drives UART)
@@ -437,6 +542,19 @@ can_stats_t getStats() {
return g_can_stats; return g_can_stats;
} }
driveline_t getDriveline() {
driveline_t snapshot;
if (xSemaphoreTake(g_data_mutex, pdMS_TO_TICKS(10)) == pdTRUE) {
snapshot = g_driveline;
xSemaphoreGive(g_data_mutex);
} else {
// Never hand back a torn read; an all-zero snapshot is honest about
// having no fresh data (engine_run_state 0 == ENGINE_RUN_OFF).
memset(&snapshot, 0, sizeof(snapshot));
}
return snapshot;
}
bool isActive() { bool isActive() {
return g_can_active; return g_can_active;
} }
+5 -3
View File
@@ -1,6 +1,6 @@
--- ---
type: index type: index
updated: 2026-07-16 updated: 2026-07-17
--- ---
# Index # Index
@@ -16,11 +16,12 @@ Catalog of every page in the wiki. Read this first when answering questions. Kee
## Concepts ## Concepts
- [[can-bus-integration]] — the core challenge; current firmware ID map flagged as placeholder, verification plan - [[can-bus-integration]] — the core challenge; current firmware ID map flagged as placeholder, verification plan
- [[driveline-speed-signals]] — **engine / turbine / output-shaft speeds**: turbine speed as physical proof of gear engagement, and the output-shaft field that is our **only road-speed source** (no DSC on this bus) — the feedback variable for a future cruise-control PoC, with the safety envelope that would require
- [[dual-controller-architecture]] — Controller A → UART 5Hz → Controller B (1.3" display); packet format - [[dual-controller-architecture]] — Controller A → UART 5Hz → Controller B (1.3" display); packet format
## Synthesis ## Synthesis
- [[can-id-candidates]] — **the E60/E65 CAN ID map from web research, now CONFIRMED live**: 0x1D0/0x1D2/0x0B5/0x3B4 present on the real bus; placeholder IDs verified absent; fault codes not passively broadcast - [[can-id-candidates]] — **the E60/E65 CAN ID map — now decoded end-to-end**: gear (lever + engaged + mode), coolant, gearbox temp (raw−40), battery (12-bit ×0.015), RPM, turbine speed, engine state all verified; placeholder IDs verified absent; fault codes and boost not passively broadcast
- [[open-questions]] — the research frontier: bench-verify the candidate IDs, operating temp, transient protection, fault-code design decision - [[open-questions]] — the research frontier: bench-verify the candidate IDs, operating temp, transient protection, fault-code design decision
## Sources ## Sources
@@ -29,4 +30,5 @@ 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 - [[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 - [[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` - [[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` - [[gear-box-can-revealings]] — **gear fully decoded & VERIFIED** (2026-07-16/17): `0x1D2` byte0 = lever, **byte1 = engaged gear 1–6**, byte4 = Drive/Sport/Manual mode; `0x0BA` = the box's own target gear incl. **reverse**; raw at `raw/gear_box_can_revealings.csv` + `raw/gearbox_engaged_gear.csv`
- [[e65-reverse-engineering-repo]] — **E65 per-ID DBC-style docs (ingested 2026-07-17)** — the highest-value source yet: settled the gearbox-temp offset (raw−40) and battery layout (12-bit ×0.015), proved the engine was running in our capture, and revealed turbine speed, output shaft, pedal position and cruise state
+4
View File
@@ -26,6 +26,10 @@ User confirmed: donor chassis is **E60/E65 (2003+)**, transmission is a **BMW au
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). 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-17] ingest | E65_ReverseEngineering repo — both disputes resolved, driveline speeds discovered
User pointed at `HeinrichG-V12/E65_ReverseEngineering` (per-ID DBC-style docs, worked example on every page) → [[e65-reverse-engineering-repo]]. Highest-value source to date; combined with re-analysis of our own `raw/can-capture-2026-07-15-gearshift.csv` it closed most of the frontier. **Resolved**: gearbox oil temp = **raw − 40** (source example + our own gearbox-31 °C-vs-coolant-37 °C warm-up cross-check; my earlier "leaning offset 0" was wrong); battery = **12-bit LE × 0.015**; engine **was running** in the 2026-07-15 capture (`ST_ENGINE_RUN`=2 in 397/397) — **cold-start capture no longer needed**; RPM = `0x0AA` ×0.25 (679–684 idle). **Discovered**: `0x1A2` `RPM_GRB_TURB` turbine speed — a *physical* engagement proof (P/N ≈634/628 free-spinning vs D ≈70, R ≈0 stalled — textbook converter behaviour), plus `0x0BA` bits 20–39 output shaft (undocumented anywhere; zero in every stationary frame incl. engaged-in-D, non-zero once wheels turn), plus `ANG_ACPD` pedal % and `ST_CLCTR_V` cruise state. New page [[driveline-speed-signals]] — emphasized per user: **no DSC on this bus ⇒ output shaft is our only road-speed source**, hence the feedback variable for a future cruise-control PoC (safety envelope documented; actuation = transmitting torque requests, a different risk class from everything read-only so far). **Corrected three of my own 2026-07-16 claims**: `0x1D2` D1 is the *engaged gear* (not a "drive-gate flag" — it read 1 because the car was stationary); D4 `0xF2` is a persistent *Manual mode* (not a "downshift event" — it holds across gears 2–6); `0x0BA` is **not** to be dismissed (I'd read D7, an alive counter, instead of D0's `ST_GR_GRB` — which is the only source of engaged **reverse**, `0x1D2` D1 staying `0x0F` in R). Also: boost is **not** broadcast (`AIP_ENG` caps at 1108 hPa = barometric) — confirms the Launch must poll. Updated [[can-id-candidates]], [[gear-box-can-revealings]], [[open-questions]], index. Next: firmware pass over the whole verified map.
## [2026-07-16] ingest | First live CAN capture — research map CONFIRMED ## [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. 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.
+52 -27
View File
@@ -1,7 +1,7 @@
--- ---
type: synthesis type: synthesis
tags: [can-bus, reverse-engineering, e60, research] tags: [can-bus, reverse-engineering, e60, research]
updated: 2026-07-16 updated: 2026-07-17
--- ---
# E60/E65 CAN ID Candidates (Research Results) # E60/E65 CAN ID Candidates (Research Results)
@@ -15,7 +15,14 @@ Findings from the 2026-07-15 deep-research run (95 claims extracted from ~15 sou
> - `0x1D0` byte0 drifts up `0x55→0x58` = coolant warming (−48 scaling holds). **Oil temp `0x1D0` byte1 = `0xFF`** (not populated here). > - `0x1D0` byte0 drifts up `0x55→0x58` = coolant warming (−48 scaling holds). **Oil temp `0x1D0` byte1 = `0xFF`** (not populated here).
> - `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. > - `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`. > - 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.
> [!success] 2026-07-17 — [[e65-reverse-engineering-repo]] ingested: both disputes resolved, engine state closed
> A per-ID DBC-style source with worked examples on every page. Combined with re-analysis of our own capture:
> - **Gearbox oil temp offset RESOLVED → `raw − 40`** (not offset 0, not +40). Cross-checked against our coolant trace.
> - **Battery layout RESOLVED → 12-bit LE × 0.015** (the E65 reading; the E90 24-bit BE reading is wrong for us).
> - **Engine-run state CLOSED** — `0x1D0` bits 20–21 read "running" in 397/397 frames of the 2026-07-15 capture. That dump *was* a genuine warm-up trace, so **no cold-start capture is needed to trust the coolant scaling**.
> - **Engaged gear number RESOLVED** without a drive capture → `0x1D2` D1 high nibble ([[gear-box-can-revealings]]).
> - **New signals**: turbine speed (`0x1A2`), output shaft speed (`0x0BA` D3/D4), pedal position + cruise state (`0x0AA`) → [[driveline-speed-signals]].
## The map (replaces the firmware's placeholder IDs) ## The map (replaces the firmware's placeholder IDs)
@@ -23,12 +30,19 @@ 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) | | 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 | | 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) | | Gearbox oil temp | **0x0B5** (`TEMP_GRB`) | byte 7 | **°C = raw − 40** | EGS | 10 ms | **✅ RESOLVED 2026-07-17** — [[e65-reverse-engineering-repo]] worked example (raw `0x43`=67 → 27 °C), plus our own cross-check: D7 `0x47`(71)→**31 °C** while coolant read 37 °C and climbing. Offset-0 would have the box at 71 °C with the engine at 37 °C — impossible for a warm-up |
| 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]] | | Gear lever position | **0x1D2** ("TransmissionDataDisplay") | **byte 0** | `0xE1`=P `0xD2`=R `0xB4`=N `0x78`=D/(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) | | Gearbox mode | **0x1D2** | **byte 4** | `0xF0`=Drive(auto) `0xF1`=Sport `0xF2`=Manual | EGS | 200 ms | **✅ VERIFIED 2026-07-17** — `0xF2` is a *persistent mode*, not a downshift event (earlier claim corrected) |
| 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) | | Engaged gear number | **0x1D2** | **byte 1** | `gear = (D1 >> 4) − 4`; `0x0F` = none (P/R/N) | EGS | 200 ms | **✅ VERIFIED 2026-07-17** — clean +16 ladder across gears 1–6, identical in D and M/S ([[gear-box-can-revealings]]). **Never set for R** |
| Engine RPM (bonus) | **0x0AA** | bytes 4–5 | RPM = raw / 4 | DME/DDE | 10 ms | High — cross-generation (E65 + E90 comment) | | Engaged gear **incl. reverse** | **0x0BA** (`ST_GR_GRB`) | byte 0 low nibble | `1`=N `2`=**R** `3`=P `5`–`A`=1st–6th `0xF`=invalid | EGS | 20 ms | **✅ VERIFIED 2026-07-17** for 1/2/3/5 against our capture; 6–A inferred. **The only source of engaged reverse** — `0x1D2` D1 is blind to it |
| 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 | | Battery voltage | **0x3B4** (`U_BT`) | bits 0–11 | **`((D1 & 0x0F) << 8 \| D0) × 0.015` V** | Power module | 5 s | **✅ RESOLVED 2026-07-17** — 12-bit LE × 0.015 confirmed by [[e65-reverse-engineering-repo]] worked example (`0x3D9`→14.775 V). The E90 24-bit BE × 0.001 reading is **wrong for us**. Bonus: `ENG_ST` bits 16–19 |
| Engine RPM | **0x0AA** (`RPM_ENG`) | bits 32–47 | **`(D4 + D5×256) × 0.25`** 1/min | DME/DDE | 10 ms | **✅ VERIFIED 2026-07-17** — 679–684 rpm at idle on our capture, matching `RPM_IDLE_TARGET`=700 from `0x1D0` |
| **Turbine speed** | **0x1A2** (`RPM_GRB_TURB`) | bits 0–15 | **`(D0 + D1×256) × 0.125 + 6`** 1/min | EGS | 20 ms | **✅ VERIFIED 2026-07-17** — physical proof of gear engagement; collapses ~630→~0 when the box engages. → [[driveline-speed-signals]] |
| **Output shaft speed** | **0x0BA** | bits 20–39 (D3/D4) | ⚠ **uncalibrated** | EGS | 20 ms | 🔬 **Hypothesis, strong** — undocumented in the source repo; zero in every stationary frame incl. engaged-in-D, non-zero once wheels turn. **Our only road-speed signal** (no DSC on this bus) → [[driveline-speed-signals]] |
| Engine run state | **0x1D0** (`ST_ENGINE_RUN`) | bits 20–21 | `0`=off `1`=starting `2`=running `3`=invalid | DME/DDE | 100 ms | **✅ VERIFIED 2026-07-17** — read 2 ("running") in 397/397 frames of the 2026-07-15 capture |
| Pedal position / cruise state | **0x0AA** | `ANG_ACPD` bits 24–31 (×0.39063 %); `ST_CLCTR_V` bits 52–55 | see [[driveline-speed-signals]] | DME/DDE | 10 ms | (source: [[e65-reverse-engineering-repo]]) — relevant to a cruise-control PoC |
| Gearbox cooling demand | **0x0B5** (`ST_OTMP_GRB`) | bits 38–39 | `0`=none `1`=stage 1 `2`=stage 2 `3`=invalid | EGS | 10 ms | (source: [[e65-reverse-engineering-repo]]) — the box's own overheat opinion; better display warning than a raw threshold |
| Ignition/terminal status | **0x130** | byte 0 bitmasks | 0xD5/0xC5/0xC1 | CAS | 100 ms | **Absent from our bus** (verified 2026-07-15) — CAS not retained in the swap |
### The 0x1D2 encoding dispute — ✅ RESOLVED on the swap bus (2026-07-16) ### The 0x1D2 encoding dispute — ✅ RESOLVED on the swap bus (2026-07-16)
@@ -37,30 +51,39 @@ The live lever capture ([[gear-box-can-revealings]]) settles it — **DLC 6**, w
| Byte | Meaning | Values | | Byte | Meaning | Values |
|------|---------|--------| |------|---------|--------|
| **0** | **Lever position** | `0xE1`=P, `0xD2`=R, `0xB4`=N, `0x78`=D **and** S/M | | **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 | | **1** | **Engaged gear** | `gear = (D1 >> 4) − 4`; `0x0F` = none (P/R/N). Never set for R |
| 2 | unused | `0xFF` |
| 3 | Rolling counter | fluctuates — ignore (matches the predicted byte-3 counter) | | 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 | | **4** | **Mode** | `0xF0`=Drive(auto), `0xF1`=Sport, `0xF2`=Manual |
| 5 | unused | `0xFF` |
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. Byte 0 alone gives P/R/N/D; byte 4 splits **D vs S vs M**; byte 1 gives the engaged gear 1–6. 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]] > [!warning] Two 2026-07-16 labels on this page were wrong — corrected 2026-07-17
> - **D1 was called a "drive-gate flag"**. It is the **engaged gear number**; it only ever showed two values because the vehicle was stationary in 1st. This also means the "engaged gear needs a drive capture" task was never real — a per-detent capture sufficed.
> - **D4 `0xF2` was called "downshift (−)"**, a transient event. It is a **persistent Manual-mode flag** — it holds across gears 2–6. The `+`/`−` nudges have no distinct code; they merely promote Sport → Manual. The old "up-shift (+) value unconfirmed" question therefore dissolves rather than being answered.
>
> Both errors came from over-reading a two-value field as a boolean. Full evidence: [[gear-box-can-revealings]].
> Note `0x1D2` is where **our decode is ahead of the published source**: [[e65-reverse-engineering-repo]] lists `0x1D2` as "Display Gearbox Data" with an **empty signal table** — it never decoded it. Its sample frame (`E1 0C 8F 7C F0 FF`) does independently confirm `0xE1`=P.
> The firmware's `automotive_data.h` gear map should be rewritten to `0x1D2` byte 0 + byte 1 + byte 4, with `0x0BA` for engaged reverse. → [[can-bus-integration]]
## Field checklist for the live capture session ## Field checklist for the live capture session
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. 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.
Setup notes still apply. **Most of the original checklist is now done** — gear (lever, engaged, mode), coolant, gearbox temp, battery, RPM, engine state are all resolved. What remains:
| Test | Watch | Confirms | | Test | Watch | Confirms |
|------|-------|----------| |------|-------|----------|
| Ignition on, engine off | `0x130` byte 0 changes per key position; `0x3B4` appears (~every 5 s) | Terminal status; battery message alive | | **Wheels lifted, steady speed in D; step 1st→6th** | `0x0BA` D3/D4 vs `0x1A2` turbine vs `0x0AA` RPM, logged together | **Output-shaft scaling.** Turbine ÷ output at each gear should reproduce the 6HP26 ratios — a built-in self-check. → [[driveline-speed-signals]] |
| Compare `0x3B4` to a multimeter at the battery | Try 12-bit LE ×0.015 and ×0.0147 vs meter (engine off ≈12.4 V, running ≈14+ V); check byte 3 flips 0x00→0x09 on start | Battery layout + factor; engine-running flag | | Compare `0x3B4` to a multimeter at the battery | `((D1 & 0x0F) << 8 \| D0) × 0.015` vs meter (engine off ≈12.4 V, running ≈14+ V) | Battery factor — layout is settled, this is a sanity pass only |
| Cold start, note ambient temp | `0x1D0` byte 0 ≈ ambient+48 raw, then climbs steadily to ~90 °C (raw ~0x8A) | Coolant ID + −48 scaling | | Cross-check `0x0B5` D7 − 40 against the Launch's gearbox oil temp readout | Expect agreement within a degree | Confirmatory only — offset already settled two ways |
| Same, byte 1 | Should ALSO start near ambient but climb **slower** than byte 0 and lag behind | Oil temp really is byte 1 (weakest engine signal) | | Lever to R **on the ground**, brake released | `0x1A2` turbine ÷ `0x0AA` RPM ratio | The engagement test for the "lever says R but nothing happens" fault → [[driveline-speed-signals]] |
| Cold start | `0x0B5` byte 7: if raw ≈ ambient → offset 0; if raw ≈ ambient+40… i.e. reads 40 under ambient with offset 0 assumed → offset +40 | Gearbox temp offset dispute (cold start makes the two hypotheses ~40 apart — unmistakable) | | Engage cruise (if the donor's stalk is wired) | `0x0AA` `ST_CLCTR_V` bits 52–55 → `0x4`–`0x7` | Whether the DME's CC regulator is live on this swap |
| Hold brake, shift P→R→N→D→(S/M) slowly | `0x1D2` byte 0 (note DLC: 5 vs 6!); `0x304` bytes; `0x0BA` bits 0–3 | Gear lever encoding + which message to use; settles the D=R typo in the E60 sheet |
| Drive: let the box shift 1→2→3… | `0x1D2` byte 1 upper nibble, `0x0BA` low nibble increments per shift | Current gear number source |
| Blip throttle | `0x0AA` bytes 4–5 = RPM×4 | RPM sanity check (fast cross-check that you're on the right bus) |
If an expected ID is absent entirely, note it — it means the swap harness dropped that module's traffic, which is itself an answer ([[open-questions]] #3). Absent IDs are themselves answers — `0x130`/`0x304`/`0x192` and the whole DSC group (`0x0CE`/`0x19E`/`0x1A0`) never appear, meaning CAS and DSC aren't on the swap bus ([[open-questions]] #3).
## Fault codes: passive reading is NOT possible ⚠ ## Fault codes: passive reading is NOT possible ⚠
@@ -77,9 +100,9 @@ Also useful: an E60 forum claim `(unverified)` that arbitration IDs are identica
## Sources ## Sources
- [[e65-reverse-engineering-repo]] — **E65/E66 per-ID DBC-style docs (ingested 2026-07-17)** — the highest-value source found so far: resolved the gearbox-temp offset and battery layout, closed the engine-state question, and supplied turbine speed, output shaft, pedal position and cruise state. Caveat: petrol MED 9.2.1 donor, not M57N diesel
- [[e60-vfl-can-codes-xlsx]] — **E60 VFL community spreadsheet (ingested)**: E60-specific confirmation of 0x1D0 (−48 scaling), 0x3B4, 0x1D2 DLC 6; adds 0x304 gear lever; contains NO oil-temp or gearbox-temp rows - [[e60-vfl-can-codes-xlsx]] — **E60 VFL community spreadsheet (ingested)**: E60-specific confirmation of 0x1D0 (−48 scaling), 0x3B4, 0x1D2 DLC 6; adds 0x304 gear lever; contains NO oil-temp or gearbox-temp rows
- [[listen-and-send-pid-arduino]] — technique reference (ingested): ELM327 PID-request pattern for the fault-code fallback; E46 cluster frames, not E60 evidence - [[listen-and-send-pid-arduino]] — technique reference (ingested): ELM327 PID-request pattern for the fault-code fallback; E46 cluster frames, not E60 evidence
- `HeinrichG-V12/E65_ReverseEngineering` (GitHub) — E65 760Li PT-CAN, docs verified verbatim by the adversarial pass (0x1D0, 0x3B4, 0x192, 0x1D2, 0x0BA, 0x1A2)
- `damienmaguire/BMW-E65-CANBUS` (GitHub) — live E65 735i captures + working EGS emulator code (0x1D2 encoding, 0x192, 0x0AA) - `damienmaguire/BMW-E65-CANBUS` (GitHub) — live E65 735i captures + working EGS emulator code (0x1D2 encoding, 0x192, 0x0AA)
- `TimesNewRomanZ/e60-canbus` (GitHub, community `bmw_e9x_e8x.dbc`) — author runs a real E60 545i; 0x1D0 confirmed live on E60 - `TimesNewRomanZ/e60-canbus` (GitHub, community `bmw_e9x_e8x.dbc`) — author runs a real E60 545i; 0x1D0 confirmed live on E60
- `kmalinich/dieslg8` (GitHub) — M57 diesel (E90 335d, EDC17): diagnostic-request-only coolant/DTC evidence - `kmalinich/dieslg8` (GitHub) — M57 diesel (E90 335d, EDC17): diagnostic-request-only coolant/DTC evidence
@@ -89,11 +112,13 @@ Also useful: an E60 forum claim `(unverified)` that arbitration IDs are identica
## Caveats ## Caveats
- 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. - 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, and the M57 dieslg8 project. Engine-side layouts are inferred from petrol DME captures of the same bus generation. **Mitigating evidence (2026-07-17)**: every signal from the petrol-donor [[e65-reverse-engineering-repo]] that we checked against our own bus decoded to physically sensible values first try — coolant, gearbox temp, RPM, turbine speed, engine state, gear. The layouts evidently carry.
- **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). - **Engine oil temp is now the only dead signal**: `0x1D0` byte 1 reads `0xFF` on our bus — the sensor isn't populated on this M57N. Not a decode error; there is nothing to read. The UART packet's `engine_oil_temp` field has no source.
- 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]] - **`AIP_ENG` (`0x1D0` byte 3) is barometric, not boost** — 8 bits ×2 +598 caps at 1108 hPa; a boosting M57N reaches ~2500 hPa absolute. Manifold boost is **not broadcast**; the Launch polls for it. → [[obd-diagnostic-polling]]
- 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. - Firmware's original 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]]
- **The cold-start capture is no longer needed.** It was on the list only because the 2026-07-15 engine state was unknown; `ST_ENGINE_RUN` = running in 397/397 frames settles that, making the coolant trace a genuine warm-up and its −48 scaling trustworthy.
- Remaining `(unverified)`: `0x0BA` `ST_GR_GRB` values 6–A (2nd–6th, inferred from the parallel `0x1D2` ladder), and the `0x0BA` D3/D4 output-shaft **scaling**. → [[driveline-speed-signals]]
## Related ## Related
[[can-bus-integration]] · [[bmw-m57n-engine]] · [[nissan-patrol-swap]] · [[open-questions]] [[can-bus-integration]] · [[driveline-speed-signals]] · [[e65-reverse-engineering-repo]] · [[gear-box-can-revealings]] · [[bmw-m57n-engine]] · [[nissan-patrol-swap]] · [[open-questions]]
+137
View File
@@ -0,0 +1,137 @@
---
type: concept
tags: [can-bus, egs, dde, speed, gear, cruise-control, verified]
updated: 2026-07-17
---
# Driveline Speed Signals
The three rotating speeds our bus exposes — **engine**, **turbine (gearbox input)**, and **output shaft** — and why they matter well beyond the gear display. Together they give (a) a physical proof of gear engagement that no status byte can provide, and (b) the feedback variable a **cruise-control proof of concept** would be built on.
> [!important] Why this page exists
> The swap bus carries **no DSC module** — the 2026-07-15 capture found 15 IDs and *none* of the chassis/stability IDs (`0x0CE`, `0x19E`, `0x1A0`) the [[e65-reverse-engineering-repo]] documents. **There is no wheel-speed message on this bus.** So the gearbox's own shaft speeds are not a nice-to-have — they are the *only* road-speed information available to us. Anything speed-dependent this project ever does, including cruise control, has to come from here.
## The three speeds
| What | ID | Bytes | Decode | Status |
|---|---|---|---|---|
| **Engine RPM** | `0x0AA` `RPM_ENG` | bits 32–47 | `(D4 + D5×256) × 0.25` 1/min | ✅ **verified** — 679–684 at idle |
| **Turbine (input)** | `0x1A2` `RPM_GRB_TURB` | bits 0–15 | `(D0 + D1×256) × 0.125 + 6` 1/min | ✅ **verified** — see below |
| **Output shaft** | `0x0BA` bits 20–39 | D3/D4 | ⚠ **uncalibrated** | 🔬 **hypothesis** — see below |
`0x1A2` is DLC 4 @ 20 ms; `0x0AA` is DLC 8 @ 10 ms; `0x0BA` is DLC 8 @ 20 ms. All three are fast — good for a control loop.
> [!note] Do not use `GRDT_REIN` (`0x0BA` bits 8–19)
> The repo documents it as a gearbox speed (×0.125 1/min), but on **our** bus it reads `0xFFE`/`0xFFF` — the invalid marker — across every frame of both captures. Not populated here. `0x1A2` is the turbine source that works. (verified, 2026-07-17)
## Turbine speed = physical proof of engagement ✅
The single most useful thing this ingest produced. Correlating `0x1A2` against lever position across the 2026-07-15 capture (engine idling ~680 rpm, vehicle stationary on its brakes):
| Lever | Frames | Turbine min | **avg** | max |
|---|---|---|---|---|
| P | 1370 | 6 | **634** | 652 |
| N | 95 | 6 | **628** | 649 |
| **D** | 458 | 6 | **70** | 652 |
| **R** | 2 | 6 | **~0** | 6 |
(verified, 2026-07-17 — derived from `raw/can-capture-2026-07-15-gearshift.csv`)
This is textbook torque-converter behaviour and it is unambiguous:
- **P/N** — nothing is engaged, so the turbine free-spins at roughly engine speed (~630 vs ~680; the gap is normal converter slip).
- **D/R** — the box engages, the output shaft is held by the brakes, and the turbine **stalls to near zero**.
The D column's `max` of 652 and the wide min/max spread are just the transition frames as the lever passed through — the *average* tells the story.
### Why this beats every status byte
`ST_GR_GRB` (`0x0BA`) tells you what the gearbox **intends**. `0x1D2` D0 tells you what the driver **selected**. Neither is proof that anything mechanically happened. **Turbine speed is a physical measurement of load** — the box can't fake it.
**The engagement test** is the *ratio* of turbine to engine speed, not the absolute value:
```
ratio = RPM_GRB_TURB (0x1A2) / RPM_ENG (0x0AA)
ratio ≈ 1.0 → turbine free-spinning → NOT engaged (normal in P/N)
ratio ≈ 0 → turbine stalled/loaded → engaged, output held
0 < ratio < 1 → engaged and moving (converter slip under load)
```
This directly answers the UX problem that motivated the search — *"lever says R but the car isn't moving."* With the vehicle on the ground and the brake released:
- lever = R, **ratio ≈ 0 or climbing from 0** → box engaged, it's working
- lever = R, **ratio ≈ 1.0** → **the box never took the request** ⚠ this is the fault to surface
> [!warning] The ratio is only meaningful under known output conditions
> On a **lift with the wheels free**, an engaged box spins the wheels up until the turbine approaches engine speed again — so `ratio ≈ 1.0` is normal there and does **not** indicate a fault. The test is only valid when the output is loaded (on the ground). Any firmware use of this must gate on output-shaft speed ≈ 0, or the display will cry wolf every time the car is jacked up.
## Output shaft speed — the cruise-control variable 🔬
`0x0BA` bits **20–39** (D2 high nibble, D3, D4) are a **gap in the published source** — the [[e65-reverse-engineering-repo]] table jumps from `GRDT_REIN` at bit 19 straight to the checksum at bit 40. Its own E65 example leaves those bytes zero. **Our bus populates them.**
Evidence that they are an output-shaft/road-speed field (verified, 2026-07-17):
| Condition | D3 | D4 | Turbine | Interpretation |
|---|---|---|---|---|
| P — stationary | `00` | `00` | ~634 | output stopped |
| N — stationary | `00` | `00` | ~628 | output stopped |
| **D — stationary, brakes on** | `00` | `00` | **~70** | engaged but **output held** → zero |
| **R — wheels lifted & turning** | `A8` | `01` | — | **output turning → non-zero** |
The field is zero in *every* stationary frame **including engaged-in-D**, and non-zero the moment the wheels actually rotate. That decouples it from engine, turbine, and gear state — it tracks the **output shaft** and nothing else. Which is exactly the definition of road speed, minus a diff ratio and a tyre circumference.
Read as 16-bit Intel at bit 24: `0x01A8` = 424. At the ×0.125 factor its neighbours use, ~53 rpm — plausible for lifted wheels idling in R, but **the scaling is a guess off a single snapshot and must not be trusted yet.**
### Calibrating it (the next capture)
1. Wheels lifted, hold a steady speed in **D**, log `0x0BA` + `0x1A2` + `0x0AA` together.
2. Step through 1st→6th if the box will shift, recording D3/D4 at each. Turbine ÷ output at each gear should reproduce the **6HP26 gear ratios** — which is a self-check: if the ratios come out right, the scaling is right.
3. `6HP26.pdf` lives in the source repo's `docs/` and gives those ratios. → [[open-questions]] wishlist.
4. Cross-check against the Launch's road-speed readout if it exposes one. → [[obd-diagnostic-polling]]
Getting from output-shaft rpm to km/h needs the **final drive ratio and tyre size of the Patrol**, not the donor — a swap-specific number nobody has written down yet. → [[nissan-patrol-swap]]
## Cruise control: what the bus already gives us
The DME publishes its own cruise/ACC regulation state. `0x0AA` `ST_CLCTR_V` (bits 52–55):
| Value | Meaning |
|---|---|
| `0x0` | ACC regulation, pedal not pressed |
| `0x1` | ACC regulation, pedal pressed |
| `0x4` | **CC regulation, retard** |
| `0x5` | **CC regulation, constant speed** |
| `0x6` | **CC regulation, recall** |
| `0x7` | **CC regulation, speed up** |
| `0x8` | Pedal not pressed |
| `0x9` | Pedal pressed |
| `0xA` | Pedal transgress |
| `0xB` | Pedal kickdown |
(source: [[e65-reverse-engineering-repo]]. Our capture reads `0x0` on all 3835 frames — pedal untouched, consistent with a stationary idling test. (verified, 2026-07-17))
Also available: **`ANG_ACPD`** (`0x0AA` bits 24–31, ×0.39063 %) — accelerator pedal position, `0x00` unpressed → `0xFF` floored. And **`TORQ_DVCH`** (bits 12–23, signed ×0.5 Nm) — driver-demand torque.
### Why a PoC is architecturally plausible
The E65 powertrain is built around **external modules requesting torque from the DME** — that is precisely what `0x0B5` ("Torque Request EGS") is, and what `0x0BA`'s repo title ("Torque Request ACC") points at. The DME arbitrates requests from the EGS, from ACC, and from itself; `ST_CLCTR_V` is it *reporting which regulator currently has the ball*. So the plumbing for "another module asks the engine for torque" is native to this bus, not something we'd have to invent.
A PoC would then need:
- **Feedback**: output shaft speed (`0x0BA` D3/D4) — *the only road-speed source we have* ⬅ the reason this page exists
- **Actual/limits**: `RPM_ENG`, `ANG_ACPD` (driver override — pedal press must instantly disengage)
- **Engagement sanity**: turbine ratio, so it can't regulate against a box in N
- **Actuation**: a torque-request frame the DME accepts
> [!danger] Actuation is a different category of risk from everything so far
> Every capability in this project to date is **read-only**. A cruise-control PoC **transmits frames that command engine torque**. Getting the ID, scaling, checksum, or alive counter wrong doesn't produce a bad reading — it produces **unintended acceleration**. Additional hazards specific to our situation:
> - The board already runs `TWAI_MODE_NORMAL` and ACKs the bus, so transmit is one function call away — there is **no accidental-write safety margin** left. → [[can-bus-integration]]
> - `0x0B5`/`0x0BA` carry **checksums and alive counters**; the DME rejects (and may fault on) malformed requests. Both algorithms are unknown to us.
> - The swap has **no DSC and no brake-pedal switch on the bus** we've found — so the usual "brake cancels cruise" interlock has no source. A PoC would have no independent way to know the driver is braking.
>
> Treat this as a **bench/lifted-wheels-only** exercise until every one of those is resolved. Nothing here should be enabled on a moving vehicle on the strength of a wiki page.
## Related
[[e65-reverse-engineering-repo]] · [[can-id-candidates]] · [[gear-box-can-revealings]] · [[can-bus-integration]] · [[nissan-patrol-swap]] · [[open-questions]]
+24 -5
View File
@@ -1,7 +1,7 @@
--- ---
type: synthesis type: synthesis
tags: [meta, todo] tags: [meta, todo]
updated: 2026-07-16 updated: 2026-07-17
--- ---
# Open Questions # Open Questions
@@ -10,7 +10,15 @@ The research frontier. Answering any of these should trigger updates across the
## Blocking ## Blocking
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]] *(Nothing is blocking as of 2026-07-17 — the CAN map is decoded end-to-end. See #8 for the one live calibration left.)*
## Active
8. **What is the scaling of `0x0BA` D3/D4 (output shaft speed)?** The field is undocumented in every source; we know it's zero when the output is held and non-zero when the wheels turn, but not what a count is worth. **This is the project's only road-speed signal** — there is no DSC/wheel-speed module on the swap bus — so anything speed-dependent (notably a cruise-control PoC) waits on this. Calibrate by logging `0x0BA` + `0x1A2` + `0x0AA` at steady speed through gears 1–6; turbine ÷ output should reproduce the 6HP26 ratios as a self-check. → [[driveline-speed-signals]]
9. **Is a cruise-control PoC worth pursuing, and under what safety envelope?** The bus architecture supports it natively (the DME arbitrates torque requests from the EGS and ACC; `ST_CLCTR_V` reports which regulator has control). But actuation means **transmitting frames that command engine torque**, with unknown checksum/alive-counter algorithms and **no brake-pedal signal on this bus** to build the standard cancel interlock from. Design decision, not a research question. → [[driveline-speed-signals]]
10. **What are the Patrol's final drive ratio and tyre size?** Needed to turn output-shaft rpm into road speed. Swap-specific — not in any donor documentation. → [[nissan-patrol-swap]]
## Project context ## Project context
@@ -22,10 +30,18 @@ The research frontier. Answering any of these should trigger updates across the
5. **Operating temperature 0–65 °C** (source: waveshare-wiki) — outside automotive norms at both ends (sub-zero winter cabins, sun-baked dashboards). Is the mounting location temperature-controlled enough? Any mitigation (mounting away from vents/sun, accepting reduced lifespan)? 5. **Operating temperature 0–65 °C** (source: waveshare-wiki) — outside automotive norms at both ends (sub-zero winter cabins, sun-baked dashboards). Is the mounting location temperature-controlled enough? Any mitigation (mounting away from vents/sun, accepting reduced lifespan)?
6. **Transient protection on the 7–36 V input**: the board takes vehicle 12 V directly, but ISO 7637 load-dump spikes can exceed 36 V `(unverified)`. Consider an upstream TVS diode / automotive-rated buck. Also: ignition-switched vs constant power (the isolated digital input could sense ignition). 6. **Transient protection on the 7–36 V input**: the board takes vehicle 12 V directly, but ISO 7637 load-dump spikes can exceed 36 V `(unverified)`. Consider an upstream TVS diode / automotive-rated buck. Also: ignition-switched vs constant power (the isolated digital input could sense ignition).
7. **Fault codes**: the UART packet reserves a field for fault codes — DDE fault codes are read via diagnostic protocols (KWP2000/UDS over K-line or CAN), not passively broadcast. Is passive reading even possible? `(unverified)` 7. **Fault codes**: the UART packet reserves a field for fault codes — DDE fault codes are read via diagnostic protocols (KWP2000/UDS over K-line or CAN), not passively broadcast. Is passive reading even possible? `(unverified)` — **update 2026-07-17**: the same barrier explains why the Launch scanner shows boost/gearbox data our dump lacks (it polls; nothing broadcasts them). A capture *while the Launch is connected* would record both request and reply frames, handing us the exact bytes to replay. → [[obd-diagnostic-polling]]
## Answered ## Answered
- ~~Was the engine actually running during the 2026-07-15 capture?~~ → **Yes** — `0x1D0` `ST_ENGINE_RUN` = 2 ("running") in **397/397 frames** (verified, 2026-07-17). The coolant trace is genuine warm-up data; **the cold-start capture that was blocking #1 is no longer needed.** → [[e65-reverse-engineering-repo]]
- ~~Gearbox oil temp offset: 0 or +40?~~ → **Neither — `raw − 40`** (verified two ways, 2026-07-17): the source's worked example, plus our own gearbox-at-31 °C vs coolant-at-37 °C warm-up cross-check. → [[e65-reverse-engineering-repo]]
- ~~Battery voltage layout: 12-bit LE ×0.015 or 24-bit BE ×0.001?~~ → **12-bit LE × 0.015** (source: E65 repo worked example `0x3D9`→14.775 V, 2026-07-17).
- ~~What is the actual engaged gear number, and does it need a drive capture?~~ → **`0x1D2` D1**, `gear = (D1>>4)−4`. **No drive capture needed** — a per-detent capture sufficed. (verified, 2026-07-17) → [[gear-box-can-revealings]]
- ~~What is the manual up-shift (+) value on `0x1D2` D4?~~ → **The question was malformed.** D4 is a persistent *mode* (`0xF0` auto / `0xF1` Sport / `0xF2` Manual), not a shift-event field; `+` and `−` have no distinct codes. (verified, 2026-07-17)
- ~~Is engaged **reverse** observable?~~ → **Yes, but not on `0x1D2`** (D1 stays `0x0F` in R). Use **`0x0BA` `ST_GR_GRB` = 2**. For physical proof of engagement, use turbine speed. (verified, 2026-07-17) → [[driveline-speed-signals]]
- ~~Is boost passively broadcast?~~ → **No.** `0x1D0` `AIP_ENG` is barometric (caps at 1108 hPa vs ~2500 needed). Diagnostic polling only. (2026-07-17)
- ~~Which donor vehicle?~~ → **E60/E65 (2003+)** (verified — user, 2026-07-15) → [[bmw-m57n-engine]] - ~~Which donor vehicle?~~ → **E60/E65 (2003+)** (verified — user, 2026-07-15) → [[bmw-m57n-engine]]
- ~~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 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]] - ~~Is the target a Nissan Patrol?~~ → **Yes.** (verified — user, 2026-07-15) → [[nissan-patrol-swap]]
@@ -38,5 +54,8 @@ The research frontier. Answering any of these should trigger updates across the
- ~~Waveshare product page~~ ✅ ingested → [[esp32-s3-touch-lcd-5b-waveshare-wiki]] - ~~Waveshare product page~~ ✅ ingested → [[esp32-s3-touch-lcd-5b-waveshare-wiki]]
- Waveshare **schematic PDF** (linked from the product page: `ESP32-S3-Touch-LCD-5-Sch.pdf`) — would confirm CAN GPIO routing and power path - Waveshare **schematic PDF** (linked from the product page: `ESP32-S3-Touch-LCD-5-Sch.pdf`) — would confirm CAN GPIO routing and power path
- A community DBC / CAN-ID list for the donor platform - ~~A community DBC / CAN-ID list for the donor platform~~ ✅ ingested → [[e65-reverse-engineering-repo]]
- A real candump log from the engine running - ~~A real candump log from the engine running~~ ✅ → [[can-capture-2026-07-15]] (engine confirmed running, 2026-07-17)
- **`6HP26.pdf`** — sitting in the E65 repo's `docs/`. The ZF 6HP26 manual, very likely our exact gearbox: gear ratios would let us convert output-shaft rpm → road speed and self-check the D3/D4 scaling. → [[driveline-speed-signals]]
- **`can_message_list.txt`** (same repo) — full ID → name → sending-module map, 0x00–0xFFF. Not yet mined; useful if the project ever wants non-powertrain data
- A capture taken **while the Launch scanner is polling** — would reveal the request/response byte sequences for boost, gearbox temp and DTCs → [[obd-diagnostic-polling]]
File diff suppressed because it is too large Load Diff
+13
View File
@@ -0,0 +1,13 @@
PID,LEN,D0,D1,D2,D3,D4,D5,Actual Gear
1D2,6,120,95,255,Fluctuation,240,255,Drive 1
1D2,6,120,111,255,Fluctuation,240,255,Drive 2
1D2,6,120,127,255,Fluctuation,240,255,Drive 3
1D2,6,120,143,255,Fluctuation,240,255,Drive 4
1D2,6,120,159,255,Fluctuation,240,255,Drive 5
1D2,6,120,175,255,Fluctuation,240,255,Drive 6
1D2,6,120,95,255,Fluctuation,241,255,M/S 1
1D2,6,120,111,255,Fluctuation,242,255,M/S 2
1D2,6,120,127,255,Fluctuation,242,255,M/S 3
1D2,6,120,143,255,Fluctuation,242,255,M/S 4
1D2,6,120,159,255,Fluctuation,242,255,M/S 5
1D2,6,120,175,255,Fluctuation,242,255,M/S 6
1 PID LEN D0 D1 D2 D3 D4 D5 Actual Gear
2 1D2 6 120 95 255 Fluctuation 240 255 Drive 1
3 1D2 6 120 111 255 Fluctuation 240 255 Drive 2
4 1D2 6 120 127 255 Fluctuation 240 255 Drive 3
5 1D2 6 120 143 255 Fluctuation 240 255 Drive 4
6 1D2 6 120 159 255 Fluctuation 240 255 Drive 5
7 1D2 6 120 175 255 Fluctuation 240 255 Drive 6
8 1D2 6 120 95 255 Fluctuation 241 255 M/S 1
9 1D2 6 120 111 255 Fluctuation 242 255 M/S 2
10 1D2 6 120 127 255 Fluctuation 242 255 M/S 3
11 1D2 6 120 143 255 Fluctuation 242 255 M/S 4
12 1D2 6 120 159 255 Fluctuation 242 255 M/S 5
13 1D2 6 120 175 255 Fluctuation 242 255 M/S 6
Binary file not shown.
@@ -0,0 +1,162 @@
---
type: source
tags: [can-bus, e65, reverse-engineering, dbc, egs, dde, verified]
updated: 2026-07-17
---
# HeinrichG-V12/E65_ReverseEngineering (GitHub)
<https://github.com/HeinrichG-V12/E65_ReverseEngineering>
Per-ID CAN documentation for the **BMW E65/E66** PT-CAN, written DBC-style (signal name, start bit, length, byte order, factor, offset, unit) with a **worked decode example on every page**. Ingested 2026-07-17. This is the single highest-value source the project has found: it resolved two long-standing disputes, closed an open question, and handed us three signals we didn't know existed.
Structure: `docs/` holds 39 markdown files named by ID (`0x1D0.md`, `0x0B5.md`, …) plus `can_message_list.txt`/`.xlsx` (full ID → name → sending-module table), `can_error_list.txt`, and **`6HP26.pdf`** — the ZF 6HP26 transmission document, i.e. very likely *our* gearbox. Also `Log1.blf`/`Log2.blf` raw captures.
> [!warning] Generation/engine caveat
> The donor for this repo is an **E65 with a petrol MED 9.2.1 DME** (N73-era V12), not an M57N diesel. Engine-side layouts are therefore cross-engine inferences. **However**: every signal we checked against our own live capture decoded to physically sensible values on the first try (see below), so the EGS/DME message layouts evidently carry across the generation. Treat gearbox/power-management signals as strong, engine-internal ones as good-but-confirm.
## What it resolved
### ✅ Gearbox oil temp offset — the dispute is over
`0x0B5` = **Torque Request EGS**, DLC 8, 10 ms. `TEMP_GRB` at **start bit 56 (byte 7)**, length 8, factor 1, offset 40 — and the repo's own worked example decodes raw `0x43` (67) → **27 °C**. So the physical value is **raw − 40**.
> [!note] Sign-convention wrinkle
> The table literally prints `Offset | 40`, which in strict DBC convention (`phys = raw × factor + offset`) would mean raw **+** 40. The page's worked example computes raw **−** 40. The example wins — and our own data independently confirms it (below). Flagging so nobody "corrects" this back later.
**Independently confirmed on our bus** (verified, 2026-07-17): during the 2026-07-15 capture, `0x0B5` D7 read `0x47`/`0x48` (71–72) while `0x1D0` D0 showed coolant at 37–40 °C and climbing. raw−40 → gearbox at **31–32 °C**, sitting just behind a warming coolant. That's a correct cold-start picture. The offset-0 reading would put the gearbox at **71 °C while the engine was still at 37 °C** — the transmission warming faster than the engine it's bolted to, which is not a thing.
Other useful signals on `0x0B5`: `ST_OTMP_GRB` (bits 38–39) = gearbox cooling demand — `0x0`=none, `0x1`=stage 1, `0x2`=stage 2, `0x3`=invalid. **The box's own overheat opinion — a better display warning than thresholding raw temperature.** Also `TORQ_TAR_EGS` (bits 12–23, signed, ×0.5 Nm) and `TORQ_DRAW_GRB` (bits 48–55, Nm).
### ✅ Battery voltage layout — 12-bit wins
`0x3B4` = **Power Management Battery Voltage**, DLC 8, 5 s cycle.
| Signal | Start bit | Len | Factor | Meaning |
|---|---|---|---|---|
| `U_BT` | 0 | 12 | 0.015 V | Battery voltage (Intel/LE) |
| `ST_BTSW` | 12 | 2 | 1 | Battery main switch: `0`=closed, `1`=opening within 5 s, `2`=invalid |
| `ENG_ST` | 16 | 4 | 1 | Engine state |
| `ST_SWO_KL_30` | 30 | 2 | 1 | `1`=no PM shutdown, `2`=PM shutdown executed, `3`=invalid |
| `SDWN_COU_BTSW` | 32 | 8 | 1 | Shutdown counter (s) |
Worked example: `D9 03 00 53 FE 18 32 08` → `0x3D9` = 985 × 0.015 = **14.775 V**. This settles the [[can-id-candidates]] dispute in favour of **12-bit LE × 0.015**, against the 24-bit BE × 0.001 reading from the E90 DBC. Decode: `((D1 & 0x0F) << 8 | D0) × 0.015`.
### ✅ Engine-run state — open question closed
`0x1D0` carries `ST_ENGINE_RUN` at **bits 20–21** (byte 2): `0x0`=off, `0x1`=starting, `0x2`=**running**, `0x3`=invalid.
Checked across our capture: **`ST_ENGINE_RUN` = 2 in 397 of 397 frames** (verified, 2026-07-17). The engine was definitively running during the 2026-07-15 session, so its coolant trace is genuine warm-up data. This retires the "engine state unconfirmed" caveat that was blocking [[open-questions]] #1.
## `0x1D0` Engine Data (DLC 8, 100 ms) — full table
| Signal | Start bit | Len | Factor | Offset | Unit |
|---|---|---|---|---|---|
| `TEMP_ENG` | 0 | 8 | 1 | −48 | °C |
| `TEMP_EOI` | 8 | 8 | 1 | −48 | °C |
| `ALIV_COUNT_DME` | 16 | 4 | 1 | 0 | — |
| `ST_ENGINE_RUN` | 20 | 2 | 1 | 0 | — |
| `ST_SW_WAUP` | 22 | 2 | 1 | 0 | — |
| `AIP_ENG` | 24 | 8 | 2 | 598 | hPa |
| `IJV_FU` | 32 | 16 | 1 | 0 | µl |
| `CTL_SLCK` | 48 | 2 | 1 | 0 | — |
| `RPM_IDLE_TARGET` | 56 | 8 | 5 | 0 | 1/min |
`ST_SW_WAUP`: `0`=warming up, `1`=engine warm, `2`=EGS forced switching active, `3`=invalid.
`CTL_SLCK`: `0`=not allowed, `1`=no shiftlock requirement, `2`=shiftlock required, `3`=invalid.
Worked example `5D 3C 66 B7 CE 3A 8D 8C`: coolant 93−48=**45 °C**; oil 60−48=**12 °C**; air 183×2+598=**964 hPa**; fuel injection `0x3ACE`=**15054 µl**; idle target 140×5=**700 rpm**.
- **Coolant `−48` confirmed** — this is now the third independent source, plus our own live trace.
- **Oil temp = D1, also −48.** Ours reads `0xFF` → the sensor is genuinely unpopulated on this M57N, not a decode error. (verified, 2026-07-15)
- **`AIP_ENG` is NOT boost.** 8 bits × 2 + 598 caps at **1108 hPa**; a boosting M57N reaches ~2500 hPa absolute. The range 598–1108 hPa is barometric/altitude. Manifold boost is **not** broadcast — consistent with the finding that the Launch scanner must poll for it. → [[obd-diagnostic-polling]]
- `IJV_FU` (fuel injection quantity, µl) is a bonus the project never asked for but could display.
## `0x0AA` Torque 3 (DLC 8, 10 ms) — DME
| Signal | Start bit | Len | Factor | Unit | Meaning |
|---|---|---|---|---|---|
| `CHKSM_TORQ_3_DME` | 0 | 8 | 1 | — | Checksum |
| `ALIV_TORQ_3_DME` | 8 | 4 | 1 | — | Alive counter |
| `TORQ_DVCH` | 12 | 12 | 0.5 | Nm | Driver-demand torque (signed) |
| `ANG_ACPD` | 24 | 8 | 0.39063 | % | **Accelerator pedal position** (`0x00`=unpressed, `0xFF`=floored) |
| `RPM_ENG` | 32 | 16 | 0.25 | 1/min | **Engine RPM** |
| `RPM_ENG_ERR` | 48 | 2 | 1 | — | `0`=clear, `1`=speed sensor defective, `3`=invalid |
| `ST_IDLG_ENG` | 50 | 2 | 1 | — | `0`=idle, `1`=not idle, `3`=invalid |
| `ST_CLCTR_V` | 52 | 4 | 1 | — | **Cruise/pedal state** — see [[driveline-speed-signals]] |
| `RQAM_FU` | 56 | 8 | 1 | l/h | Fuel rate |
**RPM factor is 0.25, not the ÷4-on-bytes-4-5 guess in [[can-id-candidates]]** — same arithmetic, now with a named field and exact bit positions. Verified on our capture: **679–684 rpm at idle** (verified, 2026-07-17), matching `RPM_IDLE_TARGET` = 700 from `0x1D0`.
`ST_CLCTR_V` is the headline find here — a **cruise-control state field the DME already publishes**. Full encoding and why it matters: [[driveline-speed-signals]].
## `0x1A2` (DLC 4, 20 ms) — turbine speed
| Signal | Start bit | Len | Factor | Offset | Unit |
|---|---|---|---|---|---|
| `RPM_GRB_TURB` | 0 | 16 | 0.125 | 6 | 1/min |
Worked example `68 14 00 FF` → `0x1468` = 5224 × 0.125 + 6 = **659 rpm**.
**The most valuable single discovery in this ingest.** This is the gearbox *input* (turbine) speed, and it turns out to be a direct, physical **engagement** signal. Verified against our capture and written up in full: [[driveline-speed-signals]].
## `0x0BA` (DLC 8, 20 ms) — gearbox state ⚠ our earlier reading was wrong
Titled "Torque Request ACC" in the repo, but every signal is suffixed `_GRB` (*Getriebe*) — this is **gearbox-sourced**, and the title looks like a copy-paste artifact.
| Signal | Start bit | Len | Factor | Unit | Meaning |
|---|---|---|---|---|---|
| `ST_GR_GRB` | 0 | 4 | 1 | — | **Target gear** (N, R, 1st–6th; `0xF`=invalid) |
| `ST_GRLV_ACV` | 4 | 2 | 1 | — | Gear lever active |
| `ST_CCLT` | 6 | 2 | 1 | — | Torque converter lockup clutch: disengaged / controlled / closed / invalid |
| `GRDT_REIN` | 8 | 12 | 0.125 | 1/min | Gearbox speed |
| **(bits 20–39)** | — | — | — | — | **UNDOCUMENTED — populated on our bus** → [[driveline-speed-signals]] |
| `CHKSM_GRB` | 40 | 8 | 1 | — | Checksum |
| `ALIV_GRB` | 48 | 4 | 1 | — | Alive counter |
| `ST_MOD_GRB` | 52 | 3 | 1 | — | Gearbox mode |
| `ST_HYPP_ACV` | 56 | 2 | 1 | — | — |
Worked example `03 FF 0F 00 00 48 8B EF` → gear = **P**, clutch disengaged.
**`ST_GR_GRB` (D0 low nibble) verified against our capture** (verified, 2026-07-17) — frame counts from the 2026-07-15 dump:
| Value | Meaning | Frames | Status |
|---|---|---|---|
| `1` | N | 102 | verified |
| `2` | **R** | 2 | verified — see the R snapshot below |
| `3` | P | 1378 | verified |
| `5` | 1st gear | 453 | verified |
| `6`–`A` | 2nd–6th | — | `(unverified)` — inferred from the identical ladder in `0x1D2` D1 |
| `4` | ? | — | unaccounted for |
| `0xF` | invalid | — | (source) |
Note `5` = 1st gear here, **the same ladder as `0x1D2` D1's high nibble** — two independent messages sharing one encoding, which is good mutual corroboration.
> [!warning] Correcting the 2026-07-16 wiki claim
> [[gear-box-can-revealings]] recorded "`0x0BA` — secondary, do NOT use … D7 collides R=D=`0xCF`". **That dismissal was wrong**: D7 is `ST_HYPP_ACV`/alive-counter territory, not a gear field. The gear lives in **D0's low nibble**, which does not collide, and which carries a **distinct R code that `0x1D2` D1 lacks entirely**. `0x0BA` is not redundant — it is the only source for engaged reverse. Corrected in [[can-id-candidates]].
>
> Likewise, the same page's note that "`0x0BA` D5/D6 fluctuate so there are no values" is now explained rather than dismissed: **D5 = `CHKSM_GRB` (checksum), D6 = `ALIV_GRB` (alive counter)**. They fluctuate by design.
## Reverse-engaged snapshot (user-reported, 2026-07-17, verified)
Values with the lever held in **R** and the box engaged:
```
0BA DLC 8: 02 FE 0F A8 01 CF 8B CF
1D2 DLC 6: D2 0F FF DC F0 FF
```
- `0x0BA` D0 = `0x02` → `ST_GR_GRB` = **R**. ✅
- `0x1D2` D0 = `0xD2` → lever R; **D1 = `0x0F` → no gear number**. Confirms `0x1D2` D1 is blind to reverse — reverse is unnumbered there.
- `0x0BA` D3/D4 = `A8 01` — **non-zero**, where the repo's E65 example and every stationary frame of our own capture show `00 00`. → [[driveline-speed-signals]]
- `GRDT_REIN` = `0xFFE` ≈ invalid marker; this field reads `0xFFE`/`0xFFF` across both our captures and appears **not to be populated** on our bus. Use `0x1A2` for turbine speed instead.
## Cross-references worth chasing
- **`6HP26.pdf`** in `docs/` — the ZF 6HP26 manual. If our box is a 6HP26 (likely for an E60/E65 M57N), this is a primary source for gear ratios, which would let us convert output-shaft speed → road speed. Added to the [[open-questions]] sourcing wishlist.
- **`can_message_list.txt`** — full ID → name → sending-module map spanning 0x00–0xFFF, including K-CAN comfort/lighting. Not yet mined; worth a pass if the project ever wants non-powertrain data.
- `Log1.blf` / `Log2.blf` — real E65 captures for offline cross-checking.
## Related
[[can-id-candidates]] · [[driveline-speed-signals]] · [[gear-box-can-revealings]] · [[can-capture-2026-07-15]] · [[can-bus-integration]] · [[bmw-m57n-engine]]
+79 -24
View File
@@ -1,46 +1,101 @@
--- ---
type: source type: source
tags: [can-bus, capture, verified, gear, egs, e60] tags: [can-bus, capture, verified, gear, egs, e60]
updated: 2026-07-16 updated: 2026-07-17
--- ---
# Gearbox Lever Decode — 2026-07-16 (VERIFIED) # Gearbox Lever & Gear Decode — 2026-07-16/17 (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. User-recorded per-detent captures of the Steptronic selector: `raw/gear_box_can_revealings.csv` (lever positions, 2026-07-16) and `raw/gearbox_engaged_gear.csv` (engaged gear 1–6 in both D and M/S, 2026-07-17). Together these **verify `0x1D2` as the gear source** and decode the lever, the engaged gear number, and the D/S/M mode.
Two IDs react to the lever: **`0x1D2`** (clean, use this) and **`0x0BA`** (secondary, messier). Two IDs react to the gearbox: **`0x1D2`** (lever + engaged gear) and **`0x0BA`** (the gearbox's own target gear). **Both are needed** — see the correction notice below.
## `0x1D2` (DLC 6) — the gear lever ✅ VERIFIED ## `0x1D2` (DLC 6) — lever + engaged gear ✅ VERIFIED
| Lever | D0 | D1 | D4 | | Byte | Meaning | Values |
|-------|------|------|------| |---|---|---|
| P | `0xE1` | `0x0F` | `0xF0` | | **0** | **Lever position** | `0xE1`=P · `0xD2`=R · `0xB4`=N · `0x78`=D **and** S/M |
| R | `0xD2` | `0x0F` | `0xF0` | | **1** | **Engaged gear** | high nibble − 4 = gear; `0x0F` = no numbered gear |
| N | `0xB4` | `0x0F` | `0xF0` | | 2 | unused | `0xFF` |
| D | `0x78` | `0x5F` | `0xF0` | | 3 | rolling counter | fluctuates — ignore |
| S/M | `0x78` | `0x5F` | `0xF1` | | **4** | **Mode** | `0xF0`=Drive(auto) · `0xF1`=Sport · `0xF2`=Manual |
| 5 | unused | `0xFF` |
- **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) ### Byte 0 — lever position
- **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. Whole-byte codes, **matching the documented E65/E90 values exactly**, every one. (verified, 2026-07-16)
- **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). Byte 0 **cannot** split D from S/M (both `0x78`) — Steptronic's S/M is a side-gate off D, so the fore/aft position is physically identical. Byte 4 does that job.
### Byte 1 — engaged gear ✅ (2026-07-17)
The `raw/gearbox_engaged_gear.csv` capture resolves this. D1 is a clean arithmetic ladder, **+16 per gear** — the high nibble counts, the low nibble is a constant `0xF`:
| D1 | hex | Engaged gear |
|---|---|---|
| 15 | `0x0F` | none (P / R / N) |
| 95 | `0x5F` | 1 |
| 111 | `0x6F` | 2 |
| 127 | `0x7F` | 3 |
| 143 | `0x8F` | 4 |
| 159 | `0x9F` | 5 |
| 175 | `0xAF` | 6 |
`gear = (D1 >> 4) − 4`
**The D and M/S halves of the capture show identical D1 values for the same gear** — which is the proof that this is *engaged* gear and not a lever field: the box is in 3rd whether it chose 3rd or the driver asked for it.
Corroborated by the earlier dump: `E10F` (P), `D20F` (R), `B40F` (N), `785F` (D) — D at standstill = gear 1. And `0x0BA` `ST_GR_GRB` uses **the same ladder** (`5` = 1st), independently. (verified, 2026-07-17)
> [!warning] Corrects the 2026-07-16 claim "D1 = drive-gate flag"
> This page previously called D1 a boolean gate (`0x0F` in P/R/N → `0x5F` in D+S/M). **Wrong** — it was the gear number all along, reading 1 because the vehicle was stationary. Only two values were ever observed, so a flag looked like a reasonable fit. This also **closes the "actual engaged gear needs a drive capture"** item that this page previously listed as open — it didn't need a drive capture, it needed the lever held per-gear.
> [!note] Reverse is not numbered
> D1 stays `0x0F` with the lever in R and the box **engaged** (verified 2026-07-17: `1D2 = D2 0F FF DC F0 FF`). `0x1D2` D1 is blind to reverse. **The engaged-R signal is `0x0BA` `ST_GR_GRB` = 2.**
### Byte 4 — mode ✅ (2026-07-17)
| D4 | Mode |
|---|---|
| `0xF0` | Drive — automatic |
| `0xF1` | **Sport** — side gate, no manual input yet |
| `0xF2` | **Manual** — driver has taken control via +/− |
From `gearbox_engaged_gear.csv`: M/S 1st = `0xF1`, M/S 2nd–6th = `0xF2`. Read with the user's note — *"when I switch the lever to M/S the D4 has 241; I have not yet pulled the lever +; when I do it becomes 242"* — this maps onto Steptronic behaviour: the **side gate puts you in S**, and the **first +/− tap promotes you to M**, where it stays.
> [!warning] Corrects the 2026-07-16 claim "0xF2 = downshift (−)"
> This page previously called `0xF2` a transient downshift **event**. **Wrong** — it *persists* across M/S gears 2 through 6, and events don't hold steady. It's a **mode flag**, not a shift pulse. The original observation (pushing the lever forward → `0xF2`) is still true but was misread: the downshift didn't *signal* `0xF2`, it *promoted the box into Manual*, which is what `0xF2` reports. This also dissolves the old "manual up-shift (+) value unconfirmed" question — `+` and `−` don't have distinct D4 codes; both simply mean *Manual*.
### Recommended decode ### Recommended decode
``` ```
gear = D0: 0xE1→P 0xD2→R 0xB4→N 0x78→D (if D0==0x78 && D4!=0xF0 → S/M) lever = D0: 0xE1→P 0xD2→R 0xB4→N 0x78→D/S/M
manual: D4 0xF0 auto · 0xF1 manual · 0xF2 downshift(−) mode = D4: 0xF0→auto Drive 0xF1→Sport 0xF2→Manual
gear = D1: 0x0F→none, else (D1>>4)−4 (1..6; never set for R)
engaged R → 0x0BA D0 low nibble == 2
``` ```
## `0x0BA` (DLC 8) — secondary, do NOT use ## `0x0BA` (DLC 8) — the gearbox's own target gear ⚠ previously dismissed in error
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`. > [!warning] Corrects the 2026-07-16 claim "`0x0BA` — secondary, do NOT use"
> The 2026-07-16 dismissal rested on **D7 colliding R=D=`0xCF`**. D7 is not a gear field — per [[e65-reverse-engineering-repo]] it's `ST_HYPP_ACV`/alive-counter territory. **The gear is in D0's low nibble** (`ST_GR_GRB`), which does not collide and which carries a **distinct R code that `0x1D2` has nowhere**. `0x0BA` is not redundant — it is the *only* source of engaged reverse and the only source of output-shaft motion. Do use it.
>
> Similarly "D5/D6 fluctuate so there are no values" — **D5 = `CHKSM_GRB` (checksum), D6 = `ALIV_GRB` (alive counter)**. The observation was correct; the fluctuation is by design, not noise.
`ST_GR_GRB` = D0 low nibble: `1`=N, `2`=**R**, `3`=P, `5`–`A`=gears 1–6, `0xF`=invalid. Values 1/2/3/5 verified against our capture; 6–A inferred from the matching `0x1D2` ladder `(unverified)`.
`0x0BA` **D3/D4** carry what is almost certainly **output shaft speed** — undocumented in the source repo, zero in every stationary frame, non-zero the moment the wheels turn. This is the project's only road-speed signal. → [[driveline-speed-signals]]
## Lever vs box: the UX cross-check
`0x1D2` D0 = what the driver **selected**; `0x0BA` `ST_GR_GRB` = what the box **intends**. Disagreement means the box refused the request — a real fault worth surfacing on the display. Neither, however, is proof of mechanical engagement; for that, use **turbine speed** (`0x1A2`), which physically collapses when the box loads up. Full treatment: [[driveline-speed-signals]].
## Still open ## 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). - `0x0BA` `ST_GR_GRB` values `6`–`A` (2nd–6th) not directly observed — inferred.
- **Manual up-shift (+) value** on `0x1D2` D4 not captured. - Value `4` in the `ST_GR_GRB` ladder unaccounted for.
- `0x0BA` D3/D4 **scaling uncalibrated** → [[driveline-speed-signals]].
## Related ## Related
[[can-id-candidates]] · [[can-capture-2026-07-15]] · [[can-bus-integration]] · [[bmw-m57n-engine]] [[can-id-candidates]] · [[driveline-speed-signals]] · [[e65-reverse-engineering-repo]] · [[can-capture-2026-07-15]] · [[can-bus-integration]]