mirror of
https://github.com/MoreTore/openpilot.git
synced 2026-09-15 03:54:03 +08:00
FPv2: support collecting versions for specific ecus (#25699)
* Add VMCU address for EV6 * Rename vmcu * add to tests add to tests * rename to more generic name * more explicit * remove print * Like this much better, removes subtle fingerprinting problems * clean up * add test and clean up * remove hyundai stuffs * global * Fpv2Config class * fix missing fw versions from import order * unused * revert for now * test for fpv2 configs with subtests * subtests don't work that way * remove this * . * intersection * print ecus * shorter * fix typing * use config
This commit is contained in:
@@ -166,14 +166,13 @@ FW_QUERY_CONFIG = FwQueryConfig(
|
||||
bus=0,
|
||||
),
|
||||
],
|
||||
extra_ecus=[
|
||||
(Ecu.hcp, 0x7e2, None), # manages transmission on hybrids
|
||||
(Ecu.abs, 0x7e4, None), # alt address for abs on hybrids
|
||||
],
|
||||
)
|
||||
|
||||
FW_VERSIONS = {
|
||||
CAR.PACIFICA_2019_HYBRID: {
|
||||
(Ecu.hcp, 0x7e2, None): [],
|
||||
(Ecu.abs, 0x7e4, None): [],
|
||||
},
|
||||
|
||||
CAR.RAM_1500: {
|
||||
(Ecu.combinationMeter, 0x742, None): [
|
||||
b'68294063AH',
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
import capnp
|
||||
from dataclasses import dataclass, field
|
||||
import struct
|
||||
from typing import Dict, List
|
||||
from typing import Dict, List, Optional, Tuple
|
||||
|
||||
import panda.python.uds as uds
|
||||
|
||||
@@ -64,3 +64,5 @@ class FwQueryConfig:
|
||||
requests: List[Request]
|
||||
# Overrides and removes from essential ecus for specific models and ecus (exact matching)
|
||||
non_essential_ecus: Dict[capnp.lib.capnp._EnumModule, List[str]] = field(default_factory=dict)
|
||||
# Ecus added for data collection, not to be fingerprinted on
|
||||
extra_ecus: List[Tuple[capnp.lib.capnp._EnumModule, int, Optional[int]]] = field(default_factory=list)
|
||||
|
||||
@@ -213,6 +213,11 @@ def get_fw_versions_ordered(logcan, sendcan, ecu_rx_addrs, timeout=0.1, debug=Fa
|
||||
|
||||
def get_fw_versions(logcan, sendcan, query_brand=None, extra=None, timeout=0.1, debug=False, progress=False):
|
||||
versions = VERSIONS.copy()
|
||||
|
||||
# Each brand can define extra ECUs to query for data collection
|
||||
for brand, config in FW_QUERY_CONFIGS.items():
|
||||
versions[brand]["debug"] = {ecu: [] for ecu in config.extra_ecus}
|
||||
|
||||
if query_brand is not None:
|
||||
versions = {query_brand: versions[query_brand]}
|
||||
|
||||
|
||||
@@ -44,6 +44,13 @@ class TestFwFingerprint(unittest.TestCase):
|
||||
duplicates = {fw for fw in ecu_fw if ecu_fw.count(fw) > 1}
|
||||
self.assertFalse(len(duplicates), f"{car_model}: Duplicate FW versions: Ecu.{ECU_NAME[ecu[0]]}, {duplicates}")
|
||||
|
||||
def test_data_collection_ecus(self):
|
||||
for brand, config in FW_QUERY_CONFIGS.items():
|
||||
for car_model, ecus in VERSIONS[brand].items():
|
||||
bad_ecus = set(ecus).intersection(config.extra_ecus)
|
||||
with self.subTest(car_model=car_model):
|
||||
self.assertFalse(len(bad_ecus), f'{car_model}: Fingerprints contain ECUs added for data collection: {bad_ecus}')
|
||||
|
||||
def test_blacklisted_ecus(self):
|
||||
blacklisted_addrs = (0x7c4, 0x7d0) # includes A/C ecu and an unknown ecu
|
||||
for car_model, ecus in FW_VERSIONS.items():
|
||||
|
||||
Reference in New Issue
Block a user