mirror of
https://github.com/sunnypilot/sunnypilot.git
synced 2026-08-05 22:05:42 +08:00
hda2 only
This commit is contained in:
+1
-1
Submodule panda updated: d80734ba27...7f77ee90ce
@@ -106,10 +106,10 @@ class CarController:
|
||||
if self.angle_limit_counter >= MAX_ANGLE_FRAMES + MAX_ANGLE_CONSECUTIVE_FRAMES:
|
||||
self.angle_limit_counter = 0
|
||||
|
||||
can_canfd = self.CP.flags & HyundaiFlags.CAN_CANFD
|
||||
can_canfd_hda2 = self.CP.flags & HyundaiFlags.CAN_CANFD_HDA2
|
||||
|
||||
# CAN-FD platforms
|
||||
if self.CP.carFingerprint in CANFD_CAR or can_canfd:
|
||||
if self.CP.carFingerprint in CANFD_CAR or can_canfd_hda2:
|
||||
hda2 = self.CP.flags & HyundaiFlags.CANFD_HDA2
|
||||
hda2_long = hda2 and self.CP.openpilotLongitudinalControl
|
||||
|
||||
@@ -117,11 +117,11 @@ class CarController:
|
||||
can_sends.extend(hyundaicanfd.create_steering_messages(self.packer, self.CP, CC.enabled, lat_active, apply_steer))
|
||||
|
||||
# disable LFA on HDA2
|
||||
if self.frame % 5 == 0 and (hda2 or can_canfd):
|
||||
if self.frame % 5 == 0 and (hda2 or can_canfd_hda2):
|
||||
can_sends.append(hyundaicanfd.create_cam_0x2a4(self.packer, CS.cam_0x2a4))
|
||||
|
||||
# LFA and HDA icons
|
||||
if self.frame % 5 == 0 and (not hda2 or hda2_long) and not can_canfd:
|
||||
if self.frame % 5 == 0 and (not hda2 or hda2_long) and not can_canfd_hda2:
|
||||
can_sends.append(hyundaicanfd.create_lfahda_cluster(self.packer, self.CP, CC.enabled))
|
||||
|
||||
# blinkers
|
||||
@@ -137,7 +137,7 @@ class CarController:
|
||||
self.accel_last = accel
|
||||
else:
|
||||
# button presses
|
||||
if can_canfd:
|
||||
if can_canfd_hda2:
|
||||
if CC.cruiseControl.cancel:
|
||||
can_sends.append(hyundaican.create_clu11(self.packer, self.frame, CS.clu11, Buttons.CANCEL, self.CP))
|
||||
elif CC.cruiseControl.resume:
|
||||
|
||||
@@ -99,7 +99,7 @@ class CarState(CarStateBase):
|
||||
ret.cruiseState.enabled = cp.vl["TCS13"]["ACC_REQ"] == 1
|
||||
ret.cruiseState.standstill = False
|
||||
else:
|
||||
scc_bus = "SCC12" if self.CP.flags & HyundaiFlags.CAN_CANFD.value else "SCC11"
|
||||
scc_bus = "SCC12" if self.CP.flags & HyundaiFlags.CAN_CANFD_HDA2.value else "SCC11"
|
||||
ret.cruiseState.available = cp_cruise.vl[scc_bus]["MainMode_ACC"] == 1
|
||||
ret.cruiseState.enabled = cp_cruise.vl["SCC12"]["ACCMode"] != 0
|
||||
ret.cruiseState.standstill = cp_cruise.vl[scc_bus]["SCCInfoDisplay"] == 4.
|
||||
@@ -135,7 +135,7 @@ class CarState(CarStateBase):
|
||||
|
||||
ret.gearShifter = self.parse_gear_shifter(self.shifter_values.get(gear))
|
||||
|
||||
if not self.CP.openpilotLongitudinalControl and not (self.CP.flags & HyundaiFlags.CAN_CANFD.value):
|
||||
if not self.CP.openpilotLongitudinalControl and not (self.CP.flags & HyundaiFlags.CAN_CANFD_HDA2.value):
|
||||
aeb_src = "FCA11" if self.CP.flags & HyundaiFlags.USE_FCA.value else "SCC12"
|
||||
aeb_sig = "FCA_CmdAct" if self.CP.flags & HyundaiFlags.USE_FCA.value else "AEB_CmdAct"
|
||||
aeb_warning = cp_cruise.vl[aeb_src]["CF_VSM_Warn"] != 0
|
||||
@@ -150,7 +150,7 @@ class CarState(CarStateBase):
|
||||
# save the entire LKAS11 and CLU11
|
||||
self.lkas11 = copy.copy(cp_cam.vl["LKAS11"])
|
||||
self.clu11 = copy.copy(cp.vl["CLU11"])
|
||||
if self.CP.flags & HyundaiFlags.CAN_CANFD:
|
||||
if self.CP.flags & HyundaiFlags.CAN_CANFD_HDA2:
|
||||
self.cam_0x2a4 = copy.copy(cp_cam.vl["CAM_0x2a4"])
|
||||
self.steer_state = cp.vl["MDPS12"]["CF_Mdps_ToiActive"] # 0 NOT ACTIVE, 1 ACTIVE
|
||||
self.prev_cruise_buttons = self.cruise_buttons[-1]
|
||||
@@ -305,10 +305,10 @@ class CarState(CarStateBase):
|
||||
("WHL_SPD11", 50),
|
||||
("SAS11", 100),
|
||||
]
|
||||
freq_mdps12 = 100 if CP.flags & HyundaiFlags.CAN_CANFD.value else 50
|
||||
freq_mdps12 = 100 if CP.flags & HyundaiFlags.CAN_CANFD_HDA2.value else 50
|
||||
checks.append(("MDPS12", freq_mdps12))
|
||||
|
||||
if not CP.openpilotLongitudinalControl and CP.carFingerprint not in CAMERA_SCC_CAR and not (CP.flags & HyundaiFlags.CAN_CANFD.value):
|
||||
if not CP.openpilotLongitudinalControl and CP.carFingerprint not in CAMERA_SCC_CAR and not (CP.flags & HyundaiFlags.CAN_CANFD_HDA2.value):
|
||||
signals += [
|
||||
("MainMode_ACC", "SCC11"),
|
||||
("VSetDis", "SCC11"),
|
||||
@@ -334,7 +334,7 @@ class CarState(CarStateBase):
|
||||
("CF_VSM_Warn", "SCC12"),
|
||||
("CF_VSM_DecCmdAct", "SCC12"),
|
||||
]
|
||||
elif CP.flags & HyundaiFlags.CAN_CANFD.value:
|
||||
elif CP.flags & HyundaiFlags.CAN_CANFD_HDA2.value:
|
||||
signals += [
|
||||
("MainMode_ACC", "SCC12"),
|
||||
("VSetDis", "SCC12"),
|
||||
@@ -351,7 +351,7 @@ class CarState(CarStateBase):
|
||||
("CF_Lca_IndLeft", "LCA11"),
|
||||
("CF_Lca_IndRight", "LCA11"),
|
||||
]
|
||||
freq_lca11 = 20 if CP.flags & HyundaiFlags.CAN_CANFD.value else 50
|
||||
freq_lca11 = 20 if CP.flags & HyundaiFlags.CAN_CANFD_HDA2.value else 50
|
||||
checks.append(("LCA11", freq_lca11))
|
||||
|
||||
if CP.carFingerprint in (HYBRID_CAR | EV_CAR):
|
||||
@@ -382,7 +382,7 @@ class CarState(CarStateBase):
|
||||
signals.append(("CF_Lvr_Gear", "LVR12"))
|
||||
checks.append(("LVR12", 100))
|
||||
|
||||
bus = 5 if CP.flags & HyundaiFlags.CAN_CANFD.value else 0
|
||||
bus = 5 if CP.flags & HyundaiFlags.CAN_CANFD_HDA2.value else 0
|
||||
return CANParser(DBC[CP.carFingerprint]["pt"], signals, checks, bus)
|
||||
|
||||
@staticmethod
|
||||
@@ -393,7 +393,7 @@ class CarState(CarStateBase):
|
||||
signals = []
|
||||
checks = []
|
||||
|
||||
if not (CP.flags & HyundaiFlags.CAN_CANFD):
|
||||
if not (CP.flags & HyundaiFlags.CAN_CANFD_HDA2):
|
||||
signals += [
|
||||
# signal_name, signal_address
|
||||
("CF_Lkas_LdwsActivemode", "LKAS11"),
|
||||
@@ -443,11 +443,11 @@ class CarState(CarStateBase):
|
||||
("CF_VSM_DecCmdAct", "SCC12"),
|
||||
]
|
||||
|
||||
if CP.flags & HyundaiFlags.CAN_CANFD:
|
||||
if CP.flags & HyundaiFlags.CAN_CANFD_HDA2:
|
||||
signals += [(f"BYTE{i}", "CAM_0x2a4") for i in range(3, 24)]
|
||||
checks += [("CAM_0x2a4", 20)]
|
||||
|
||||
bus = 6 if CP.flags & HyundaiFlags.CAN_CANFD else 2
|
||||
bus = 6 if CP.flags & HyundaiFlags.CAN_CANFD_HDA2 else 2
|
||||
return CANParser(DBC[CP.carFingerprint]["pt"], signals, checks, bus)
|
||||
|
||||
@staticmethod
|
||||
|
||||
@@ -83,7 +83,7 @@ def create_clu11(packer, frame, clu11, button, CP):
|
||||
values["CF_Clu_CruiseSwState"] = button
|
||||
values["CF_Clu_AliveCnt1"] = frame % 0x10
|
||||
# send buttons to camera on camera-scc based cars
|
||||
bus = 2 if CP.carFingerprint in CAMERA_SCC_CAR else 5 if CP.flags & HyundaiFlags.CAN_CANFD else 0
|
||||
bus = 2 if CP.carFingerprint in CAMERA_SCC_CAR else 5 if CP.flags & HyundaiFlags.CAN_CANFD_HDA2 else 0
|
||||
return packer.make_can_msg("CLU11", bus, values)
|
||||
|
||||
|
||||
|
||||
@@ -24,7 +24,7 @@ def create_steering_messages(packer, CP, enabled, lat_active, apply_steer):
|
||||
"NEW_SIGNAL_2": 0,
|
||||
}
|
||||
|
||||
if CP.flags & HyundaiFlags.CANFD_HDA2 or CP.flags & HyundaiFlags.CAN_CANFD:
|
||||
if CP.flags & HyundaiFlags.CANFD_HDA2 or CP.flags & HyundaiFlags.CAN_CANFD_HDA2:
|
||||
if CP.openpilotLongitudinalControl:
|
||||
ret.append(packer.make_can_msg("LFA", 5, values))
|
||||
ret.append(packer.make_can_msg("LKAS", 4, values))
|
||||
|
||||
@@ -47,7 +47,7 @@ class CarInterface(CarInterfaceBase):
|
||||
else:
|
||||
# detect platforms with HKG CAN and CAN-FD definitions
|
||||
if 0x50 in fingerprint[6] and 0x420 in fingerprint[5]:
|
||||
ret.flags |= HyundaiFlags.CAN_CANFD.value
|
||||
ret.flags |= HyundaiFlags.CAN_CANFD_HDA2.value
|
||||
|
||||
# Send LFA message on cars with HDA
|
||||
if 0x485 in fingerprint[2]:
|
||||
@@ -239,7 +239,7 @@ class CarInterface(CarInterfaceBase):
|
||||
else:
|
||||
ret.longitudinalTuning.kpV = [0.5]
|
||||
ret.longitudinalTuning.kiV = [0.0]
|
||||
ret.experimentalLongitudinalAvailable = candidate not in (LEGACY_SAFETY_MODE_CAR | CAMERA_SCC_CAR) and not (ret.flags & HyundaiFlags.CAN_CANFD)
|
||||
ret.experimentalLongitudinalAvailable = candidate not in (LEGACY_SAFETY_MODE_CAR | CAMERA_SCC_CAR) and not (ret.flags & HyundaiFlags.CAN_CANFD_HDA2)
|
||||
ret.openpilotLongitudinalControl = experimental_long and ret.experimentalLongitudinalAvailable
|
||||
ret.pcmCruise = not ret.openpilotLongitudinalControl
|
||||
|
||||
@@ -254,7 +254,7 @@ class CarInterface(CarInterfaceBase):
|
||||
if candidate in CANFD_CAR:
|
||||
ret.enableBsm = 0x1e5 in fingerprint[get_e_can_bus(ret)]
|
||||
else:
|
||||
bus = 5 if ret.flags & HyundaiFlags.CAN_CANFD else 0
|
||||
bus = 5 if ret.flags & HyundaiFlags.CAN_CANFD_HDA2 else 0
|
||||
ret.enableBsm = 0x58b in fingerprint[bus]
|
||||
|
||||
# *** panda safety config ***
|
||||
@@ -272,10 +272,10 @@ class CarInterface(CarInterfaceBase):
|
||||
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)]
|
||||
elif ret.flags & HyundaiFlags.CAN_CANFD:
|
||||
elif ret.flags & HyundaiFlags.CAN_CANFD_HDA2:
|
||||
ret.safetyConfigs = [get_safety_config(car.CarParams.SafetyModel.noOutput),
|
||||
get_safety_config(car.CarParams.SafetyModel.hyundai)]
|
||||
ret.safetyConfigs[1].safetyParam |= Panda.FLAG_HYUNDAI_CAN_CANFD
|
||||
ret.safetyConfigs[1].safetyParam |= Panda.FLAG_HYUNDAI_CAN_CANFD_HDA2
|
||||
else:
|
||||
ret.safetyConfigs = [get_safety_config(car.CarParams.SafetyModel.hyundai, 0)]
|
||||
|
||||
|
||||
@@ -62,7 +62,7 @@ class HyundaiFlags(IntFlag):
|
||||
CANFD_ALT_GEARS_2 = 64
|
||||
SEND_LFA = 128
|
||||
USE_FCA = 256
|
||||
CAN_CANFD = 512
|
||||
CAN_CANFD_HDA2 = 512
|
||||
|
||||
|
||||
class CAR:
|
||||
|
||||
Reference in New Issue
Block a user