-
Notifications
You must be signed in to change notification settings - Fork 9.1k
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
Chrysler VIN fuzzy fingerprint #33000
Closed
Closed
Changes from 7 commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
import random | ||
import re | ||
|
||
from cereal import car | ||
from openpilot.selfdrive.car.chrysler.values import CAR, FW_QUERY_CONFIG | ||
from openpilot.selfdrive.car.chrysler.fingerprints import FW_VERSIONS | ||
|
||
Ecu = car.CarParams.Ecu | ||
|
||
CHASSIS_CODE_PATTERN = re.compile('[A-Z0-9]{2}') | ||
|
||
|
||
class TestChryslerPlatformConfigs: | ||
def test_vin_parse_codes(self, subtests): | ||
for platform in CAR: | ||
with subtests.test(platform=platform.value): | ||
assert len(platform.config.chassis_codes) > 0, "Chassis codes not set" | ||
assert len(platform.config.engines) > 0, "engines not set" | ||
assert len(platform.config.years) > 0, "years codes not set" | ||
assert all(CHASSIS_CODE_PATTERN.match(cc) for cc in \ | ||
platform.config.chassis_codes), "Bad chassis codes" | ||
|
||
# No two platforms should share chassis codes | ||
for comp in CAR: | ||
if platform == comp: | ||
continue | ||
assert set() == (platform.config.chassis_codes & comp.config.chassis_codes) \ | ||
or (platform.config.years != comp.config.years) \ | ||
or (platform.config.engines & comp.config.engines), \ | ||
f"Shared chassis codes: {comp}" | ||
|
||
def test_custom_fuzzy_fingerprinting(self, subtests): | ||
all_radar_fw = list({fw for ecus in FW_VERSIONS.values() for fw in ecus[Ecu.fwdRadar, 0x753, None]}) | ||
|
||
for platform in CAR: | ||
with subtests.test(platform=platform.name): | ||
for year in platform.config.years: | ||
for engine in platform.config.engines: | ||
for chassis_code in platform.config.chassis_codes | {"00"}: | ||
vin = ["0"] * 17 | ||
vin[9] = year | ||
vin[4:6] = chassis_code | ||
vin[7] = engine | ||
vin = "".join(vin) | ||
|
||
# Check a few FW cases - expected, unexpected | ||
for radar_fw in random.sample(all_radar_fw, 5) + [b'\xf1\x875Q0907572G \xf1\x890571', b'\xf1\x877H9907572AA\xf1\x890396']: | ||
should_match = ((engine in platform.config.engines and chassis_code in platform.config.chassis_codes and \ | ||
platform.config.years[0] <= year <= platform.config.years[1]) and radar_fw in all_radar_fw) | ||
|
||
live_fws = {(0x753, None): [radar_fw]} | ||
matches = FW_QUERY_CONFIG.match_fw_to_car_fuzzy(live_fws, vin, FW_VERSIONS) | ||
|
||
expected_matches = {platform} if should_match else set() | ||
assert expected_matches == matches, "Bad match" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does the engine denote the trim/or if hybrid? Recently we're erring on the side of allowing more variants to fingerprint, if we reasonably expect them to work fine. For example, on Toyota the Corolla and Corolla Hybrid are treated the same. If the engine code here is supposed to split those, perhaps we don't need it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes it denotes hybrid
Ok so maybe we can rearrange the platforms into 2:
CHRYSLER_PACIFICA_2017 that contains 2017_HYBRID, 2018_HYBRID and 2018
CHRYSLER_PACIFICA_2020 that contains 2020 and 2019_HYBRID
CHRYSLER_PACIFICA_2020 needs to be different because handled differently in interface.py