|
|
@ -1,4 +1,5 @@ |
|
|
|
#!/usr/bin/env python3 |
|
|
|
#!/usr/bin/env python3 |
|
|
|
|
|
|
|
import re |
|
|
|
import unittest |
|
|
|
import unittest |
|
|
|
from collections import defaultdict |
|
|
|
from collections import defaultdict |
|
|
|
|
|
|
|
|
|
|
@ -7,35 +8,12 @@ from selfdrive.car.fw_versions import build_fw_dict |
|
|
|
# from selfdrive.car.hyundai.values import CAMERA_SCC_CAR, CANFD_CAR, CAN_GEARS, CAR, CHECKSUM, DATE_FW_ECUS, \ |
|
|
|
# from selfdrive.car.hyundai.values import CAMERA_SCC_CAR, CANFD_CAR, CAN_GEARS, CAR, CHECKSUM, DATE_FW_ECUS, \ |
|
|
|
# EV_CAR, FW_QUERY_CONFIG, FW_VERSIONS, LEGACY_SAFETY_MODE_CAR, \ |
|
|
|
# EV_CAR, FW_QUERY_CONFIG, FW_VERSIONS, LEGACY_SAFETY_MODE_CAR, \ |
|
|
|
# PLATFORM_CODE_ECUS, get_platform_codes |
|
|
|
# PLATFORM_CODE_ECUS, get_platform_codes |
|
|
|
from selfdrive.car.toyota.values import TSS2_CAR, ANGLE_CONTROL_CAR, FW_VERSIONS, FW_QUERY_CONFIG, EV_HYBRID_CAR |
|
|
|
from selfdrive.car.toyota.values import TSS2_CAR, ANGLE_CONTROL_CAR, FW_VERSIONS, FW_QUERY_CONFIG, EV_HYBRID_CAR, \ |
|
|
|
|
|
|
|
FW_PATTERN, FW_LEN_CODE, FW_PATTERN_V3 |
|
|
|
|
|
|
|
|
|
|
|
Ecu = car.CarParams.Ecu |
|
|
|
Ecu = car.CarParams.Ecu |
|
|
|
ECU_NAME = {v: k for k, v in Ecu.schema.enumerants.items()} |
|
|
|
ECU_NAME = {v: k for k, v in Ecu.schema.enumerants.items()} |
|
|
|
|
|
|
|
|
|
|
|
# # Some platforms have date codes in a different format we don't yet parse (or are missing). |
|
|
|
|
|
|
|
# # For now, assert list of expected missing date cars |
|
|
|
|
|
|
|
# NO_DATES_PLATFORMS = { |
|
|
|
|
|
|
|
# # CAN FD |
|
|
|
|
|
|
|
# CAR.KIA_SPORTAGE_5TH_GEN, |
|
|
|
|
|
|
|
# CAR.KIA_SPORTAGE_HYBRID_5TH_GEN, |
|
|
|
|
|
|
|
# CAR.SANTA_CRUZ_1ST_GEN, |
|
|
|
|
|
|
|
# CAR.TUCSON_4TH_GEN, |
|
|
|
|
|
|
|
# CAR.TUCSON_HYBRID_4TH_GEN, |
|
|
|
|
|
|
|
# # CAN |
|
|
|
|
|
|
|
# CAR.ELANTRA, |
|
|
|
|
|
|
|
# CAR.KIA_CEED, |
|
|
|
|
|
|
|
# CAR.KIA_FORTE, |
|
|
|
|
|
|
|
# CAR.KIA_OPTIMA_G4, |
|
|
|
|
|
|
|
# CAR.KIA_OPTIMA_G4_FL, |
|
|
|
|
|
|
|
# CAR.KIA_SORENTO, |
|
|
|
|
|
|
|
# CAR.KONA, |
|
|
|
|
|
|
|
# CAR.KONA_EV, |
|
|
|
|
|
|
|
# CAR.KONA_EV_2022, |
|
|
|
|
|
|
|
# CAR.KONA_HEV, |
|
|
|
|
|
|
|
# CAR.SONATA_LF, |
|
|
|
|
|
|
|
# CAR.VELOSTER, |
|
|
|
|
|
|
|
# } |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class TestToyotaInterfaces(unittest.TestCase): |
|
|
|
class TestToyotaInterfaces(unittest.TestCase): |
|
|
|
def test_angle_car_set(self): |
|
|
|
def test_angle_car_set(self): |
|
|
@ -43,6 +21,22 @@ class TestToyotaInterfaces(unittest.TestCase): |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class TestToyotaFingerprint(unittest.TestCase): |
|
|
|
class TestToyotaFingerprint(unittest.TestCase): |
|
|
|
|
|
|
|
def test_fw_pattern(self): |
|
|
|
|
|
|
|
for car_model, ecus in FW_VERSIONS.items(): |
|
|
|
|
|
|
|
# print() |
|
|
|
|
|
|
|
# print(car_model) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
for ecu, fws in ecus.items(): |
|
|
|
|
|
|
|
for fw in fws: |
|
|
|
|
|
|
|
match = FW_PATTERN.search(fw) |
|
|
|
|
|
|
|
length = FW_LEN_CODE.search(fw) |
|
|
|
|
|
|
|
if ecu[0] in (Ecu.fwdRadar, Ecu.fwdCamera): |
|
|
|
|
|
|
|
assert (length is None) == (car_model not in TSS2_CAR), (car_model, ecu, fw) |
|
|
|
|
|
|
|
if ecu[0] in (Ecu.engine,): |
|
|
|
|
|
|
|
assert length is not None |
|
|
|
|
|
|
|
# assert match is not None, (ecu, fw, match) |
|
|
|
|
|
|
|
# print(fw, match) |
|
|
|
|
|
|
|
|
|
|
|
# def test_fw_debugging(self): |
|
|
|
# def test_fw_debugging(self): |
|
|
|
# for car_model, ecus in FW_VERSIONS.items(): |
|
|
|
# for car_model, ecus in FW_VERSIONS.items(): |
|
|
|
# print() |
|
|
|
# print() |
|
|
@ -66,21 +60,27 @@ class TestToyotaFingerprint(unittest.TestCase): |
|
|
|
def test_shared_fw(self): |
|
|
|
def test_shared_fw(self): |
|
|
|
all_fw = defaultdict(set) |
|
|
|
all_fw = defaultdict(set) |
|
|
|
for car_model, ecus in FW_VERSIONS.items(): |
|
|
|
for car_model, ecus in FW_VERSIONS.items(): |
|
|
|
print() |
|
|
|
# print() |
|
|
|
print(car_model) |
|
|
|
# print(car_model) |
|
|
|
|
|
|
|
|
|
|
|
for ecu, fws in ecus.items(): |
|
|
|
for ecu, fws in ecus.items(): |
|
|
|
|
|
|
|
parts = set() |
|
|
|
for fw in fws: |
|
|
|
for fw in fws: |
|
|
|
|
|
|
|
length, part = FW_PATTERN_V3.search(fw).groups() |
|
|
|
|
|
|
|
parts.add(part) |
|
|
|
|
|
|
|
|
|
|
|
all_fw[(ecu[1], fw)].add(car_model) |
|
|
|
all_fw[(ecu[1], fw)].add(car_model) |
|
|
|
|
|
|
|
if len(parts) > 1: |
|
|
|
|
|
|
|
print('uoh' ,car_model, ecu, parts) |
|
|
|
|
|
|
|
|
|
|
|
print(all_fw) |
|
|
|
# print(all_fw) |
|
|
|
|
|
|
|
|
|
|
|
# shared abs (or whatever is in the continue statement) |
|
|
|
# shared abs (or whatever is in the continue statement) |
|
|
|
shared = defaultdict(set) |
|
|
|
shared = defaultdict(set) |
|
|
|
|
|
|
|
|
|
|
|
for car_model, ecus in FW_VERSIONS.items(): |
|
|
|
for car_model, ecus in FW_VERSIONS.items(): |
|
|
|
print() |
|
|
|
# print() |
|
|
|
print(car_model) |
|
|
|
# print(car_model) |
|
|
|
|
|
|
|
|
|
|
|
for ecu, fws in ecus.items(): |
|
|
|
for ecu, fws in ecus.items(): |
|
|
|
if ecu[0] != Ecu.abs: |
|
|
|
if ecu[0] != Ecu.abs: |
|
|
|