Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Volkswagen: fingerprint on VIN chassis code #32148

Merged
merged 49 commits into from
Apr 13, 2024
Merged

Volkswagen: fingerprint on VIN chassis code #32148

merged 49 commits into from
Apr 13, 2024

Conversation

sshane
Copy link
Contributor

@sshane sshane commented Apr 10, 2024

Related: #32147

Just a custom fuzzy fingerprinting function that takes VIN.

References for WMI and chassis codes:

Currently we match on the union of the match results from exact, fuzzy and custom fuzzy. Currently, I think if we get multiple results from that (which we will for camera harness users since we only get radar), we throw that out and use the custom function as an alternative.

We can refine this behavior as we go, but it seems straightforward enough to me as a start. I don't think we want to get rid of FW matching for VW just yet, we use the ECU addrs to sort the fingerprinting and matching.

Cars returning VIN from camera:

  • VOLKSWAGEN_GOLF_MK7 - ed13f591d2a47f7f/00000047--7a38b65908
  • VOLKSWAGEN_ATLAS_MK1 - d7251ede344ff957/0000000d--9ada8ed097
  • VOLKSWAGEN_GOLF_MK7 - cda8fa70cc0c0fed/00000001--258ebaa655
  • SKODA_OCTAVIA_MK3 - c5fc8ee4e8be2d97/0000005a--47a8ef422f
  • VOLKSWAGEN_GOLF_MK7 - c45851925d1d1d67/0000004e--2f908d3606
  • SKODA_SUPERB_MK3 - a7adec1fdbb46a1c/00000029--17cbb1129c
  • VOLKSWAGEN_TIGUAN_MK2 - 96597f285021abd0/00000000--0fa17d8c0a
  • VOLKSWAGEN_ATLAS_MK1 - 8d09dff0af485a2c/00000075--8d6113c49d
  • VOLKSWAGEN_ATLAS_MK1 - 6439fb08910d24cb/00000095--cd86ea9c80
  • SKODA_OCTAVIA_MK3 - 44379c05b64fd7e3/00000000--77bf0b2cd6

  • mark EPS as non-essential for camera-less VWs (they get srs, transmission, and engine which is enough) - Volkswagen: add missing chassis codes #32189
  • just a normal generic fuzzy fingerprint function!
  • check expected WMI, not any WMI
  • check expected gateway, not any gateway
    • check radar FW exact matches
  • Check chassis code
    • test
  • Check WMI
    • test
  • Check (radar) FW as sanity check / secondary source to avoid false positives (adeeb suggested)
    • test
  • add VIN to match_fw_to_car input args

@sshane sshane changed the title VW: fingerprint on VIN chassis code Volkswagen: fingerprint on VIN chassis code Apr 10, 2024
@sshane sshane mentioned this pull request Apr 10, 2024
1 task
# as we lose too many ECUs to reliably identify the vehicle
CHASSIS_CODE_PATTERN = re.compile('[A-Z0-9]{2}')
# TODO: determine the unknown groups
FW_PATTERN = re.compile(b'\xf1\x87(?P<gateway>[0-9][0-9A-Z]{2})(?P<unknown>[0-9][0-9A-Z][0-9])(?P<unknown2>[0-9A-Z]{2}[0-9])([A-Z0-9]| )')
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jyoung8607 not a blocker, but would be good to add if you know what the unknown part/parts are

@sshane
Copy link
Contributor Author

sshane commented Apr 11, 2024

Actually, as long as we don't set non_essential_ecus, or remove the other ECUs, we don't have to worry about a car with only radar responding matching with multiple cars since the exact matchers require all ECUs existing, and fuzzy requires 2 ECUs (satisfied if we added camera but it only returns 1 or 0 matches, never multiple).

Overriding the matches isn't actually needed.

match_fw_to_car takes vin
@sshane sshane marked this pull request as ready for review April 12, 2024 04:56
@sshane sshane linked an issue Apr 12, 2024 that may be closed by this pull request
Copy link
Contributor

@adeebshihadeh adeebshihadeh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Very cool!

selfdrive/car/volkswagen/values.py Show resolved Hide resolved
Comment on lines +433 to +434
wmi = vin[:3]
chassis_code = vin[6:8]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we should probably pass around a nice VIN struct instead of a raw string


# These ECUs are required to match to gain a VIN match
# TODO: do we want to check camera when we add its FW?
CHECK_FUZZY_ECUS = {Ecu.fwdRadar}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ACC commands come from this ECU?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes.

@sshane sshane merged commit 6acf763 into master Apr 13, 2024
29 checks passed
@sshane sshane deleted the vw-vin-fp branch April 13, 2024 05:00
cydia2020 pushed a commit to cydia2020/dodgypilot that referenced this pull request May 14, 2024
* add function signature and behavior comment

* add test

* move chassis codes to platform config!

* add a shared chassis code test

* function

* test matching

* this commit isn't complete yet

* Revert "this commit isn't complete yet"

This reverts commit ae77d5c.

* need to check WMI

* TODO: test WMI

* test wmi

* radar FW sanity check

* fix test

* fixes from merge

fixes from merge

* whoops

* fix static analysis!

* do match_fw_to_car

match_fw_to_car takes vin

* makes sense to keep it one function, and we can return exact or fuzzy!

* clean up

* kinda pointless

* fix more tests

* back to function being only fuzzy

* revert test_fw_fingerprint

* revert test_fw_fingerprint

* simplify

* clean up/fixes

* rename test

* less duplicatey WMI descriptions

* fix

* convert to enum

* I am confident about these WMIs

* these are also good

* we support 5N AUS/NZ and NAR (North American) AX Tiguans

fixes

* Tiguan also Mexico

* only one user for caddy

* got from the test route

* check that the gateway type matches the platform (each platform has 1 or 2 types)

* ~gateway~ -> exact FW match

* remove re

* ensure WMIs are set

* actually no reason to delete

* move comment up to the platform config

* proper wmis typing

* spacing

* flip
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

VW: query FW versions on non-OBD bus
3 participants