Hyundai: fix alt CAN-FD cancel (#26057)

old-commit-hash: 4ee0b8196f85b29b735c3319924f3c40cebc86e5
This commit is contained in:
Adeeb Shihadeh
2022-10-12 21:54:53 -07:00
committed by GitHub
parent f6803bc8df
commit ecfef77606
3 changed files with 10 additions and 6 deletions
+1
View File
@@ -117,6 +117,7 @@ class CarController:
# cruise cancel
if CC.cruiseControl.cancel:
if self.CP.flags & HyundaiFlags.CANFD_ALT_BUTTONS:
can_sends.append(hyundaicanfd.create_acc_cancel(self.packer, self.CP, CS.cruise_info))
self.last_button_frame = self.frame
else:
for _ in range(20):
+3 -1
View File
@@ -34,6 +34,8 @@ class CarState(CarStateBase):
self.brake_error = False
self.buttons_counter = 0
self.cruise_info = {}
# On some cars, CLU15->CF_Clu_VehicleSpeed can oscillate faster than the dash updates. Sample at 5 Hz
self.cluster_speed = 0
self.cluster_speed_counter = CLUSTER_SAMPLE_RATE
@@ -194,13 +196,13 @@ class CarState(CarStateBase):
cp_cruise_info = cp if self.CP.flags & HyundaiFlags.CANFD_HDA2 else cp_cam
ret.cruiseState.speed = cp_cruise_info.vl["CRUISE_INFO"]["SET_SPEED"] * speed_factor
ret.cruiseState.standstill = cp_cruise_info.vl["CRUISE_INFO"]["CRUISE_STANDSTILL"] == 1
self.cruise_info = copy.copy(cp_cruise_info.vl["CRUISE_INFO"])
cruise_btn_msg = "CRUISE_BUTTONS_ALT" if self.CP.flags & HyundaiFlags.CANFD_ALT_BUTTONS else "CRUISE_BUTTONS"
self.prev_cruise_buttons = self.cruise_buttons[-1]
self.cruise_buttons.extend(cp.vl_all[cruise_btn_msg]["CRUISE_BUTTONS"])
self.main_buttons.extend(cp.vl_all[cruise_btn_msg]["ADAPTIVE_CRUISE_MAIN_BTN"])
self.buttons_counter = cp.vl[cruise_btn_msg]["COUNTER"]
self.cruise_info_copy = {}
if self.CP.flags & HyundaiFlags.CANFD_HDA2:
self.cam_0x2a4 = copy.copy(cp_cam.vl["CAM_0x2a4"])
+6 -5
View File
@@ -47,12 +47,13 @@ def create_buttons(packer, cnt, btn):
}
return packer.make_can_msg("CRUISE_BUTTONS", 5, values)
def create_cruise_info(packer, cruise_info_copy, cancel):
def create_acc_cancel(packer, CP, cruise_info_copy):
values = cruise_info_copy
if cancel:
values["CRUISE_STATUS"] = 0
values["CRUISE_INACTIVE"] = 1
return packer.make_can_msg("CRUISE_INFO", 5, values)
values.update({
"CRUISE_STATUS": 0,
"CRUISE_INACTIVE": 1,
})
return packer.make_can_msg("CRUISE_INFO", get_e_can_bus(CP), values)
def create_lfahda_cluster(packer, CP, enabled):
values = {