CAN raw logger + toggle fix; wiki: first live capture confirms ID map

Firmware — make the board a working CAN sniffer and fix real bugs:
- can_driver: add raw candump-style logger (CANRAW,<ts>,<id>,<extd>,<dlc>,<hex>),
  capturing every frame incl. unknown IDs for offline decoding. Single atomic
  write per frame.
- serial_lock: new global serial mutex so concurrent task writes (CAN logger,
  UART 5Hz log, heartbeat) no longer splice mid-line. Corruption 3.2% -> 1.4%.
- Fix CAN toggle: the switch had no event handler registered, so it never
  started CAN and reverted on screen change. Wire up onCANBusToggle.
- platformio: route Serial to native USB-CDC (USB_MODE=1, CDC_ON_BOOT=1) so the
  ~486 frame/s stream isn't throttled by the 115200 UART ceiling; bump monitor
  baud to 921600.
- tools/fix_toolchain_path.py: pre-build workaround for pioarduino nesting the
  Xtensa toolchain bin under a subdir that never reaches PATH.
- Correct misleading "LISTEN_ONLY" log string (driver runs TWAI_MODE_NORMAL).

Wiki — ingest the first live capture off the real swap bus:
- raw/can-capture-2026-07-15-gearshift.csv (20,596 frames) + sources page.
- Research map CONFIRMED: 0x1D0/0x1D2/0x0B5/0x3B4 all live; placeholder IDs
  (0x4F/0x55/0x201/0x1001/0x101F) verified absent; 0x130/0x304/0x192 absent.
- 0x1D0 b0 coolant drifts up (37->40C, -48 holds); 0x1D0 b1 oil temp = 0xFF.
- 0x1D2 gear encoding resolved: DLC 6, byte0 gear codes (E1=P, B4=N, 78=D live).
- Corrected LISTEN_ONLY -> NORMAL/ACK across pages; documented non-isolated
  TJA1051 grounding requirement. Updated index + log.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-07-16 12:24:25 +02:00
parent f7a2d1c3bd
commit 87801c593c
19 changed files with 20929 additions and 26 deletions
+35
View File
@@ -0,0 +1,35 @@
# fix_toolchain_path.py (PlatformIO pre-build extra script)
#
# WORKAROUND for a pioarduino first-install issue on this machine.
#
# The Xtensa toolchain (toolchain-xtensa-esp-elf) extracts its binaries to a
# NESTED folder:
# <pkg>/xtensa-esp-elf/bin/xtensa-esp32s3-elf-gcc.exe (and g++, ar, ld, ...)
# but pioarduino's export_paths PATH-injection did not reach the SCons build
# environment, so the compiler was invoked by bare name and the shell reported
# "'xtensa-esp32s3-elf-gcc' is not recognized as an internal or external command".
#
# This script finds the toolchain package dir dynamically and prepends its real
# bin/ folder to the build PATH. It is a no-op if the bin folder isn't nested
# (e.g. after a future clean reinstall that flattens the layout), so it's safe
# to leave in place.
#
# Proper long-term fix (optional): remove ~/.platformio/packages/toolchain-xtensa-esp-elf
# and ~/.espressif, then rebuild so pioarduino re-runs idf_tools install cleanly.
Import("env") # noqa: F821 (injected by PlatformIO/SCons)
from os.path import isdir, join
platform = env.PioPlatform()
toolchain_pkg = platform.get_package_dir("toolchain-xtensa-esp-elf")
if toolchain_pkg:
nested_bin = join(toolchain_pkg, "xtensa-esp-elf", "bin")
if isdir(nested_bin):
env.PrependENVPath("PATH", nested_bin)
print("[fix_toolchain_path] Prepended toolchain bin to PATH: %s" % nested_bin)
else:
print("[fix_toolchain_path] Nested bin not found (layout OK?): %s" % nested_bin)
else:
print("[fix_toolchain_path] toolchain-xtensa-esp-elf package dir not found")