From f5ddccab1e3850cfb3ded3d2deec7e8367e07586 Mon Sep 17 00:00:00 2001 From: Shane Smiskol Date: Tue, 20 Jun 2023 14:10:21 -0700 Subject: [PATCH] abs and engine are very rarely shared (avalonh tss2 and camryh tss2 is one example) --- selfdrive/car/toyota/tests/test_toyota.py | 57 ++++++++++++++++++----- 1 file changed, 45 insertions(+), 12 deletions(-) diff --git a/selfdrive/car/toyota/tests/test_toyota.py b/selfdrive/car/toyota/tests/test_toyota.py index f25a44a89e..064cfeba46 100755 --- a/selfdrive/car/toyota/tests/test_toyota.py +++ b/selfdrive/car/toyota/tests/test_toyota.py @@ -1,5 +1,6 @@ #!/usr/bin/env python3 import unittest +from collections import defaultdict from cereal import car from selfdrive.car.fw_versions import build_fw_dict @@ -42,25 +43,57 @@ class TestToyotaInterfaces(unittest.TestCase): class TestToyotaFingerprint(unittest.TestCase): - def test_fw_debugging(self): + # def test_fw_debugging(self): + # for car_model, ecus in FW_VERSIONS.items(): + # print() + # print(car_model) + # cam_len_code = False + # eng_len_code = False + # + # for ecu, fws in ecus.items(): + # if ecu[0] in (Ecu.fwdRadar, Ecu.fwdCamera): + # cam_len_code |= all(f[0] < 4 for f in fws) + # if ecu[0] in (Ecu.engine, Ecu.abs): + # eng_len_code |= all(1 < f[0] < 4 for f in fws) + # print(ecu, eng_len_code) + # + # if (car_model in TSS2_CAR) != cam_len_code: + # print(car_model, car_model in TSS2_CAR, cam_len_code) + # + # if (car_model in EV_HYBRID_CAR) != eng_len_code: + # print('MISMATCH', car_model, car_model in EV_HYBRID_CAR, eng_len_code) + + def test_shared_fw(self): + all_fw = defaultdict(set) + for car_model, ecus in FW_VERSIONS.items(): + print() + print(car_model) + + for ecu, fws in ecus.items(): + for fw in fws: + all_fw[(ecu[1], fw)].add(car_model) + + print(all_fw) + + # shared abs (or whatever is in the continue statement) + shared = defaultdict(set) + for car_model, ecus in FW_VERSIONS.items(): print() print(car_model) - cam_len_code = False - eng_len_code = False for ecu, fws in ecus.items(): - if ecu[0] in (Ecu.fwdRadar, Ecu.fwdCamera): - cam_len_code |= all(f[0] < 4 for f in fws) - if ecu[0] in (Ecu.engine, Ecu.abs): - eng_len_code |= all(1 < f[0] < 4 for f in fws) - print(ecu, eng_len_code) + if ecu[0] != Ecu.abs: + continue + for fw in fws: + if len(all_fw[ecu[1], fw]) > 1: + shared[car_model] |= all_fw[ecu[1], fw] + # print(car_model, all_fw[ecu[1], fw]) + # # all_fw[(ecu[1], fw)].add(car_model) - if (car_model in TSS2_CAR) != cam_len_code: - print(car_model, car_model in TSS2_CAR, cam_len_code) + print(shared) + print(len(shared)) - if (car_model in EV_HYBRID_CAR) != eng_len_code: - print('MISMATCH', car_model, car_model in EV_HYBRID_CAR, eng_len_code) # Tests for platform codes, part numbers, and FW dates which Hyundai will use to fuzzy # fingerprint in the absence of full FW matches: