diff --git a/selfdrive/car/fw_query_definitions.py b/selfdrive/car/fw_query_definitions.py index ed886a69db..350c062826 100755 --- a/selfdrive/car/fw_query_definitions.py +++ b/selfdrive/car/fw_query_definitions.py @@ -65,6 +65,9 @@ class StdQueries: GM_VIN_REQUEST = b'\x1a\x90' GM_VIN_RESPONSE = b'\x5a\x90' + KWP_VIN_REQUEST = b'\x21\x81' + KWP_VIN_RESPONSE = b'\x61\x81' + @dataclass class Request: diff --git a/selfdrive/car/tests/test_fw_fingerprint.py b/selfdrive/car/tests/test_fw_fingerprint.py index fa006e51a6..17eba80d2a 100755 --- a/selfdrive/car/tests/test_fw_fingerprint.py +++ b/selfdrive/car/tests/test_fw_fingerprint.py @@ -225,7 +225,7 @@ class TestFwFingerprintTiming(unittest.TestCase): def test_startup_timing(self): # Tests worse-case VIN query time and typical present ECU query time - vin_ref_times = {'worst': 1.0, 'best': 0.5} # best assumes we go through all queries to get a match + vin_ref_times = {'worst': 1.2, 'best': 0.6} # best assumes we go through all queries to get a match present_ecu_ref_time = 0.75 def fake_get_ecu_addrs(*_, timeout): diff --git a/selfdrive/car/vin.py b/selfdrive/car/vin.py index 184455af17..e668c35f7d 100755 --- a/selfdrive/car/vin.py +++ b/selfdrive/car/vin.py @@ -22,6 +22,7 @@ def get_vin(logcan, sendcan, buses, timeout=0.1, retry=2, debug=False): (StdQueries.UDS_VIN_REQUEST, StdQueries.UDS_VIN_RESPONSE, (0, 1), STANDARD_VIN_ADDRS, FUNCTIONAL_ADDRS, 0x8), (StdQueries.OBD_VIN_REQUEST, StdQueries.OBD_VIN_RESPONSE, (0, 1), STANDARD_VIN_ADDRS, FUNCTIONAL_ADDRS, 0x8), (StdQueries.GM_VIN_REQUEST, StdQueries.GM_VIN_RESPONSE, (0,), [0x24b], None, 0x400), # Bolt fwdCamera + (StdQueries.KWP_VIN_REQUEST, StdQueries.KWP_VIN_RESPONSE, (0,), [0x797], None, 0x3), # Nissan Leaf VCM ): if bus not in valid_buses: continue @@ -40,8 +41,8 @@ def get_vin(logcan, sendcan, buses, timeout=0.1, retry=2, debug=False): for addr in vin_addrs: vin = results.get((addr, None)) if vin is not None: - # Ford pads with null bytes - if len(vin) == 24: + # Ford and Nissan pads with null bytes + if len(vin) in (19, 24): vin = re.sub(b'\x00*$', b'', vin) # Honda Bosch response starts with a length, trim to correct length