Retire .docs; move UART spec to docs/; correct stale CAN/UART facts in CLAUDE.md
- Delete .docs/CAN_BUS_INTEGRATION.md (placeholder CAN IDs, external transceiver wiring the board does not need); superseded by wiki/pages/can-id-candidates.md - Move UART_PROTOCOL.md to docs/ as the single copy of the packet spec - Move the annotated board photo into wiki/raw/ and add a source page for it - CLAUDE.md: verified 11-bit CAN ID list replaces the placeholders, TWAI_MODE_NORMAL replaces LISTEN_ONLY, UART TX is GPIO 44, dummy-data references removed - Wiki index/log updated; note the schematic PDF is missing from disk Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -106,13 +106,13 @@ include/
|
||||
- Defines `automotive_data_t` structure (6 sensor values: gear position, 3 temperatures, battery voltage, fault codes)
|
||||
- UART packet framing protocol: `uart_packet_t` with start/end markers (0xAA/0x55), version byte, XOR checksum
|
||||
- Helper functions: `calculate_checksum()`, `validate_packet()`, temperature/voltage formatters
|
||||
- **BMW CAN Bus ID mappings**: Real BMW CAN message IDs and byte positions (see CAN_BUS_INTEGRATION.md)
|
||||
- UART config: 115200 baud on GPIO 43 (TX) / 44 (RX)
|
||||
- **BMW CAN Bus ID mappings**: 11-bit PT-CAN IDs verified live on the swap bus (evidence: `wiki/pages/can-id-candidates.md`)
|
||||
- UART config: 115200 baud on GPIO 44 (TX) / 43 (RX, unused) — leaves the board via the SP3485 RS485 transceiver
|
||||
|
||||
**include/drivers/can_driver.h/cpp**
|
||||
- CAN Bus driver using ESP32 TWAI (Two-Wire Automotive Interface)
|
||||
- Hardware: GPIO 15 (TX), GPIO 16 (RX) - 500 Kbps baud rate
|
||||
- Mode: LISTEN_ONLY (safe, won't transmit on vehicle CAN bus)
|
||||
- Mode: TWAI_MODE_NORMAL (ACKs frames; LISTEN_ONLY caused transmitter retry-flooding). Firmware never sends data frames
|
||||
- Parses BMW-specific CAN messages and updates shared automotive data structure
|
||||
- Task runs on Core 0 with FreeRTOS queue for start/stop commands
|
||||
|
||||
@@ -168,19 +168,18 @@ Settings persist across power cycles via ESP32 NVS (Non-Volatile Storage):
|
||||
**Transmission Protocol**:
|
||||
- Packet structure: `uart_packet_t` = Start(0xAA) + Version + Length + `automotive_data_t` + Checksum(XOR) + End(0x55)
|
||||
- Transmission rate: 5Hz (every 200ms) when enabled
|
||||
- Hardware: Serial1 on GPIO 43/44 (RS485 terminal block on board)
|
||||
- Hardware: Serial1 TX GPIO 44 / RX GPIO 43 (RS485 terminal block on board)
|
||||
|
||||
**Task Flow**:
|
||||
- `uartTask()` runs on Core 0
|
||||
- Events via `g_uart_event_queue`: `UART_EVENT_START`, `UART_EVENT_STOP`, `UART_EVENT_SEND_DATA`
|
||||
- Dummy data generation: `updateDummyData()` simulates sensor variations (for testing before CAN integration)
|
||||
- Default data: `initializeDefaultData()` seeds the structure until CAN updates it; the dummy generator was removed
|
||||
- Actual transmission: `sendUARTPacket()` builds packet, calculates checksum, sends via `Serial1.write()`
|
||||
- Mutex protection: `g_data_mutex` guards `g_automotive_data` structure
|
||||
|
||||
**CAN Bus Integration**:
|
||||
- CAN driver reads BMW-specific messages and updates `g_automotive_data`
|
||||
- When CAN is enabled, real vehicle data replaces dummy data
|
||||
- When CAN is disabled, dummy data simulation continues for testing
|
||||
- UART auto-starts/stops with the CAN task (`linkToCANState()`); no dummy simulation remains
|
||||
- Shared data structure (`g_automotive_data`) is mutex-protected for thread safety
|
||||
|
||||
### CAN Bus Architecture
|
||||
@@ -189,15 +188,17 @@ Settings persist across power cycles via ESP32 NVS (Non-Volatile Storage):
|
||||
- Controller: ESP32-S3 TWAI (Two-Wire Automotive Interface)
|
||||
- Pins: GPIO 15 (TX), GPIO 16 (RX)
|
||||
- Baud Rate: 500 Kbps (BMW standard)
|
||||
- Mode: LISTEN_ONLY (safe, non-intrusive monitoring)
|
||||
- Mode: TWAI_MODE_NORMAL (ACKs frames; never transmits data frames)
|
||||
|
||||
**BMW CAN Message IDs**:
|
||||
- `0x4F` [byte 0] → Engine Coolant Temperature
|
||||
- `0x55` [byte 7] → Engine Oil Temperature
|
||||
- `0x201` [byte 3] → Gearbox Oil Temperature
|
||||
- `0x1001` [byte 0] → Gearbox Position (P/R/N/D/S/M)
|
||||
- `0x1001` [byte 1] → Current Gear Number (1-8)
|
||||
- `0x101F` [bytes 0-1] → Battery Voltage (16-bit, big-endian)
|
||||
**BMW CAN Message IDs** (all 11-bit standard frames, verified live; full decode in `wiki/pages/can-id-candidates.md`):
|
||||
- `0x1D0` [byte 0] → Coolant temperature (raw − 48 °C); [byte 1] engine oil temp (reads 0xFF on this M57N); [byte 2 bits 4-5] engine run state
|
||||
- `0x0B5` [byte 7] → Gearbox oil temperature (raw − 40 °C); [byte 4 bits 6-7] cooling demand
|
||||
- `0x1D2` [byte 0] → Gear lever (E1=P D2=R B4=N 78=D/S/M); [byte 1] engaged gear; [byte 4] drive/sport/manual mode
|
||||
- `0x0BA` [byte 0 low nibble] → Gearbox target gear incl. reverse; [bits 6-7] converter lockup; [bytes 3-4] output shaft speed (scaling open)
|
||||
- `0x1A2` [bytes 0-1] → Turbine speed
|
||||
- `0x0AA` [bytes 4-5] → Engine RPM (× 0.25); [byte 3] pedal position
|
||||
- `0x0A8` [bytes 1-2] → Available engine torque
|
||||
- `0x3B4` [12-bit LE × 0.015] → Battery voltage; [byte 2 low nibble] ignition
|
||||
|
||||
**Task Flow**:
|
||||
- `canTask()` runs on Core 0 with Priority 1
|
||||
@@ -207,12 +208,10 @@ Settings persist across power cycles via ESP32 NVS (Non-Volatile Storage):
|
||||
- Statistics tracking: Messages received, parsed, errors
|
||||
|
||||
**Safety Features**:
|
||||
- LISTEN_ONLY mode prevents accidental CAN bus writes
|
||||
- No transmission capability - read-only monitoring
|
||||
- NORMAL mode: the controller ACKs received frames; the firmware has no transmit path for data frames
|
||||
- Error detection: Bus errors, queue overflow, passive errors
|
||||
- Graceful degradation: Falls back to dummy data if CAN fails
|
||||
|
||||
**See Also**: `.docs/CAN_BUS_INTEGRATION.md` for testing and development guide
|
||||
**See Also**: `wiki/pages/can-id-candidates.md` for the verified CAN ID map and evidence, `wiki/pages/can-bus-integration.md` for integration notes
|
||||
|
||||
### UI State Synchronization
|
||||
|
||||
@@ -328,8 +327,8 @@ xTaskCreatePinnedToCore(
|
||||
|
||||
### GPIO Assignments
|
||||
|
||||
- **CAN Bus**: GPIO 15 (TX), GPIO 16 (RX) - 500 Kbps, LISTEN_ONLY mode
|
||||
- **UART1**: GPIO 43 (TX), GPIO 44 (RX) - RS485 terminal block on board, 115200 baud
|
||||
- **CAN Bus**: GPIO 15 (TX), GPIO 16 (RX) - 500 Kbps, TWAI_MODE_NORMAL, onboard TJA1051 on the terminal block
|
||||
- **UART1**: GPIO 44 (TX), GPIO 43 (RX, unused) - reaches the terminal block only as the RS485 A/B pair (SP3485), 115200 baud
|
||||
- **USB Serial**: UART0 (default Serial) - 115200 baud for debug output
|
||||
|
||||
### Display Panel
|
||||
@@ -385,5 +384,5 @@ xTaskCreatePinnedToCore(
|
||||
|
||||
- **SquareLine Studio Export**: ALWAYS export UI files to `ui/` directory, NEVER to `src/` (prevents overwriting main.cpp)
|
||||
- **Event Handler Registration**: Event handlers for SquareLine UI elements are registered in `ui_Settings_Screen.c` auto-generated code. When adding new toggles, add event callback registration via `lv_obj_add_event_cb()` and declare handler in `ui_events.h`
|
||||
- **CAN Bus Integration**: BMW CAN IDs are configured in `automotive_data.h`. CAN driver runs in LISTEN_ONLY mode for safe monitoring. See `.docs/CAN_BUS_INTEGRATION.md` for testing with CAN simulators
|
||||
- **CAN Bus Integration**: BMW CAN IDs are defined in `automotive_data.h` (all 11-bit standard frames, verified live on the swap bus). The CAN driver runs in `TWAI_MODE_NORMAL` (it ACKs frames; not LISTEN_ONLY). Evidence and confidence labels live in `wiki/pages/can-id-candidates.md`
|
||||
- **Security**: Password field (`uic_Wifi_Passkey_TB`) is cleared after connection attempt for security (line 1015, 1029)
|
||||
|
||||
Reference in New Issue
Block a user