2 Commits

Author SHA1 Message Date
4335d71187 fix(balance): TWAI bus-off detection, auto-recovery, console off UART0
- vesc_can: poll twai_get_status_info() every 500ms; auto-recover from
  bus-off (twai_initiate_recovery) and stopped state (twai_start)
- vesc_can: expose g_twai_bus_off / g_twai_tx_err_count / g_twai_rx_err_count
- main: set flags bit2 when TWAI is bus-off (visible in TELEM_STATUS)
- sdkconfig: switch console from UART0 (conflicts with binary protocol
  at 460800) to USB serial JTAG — eliminates log corruption on Orin

Flags byte: bit0=estop, bit1=hb_timeout, bit2=twai_bus_off

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-19 22:54:03 -04:00
b830420efc feat: add UART/USB serial protocol for Orin comms, proxy VESC CAN (bd-66hx)
Replaces Orin↔ESP32-S3 BALANCE CAN comms (0x300-0x303 / 0x400-0x401)
with binary serial framing over CH343 USB-CDC at 460800 baud.

Protocol matches bd-wim1 (sl-perception) exactly:
  Frame: [0xAA][LEN][TYPE][PAYLOAD][CRC8-SMBUS]
  CRC covers LEN+TYPE+PAYLOAD, big-endian multi-byte fields.

Commands (Orin→ESP32): HEARTBEAT/DRIVE/ESTOP/ARM/PID
Telemetry (ESP32→Orin): TELEM_STATUS, TELEM_VESC_LEFT (ID 56),
                         TELEM_VESC_RIGHT (ID 68), ACK/NACK

VESC CAN TWAI kept for motor control; drive commands from Orin
forwarded to VESCs via SET_RPM. Hardware note: SN65HVD230
rewired from IO43/44 to IO2/IO1 to free IO43/44 for CH343.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-17 22:09:12 -04:00