Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions opendbc/car/mazda/fingerprints.py
Original file line number Diff line number Diff line change
Expand Up @@ -259,6 +259,8 @@
CAR.MAZDA_CX9_2021: {
(Ecu.eps, 0x730, None): [
b'TC3M-3210X-A-00\x00\x00\x00\x00\x00\x00\x00\x00\x00',
# CX-9 with a supported 2022+ CX-5 EPS swap
b'KSD5-3210X-C-00\x00\x00\x00\x00\x00\x00\x00\x00\x00',
],
(Ecu.engine, 0x7e0, None): [
b'PW25-188K2-\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00',
Expand Down
31 changes: 31 additions & 0 deletions opendbc/car/mazda/tests/test_mazda_interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

from opendbc.car import structs
from opendbc.car.common.conversions import Conversions as CV
from opendbc.car.fw_versions import match_fw_to_car
from opendbc.car.mazda.interface import CarInterface
from opendbc.car.mazda.values import CAR, LKAS_LIMITS, STEER_TO_ZERO_EPS_FW

Expand All @@ -21,6 +22,26 @@ def _eps_fw(version: bytes) -> list[structs.CarParams.CarFw]:
return [fw]


def _fw(ecu, address: int, version: bytes) -> structs.CarParams.CarFw:
fw = structs.CarParams.CarFw()
fw.brand = 'mazda'
fw.ecu = ecu
fw.address = address
fw.subAddress = 0
fw.fwVersion = version
return fw


HYBRID_CX9_FW = [
_fw(Ecu.engine, 0x7e0, b'PXM7-188K2-E' + b'\x00' * 12),
_fw(Ecu.transmission, 0x7e1, b'PXM7-21PS1-B' + b'\x00' * 12),
_fw(Ecu.abs, 0x760, b'TA0B-437K2-C' + b'\x00' * 12),
_fw(Ecu.fwdRadar, 0x764, b'K131-67XK2-F' + b'\x00' * 12),
_fw(Ecu.fwdCamera, 0x706, b'GSH7-67XK2-S' + b'\x00' * 12),
_fw(Ecu.eps, 0x730, b'KSD5-3210X-C-00' + b'\x00' * 9),
]


def _params(candidate, car_fw=None, alpha_long=False):
return CarInterface.get_params(candidate, {0: {}, 1: {}, 2: {}}, car_fw or [],
alpha_long, is_release=False, docs=False)
Expand All @@ -46,6 +67,16 @@ def test_swapped_eps_lifts_dashcam_and_the_speed_floor(self):
assert CP.minSteerSpeed == 0
assert CP.steerActuatorDelay == pytest.approx(0.14)

def test_hybrid_cx9_is_identified_with_the_swapped_eps(self):
exact, candidates = match_fw_to_car(HYBRID_CX9_FW, "", allow_fuzzy=False, log=False)
assert exact
assert candidates == {CAR.MAZDA_CX9_2021}

CP = _params(CAR.MAZDA_CX9_2021, HYBRID_CX9_FW)
assert not CP.dashcamOnly
assert CP.minSteerSpeed == 0
assert CP.steerActuatorDelay == pytest.approx(0.14)

def test_swapped_eps_does_not_unlock_longitudinal(self):
# the radar and camera are not part of an EPS swap, and this car keeps its own pre-2022 pair
CP = _params(CAR.MAZDA_CX5, _eps_fw(SWAPPED_EPS_FW), alpha_long=True)
Expand Down
Loading