mirror of
https://github.com/sunnypilot/sunnypilot.git
synced 2026-02-18 22:23:56 +08:00
PlatformConfig: clean up and print all flags (#32369)
* script to print flags * don't need * SAL * back * fix
This commit is contained in:
@@ -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)
|
||||
|
||||
18
selfdrive/debug/print_flags.py
Executable file
18
selfdrive/debug/print_flags.py
Executable file
@@ -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",
|
||||
|
||||
Reference in New Issue
Block a user