From 02f3e2ff58ba1f15a235b568c0555faaed9cc139 Mon Sep 17 00:00:00 2001 From: Shane Smiskol Date: Sun, 10 Sep 2023 21:11:20 -0700 Subject: [PATCH] spot check --- selfdrive/car/toyota/tests/test_toyota.py | 34 ++++++++--------------- selfdrive/car/toyota/values.py | 3 +- 2 files changed, 13 insertions(+), 24 deletions(-) diff --git a/selfdrive/car/toyota/tests/test_toyota.py b/selfdrive/car/toyota/tests/test_toyota.py index 73f3ff8ff4..36f72eaca2 100755 --- a/selfdrive/car/toyota/tests/test_toyota.py +++ b/selfdrive/car/toyota/tests/test_toyota.py @@ -115,36 +115,26 @@ class TestToyotaFingerprint(unittest.TestCase): # # Some examples of valid formats: b"56310-L0010", b"56310L0010", b"56310/M6300" # self.assertTrue(all({b"-" in code for code, _ in codes}), # f"FW does not have part number: {fw}") - # + def test_platform_codes_spot_check(self): - return # Asserts basic platform code parsing behavior for a few cases - results = get_platform_codes([b'\x018966306L3100\x00\x00\x00\x00']) - self.assertEqual(results, {(b"89663-06", b"L3-100")}) + results = get_platform_codes([b"F152607140\x00\x00\x00\x00\x00\x00"]) + self.assertEqual(results, {(b"F1526-07-1", b"40")}) - # Some cameras and all radars do not have dates - results = get_platform_codes([b"\xf1\x00AEhe SCC H-CUP 1.01 1.01 96400-G2000 "]) - self.assertEqual(results, {(b"AEhe-G2000", None)}) + results = get_platform_codes([b"\x028646F4104100\x00\x00\x00\x008646G5301200\x00\x00\x00\x00"]) + self.assertEqual(results, {(b"8646F-41-04", b"100")}) - results = get_platform_codes([b"\xf1\x00CV1_ RDR ----- 1.00 1.01 99110-CV000 "]) - self.assertEqual(results, {(b"CV1-CV000", None)}) + # Short version has no part number + results = get_platform_codes([b"\x0235879000\x00\x00\x00\x00\x00\x00\x00\x00A4701000\x00\x00\x00\x00\x00\x00\x00\x00"]) + self.assertEqual(results, {(b"35-87", b"9000")}) results = get_platform_codes([ - b"\xf1\x00DH LKAS 1.1 -150210", - b"\xf1\x00AEhe SCC H-CUP 1.01 1.01 96400-G2000 ", - b"\xf1\x00CV1_ RDR ----- 1.00 1.01 99110-CV000 ", + b"F152607140\x00\x00\x00\x00\x00\x00", + b"\x028646F4104100\x00\x00\x00\x008646G5301200\x00\x00\x00\x00", + b"\x0235879000\x00\x00\x00\x00\x00\x00\x00\x00A4701000\x00\x00\x00\x00\x00\x00\x00\x00", ]) - self.assertEqual(results, {(b"DH", b"150210"), (b"AEhe-G2000", None), (b"CV1-CV000", None)}) + self.assertEqual(results, {(b"F1526-07-1", b"40"), (b"8646F-41-04", b"100"), (b"35-87", b"9000")}) - results = get_platform_codes([ - b"\xf1\x00LX2 MFC AT USA LHD 1.00 1.07 99211-S8100 220222", - b"\xf1\x00LX2 MFC AT USA LHD 1.00 1.08 99211-S8100 211103", - b"\xf1\x00ON MFC AT USA LHD 1.00 1.01 99211-S9100 190405", - b"\xf1\x00ON MFC AT USA LHD 1.00 1.03 99211-S9100 190720", - ]) - self.assertEqual(results, {(b"LX2-S8100", b"220222"), (b"LX2-S8100", b"211103"), - (b"ON-S9100", b"190405"), (b"ON-S9100", b"190720")}) - # def test_fuzzy_excluded_platforms(self): # Asserts a list of platforms that will not fuzzy fingerprint with platform codes due to them being shared. # This list can be shrunk as we combine platforms, detect features, and add the hybrid ECU diff --git a/selfdrive/car/toyota/values.py b/selfdrive/car/toyota/values.py index 91f528670b..4d1a572496 100644 --- a/selfdrive/car/toyota/values.py +++ b/selfdrive/car/toyota/values.py @@ -2,7 +2,7 @@ import re from collections import defaultdict from dataclasses import dataclass, field from enum import Enum, IntFlag -from typing import Dict, List, Optional, Set, Tuple, Union +from typing import Dict, List, Set, Tuple, Union from cereal import car from openpilot.common.conversions import Conversions as CV @@ -357,7 +357,6 @@ FW_LEN_CODE = re.compile(b'^[\x01-\x05]') # 5 chunks max. highest seen is 3 chu FW_CHUNK_LEN = 16 # List of ECUs expected to have platform codes -# TODO: use hybrid ECU, splits many similar ICE and hybrid variants PLATFORM_CODE_ECUS = [Ecu.abs, Ecu.engine, Ecu.eps, Ecu.dsu, Ecu.fwdCamera, Ecu.fwdRadar]