diff --git a/opendbc_repo/opendbc/car/hyundai/carstate.py b/opendbc_repo/opendbc/car/hyundai/carstate.py index 0cc87a9a85..a7054d7fbb 100644 --- a/opendbc_repo/opendbc/car/hyundai/carstate.py +++ b/opendbc_repo/opendbc/car/hyundai/carstate.py @@ -417,6 +417,11 @@ class CarState(CarStateBase): ret.buttonEvents = button_events ret.blockPcmEnable = not self.recent_button_interaction() + if self.CP.carFingerprint == CAR.HYUNDAI_KONA_EV_2023_NON_SCC: + set_or_resume = next((not main and button in (Buttons.SET_DECEL, Buttons.RES_ACCEL) + for button, main in zip(reversed(self.cruise_buttons), reversed(self.main_buttons), strict=True) + if main or button in ENABLE_BUTTONS), False) + ret.blockPcmEnable = not set_or_resume or ret.brakePressed or ret.gasPressed # low speed steer alert hysteresis logic (only for cars with steer cut off above 10 m/s) if ret.vEgo < (self.CP.minSteerSpeed + 2.) and self.CP.minSteerSpeed > 10.: diff --git a/opendbc_repo/opendbc/car/hyundai/tests/test_kona_electric_se.py b/opendbc_repo/opendbc/car/hyundai/tests/test_kona_electric_se.py index d4b696a17f..76c93ba502 100644 --- a/opendbc_repo/opendbc/car/hyundai/tests/test_kona_electric_se.py +++ b/opendbc_repo/opendbc/car/hyundai/tests/test_kona_electric_se.py @@ -89,3 +89,19 @@ class TestKonaElectricSE(TestCase): del fp[2][0x421] fp[1][0x329] = 7 self.assertIsNone(kona_electric_se_candidate(SE_VIN, fp, firmware)) + + def test_only_regular_set_and_resume_allow_pcm_enable(self): + from opendbc.can import CANPacker + + for main, button, permitted in ((True, 0, False), (False, 4, False), (True, 2, False), + (False, 2, True), (False, 1, True)): + with self.subTest(main=main, button=button): + ci = interface(SE_VIN) + packer = CANPacker('hyundai_can_generated') + stamp = 1_000_000_000 + ci.CS.cruise_buttons.append(button) + ci.CS.main_buttons.append(main) + active = packer.make_can_msg('LABEL11', 0, {'CC_React': 1, 'CC_Engaged': 1}) + result = ci.update([(stamp, [active])]) + self.assertTrue(result.cruiseState.available and result.cruiseState.enabled) + self.assertEqual(not result.blockPcmEnable, permitted) diff --git a/prebuilt.json b/prebuilt.json index 725623e130..d4f3c2bc5c 100644 --- a/prebuilt.json +++ b/prebuilt.json @@ -1 +1 @@ -{"protected_inventory_sha256": "cfe68f6e0bd14e793a4c2240add89bf49b6e1dcfdaef8deb731ba3a257a520e1", "schema_version": 1} +{"protected_inventory_sha256": "6bf8757a417f15eecccc73d5b571f3c773ffb9ba7b04fa9025a7f3eb28331b1d", "schema_version": 1}