PlatformConfig: clean up and print all flags (#32369)

* script to print flags

* don't need

* SAL

* back

* fix
pull/32379/head
Shane Smiskol 12 months ago committed by GitHub
parent f93b139098
commit f597d63bf6
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 18
      selfdrive/car/__init__.py
  2. 3
      selfdrive/car/hyundai/values.py
  3. 3
      selfdrive/car/subaru/values.py
  4. 18
      selfdrive/debug/print_flags.py
  5. 2
      tools/car_porting/examples/subaru_fuzzy_fingerprint.ipynb

@ -1,5 +1,5 @@
# functions common among cars
from collections import defaultdict, namedtuple
from collections import namedtuple
from dataclasses import dataclass
from enum import IntFlag, ReprEnum, EnumType
from dataclasses import replace
@ -276,19 +276,3 @@ class Platforms(str, ReprEnum, metaclass=PlatformsType):
@classmethod
def with_flags(cls, flags: IntFlag) -> set['Platforms']:
return {p for p in cls if p.config.flags & flags}
@classmethod
def without_flags(cls, flags: IntFlag) -> set['Platforms']:
return {p for p in cls if not (p.config.flags & flags)}
@classmethod
def print_debug(cls, flags):
platforms_with_flag = defaultdict(list)
for flag in flags:
for platform in cls:
if platform.config.flags & flag:
assert flag.name is not None
platforms_with_flag[flag.name].append(platform)
for flag, platforms in platforms_with_flag.items():
print(f"{flag:32s}: {', '.join(p.name for p in platforms)}")

@ -746,6 +746,3 @@ LEGACY_SAFETY_MODE_CAR = CAR.with_flags(HyundaiFlags.LEGACY)
UNSUPPORTED_LONGITUDINAL_CAR = CAR.with_flags(HyundaiFlags.LEGACY) | CAR.with_flags(HyundaiFlags.UNSUPPORTED_LONGITUDINAL)
DBC = CAR.create_dbc_map()
if __name__ == "__main__":
CAR.print_debug(HyundaiFlags)

@ -273,6 +273,3 @@ FW_QUERY_CONFIG = FwQueryConfig(
)
DBC = CAR.create_dbc_map()
if __name__ == "__main__":
CAR.print_debug(SubaruFlags)

@ -0,0 +1,18 @@
#!/usr/bin/env python3
from openpilot.selfdrive.car.values import BRANDS
for brand in BRANDS:
all_flags = set()
for platform in brand:
if platform.config.flags != 0:
all_flags |= set(platform.config.flags)
if len(all_flags):
print(brand.__module__.split('.')[-2].upper() + ':')
for flag in sorted(all_flags):
print(f' {flag.name:<24}: ', end='')
for platform in brand:
if platform.config.flags & flag:
print(platform.name, end=', ')
print()
print()

@ -18,7 +18,7 @@
"from openpilot.selfdrive.car.subaru.values import CAR, SubaruFlags\n",
"from openpilot.selfdrive.car.subaru.fingerprints import FW_VERSIONS\n",
"\n",
"TEST_PLATFORMS = CAR.without_flags(SubaruFlags.PREGLOBAL)\n",
"TEST_PLATFORMS = set(CAR) - CAR.with_flags(SubaruFlags.PREGLOBAL)\n",
"\n",
"Ecu = car.CarParams.Ecu\n",
"\n",

Loading…
Cancel
Save