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

pull/26061/head
Adeeb Shihadeh 3 years ago committed by GitHub
parent c782380fc1
commit 4ee0b8196f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 1
      selfdrive/car/hyundai/carcontroller.py
  2. 4
      selfdrive/car/hyundai/carstate.py
  3. 11
      selfdrive/car/hyundai/hyundaicanfd.py

@ -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):

@ -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"])

@ -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 = {

Loading…
Cancel
Save