son day I'll get this

This commit is contained in:
firestar5683
2026-06-14 21:02:31 -05:00
parent 00c64ba805
commit 9aeaf593c3
2 changed files with 36 additions and 1 deletions
+5 -1
View File
@@ -204,8 +204,12 @@ class CarState(CarStateBase):
return button_events
def create_lkas_button_events(self, cp: CANParser, prev_lda_button: int) -> list[structs.CarState.ButtonEvent]:
if self.CP.carFingerprint == CAR.HYUNDAI_SONATA_HYBRID and cp.ts_nanos["BCM_PO_11"]["LDA_BTN"] > 0:
# Route-proven: late-model Sonata Hybrid publishes a live LKAS button on BCM_PO_11
# while CLU13 is present on the main bus but does not carry the LKAS state.
self.lda_button = int(cp.vl["BCM_PO_11"]["LDA_BTN"])
# Some classic HKG platforms publish the LKAS button on the cluster bus instead of BCM_PO_11.
if cp.ts_nanos["CLU13"]["CF_Clu_LdwsLkasSW"] > 0:
elif cp.ts_nanos["CLU13"]["CF_Clu_LdwsLkasSW"] > 0:
self.lda_button = int(cp.vl["CLU13"]["CF_Clu_LdwsLkasSW"])
elif cp.ts_nanos["BCM_PO_11"]["LDA_BTN"] > 0:
self.lda_button = int(cp.vl["BCM_PO_11"]["LDA_BTN"])
@@ -771,6 +771,37 @@ class TestHyundaiFingerprint:
ret = update(0, 3)
assert any(be.type == ButtonType.lkas and not be.pressed for be in ret.buttonEvents)
def test_sonata_hybrid_prefers_bcm_lkas_button_over_dead_main_bus_clu13(self):
toggles = get_test_toggles()
fingerprint = gen_empty_fingerprint()
fingerprint[0][0x391] = 8
fingerprint[1][0x50C] = 8
CP = CarInterface.get_params(CAR.HYUNDAI_SONATA_HYBRID, fingerprint, [], False, False, False, toggles)
FPCP = CarInterface.get_starpilot_params(CAR.HYUNDAI_SONATA_HYBRID, fingerprint, [], CP, toggles)
car_state = CarState(CP, FPCP)
can_parsers = car_state.get_can_parsers(CP)
packer = CANPacker(DBC[CP.carFingerprint][Bus.pt])
def update(clu13_lkas_button: int, bcm_lkas_button: int, frame: int):
msgs = [
packer.make_can_msg("CLU13", 0, {
"CF_Clu_LdwsLkasSW": clu13_lkas_button,
}),
packer.make_can_msg("BCM_PO_11", 0, {
"LDA_BTN": bcm_lkas_button,
}),
]
can_parsers[Bus.pt].update([(frame, msgs)])
return car_state.update(can_parsers, toggles)[0]
update(0, 0, 1)
ret = update(0, 1, 2)
assert any(be.type == ButtonType.lkas and be.pressed for be in ret.buttonEvents)
ret = update(0, 0, 3)
assert any(be.type == ButtonType.lkas and not be.pressed for be in ret.buttonEvents)
def test_sonata_hybrid_ignores_noisy_alt_bus_clu13_lkas_button(self):
toggles = get_test_toggles()
fingerprint = gen_empty_fingerprint()