From 92e9ae87ae12198d337fe5151c4f3b638cbbc3c9 Mon Sep 17 00:00:00 2001 From: Jason Wen Date: Thu, 26 Sep 2024 18:27:57 -0400 Subject: [PATCH 1/2] update panda --- board/safety/safety_hyundai.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/board/safety/safety_hyundai.h b/board/safety/safety_hyundai.h index 3e9d23216c..af42b535d0 100644 --- a/board/safety/safety_hyundai.h +++ b/board/safety/safety_hyundai.h @@ -29,6 +29,7 @@ const LongitudinalLimits HYUNDAI_LONG_LIMITS = { static const CanMsg HYUNDAI_TX_MSGS[] = { {0x340, 0, 8}, // LKAS11 Bus 0 {0x4F1, 0, 4}, // CLU11 Bus 0 + {0x484, 0, 8}, // HDA11_MFC Bus 0 {0x485, 0, 4}, // LFAHDA_MFC Bus 0 }; @@ -250,7 +251,7 @@ static int hyundai_fwd_hook(int bus_num, int addr) { if (bus_num == 0) { bus_fwd = 2; } - if ((bus_num == 2) && (addr != 0x340) && (addr != 0x485)) { + if ((bus_num == 2) && (addr != 0x340) && (addr != 0x485) && ((addr != 0x484) && hyundai_camera_scc && !hyundai_longitudinal)) { bus_fwd = 0; } From 929c4581edd85c7a23e640af6cc6c5cb16ccf845 Mon Sep 17 00:00:00 2001 From: Jason Wen Date: Thu, 26 Sep 2024 19:11:28 -0400 Subject: [PATCH 2/2] only camera scc, update unit test --- board/safety/safety_hyundai.h | 14 +++++++++++--- tests/safety/test_hyundai.py | 3 +++ 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/board/safety/safety_hyundai.h b/board/safety/safety_hyundai.h index af42b535d0..5881613480 100644 --- a/board/safety/safety_hyundai.h +++ b/board/safety/safety_hyundai.h @@ -29,7 +29,6 @@ const LongitudinalLimits HYUNDAI_LONG_LIMITS = { static const CanMsg HYUNDAI_TX_MSGS[] = { {0x340, 0, 8}, // LKAS11 Bus 0 {0x4F1, 0, 4}, // CLU11 Bus 0 - {0x484, 0, 8}, // HDA11_MFC Bus 0 {0x485, 0, 4}, // LFAHDA_MFC Bus 0 }; @@ -251,8 +250,16 @@ static int hyundai_fwd_hook(int bus_num, int addr) { if (bus_num == 0) { bus_fwd = 2; } - if ((bus_num == 2) && (addr != 0x340) && (addr != 0x485) && ((addr != 0x484) && hyundai_camera_scc && !hyundai_longitudinal)) { - bus_fwd = 0; + + if (bus_num == 2) { + bool is_lkas_11 = (addr == 0x340); + bool is_hda11_mfc = (addr == 0x484) && hyundai_camera_scc && !hyundai_longitudinal; + bool is_lfahda_mfc = (addr == 0x485); + + bool block_msg = is_lkas_11 || is_hda11_mfc || is_lfahda_mfc; + if (!block_msg) { + bus_fwd = 0; + } } return bus_fwd; @@ -276,6 +283,7 @@ static safety_config hyundai_init(uint16_t param) { static const CanMsg HYUNDAI_CAMERA_SCC_TX_MSGS[] = { {0x340, 0, 8}, // LKAS11 Bus 0 {0x4F1, 2, 4}, // CLU11 Bus 2 + {0x484, 0, 8}, // HDA11_MFC Bus 0 {0x485, 0, 4}, // LFAHDA_MFC Bus 0 }; diff --git a/tests/safety/test_hyundai.py b/tests/safety/test_hyundai.py index 1bff99fa75..20b38e0ace 100755 --- a/tests/safety/test_hyundai.py +++ b/tests/safety/test_hyundai.py @@ -129,6 +129,9 @@ class TestHyundaiSafetyCameraSCC(TestHyundaiSafety): BUTTONS_TX_BUS = 2 # tx on 2, rx on 0 SCC_BUS = 2 # rx on 2 + TX_MSGS = [[0x340, 0], [0x4F1, 0], [0x484, 0], [0x485, 0]] + FWD_BLACKLISTED_ADDRS = {2: [0x340, 0x484, 0x485]} + def setUp(self): self.packer = CANPackerPanda("hyundai_kia_generic") self.safety = libpanda_py.libpanda