Skip to content

Commit

Permalink
Hyundai CAN-FD: Use ACCELERATOR for EV gear shifter positions (comm…
Browse files Browse the repository at this point in the history
…aai#1280)

* Hyundai CAN-FD: Use `ACCELERATOR` for EV gear shifter positions

* revert

* duplicated message checks
  • Loading branch information
sunnyhaibin authored Sep 26, 2024
1 parent 521d8ff commit 8a56957
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions opendbc/car/hyundai/carstate.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@ def __init__(self, CP):
self.cruise_buttons: deque = deque([Buttons.NONE] * PREV_BUTTON_SAMPLES, maxlen=PREV_BUTTON_SAMPLES)
self.main_buttons: deque = deque([Buttons.NONE] * PREV_BUTTON_SAMPLES, maxlen=PREV_BUTTON_SAMPLES)

self.gear_msg_canfd = "GEAR_ALT" if CP.flags & HyundaiFlags.CANFD_ALT_GEARS else \
self.gear_msg_canfd = "ACCELERATOR" if CP.flags & HyundaiFlags.EV else \
"GEAR_ALT" if CP.flags & HyundaiFlags.CANFD_ALT_GEARS else \
"GEAR_ALT_2" if CP.flags & HyundaiFlags.CANFD_ALT_GEARS_2 else \
"GEAR_SHIFTER"
if CP.carFingerprint in CANFD_CAR:
Expand Down Expand Up @@ -333,8 +334,6 @@ def get_cam_can_parser(CP):

def get_can_parser_canfd(self, CP):
messages = [
(self.gear_msg_canfd, 100),
(self.accelerator_msg_canfd, 100),
("WHEEL_SPEEDS", 100),
("STEERING_SENSORS", 100),
("MDPS", 100),
Expand All @@ -346,8 +345,14 @@ def get_can_parser_canfd(self, CP):

if CP.flags & HyundaiFlags.EV:
messages += [
("ACCELERATOR", 100),
("MANUAL_SPEED_LIMIT_ASSIST", 10),
]
else:
messages += [
(self.gear_msg_canfd, 100),
(self.accelerator_msg_canfd, 100),
]

if not (CP.flags & HyundaiFlags.CANFD_ALT_BUTTONS):
messages += [
Expand Down

0 comments on commit 8a56957

Please sign in to comment.