mirror of
https://github.com/firestar5683/StarPilot.git
synced 2026-07-01 11:32:21 +08:00
Leaf: get VIN (#31398)
* Add Leaf VIN query * add lots of requests * add exception for nissan * no more logging * update refs * lower worst case * Update selfdrive/car/car_helpers.py * update refs * it's the vcm! old-commit-hash: c65dfaac68bbf836900dd612a33667cb00cdf854
This commit is contained in:
@@ -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:
|
||||
|
||||
@@ -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):
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user