From 30322aee1c17710205d0ecb0137557799cf2470c Mon Sep 17 00:00:00 2001 From: Jason Wen Date: Sat, 26 Aug 2023 17:55:52 -0400 Subject: [PATCH] cleanup --- selfdrive/car/hyundai/carcontroller.py | 7 ++++--- selfdrive/car/hyundai/carstate.py | 13 +++++++------ 2 files changed, 11 insertions(+), 9 deletions(-) diff --git a/selfdrive/car/hyundai/carcontroller.py b/selfdrive/car/hyundai/carcontroller.py index 9c8915b65b..9cacbe27de 100644 --- a/selfdrive/car/hyundai/carcontroller.py +++ b/selfdrive/car/hyundai/carcontroller.py @@ -113,10 +113,11 @@ class CarController: # disable LFA on HDA2 if self.frame % 5 == 0 and hda2: - if not hda2_alt_steering: - can_sends.append(hyundaicanfd.create_cam_0x2a4(self.packer, self.CAN, CS.cam_0x2a4)) - elif hda2_alt_steering: + # TODO: consolidate both messages, they have similar definitions + if hda2_alt_steering: can_sends.append(hyundaicanfd.create_cam_0x362(self.packer, self.CAN, CS.cam_0x362)) + else: + can_sends.append(hyundaicanfd.create_cam_0x2a4(self.packer, self.CAN, CS.cam_0x2a4)) # LFA and HDA icons if self.frame % 5 == 0 and (not hda2 or hda2_long): diff --git a/selfdrive/car/hyundai/carstate.py b/selfdrive/car/hyundai/carstate.py index a4f0acd283..eb542cd30a 100644 --- a/selfdrive/car/hyundai/carstate.py +++ b/selfdrive/car/hyundai/carstate.py @@ -228,10 +228,12 @@ class CarState(CarStateBase): self.buttons_counter = cp.vl[self.cruise_btns_msg_canfd]["COUNTER"] ret.accFaulted = cp.vl["TCS"]["ACCEnable"] != 0 # 0 ACC CONTROL ENABLED, 1-3 ACC CONTROL DISABLED + # TODO: consolidate both messages, they have similar definitions if self.CP.flags & HyundaiFlags.CANFD_HDA2 and not self.CP.flags & HyundaiFlags.CANFD_HDA2_ALT_STEERING: - self.cam_0x2a4 = copy.copy(cp_cam.vl["CAM_0x2a4"]) - if self.CP.flags & HyundaiFlags.CANFD_HDA2 and self.CP.flags & HyundaiFlags.CANFD_HDA2_ALT_STEERING: - self.cam_0x362 = copy.copy(cp_cam.vl["CAM_0x362"]) + if self.CP.flags & HyundaiFlags.CANFD_HDA2_ALT_STEERING: + self.cam_0x362 = copy.copy(cp_cam.vl["CAM_0x362"]) + else: + self.cam_0x2a4 = copy.copy(cp_cam.vl["CAM_0x2a4"]) return ret @@ -334,9 +336,8 @@ class CarState(CarStateBase): def get_cam_can_parser_canfd(CP): messages = [] if CP.flags & HyundaiFlags.CANFD_HDA2 and not CP.flags & HyundaiFlags.CANFD_HDA2_ALT_STEERING: - messages += [("CAM_0x2a4", 20)] - elif CP.flags & HyundaiFlags.CANFD_HDA2 and CP.flags & HyundaiFlags.CANFD_HDA2_ALT_STEERING: - messages += [("CAM_0x362", 20)] + block_lfa_msg = "CAM_0x362" if CP.flags & HyundaiFlags.CANFD_HDA2_ALT_STEERING else "CAM_0x2a4" + messages += [(block_lfa_msg, 20)] elif CP.flags & HyundaiFlags.CANFD_CAMERA_SCC: messages += [ ("SCC_CONTROL", 50),