diff --git a/opendbc_repo/opendbc/car/subaru/carcontroller.py b/opendbc_repo/opendbc/car/subaru/carcontroller.py index 19339d46e..bde3669b9 100644 --- a/opendbc_repo/opendbc/car/subaru/carcontroller.py +++ b/opendbc_repo/opendbc/car/subaru/carcontroller.py @@ -138,7 +138,7 @@ class CarController(CarControllerBase): msg = subarucan.create_stop_start_control( self.packer, dashlights_msg, raw_dat=getattr(CS, "dashlights_dat", None), - counter=self.stop_start_counter, bus=self.main_bus, + counter=self.stop_start_counter, bus=CanBus.alt_for_cp(self.CP), ) self.stop_start_counter = (self.stop_start_counter + 1) % 0x10 return msg diff --git a/opendbc_repo/opendbc/car/subaru/carstate.py b/opendbc_repo/opendbc/car/subaru/carstate.py index 9d7c1787a..cee89d2df 100644 --- a/opendbc_repo/opendbc/car/subaru/carstate.py +++ b/opendbc_repo/opendbc/car/subaru/carstate.py @@ -28,9 +28,10 @@ class CarState(CarStateBase): ret = structs.CarState() if self.CP.carFingerprint in SUBARU_STOP_START_CARS: - self.dashlights_msg = copy.copy(cp.vl["Dashlights"]) - self.dashlights_dat = cp.vl_raw["Dashlights"] - self.stop_start_state = cp.vl["Engine_Stop_Start"]["STOP_START_STATE"] + stop_start_cp = cp_alt if self.CP.flags & SubaruFlags.GLOBAL_GEN2 else cp + self.dashlights_msg = copy.copy(stop_start_cp.vl["Dashlights"]) + self.dashlights_dat = stop_start_cp.vl_raw["Dashlights"] + self.stop_start_state = stop_start_cp.vl["Engine_Stop_Start"]["STOP_START_STATE"] throttle_msg = cp.vl["Throttle"] if not (self.CP.flags & SubaruFlags.HYBRID) else cp_alt.vl["Throttle_Hybrid"] ret.gasPressed = throttle_msg["Throttle_Pedal"] > 1e-5 diff --git a/opendbc_repo/opendbc/car/subaru/tests/test_subaru.py b/opendbc_repo/opendbc/car/subaru/tests/test_subaru.py index 4bad73809..d6ce08e54 100644 --- a/opendbc_repo/opendbc/car/subaru/tests/test_subaru.py +++ b/opendbc_repo/opendbc/car/subaru/tests/test_subaru.py @@ -212,10 +212,10 @@ def test_stop_start_inputs_are_captured_for_supported_models(platform): car_state = CarState(CP, None) parsers = car_state.get_can_parsers(CP) raw_dashlights = bytes.fromhex("13031407875a8100") - parsers[Bus.pt].vl["Dashlights"]["COUNTER"] = 6 - parsers[Bus.pt].vl["Dashlights"]["STOP_START"] = 0 - parsers[Bus.pt].vl["Engine_Stop_Start"]["STOP_START_STATE"] = 3 - parsers[Bus.pt].vl_raw["Dashlights"] = raw_dashlights + parsers[Bus.alt].vl["Dashlights"]["COUNTER"] = 6 + parsers[Bus.alt].vl["Dashlights"]["STOP_START"] = 0 + parsers[Bus.alt].vl["Engine_Stop_Start"]["STOP_START_STATE"] = 3 + parsers[Bus.alt].vl_raw["Dashlights"] = raw_dashlights car_state.update(parsers, SimpleNamespace(subaru_sng=False)) @@ -226,7 +226,7 @@ def test_stop_start_inputs_are_captured_for_supported_models(platform): @pytest.mark.parametrize("platform, expected_bus, start_frame", [ (CAR.SUBARU_OUTBACK_2023, CanBus.alt, 101), - (CAR.SUBARU_LEGACY_2025, CanBus.main, 401), + (CAR.SUBARU_LEGACY_2025, CanBus.alt, 401), ]) def test_stop_start_request_is_bounded_and_uses_live_dashlights(platform, expected_bus, start_frame): CP = CarInterface.get_non_essential_params(platform) diff --git a/opendbc_repo/opendbc/safety/modes/subaru.h b/opendbc_repo/opendbc/safety/modes/subaru.h index 20fdddab3..ba5f05845 100644 --- a/opendbc_repo/opendbc/safety/modes/subaru.h +++ b/opendbc_repo/opendbc/safety/modes/subaru.h @@ -292,7 +292,7 @@ static bool subaru_tx_hook(const CANPacket_t *msg) { if (msg->addr == MSG_SUBARU_Dashlights) { violation |= !subaru_stop_start_button; - violation |= msg->bus != (subaru_d_platform ? SUBARU_ALT_BUS : SUBARU_MAIN_BUS); + violation |= msg->bus != (subaru_gen2 ? SUBARU_ALT_BUS : SUBARU_MAIN_BUS); violation |= !GET_BIT(msg, 54U); violation |= subaru_get_checksum(msg) != subaru_compute_checksum(msg); } @@ -344,7 +344,7 @@ static safety_config subaru_init(uint16_t param) { static const CanMsg SUBARU_GEN2_LKAS_ANGLE_STOP_START_TX_MSGS[] = { SUBARU_BASE_TX_MSGS(SUBARU_ALT_BUS, MSG_SUBARU_ES_LKAS_ANGLE) SUBARU_COMMON_TX_MSGS(SUBARU_ALT_BUS) - SUBARU_STOP_START_TX_MSGS(SUBARU_MAIN_BUS) + SUBARU_STOP_START_TX_MSGS(SUBARU_ALT_BUS) }; static const CanMsg SUBARU_D_PLATFORM_ANGLE_MAIN_TX_MSGS[] = { diff --git a/opendbc_repo/opendbc/safety/tests/test_subaru.py b/opendbc_repo/opendbc/safety/tests/test_subaru.py index 91effbe43..826c1d3c2 100755 --- a/opendbc_repo/opendbc/safety/tests/test_subaru.py +++ b/opendbc_repo/opendbc/safety/tests/test_subaru.py @@ -373,11 +373,11 @@ class TestSubaruGen2FixedAngleSafety(TestSubaruGen2AngleStockLongitudinalSafety) class TestSubaruGen2FixedAngleStopStartSafety(TestSubaruGen2FixedAngleSafety): FLAGS = SubaruSafetyFlags.GEN2 | SubaruSafetyFlags.LKAS_ANGLE | SubaruSafetyFlags.FIXED_ANGLE_LIMITS | \ SubaruSafetyFlags.STOP_START_BUTTON - TX_MSGS = TestSubaruGen2FixedAngleSafety.TX_MSGS + [[SubaruMsg.Dashlights, SUBARU_MAIN_BUS]] + TX_MSGS = TestSubaruGen2FixedAngleSafety.TX_MSGS + [[SubaruMsg.Dashlights, SUBARU_ALT_BUS]] def _stop_start_msg(self, pressed): return self.packer.make_can_msg_safety( - "Dashlights", SUBARU_MAIN_BUS, {"COUNTER": 0, "STOP_START": pressed}, + "Dashlights", SUBARU_ALT_BUS, {"COUNTER": 0, "STOP_START": pressed}, ) def test_stop_start_tx_requires_pressed_bit(self):