diff --git a/selfdrive/car/fingerprints.py b/selfdrive/car/fingerprints.py index 977df6bc9f..e25b5486a0 100644 --- a/selfdrive/car/fingerprints.py +++ b/selfdrive/car/fingerprints.py @@ -1,3 +1,4 @@ +from typing import Any, Callable from openpilot.selfdrive.car.interfaces import get_interface_attr from openpilot.selfdrive.car.body.values import CAR as BODY from openpilot.selfdrive.car.chrysler.values import CAR as CHRYSLER @@ -10,6 +11,7 @@ from openpilot.selfdrive.car.nissan.values import CAR as NISSAN from openpilot.selfdrive.car.subaru.values import CAR as SUBARU from openpilot.selfdrive.car.tesla.values import CAR as TESLA from openpilot.selfdrive.car.toyota.values import CAR as TOYOTA +from openpilot.selfdrive.car.values import PLATFORMS, Platform from openpilot.selfdrive.car.volkswagen.values import CAR as VW FW_VERSIONS = get_interface_attr('FW_VERSIONS', combine_brands=True, ignore_none=True) @@ -336,3 +338,15 @@ MIGRATION = { "SKODA SCALA 1ST GEN": VW.SKODA_SCALA_MK1, "SKODA SUPERB 3RD GEN": VW.SKODA_SUPERB_MK3, } + + +MapFunc = Callable[[Platform], Any] + + +def create_platform_map(func: MapFunc): + ret = {str(platform): func(platform) for platform in PLATFORMS.values() if func(platform) is not None} + + for m in MIGRATION: + ret[m] = ret[MIGRATION[m]] + + return ret diff --git a/selfdrive/car/values.py b/selfdrive/car/values.py index 0c8249838b..dfbcf3b74f 100644 --- a/selfdrive/car/values.py +++ b/selfdrive/car/values.py @@ -1,4 +1,4 @@ -from typing import Any, Callable, cast +from typing import cast from openpilot.selfdrive.car.body.values import CAR as BODY from openpilot.selfdrive.car.chrysler.values import CAR as CHRYSLER from openpilot.selfdrive.car.ford.values import CAR as FORD @@ -17,9 +17,3 @@ Platform = BODY | CHRYSLER | FORD | GM | HONDA | HYUNDAI | MAZDA | MOCK | NISSAN BRANDS = [BODY, CHRYSLER, FORD, GM, HONDA, HYUNDAI, MAZDA, MOCK, NISSAN, SUBARU, TESLA, TOYOTA, VOLKSWAGEN] PLATFORMS: dict[str, Platform] = {str(platform): platform for brand in BRANDS for platform in cast(list[Platform], brand)} - -MapFunc = Callable[[Platform], Any] - - -def create_platform_map(func: MapFunc): - return {str(platform): func(platform) for platform in PLATFORMS.values() if func(platform) is not None} diff --git a/tools/cabana/dbc/generate_dbc_json.py b/tools/cabana/dbc/generate_dbc_json.py index dec1766a7e..deda0909c4 100755 --- a/tools/cabana/dbc/generate_dbc_json.py +++ b/tools/cabana/dbc/generate_dbc_json.py @@ -2,7 +2,7 @@ import argparse import json -from openpilot.selfdrive.car.values import create_platform_map +from openpilot.selfdrive.car.fingerprints import create_platform_map def generate_dbc_json() -> str: