You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
kart-core: fix ~10% STEER_STATUS loss — make CAN RX interrupt-driven
The steering link flapped (STEER_LINK_OK dropping/recovering, spamming the dash
notification): the Steervo sent STEER_STATUS at a steady 50 Hz but the Teensy
received only ~45/s with periodic ~100-300 ms zero-delivery gaps.
Diagnosed with live error counters on both nodes over a 70 s capture. Through
every gap: Steervo tx_error_counter=0, bus_error_count=0; Teensy REC=0, ESR1
ack/crc/frm/stf/bit0/bit1 all 0. Clean protocol engines on both sides while the
app still missed frames => loss above the protocol engine (not the bus, not
bit-timing; dropping 250k->125k changed nothing).
Root cause: RX was the polled 6-deep hardware FIFO (enableFIFO, no interrupt),
and FlexCAN_T4 read() services the FIFO only ~50% of calls (a FIFO/mailbox
fairness random() — the other half fall through to readMB and return 0). That
halved the drain rate, overflowed the tiny FIFO under normal loop jitter, and
dropped frames that the controller had already ACKed (hence Steervo TEC stayed
0). The 64-deep RX_SIZE_64 software ring was never used.
Fix: interrupt-driven RX. enableFIFOInterrupt() + onReceive(onCanFrame); the ISR
drains the hardware FIFO into the software ring on arrival, and events() (in the
loop) dispatches to onCanFrame() in loop context (g_steerLink stays
single-threaded). CANTEST reworked to count loopback frames through the same
ring path.
Verified on the bench (both firmwares reflashed at 250k): STEER_STATUS 50.6/s,
zero-delivery windows 0 (was 11/70 s), dashboard steerLink transitions 0 (was
18/25 s), 0% link-down (was 5.5%). CANTEST 20/20 PASS; 64/64 host tests pass.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
0 commit comments