mirror of
https://github.com/dragonpilot/dragonpilot.git
synced 2026-03-01 23:43:53 +08:00
Simplify cabana dbc dict (#32041)
* so needlessly complex! * inside generate_dbc_json * this is good * clean up! * spaces * so much clean up
This commit is contained in:
@@ -1,4 +1,3 @@
|
||||
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
|
||||
@@ -11,7 +10,6 @@ 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)
|
||||
@@ -338,15 +336,3 @@ 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
|
||||
|
||||
@@ -2,11 +2,16 @@
|
||||
import argparse
|
||||
import json
|
||||
|
||||
from openpilot.selfdrive.car.fingerprints import create_platform_map
|
||||
from openpilot.selfdrive.car.fingerprints import MIGRATION
|
||||
from openpilot.selfdrive.car.values import PLATFORMS
|
||||
|
||||
|
||||
def generate_dbc_json() -> str:
|
||||
dbc_map = create_platform_map(lambda platform: platform.config.dbc_dict["pt"] if platform != "MOCK" else None)
|
||||
dbc_map = {platform.name: platform.config.dbc_dict['pt'] for platform in PLATFORMS.values() if platform != "MOCK"}
|
||||
|
||||
for m in MIGRATION:
|
||||
dbc_map[m] = dbc_map[MIGRATION[m]]
|
||||
|
||||
return json.dumps(dict(sorted(dbc_map.items())), indent=2)
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user