Skip to content

Commit

Permalink
Fix cruise resume from standstill when ALT_BUTTONS are used.
Browse files Browse the repository at this point in the history
This is needed for the Kia Caravan '25.
  • Loading branch information
ccdunder committed Dec 17, 2024
1 parent 6c1d1a4 commit 300e557
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 10 deletions.
11 changes: 4 additions & 7 deletions opendbc/car/hyundai/carcontroller.py
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,7 @@ def create_button_messages(self, CC: structs.CarControl, CS: CarState, use_clu11
# cruise cancel
if CC.cruiseControl.cancel:
if self.CP.flags & HyundaiFlags.CANFD_ALT_BUTTONS:
# TODO: Any reason to not just send the button?
can_sends.append(hyundaicanfd.create_acc_cancel(self.packer, self.CP, self.CAN, CS.cruise_info))
self.last_button_frame = self.frame
else:
Expand All @@ -195,12 +196,8 @@ def create_button_messages(self, CC: structs.CarControl, CS: CarState, use_clu11

# cruise standstill resume
elif CC.cruiseControl.resume:
if self.CP.flags & HyundaiFlags.CANFD_ALT_BUTTONS:
# TODO: resume for alt button cars
pass
else:
for _ in range(20):
can_sends.append(hyundaicanfd.create_buttons(self.packer, self.CP, self.CAN, CS.buttons_counter+1, Buttons.RES_ACCEL))
self.last_button_frame = self.frame
for _ in range(20):
can_sends.append(hyundaicanfd.create_buttons(self.packer, self.CP, self.CAN, CS.buttons_counter+1, Buttons.RES_ACCEL))
self.last_button_frame = self.frame

return can_sends
11 changes: 8 additions & 3 deletions opendbc/car/hyundai/hyundaicanfd.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,14 +73,19 @@ def create_suppress_lfa(packer, CAN, hda2_lfa_block_msg, hda2_alt_steering):
return packer.make_can_msg(suppress_msg, CAN.ACAN, values)

def create_buttons(packer, CP, CAN, cnt, btn):
canfd_msg = "CRUISE_BUTTONS_ALT" if CP.flags & HyundaiFlags.CANFD_ALT_BUTTONS else \
"CRUISE_BUTTONS"
# If we discover cars use different values for this in the future, echoing back
# what's read from the car would also work.
SET_ME_2 = 6
values = {
"COUNTER": cnt,
"SET_ME_1": 1,
"CRUISE_BUTTONS": btn,
}
"SET_ME_1": 1,
} | {"SET_ME_2": SET_ME_2} if CP.flags & HyundaiFlags.CANFD_ALT_BUTTONS else {}

bus = CAN.ECAN if CP.flags & HyundaiFlags.CANFD_HDA2 else CAN.CAM
return packer.make_can_msg("CRUISE_BUTTONS", bus, values)
return packer.make_can_msg(canfd_msg, bus, values)

def create_acc_cancel(packer, CP, CAN, cruise_info_copy):
# TODO: why do we copy different values here?
Expand Down

0 comments on commit 300e557

Please sign in to comment.