FPv2 tests: test all addrs map to one ECU (#26151)

* add test

* fix mapping
old-commit-hash: e9fcef99e1
taco
Shane Smiskol 3 years ago committed by GitHub
parent c2141b7f48
commit f13e98f0c5
  1. 10
      selfdrive/car/honda/values.py
  2. 11
      selfdrive/car/tests/test_fw_fingerprint.py

@ -446,7 +446,7 @@ FW_VERSIONS = {
b'78109-TED-Q510\x00\x00', b'78109-TED-Q510\x00\x00',
b'78109-TEG-A310\x00\x00', b'78109-TEG-A310\x00\x00',
], ],
(Ecu.fwdCamera, 0x18dab0f1, None): [ (Ecu.fwdRadar, 0x18dab0f1, None): [
b'36161-TBA-A020\x00\x00', b'36161-TBA-A020\x00\x00',
b'36161-TBA-A030\x00\x00', b'36161-TBA-A030\x00\x00',
b'36161-TBA-A040\x00\x00', b'36161-TBA-A040\x00\x00',
@ -964,7 +964,7 @@ FW_VERSIONS = {
b'77959-THR-A110\x00\x00', b'77959-THR-A110\x00\x00',
b'77959-THR-X010\x00\x00', b'77959-THR-X010\x00\x00',
], ],
(Ecu.fwdCamera, 0x18dab0f1, None): [ (Ecu.fwdRadar, 0x18dab0f1, None): [
b'36161-THR-A020\x00\x00', b'36161-THR-A020\x00\x00',
b'36161-THR-A030\x00\x00', b'36161-THR-A030\x00\x00',
b'36161-THR-A110\x00\x00', b'36161-THR-A110\x00\x00',
@ -1068,7 +1068,7 @@ FW_VERSIONS = {
b'39990-TG7-A070\x00\x00', b'39990-TG7-A070\x00\x00',
b'39990-TGS-A230\x00\x00', b'39990-TGS-A230\x00\x00',
], ],
(Ecu.fwdCamera, 0x18dab0f1, None): [ (Ecu.fwdRadar, 0x18dab0f1, None): [
b'36161-TG7-A310\x00\x00', b'36161-TG7-A310\x00\x00',
b'36161-TG7-A520\x00\x00', b'36161-TG7-A520\x00\x00',
b'36161-TG7-A630\x00\x00', b'36161-TG7-A630\x00\x00',
@ -1176,7 +1176,7 @@ FW_VERSIONS = {
b'57114-TX5-A220\x00\x00', b'57114-TX5-A220\x00\x00',
b'57114-TX4-A220\x00\x00', b'57114-TX4-A220\x00\x00',
], ],
(Ecu.fwdCamera, 0x18dab0f1, None): [ (Ecu.fwdRadar, 0x18dab0f1, None): [
b'36161-TX5-A030\x00\x00', b'36161-TX5-A030\x00\x00',
b'36161-TX4-A030\x00\x00', b'36161-TX4-A030\x00\x00',
], ],
@ -1273,7 +1273,7 @@ FW_VERSIONS = {
b'39990-T6Z-A030\x00\x00', b'39990-T6Z-A030\x00\x00',
b'39990-T6Z-A050\x00\x00', b'39990-T6Z-A050\x00\x00',
], ],
(Ecu.fwdCamera, 0x18dab0f1, None): [ (Ecu.fwdRadar, 0x18dab0f1, None): [
b'36161-T6Z-A020\x00\x00', b'36161-T6Z-A020\x00\x00',
b'36161-T6Z-A310\x00\x00', b'36161-T6Z-A310\x00\x00',
b'36161-T6Z-A420\x00\x00', b'36161-T6Z-A420\x00\x00',

@ -1,6 +1,7 @@
#!/usr/bin/env python3 #!/usr/bin/env python3
import random import random
import unittest import unittest
from collections import defaultdict
from parameterized import parameterized from parameterized import parameterized
from cereal import car from cereal import car
@ -44,6 +45,16 @@ class TestFwFingerprint(unittest.TestCase):
duplicates = {fw for fw in ecu_fw if ecu_fw.count(fw) > 1} 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}") self.assertFalse(len(duplicates), f"{car_model}: Duplicate FW versions: Ecu.{ECU_NAME[ecu[0]]}, {duplicates}")
def test_all_addrs_map_to_one_ecu(self):
for brand, cars in VERSIONS.items():
addr_to_ecu = defaultdict(set)
for ecus in cars.values():
for ecu_type, addr, sub_addr in ecus.keys():
addr_to_ecu[(addr, sub_addr)].add(ecu_type)
ecus_for_addr = addr_to_ecu[(addr, sub_addr)]
ecu_strings = ", ".join([f'Ecu.{ECU_NAME[ecu]}' for ecu in ecus_for_addr])
self.assertLessEqual(len(ecus_for_addr), 1, f"{brand} has multiple ECUs that map to one address: {ecu_strings} -> ({hex(addr)}, {sub_addr})")
def test_data_collection_ecus(self): def test_data_collection_ecus(self):
# Asserts no extra ECUs are in the fingerprinting database # Asserts no extra ECUs are in the fingerprinting database
for brand, config in FW_QUERY_CONFIGS.items(): for brand, config in FW_QUERY_CONFIGS.items():

Loading…
Cancel
Save