Skip to content

Commit

Permalink
Hyundai CAN-FD Longitudinal: Enable for radar-based SCC platforms (no…
Browse files Browse the repository at this point in the history
…n-HDA2)
  • Loading branch information
sunnyhaibin committed Sep 25, 2024
1 parent 521d8ff commit 4844ba2
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 11 deletions.
4 changes: 3 additions & 1 deletion opendbc/car/hyundai/carcontroller.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ def update(self, CC, CS, now_nanos):
# tester present - w/ no response (keeps relevant ECU disabled)
if self.frame % 100 == 0 and not (self.CP.flags & HyundaiFlags.CANFD_CAMERA_SCC.value) and self.CP.openpilotLongitudinalControl:
# for longitudinal control, either radar or ADAS driving ECU
addr, bus = 0x7d0, 0
addr, bus = 0x7d0, self.CAN.ECAN if self.CP.carFingerprint in CANFD_CAR else 0
if self.CP.flags & HyundaiFlags.CANFD_HDA2.value:
addr, bus = 0x730, self.CAN.ECAN
can_sends.append(make_tester_present_msg(addr, bus, suppress_response=True))
Expand Down Expand Up @@ -126,6 +126,8 @@ def update(self, CC, CS, now_nanos):
if self.CP.openpilotLongitudinalControl:
if hda2:
can_sends.extend(hyundaicanfd.create_adrv_messages(self.packer, self.CAN, self.frame))
else:
can_sends.extend(hyundaicanfd.create_fca_warning_light(self.packer, self.CAN, self.frame))
if self.frame % 2 == 0:
can_sends.append(hyundaicanfd.create_acc_control(self.packer, self.CAN, CC.enabled, self.accel_last, accel, stopping, CC.cruiseControl.override,
set_speed_in_units, hud_control))
Expand Down
23 changes: 15 additions & 8 deletions opendbc/car/hyundai/hyundaicanfd.py
Original file line number Diff line number Diff line change
Expand Up @@ -172,16 +172,9 @@ def create_spas_messages(packer, CAN, frame, left_blink, right_blink):
return ret


def create_adrv_messages(packer, CAN, frame):
# messages needed to car happy after disabling
# the ADAS Driving ECU to do longitudinal control

def create_fca_warning_light(packer, CAN, frame):
ret = []

values = {
}
ret.append(packer.make_can_msg("ADRV_0x51", CAN.ACAN, values))

if frame % 2 == 0:
values = {
'AEB_SETTING': 0x1, # show AEB disabled icon
Expand All @@ -191,6 +184,20 @@ def create_adrv_messages(packer, CAN, frame):
'SET_ME_9': 0x9,
}
ret.append(packer.make_can_msg("ADRV_0x160", CAN.ECAN, values))
return ret


def create_adrv_messages(packer, CAN, frame):
# messages needed to car happy after disabling
# the ADAS Driving ECU to do longitudinal control

ret = []

values = {
}
ret.append(packer.make_can_msg("ADRV_0x51", CAN.ACAN, values))

ret.extend(create_fca_warning_light(packer, CAN, frame))

if frame % 5 == 0:
values = {
Expand Down
4 changes: 2 additions & 2 deletions opendbc/car/hyundai/interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ def _get_params(ret: structs.CarParams, candidate, fingerprint, car_fw, experime

# *** longitudinal control ***
if candidate in CANFD_CAR:
ret.experimentalLongitudinalAvailable = candidate not in (CANFD_UNSUPPORTED_LONGITUDINAL_CAR | CANFD_RADAR_SCC_CAR)
ret.experimentalLongitudinalAvailable = candidate not in CANFD_UNSUPPORTED_LONGITUDINAL_CAR
else:
ret.experimentalLongitudinalAvailable = candidate not in (UNSUPPORTED_LONGITUDINAL_CAR | CAMERA_SCC_CAR)
ret.openpilotLongitudinalControl = experimental_long and ret.experimentalLongitudinalAvailable
Expand Down Expand Up @@ -137,7 +137,7 @@ def _get_params(ret: structs.CarParams, candidate, fingerprint, car_fw, experime
@staticmethod
def init(CP, can_recv, can_send):
if CP.openpilotLongitudinalControl and not (CP.flags & HyundaiFlags.CANFD_CAMERA_SCC.value):
addr, bus = 0x7d0, 0
addr, bus = 0x7d0, CanBus(CP).ECAN if CP.carFingerprint in CANFD_CAR else 0
if CP.flags & HyundaiFlags.CANFD_HDA2.value:
addr, bus = 0x730, CanBus(CP).ECAN
disable_ecu(can_recv, can_send, bus=bus, addr=addr, com_cont_req=b'\x28\x83\x01')
Expand Down

0 comments on commit 4844ba2

Please sign in to comment.