|
|
|
@ -11,7 +11,6 @@ from openpilot.selfdrive.car.interfaces import CarInterfaceBase |
|
|
|
|
from openpilot.selfdrive.car.disable_ecu import disable_ecu |
|
|
|
|
|
|
|
|
|
Ecu = car.CarParams.Ecu |
|
|
|
|
SafetyModel = car.CarParams.SafetyModel |
|
|
|
|
ButtonType = car.CarState.ButtonEvent.Type |
|
|
|
|
EventName = car.CarEvent.EventName |
|
|
|
|
ENABLE_BUTTONS = (Buttons.RES_ACCEL, Buttons.SET_DECEL, Buttons.CANCEL) |
|
|
|
@ -19,17 +18,6 @@ BUTTONS_DICT = {Buttons.RES_ACCEL: ButtonType.accelCruise, Buttons.SET_DECEL: Bu |
|
|
|
|
Buttons.GAP_DIST: ButtonType.gapAdjustCruise, Buttons.CANCEL: ButtonType.cancel} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def set_safety_config_hyundai(candidate, CAN, can_fd=False): |
|
|
|
|
platform = SafetyModel.hyundaiCanfd if can_fd else \ |
|
|
|
|
SafetyModel.hyundaiLegacy if candidate in LEGACY_SAFETY_MODE_CAR else \ |
|
|
|
|
SafetyModel.hyundai |
|
|
|
|
cfgs = [get_safety_config(platform), ] |
|
|
|
|
if CAN.ECAN >= 4: |
|
|
|
|
cfgs.insert(0, get_safety_config(SafetyModel.noOutput)) |
|
|
|
|
|
|
|
|
|
return cfgs |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class CarInterface(CarInterfaceBase): |
|
|
|
|
@staticmethod |
|
|
|
|
def _get_params(ret, candidate, fingerprint, car_fw, experimental_long, docs): |
|
|
|
@ -54,6 +42,7 @@ class CarInterface(CarInterfaceBase): |
|
|
|
|
|
|
|
|
|
# detect HDA2 with ADAS Driving ECU |
|
|
|
|
if hda2: |
|
|
|
|
ret.flags |= HyundaiFlags.CANFD_HDA2.value |
|
|
|
|
if 0x110 in fingerprint[CAN.CAM]: |
|
|
|
|
ret.flags |= HyundaiFlags.CANFD_HDA2_ALT_STEERING.value |
|
|
|
|
else: |
|
|
|
@ -303,20 +292,30 @@ class CarInterface(CarInterfaceBase): |
|
|
|
|
ret.enableBsm = 0x58b in fingerprint[0] |
|
|
|
|
|
|
|
|
|
# *** panda safety config *** |
|
|
|
|
ret.safetyConfigs = set_safety_config_hyundai(candidate, CAN, can_fd=(candidate in CANFD_CAR)) |
|
|
|
|
|
|
|
|
|
if hda2: |
|
|
|
|
ret.flags |= HyundaiFlags.CANFD_HDA2.value |
|
|
|
|
ret.safetyConfigs[-1].safetyParam |= Panda.FLAG_HYUNDAI_CANFD_HDA2 |
|
|
|
|
|
|
|
|
|
if candidate in CANFD_CAR: |
|
|
|
|
if hda2 and ret.flags & HyundaiFlags.CANFD_HDA2_ALT_STEERING: |
|
|
|
|
ret.safetyConfigs[-1].safetyParam |= Panda.FLAG_HYUNDAI_CANFD_HDA2_ALT_STEERING |
|
|
|
|
cfgs = [get_safety_config(car.CarParams.SafetyModel.hyundaiCanfd), ] |
|
|
|
|
if CAN.ECAN >= 4: |
|
|
|
|
cfgs.insert(0, get_safety_config(car.CarParams.SafetyModel.noOutput)) |
|
|
|
|
ret.safetyConfigs = cfgs |
|
|
|
|
|
|
|
|
|
if ret.flags & HyundaiFlags.CANFD_HDA2: |
|
|
|
|
ret.safetyConfigs[-1].safetyParam |= Panda.FLAG_HYUNDAI_CANFD_HDA2 |
|
|
|
|
if ret.flags & HyundaiFlags.CANFD_HDA2_ALT_STEERING: |
|
|
|
|
ret.safetyConfigs[-1].safetyParam |= Panda.FLAG_HYUNDAI_CANFD_HDA2_ALT_STEERING |
|
|
|
|
if ret.flags & HyundaiFlags.CANFD_ALT_BUTTONS: |
|
|
|
|
ret.safetyConfigs[-1].safetyParam |= Panda.FLAG_HYUNDAI_CANFD_ALT_BUTTONS |
|
|
|
|
if ret.flags & HyundaiFlags.CANFD_CAMERA_SCC: |
|
|
|
|
ret.safetyConfigs[-1].safetyParam |= Panda.FLAG_HYUNDAI_CAMERA_SCC |
|
|
|
|
else: |
|
|
|
|
if candidate in LEGACY_SAFETY_MODE_CAR: |
|
|
|
|
# these cars require a special panda safety mode due to missing counters and checksums in the messages |
|
|
|
|
ret.safetyConfigs = [get_safety_config(car.CarParams.SafetyModel.hyundaiLegacy)] |
|
|
|
|
else: |
|
|
|
|
ret.safetyConfigs = [get_safety_config(car.CarParams.SafetyModel.hyundai, 0)] |
|
|
|
|
|
|
|
|
|
if candidate in CAMERA_SCC_CAR: |
|
|
|
|
ret.safetyConfigs[0].safetyParam |= Panda.FLAG_HYUNDAI_CAMERA_SCC |
|
|
|
|
|
|
|
|
|
if ret.flags & HyundaiFlags.CANFD_CAMERA_SCC or candidate in CAMERA_SCC_CAR: |
|
|
|
|
ret.safetyConfigs[-1].safetyParam |= Panda.FLAG_HYUNDAI_CAMERA_SCC |
|
|
|
|
if ret.openpilotLongitudinalControl: |
|
|
|
|
ret.safetyConfigs[-1].safetyParam |= Panda.FLAG_HYUNDAI_LONG |
|
|
|
|
if ret.flags & HyundaiFlags.HYBRID: |
|
|
|
|