mirror of
https://github.com/dragonpilot/dragonpilot.git
synced 2026-02-25 05:23:54 +08:00
Add Chrysler FPv2 requests and logging (#24460)
* Chrylser FPv2 * Update fw_versions.py * formatting and remove default * fix rx offset * move to end * add fw versions * this won't be fingerprinted on as it returns from Mazda * only log FW versions * add type annotation * fix typing * Skip if FW versions are for read/request-only * Fix crash if no fw versions Fix crash if no fw versions Co-authored-by: Shane Smiskol <shane@smiskol.com> Co-authored-by: Adeeb Shihadeh <adeebshihadeh@gmail.com>
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
import capnp
|
||||
from dataclasses import dataclass
|
||||
from enum import Enum
|
||||
from typing import Dict, List, Optional, Union
|
||||
from typing import Dict, List, Optional, Tuple, Union
|
||||
|
||||
from cereal import car
|
||||
from selfdrive.car import dbc_dict
|
||||
@@ -110,6 +111,21 @@ FINGERPRINTS = {
|
||||
],
|
||||
}
|
||||
|
||||
FW_VERSIONS: Dict[str, Dict[Tuple[capnp.lib.capnp._EnumModule, int, Optional[int]], List[str]]] = {
|
||||
CAR.RAM_1500: {
|
||||
(Ecu.combinationMeter, 0x742, None): [],
|
||||
(Ecu.srs, 0x744, None): [],
|
||||
(Ecu.esp, 0x747, None): [],
|
||||
(Ecu.fwdCamera, 0x753, None): [],
|
||||
(Ecu.fwdCamera, 0x764, None): [],
|
||||
(Ecu.eps, 0x761, None): [],
|
||||
(Ecu.fwdRadar, 0x757, None): [],
|
||||
(Ecu.eps, 0x75A, None): [],
|
||||
(Ecu.engine, 0x7e0, None): [],
|
||||
(Ecu.transmission, 0x7e1, None): [],
|
||||
(Ecu.gateway, 0x18DACBF1, None): [],
|
||||
}
|
||||
}
|
||||
|
||||
DBC = {
|
||||
CAR.PACIFICA_2017_HYBRID: dbc_dict('chrysler_pacifica_2017_hybrid_generated', 'chrysler_pacifica_2017_hybrid_private_fusion'),
|
||||
|
||||
@@ -92,6 +92,13 @@ SUBARU_VERSION_REQUEST = bytes([uds.SERVICE_TYPE.READ_DATA_BY_IDENTIFIER]) + \
|
||||
SUBARU_VERSION_RESPONSE = bytes([uds.SERVICE_TYPE.READ_DATA_BY_IDENTIFIER + 0x40]) + \
|
||||
p16(uds.DATA_IDENTIFIER_TYPE.APPLICATION_DATA_IDENTIFICATION)
|
||||
|
||||
CHRYSLER_VERSION_REQUEST = bytes([uds.SERVICE_TYPE.READ_DATA_BY_IDENTIFIER]) + \
|
||||
p16(0xf132)
|
||||
CHRYSLER_VERSION_RESPONSE = bytes([uds.SERVICE_TYPE.READ_DATA_BY_IDENTIFIER + 0x40]) + \
|
||||
p16(0xf132)
|
||||
|
||||
CHRYSLER_RX_OFFSET = -0x280
|
||||
|
||||
|
||||
@dataclass
|
||||
class Request:
|
||||
@@ -188,6 +195,18 @@ REQUESTS: List[Request] = [
|
||||
[TESTER_PRESENT_RESPONSE, UDS_VERSION_RESPONSE],
|
||||
bus=0,
|
||||
),
|
||||
# Chrysler / FCA / Stellantis
|
||||
Request(
|
||||
"chrysler",
|
||||
[CHRYSLER_VERSION_REQUEST],
|
||||
[CHRYSLER_VERSION_RESPONSE],
|
||||
rx_offset=CHRYSLER_RX_OFFSET,
|
||||
),
|
||||
Request(
|
||||
"chrysler",
|
||||
[CHRYSLER_VERSION_REQUEST],
|
||||
[CHRYSLER_VERSION_RESPONSE],
|
||||
),
|
||||
]
|
||||
|
||||
|
||||
@@ -445,7 +464,7 @@ if __name__ == "__main__":
|
||||
print()
|
||||
print("Found FW versions")
|
||||
print("{")
|
||||
padding = max([len(fw.brand) for fw in fw_vers])
|
||||
padding = max([len(fw.brand) for fw in fw_vers] or [0])
|
||||
for version in fw_vers:
|
||||
subaddr = None if version.subAddress == 0 else hex(version.subAddress)
|
||||
print(f" Brand: {version.brand:{padding}} - (Ecu.{version.ecu}, {hex(version.address)}, {subaddr}): [{version.fwVersion}]")
|
||||
|
||||
@@ -27,6 +27,8 @@ class TestFwFingerprint(unittest.TestCase):
|
||||
for _ in range(200):
|
||||
fw = []
|
||||
for ecu, fw_versions in ecus.items():
|
||||
if not len(fw_versions):
|
||||
raise unittest.SkipTest("Car model has no FW versions")
|
||||
ecu_name, addr, sub_addr = ecu
|
||||
fw.append({"ecu": ecu_name, "fwVersion": random.choice(fw_versions), 'brand': brand,
|
||||
"address": addr, "subAddress": 0 if sub_addr is None else sub_addr})
|
||||
|
||||
Reference in New Issue
Block a user