mirror of
https://github.com/firestar5683/StarPilot.git
synced 2026-07-06 05:52:12 +08:00
accfaa29af
* 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 ae77d5cd54e1f43d390fb70c4da38a95ac34f8da. * 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 old-commit-hash: 6acf763db49944de7a7685b46d50a6c8228a5777
76 lines
2.5 KiB
Python
Executable File
76 lines
2.5 KiB
Python
Executable File
#!/usr/bin/env python3
|
|
|
|
import argparse
|
|
from collections import defaultdict
|
|
from openpilot.selfdrive.debug.format_fingerprints import format_brand_fw_versions
|
|
|
|
from openpilot.selfdrive.car.fw_versions import match_fw_to_car
|
|
from openpilot.selfdrive.car.interfaces import get_interface_attr
|
|
from openpilot.tools.lib.logreader import LogReader, ReadMode
|
|
|
|
|
|
ALL_FW_VERSIONS = get_interface_attr("FW_VERSIONS")
|
|
ALL_CARS = get_interface_attr("CAR")
|
|
|
|
PLATFORM_TO_PYTHON_CAR_NAME = {brand: {car.value: car.name for car in ALL_CARS[brand]} for brand in ALL_CARS}
|
|
BRAND_TO_PLATFORMS = {brand: [car.value for car in ALL_CARS[brand]] for brand in ALL_CARS}
|
|
PLATFORM_TO_BRAND = dict(sum([[(platform, brand) for platform in BRAND_TO_PLATFORMS[brand]] for brand in BRAND_TO_PLATFORMS], []))
|
|
|
|
|
|
if __name__ == "__main__":
|
|
parser = argparse.ArgumentParser(description="Auto fingerprint from a route")
|
|
parser.add_argument("route", help="The route name to use")
|
|
parser.add_argument("platform", help="The platform, or leave empty to auto-determine using fuzzy", default=None, nargs='?')
|
|
args = parser.parse_args()
|
|
|
|
lr = LogReader(args.route, ReadMode.QLOG)
|
|
|
|
carFw = None
|
|
carVin = None
|
|
carPlatform = None
|
|
|
|
platform: str | None = None
|
|
|
|
CP = lr.first("carParams")
|
|
|
|
if CP is None:
|
|
raise Exception("No fw versions in the provided route...")
|
|
|
|
carFw = CP.carFw
|
|
carVin = CP.carVin
|
|
carPlatform = CP.carFingerprint
|
|
|
|
if args.platform is None: # attempt to auto-determine platform with other fuzzy fingerprints
|
|
_, possible_platforms = match_fw_to_car(carFw, carVin, log=False)
|
|
|
|
if len(possible_platforms) != 1:
|
|
print(f"Unable to auto-determine platform, possible platforms: {possible_platforms}")
|
|
|
|
if carPlatform != "MOCK":
|
|
print("Using platform from route")
|
|
platform = carPlatform
|
|
else:
|
|
platform = None
|
|
else:
|
|
platform = list(possible_platforms)[0]
|
|
else:
|
|
platform = args.platform
|
|
|
|
if platform is None:
|
|
raise Exception("unable to determine platform, try manually specifying the fingerprint.")
|
|
|
|
print("Attempting to add fw version for: ", platform)
|
|
|
|
fw_versions: dict[str, dict[tuple, list[bytes]]] = defaultdict(lambda: defaultdict(list))
|
|
brand = PLATFORM_TO_BRAND[platform]
|
|
|
|
for fw in carFw:
|
|
if fw.brand == brand and not fw.logging:
|
|
addr = fw.address
|
|
subAddr = None if fw.subAddress == 0 else fw.subAddress
|
|
key = (fw.ecu.raw, addr, subAddr)
|
|
|
|
fw_versions[platform][key].append(fw.fwVersion)
|
|
|
|
format_brand_fw_versions(brand, fw_versions)
|