Skip to content

code cleanup on lca_3 counter and hands-on-wheel spoof - no functionality change - #9

Open
thomasfifer wants to merge 3 commits into
paper5590:master-cma-dev4from
thomasfifer:master-cma-dev4
Open

thomasfifer wants to merge 3 commits into
paper5590:master-cma-dev4from
thomasfifer:master-cma-dev4

Conversation

@thomasfifer

Copy link
Copy Markdown

LCA_3 counter:
my car wasn't matching the pattern and instead just passing through the counter. it didn't appear to have any issues with passthrough but it's still probably better to use our own counter. just a normal incrementor appears to work ok.

hands-on-wheel spoof:
broke apart HANDS_ON_STEERING_WHEEL_A and _B into multiple variables including a timer and flags. we now set the flag and timer when spoofing hands on wheel and pass through all other data for a "correct" implementation instead of just alternating between two bit patterns that appeared to work.

pattern matching doesn't work for all cars and ultimately just passes through the counter. while that appears to work in most cases, we should set the counter to a known value
figured out the pscm message a bit better for the dbc, update code to reflect changes and properly spoof hands on wheel
@paper5590

paper5590 commented Oct 25, 2026 •

Copy link
Copy Markdown
Owner

Oh, I missed this PR, sorry. Not sure when I'll have availability to review this, but at least now I know about it.

About HANDS_ON_STEERING_WHEEL_A and _B:
These initially looked like driver input torque (torsion bar measurement) with a weird baseline, and one of them was a Schmitt trigger of the other, so I put a pattern "no hands on wheel, then hand on wheel" with experimentally determined values. I'll check your findings when I review this.

@thomasfifer

Copy link
Copy Markdown
Author

here's what the hands of wheel timer and flags look like (stock on top, spoofed on bottom)

image

thomasfifer added a commit to thomasfifer/StarPilot that referenced this pull request Nov 16, 2026
Reverse-engineered the PSCM message's hands-on-wheel fields more precisely:
replaces the old 2-byte HANDS_ON_STEERING_WHEEL_A/B guess with
HANDS_ON_WHEEL_ALERT_FLAGS/TIMER (and the other newly-identified signals in
that byte range) in opendbc/dbc/volvo_mid_1.dbc, and spoofs by setting the
alert flags/timer directly instead of toggling pseudo-random A/B byte values
by frame parity. Scoped to this codebase's existing lat_active-only condition
(no VolvoSpoofPAHandsOnWheel/bit-128 toggle here, since that doesn't exist in
this fork yet).

Brought in from paper5590/opendbc#9, adapted for
StarPilot's current carcontroller.py/volvocan.py. Verified by decoding the
produced PSCM CAN message with a real CANParser against the updated DBC:
ALERT_FLAGS=3/ALERT_TIMER=0 while steering, 0/0 otherwise.
thomasfifer added a commit to thomasfifer/StarPilot that referenced this pull request Nov 16, 2026
Pattern matching doesn't work for all cars and ultimately just passes
through the observed counter in the unsynced case. Replace it with a known,
predictable incrementing counter (mod 4) like the other LCA_* counters
already use, seeded from the first observed value.

Brought in from paper5590/opendbc#9, adapted for
StarPilot's current carcontroller.py. Verified by running CarController.update()
and decoding the real LCA_3 CAN output: COUNTER_1 increments 1,2,3,0,1,2,3...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants