From b41683d3231232ced665ede540bcc7c77dacf437 Mon Sep 17 00:00:00 2001 From: Shane Smiskol Date: Tue, 30 Jan 2024 04:19:12 -0600 Subject: [PATCH] GM: FPv2 logging (#31221) * bump * from https://github.com/commaai/openpilot/pull/27929 * get VIN on bolt! * might as well try on other gms * remove vin * ugh gm is going to be slow * fix * should really fix this * revert * happy?1 * fix unit test * bump * functional addressing must be an OBD gateway feature, this does nothing * fix vin response * fix addr! * finally fix fw_versions bugs since boardd IsOnroad refactor * for * only bus 0 * clean up * Update selfdrive/car/gm/values.py * ChatGPT re-write * filter out did * todo * oof * preview: what multiple DIDs per ECU would look like in the future * Revert "preview: what multiple DIDs per ECU would look like in the future" This reverts commit 88f0d8611e638de644adc5feabade848c03d59e4. * function to get all ecus * we can remove this! * can also do this! * and this one too :o * consistency * yay * clean up old-commit-hash: 06f0e5096424acd643046f4bd5a3c84a4f684e8e --- selfdrive/car/gm/fingerprints.py | 4 ++- selfdrive/car/gm/values.py | 36 ++++++++++++++++++++++ selfdrive/car/tests/test_fw_fingerprint.py | 3 +- 3 files changed, 41 insertions(+), 2 deletions(-) diff --git a/selfdrive/car/gm/fingerprints.py b/selfdrive/car/gm/fingerprints.py index 9159ddefbf..445d9571d4 100644 --- a/selfdrive/car/gm/fingerprints.py +++ b/selfdrive/car/gm/fingerprints.py @@ -1,7 +1,7 @@ # ruff: noqa: E501 from openpilot.selfdrive.car.gm.values import CAR -# Trailblazer also matches as a SILVERADO, TODO: split with fw verisions +# Trailblazer also matches as a SILVERADO, TODO: split with fw versions FINGERPRINTS = { @@ -54,3 +54,5 @@ FINGERPRINTS = { 190: 6, 193: 8, 197: 8, 201: 8, 209: 7, 211: 2, 241: 6, 249: 8, 257: 8, 288: 5, 289: 8, 298: 8, 304: 1, 309: 8, 311: 8, 313: 8, 320: 3, 328: 1, 352: 5, 381: 8, 384: 4, 386: 8, 388: 8, 413: 8, 451: 8, 452: 8, 453: 6, 455: 7, 463: 3, 479: 3, 481: 7, 485: 8, 489: 8, 497: 8, 500: 6, 501: 8, 510: 8, 528: 5, 532: 6, 560: 8, 562: 8, 563: 5, 565: 5, 587: 8, 608: 8, 609: 6, 610: 6, 611: 6, 612: 8, 613: 8, 707: 8, 715: 8, 717: 5, 753: 5, 761: 7, 789: 5, 800: 6, 810: 8, 840: 5, 842: 5, 844: 8, 869: 4, 880: 6, 977: 8, 1001: 8, 1011: 6, 1017: 8, 1020: 8, 1033: 7, 1034: 7, 1217: 8, 1221: 5, 1233: 8, 1249: 8, 1259: 8, 1261: 7, 1263: 4, 1265: 8, 1267: 1, 1271: 8, 1280: 4, 1296: 4, 1300: 8, 1611: 8, 1930: 7 }], } + +FW_VERSIONS: dict[str, dict[tuple, list[bytes]]] = {} diff --git a/selfdrive/car/gm/values.py b/selfdrive/car/gm/values.py index dbbf15100f..8188ad4e6e 100644 --- a/selfdrive/car/gm/values.py +++ b/selfdrive/car/gm/values.py @@ -6,6 +6,8 @@ from typing import Dict, List, Union from cereal import car from openpilot.selfdrive.car import dbc_dict from openpilot.selfdrive.car.docs_definitions import CarFootnote, CarHarness, CarInfo, CarParts, Column +from openpilot.selfdrive.car.fw_query_definitions import FwQueryConfig, Request, StdQueries + Ecu = car.CarParams.Ecu @@ -143,8 +145,42 @@ class CanBus: DROPPED = 192 +# In a Data Module, an identifier is a string used to recognize an object, +# either by itself or together with the identifiers of parent objects. +# Each returns a 4 byte hex representation of the decimal part number. `b"\x02\x8c\xf0'"` -> 42790951 +GM_SOFTWARE_MODULE_1_REQUEST = b'\x1a\xc1' +GM_SOFTWARE_MODULE_2_REQUEST = b'\x1a\xc2' +GM_SOFTWARE_MODULE_3_REQUEST = b'\x1a\xc3' +# This DID is for identifying the part number that reflects the mix of hardware, +# software, and calibrations in the ECU when it first arrives at the vehicle assembly plant. +# If there's an Alpha Code, it's associated with this part number and stored in the DID $DB. +GM_END_MODEL_PART_NUMBER_REQUEST = b'\x1a\xcb' +GM_BASE_MODEL_PART_NUMBER_REQUEST = b'\x1a\xcc' +GM_FW_RESPONSE = b'\x5a' + +GM_FW_REQUESTS = [ + GM_SOFTWARE_MODULE_1_REQUEST, + GM_SOFTWARE_MODULE_2_REQUEST, + GM_SOFTWARE_MODULE_3_REQUEST, + GM_END_MODEL_PART_NUMBER_REQUEST, + GM_BASE_MODEL_PART_NUMBER_REQUEST, +] + GM_RX_OFFSET = 0x400 +FW_QUERY_CONFIG = FwQueryConfig( + requests=[request for req in GM_FW_REQUESTS for request in [ + Request( + [StdQueries.SHORT_TESTER_PRESENT_REQUEST, req], + [StdQueries.SHORT_TESTER_PRESENT_RESPONSE, GM_FW_RESPONSE + bytes([req[-1]])], + rx_offset=GM_RX_OFFSET, + bus=0, + logging=True, + ), + ]], + extra_ecus=[(Ecu.fwdCamera, 0x24b, None)], +) + DBC: Dict[str, Dict[str, str]] = defaultdict(lambda: dbc_dict('gm_global_a_powertrain_generated', 'gm_global_a_object', chassis_dbc='gm_global_a_chassis')) EV_CAR = {CAR.VOLT, CAR.BOLT_EUV} diff --git a/selfdrive/car/tests/test_fw_fingerprint.py b/selfdrive/car/tests/test_fw_fingerprint.py index 7cd670cf7c..e7ba67d433 100755 --- a/selfdrive/car/tests/test_fw_fingerprint.py +++ b/selfdrive/car/tests/test_fw_fingerprint.py @@ -246,9 +246,10 @@ class TestFwFingerprintTiming(unittest.TestCase): @pytest.mark.timeout(60) def test_fw_query_timing(self): - total_ref_time = 6.5 + total_ref_time = 7.1 brand_ref_times = { 1: { + 'gm': 0.5, 'body': 0.1, 'chrysler': 0.3, 'ford': 0.2,