From 016111737b0894639dc120d115280f13d80804fc Mon Sep 17 00:00:00 2001 From: Jason Wen Date: Wed, 25 Sep 2024 00:51:37 -0400 Subject: [PATCH 01/10] Hyundai: Longitudinal support for CAN-based Camera SCC cars --- board/safety/safety_hyundai.h | 52 ++++++++++++++++++++++++++--------- 1 file changed, 39 insertions(+), 13 deletions(-) diff --git a/board/safety/safety_hyundai.h b/board/safety/safety_hyundai.h index 3e9d23216c..9287267f50 100644 --- a/board/safety/safety_hyundai.h +++ b/board/safety/safety_hyundai.h @@ -163,7 +163,7 @@ static void hyundai_rx_hook(const CANPacket_t *to_push) { bool stock_ecu_detected = (addr == 0x340); - // If openpilot is controlling longitudinal we need to ensure the radar is turned off + // If openpilot is controlling longitudinal we need to ensure the radar is turned off on radar SCC cars // Enforce by checking we don't see SCC12 if (hyundai_longitudinal && (addr == 0x421)) { stock_ecu_detected = true; @@ -250,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)) { - bus_fwd = 0; + + if (bus_num == 2) { + bool is_lkas11_msg = (addr == 0x340); + bool is_lfahda_mfc_msg = (addr == 0x485); + bool is_scc_msg = ((addr == 0x420) || (addr == 0x421) || (addr == 0x50A) || (addr == 0x389)) && hyundai_longitudinal && hyundai_camera_scc; + + bool block_msg = is_lkas11_msg || is_lfahda_mfc_msg || is_scc_msg; + if (!block_msg) { + bus_fwd = 0; + } } return bus_fwd; @@ -278,22 +286,40 @@ static safety_config hyundai_init(uint16_t param) { {0x485, 0, 4}, // LFAHDA_MFC Bus 0 }; + // TODO: Utilize macros for common tx checks + static const CanMsg HYUNDAI_CAMERA_SCC_LONG_TX_MSGS[] = { + {0x340, 0, 8}, // LKAS11 Bus 0 + {0x4F1, 2, 4}, // CLU11 Bus 2 + {0x485, 0, 4}, // LFAHDA_MFC Bus 0 + {0x420, 0, 8}, // SCC11 Bus 0 + {0x421, 0, 8}, // SCC12 Bus 0 + {0x50A, 0, 8}, // SCC13 Bus 0 + {0x389, 0, 8}, // SCC14 Bus 0 + {0x4A2, 0, 2}, // FRT_RADAR11 Bus 0 + }; + hyundai_common_init(param); hyundai_legacy = false; - if (hyundai_camera_scc) { - hyundai_longitudinal = false; - } - safety_config ret; if (hyundai_longitudinal) { - static RxCheck hyundai_long_rx_checks[] = { - HYUNDAI_COMMON_RX_CHECKS(false) - // Use CLU11 (buttons) to manage controls allowed instead of SCC cruise state - {.msg = {{0x4F1, 0, 4, .check_checksum = false, .max_counter = 15U, .frequency = 50U}, { 0 }, { 0 }}}, - }; + if (hyundai_camera_scc) { + static RxCheck hyundai_camera_scc_long_rx_checks[] = { + HYUNDAI_COMMON_RX_CHECKS(false) + // Use CLU11 (buttons) to manage controls allowed instead of SCC cruise state + {.msg = {{0x4F1, 2, 4, .check_checksum = false, .max_counter = 15U, .frequency = 50U}, { 0 }, { 0 }}}, + }; + + ret = BUILD_SAFETY_CFG(hyundai_camera_scc_long_rx_checks, HYUNDAI_CAMERA_SCC_LONG_TX_MSGS); + } else { + static RxCheck hyundai_long_rx_checks[] = { + HYUNDAI_COMMON_RX_CHECKS(false) + // Use CLU11 (buttons) to manage controls allowed instead of SCC cruise state + {.msg = {{0x4F1, 0, 4, .check_checksum = false, .max_counter = 15U, .frequency = 50U}, { 0 }, { 0 }}}, + }; - ret = BUILD_SAFETY_CFG(hyundai_long_rx_checks, HYUNDAI_LONG_TX_MSGS); + ret = BUILD_SAFETY_CFG(hyundai_long_rx_checks, HYUNDAI_LONG_TX_MSGS); + } } else if (hyundai_camera_scc) { static RxCheck hyundai_cam_scc_rx_checks[] = { HYUNDAI_COMMON_RX_CHECKS(false) From 4d1cf90d6e230ccd0acfc0fbde7f8b0985f294eb Mon Sep 17 00:00:00 2001 From: Jason Wen Date: Wed, 25 Sep 2024 02:14:57 -0400 Subject: [PATCH 02/10] move around --- board/safety/safety_hyundai.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/board/safety/safety_hyundai.h b/board/safety/safety_hyundai.h index 9287267f50..36e39084f5 100644 --- a/board/safety/safety_hyundai.h +++ b/board/safety/safety_hyundai.h @@ -254,9 +254,9 @@ static int hyundai_fwd_hook(int bus_num, int addr) { if (bus_num == 2) { bool is_lkas11_msg = (addr == 0x340); bool is_lfahda_mfc_msg = (addr == 0x485); - bool is_scc_msg = ((addr == 0x420) || (addr == 0x421) || (addr == 0x50A) || (addr == 0x389)) && hyundai_longitudinal && hyundai_camera_scc; + bool is_scc_msg = (addr == 0x420) || (addr == 0x421) || (addr == 0x50A) || (addr == 0x389); - bool block_msg = is_lkas11_msg || is_lfahda_mfc_msg || is_scc_msg; + bool block_msg = is_lkas11_msg || is_lfahda_mfc_msg || (is_scc_msg && hyundai_longitudinal && hyundai_camera_scc); if (!block_msg) { bus_fwd = 0; } From a26093a3d8ee24f9fd4923de8c323581af7dbc96 Mon Sep 17 00:00:00 2001 From: Jason Wen Date: Wed, 25 Sep 2024 02:15:05 -0400 Subject: [PATCH 03/10] unit tests --- tests/safety/common.py | 5 +++++ tests/safety/test_hyundai.py | 33 +++++++++++++++++++++++++++++++++ 2 files changed, 38 insertions(+) diff --git a/tests/safety/common.py b/tests/safety/common.py index 884f21a360..253d7bf0ce 100644 --- a/tests/safety/common.py +++ b/tests/safety/common.py @@ -792,6 +792,11 @@ def test_tx_hook_on_wrong_safety_mode(self): if attr.startswith('TestHonda'): # exceptions for common msgs across different hondas tx = list(filter(lambda m: m[0] not in [0x1FA, 0x30C, 0x33D, 0x33DB], tx)) + + # TODO: Temporary, should be fixed in panda firmware, safety_hyundai.h + if attr.startswith('TestHyundaiLongitudinal'): + # exceptions for common msgs across different Hyundai CAN platforms + tx = list(filter(lambda m: m[0] not in [0x420, 0x50A, 0x389, 0x4A2], tx)) all_tx.append([[m[0], m[1], attr] for m in tx]) # make sure we got all the msgs diff --git a/tests/safety/test_hyundai.py b/tests/safety/test_hyundai.py index 1bff99fa75..6ed95e4f68 100755 --- a/tests/safety/test_hyundai.py +++ b/tests/safety/test_hyundai.py @@ -212,5 +212,38 @@ def test_no_aeb_scc12(self): self.assertFalse(self._tx(self._accel_msg(0, aeb_decel=1.0))) +class TestHyundaiLongitudinalSafetyCameraSCC(HyundaiLongitudinalBase, TestHyundaiSafety): + TX_MSGS = [[0x340, 0], [0x4F1, 2], [0x485, 0], [0x420, 0], [0x421, 0], [0x50A, 0], [0x389, 0], [0x4A2, 0]] + + RELAY_MALFUNCTION_ADDRS = {0: (0x340, 0x421)} # LKAS11, SCC12 + + FWD_BLACKLISTED_ADDRS = {2: [0x340, 0x485, 0x420, 0x421, 0x50A, 0x389]} + + DISABLED_ECU_ACTUATION_MSG = (0x421, 0) + + def setUp(self): + self.packer = CANPackerPanda("hyundai_kia_generic") + self.safety = libpanda_py.libpanda + self.safety.set_safety_hooks(Panda.SAFETY_HYUNDAI, Panda.FLAG_HYUNDAI_LONG | Panda.FLAG_HYUNDAI_CAMERA_SCC) + self.safety.init_tests() + + def _accel_msg(self, accel, aeb_req=False, aeb_decel=0): + values = { + "aReqRaw": accel, + "aReqValue": accel, + "AEB_CmdAct": int(aeb_req), + "CR_VSM_DecCmd": aeb_decel, + } + return self.packer.make_can_msg_panda("SCC12", self.SCC_BUS, values) + + def test_no_aeb_scc12(self): + self.assertTrue(self._tx(self._accel_msg(0))) + self.assertFalse(self._tx(self._accel_msg(0, aeb_req=True))) + self.assertFalse(self._tx(self._accel_msg(0, aeb_decel=1.0))) + + def test_tester_present_allowed(self): + pass + + if __name__ == "__main__": unittest.main() From c43310ca1e5d3cfd4be47b572eaa58df8f67bf3a Mon Sep 17 00:00:00 2001 From: Jason Wen Date: Wed, 25 Sep 2024 02:18:50 -0400 Subject: [PATCH 04/10] cleanup --- board/safety/safety_hyundai.h | 4 ++-- tests/safety/test_hyundai.py | 7 +++---- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/board/safety/safety_hyundai.h b/board/safety/safety_hyundai.h index 36e39084f5..744198e2e7 100644 --- a/board/safety/safety_hyundai.h +++ b/board/safety/safety_hyundai.h @@ -163,9 +163,9 @@ static void hyundai_rx_hook(const CANPacket_t *to_push) { bool stock_ecu_detected = (addr == 0x340); - // If openpilot is controlling longitudinal we need to ensure the radar is turned off on radar SCC cars + // If openpilot is controlling longitudinal we need to ensure the radar is turned off // Enforce by checking we don't see SCC12 - if (hyundai_longitudinal && (addr == 0x421)) { + if (hyundai_longitudinal && !hyundai_camera_scc && (addr == 0x421)) { stock_ecu_detected = true; } generic_rx_checks(stock_ecu_detected); diff --git a/tests/safety/test_hyundai.py b/tests/safety/test_hyundai.py index 6ed95e4f68..a1dd778735 100755 --- a/tests/safety/test_hyundai.py +++ b/tests/safety/test_hyundai.py @@ -215,12 +215,8 @@ def test_no_aeb_scc12(self): class TestHyundaiLongitudinalSafetyCameraSCC(HyundaiLongitudinalBase, TestHyundaiSafety): TX_MSGS = [[0x340, 0], [0x4F1, 2], [0x485, 0], [0x420, 0], [0x421, 0], [0x50A, 0], [0x389, 0], [0x4A2, 0]] - RELAY_MALFUNCTION_ADDRS = {0: (0x340, 0x421)} # LKAS11, SCC12 - FWD_BLACKLISTED_ADDRS = {2: [0x340, 0x485, 0x420, 0x421, 0x50A, 0x389]} - DISABLED_ECU_ACTUATION_MSG = (0x421, 0) - def setUp(self): self.packer = CANPackerPanda("hyundai_kia_generic") self.safety = libpanda_py.libpanda @@ -244,6 +240,9 @@ def test_no_aeb_scc12(self): def test_tester_present_allowed(self): pass + def test_disabled_ecu_alive(self): + pass + if __name__ == "__main__": unittest.main() From 65f08cc6e6ce0d7c1e289134441387c9843a627c Mon Sep 17 00:00:00 2001 From: Jason Wen Date: Wed, 25 Sep 2024 02:32:29 -0400 Subject: [PATCH 05/10] common msgs macros --- board/safety/safety_hyundai.h | 42 ++++++++++++++++------------------- 1 file changed, 19 insertions(+), 23 deletions(-) diff --git a/board/safety/safety_hyundai.h b/board/safety/safety_hyundai.h index 744198e2e7..5712df237e 100644 --- a/board/safety/safety_hyundai.h +++ b/board/safety/safety_hyundai.h @@ -26,10 +26,23 @@ const LongitudinalLimits HYUNDAI_LONG_LIMITS = { .min_accel = -350, // 1/100 m/s2 }; +#define HYUNDAI_COMMON_TX_MSGS(scc_bus) \ + {0x340, 0, 8}, \ + {0x4F1, scc_bus, 4}, \ + {0x485, 0, 4}, \ + +#define HYUNDAI_LONG_COMMON_TX_MSGS(scc_bus) \ + {0x340, 0, 8}, \ + {0x4F1, scc_bus, 4}, \ + {0x485, 0, 4}, \ + {0x420, 0, 8}, \ + {0x421, 0, 8}, \ + {0x50A, 0, 8}, \ + {0x389, 0, 8}, \ + {0x4A2, 0, 2}, \ + static const CanMsg HYUNDAI_TX_MSGS[] = { - {0x340, 0, 8}, // LKAS11 Bus 0 - {0x4F1, 0, 4}, // CLU11 Bus 0 - {0x485, 0, 4}, // LFAHDA_MFC Bus 0 + HYUNDAI_COMMON_TX_MSGS(0) }; #define HYUNDAI_COMMON_RX_CHECKS(legacy) \ @@ -267,35 +280,18 @@ static int hyundai_fwd_hook(int bus_num, int addr) { static safety_config hyundai_init(uint16_t param) { static const CanMsg HYUNDAI_LONG_TX_MSGS[] = { - {0x340, 0, 8}, // LKAS11 Bus 0 - {0x4F1, 0, 4}, // CLU11 Bus 0 - {0x485, 0, 4}, // LFAHDA_MFC Bus 0 - {0x420, 0, 8}, // SCC11 Bus 0 - {0x421, 0, 8}, // SCC12 Bus 0 - {0x50A, 0, 8}, // SCC13 Bus 0 - {0x389, 0, 8}, // SCC14 Bus 0 - {0x4A2, 0, 2}, // FRT_RADAR11 Bus 0 + HYUNDAI_LONG_COMMON_TX_MSGS(0) {0x38D, 0, 8}, // FCA11 Bus 0 {0x483, 0, 8}, // FCA12 Bus 0 {0x7D0, 0, 8}, // radar UDS TX addr Bus 0 (for radar disable) }; static const CanMsg HYUNDAI_CAMERA_SCC_TX_MSGS[] = { - {0x340, 0, 8}, // LKAS11 Bus 0 - {0x4F1, 2, 4}, // CLU11 Bus 2 - {0x485, 0, 4}, // LFAHDA_MFC Bus 0 + HYUNDAI_COMMON_TX_MSGS(2) }; - // TODO: Utilize macros for common tx checks static const CanMsg HYUNDAI_CAMERA_SCC_LONG_TX_MSGS[] = { - {0x340, 0, 8}, // LKAS11 Bus 0 - {0x4F1, 2, 4}, // CLU11 Bus 2 - {0x485, 0, 4}, // LFAHDA_MFC Bus 0 - {0x420, 0, 8}, // SCC11 Bus 0 - {0x421, 0, 8}, // SCC12 Bus 0 - {0x50A, 0, 8}, // SCC13 Bus 0 - {0x389, 0, 8}, // SCC14 Bus 0 - {0x4A2, 0, 2}, // FRT_RADAR11 Bus 0 + HYUNDAI_LONG_COMMON_TX_MSGS(2) }; hyundai_common_init(param); From 5dadbffdbfb2965c85b0efd6450b44026acafcf9 Mon Sep 17 00:00:00 2001 From: Jason Wen Date: Wed, 25 Sep 2024 02:34:52 -0400 Subject: [PATCH 06/10] just long tx in macros --- board/safety/safety_hyundai.h | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/board/safety/safety_hyundai.h b/board/safety/safety_hyundai.h index 5712df237e..76b89e9085 100644 --- a/board/safety/safety_hyundai.h +++ b/board/safety/safety_hyundai.h @@ -26,10 +26,11 @@ const LongitudinalLimits HYUNDAI_LONG_LIMITS = { .min_accel = -350, // 1/100 m/s2 }; -#define HYUNDAI_COMMON_TX_MSGS(scc_bus) \ - {0x340, 0, 8}, \ - {0x4F1, scc_bus, 4}, \ - {0x485, 0, 4}, \ +static const CanMsg HYUNDAI_TX_MSGS[] = { + {0x340, 0, 8}, // LKAS11 Bus 0 + {0x4F1, 0, 4}, // CLU11 Bus 0 + {0x485, 0, 4}, // LFAHDA_MFC Bus 0 +}; #define HYUNDAI_LONG_COMMON_TX_MSGS(scc_bus) \ {0x340, 0, 8}, \ @@ -41,10 +42,6 @@ const LongitudinalLimits HYUNDAI_LONG_LIMITS = { {0x389, 0, 8}, \ {0x4A2, 0, 2}, \ -static const CanMsg HYUNDAI_TX_MSGS[] = { - HYUNDAI_COMMON_TX_MSGS(0) -}; - #define HYUNDAI_COMMON_RX_CHECKS(legacy) \ {.msg = {{0x260, 0, 8, .check_checksum = true, .max_counter = 3U, .frequency = 100U}, \ {0x371, 0, 8, .frequency = 100U}, { 0 }}}, \ @@ -287,7 +284,9 @@ static safety_config hyundai_init(uint16_t param) { }; static const CanMsg HYUNDAI_CAMERA_SCC_TX_MSGS[] = { - HYUNDAI_COMMON_TX_MSGS(2) + {0x340, 0, 8}, // LKAS11 Bus 0 + {0x4F1, 2, 4}, // CLU11 Bus 2 + {0x485, 0, 4}, // LFAHDA_MFC Bus 0 }; static const CanMsg HYUNDAI_CAMERA_SCC_LONG_TX_MSGS[] = { From 1a5fe39ce839805a3552933f0fa422bf0ecdd250 Mon Sep 17 00:00:00 2001 From: Jason Wen Date: Wed, 25 Sep 2024 02:41:20 -0400 Subject: [PATCH 07/10] simplify --- board/safety/safety_hyundai.h | 31 +++++++++++++++---------------- 1 file changed, 15 insertions(+), 16 deletions(-) diff --git a/board/safety/safety_hyundai.h b/board/safety/safety_hyundai.h index 76b89e9085..754cdd27ae 100644 --- a/board/safety/safety_hyundai.h +++ b/board/safety/safety_hyundai.h @@ -51,6 +51,10 @@ static const CanMsg HYUNDAI_TX_MSGS[] = { #define HYUNDAI_SCC12_ADDR_CHECK(scc_bus) \ {.msg = {{0x421, (scc_bus), 8, .check_checksum = true, .max_counter = 15U, .frequency = 50U}, { 0 }, { 0 }}}, \ +// Use CLU11 (buttons) to manage controls allowed instead of SCC cruise state +#define HYUNDAI_CLU11_ADDR_CHECK(scc_bus) \ + {.msg = {{0x4F1, (scc_bus), 4, .check_checksum = false, .max_counter = 15U, .frequency = 50U}, { 0 }, { 0 }}}, \ + static bool hyundai_legacy = false; static uint8_t hyundai_get_counter(const CANPacket_t *to_push) { @@ -298,23 +302,18 @@ static safety_config hyundai_init(uint16_t param) { safety_config ret; if (hyundai_longitudinal) { - if (hyundai_camera_scc) { - static RxCheck hyundai_camera_scc_long_rx_checks[] = { - HYUNDAI_COMMON_RX_CHECKS(false) - // Use CLU11 (buttons) to manage controls allowed instead of SCC cruise state - {.msg = {{0x4F1, 2, 4, .check_checksum = false, .max_counter = 15U, .frequency = 50U}, { 0 }, { 0 }}}, - }; - - ret = BUILD_SAFETY_CFG(hyundai_camera_scc_long_rx_checks, HYUNDAI_CAMERA_SCC_LONG_TX_MSGS); - } else { - static RxCheck hyundai_long_rx_checks[] = { - HYUNDAI_COMMON_RX_CHECKS(false) - // Use CLU11 (buttons) to manage controls allowed instead of SCC cruise state - {.msg = {{0x4F1, 0, 4, .check_checksum = false, .max_counter = 15U, .frequency = 50U}, { 0 }, { 0 }}}, - }; + static RxCheck hyundai_long_rx_checks[] = { + HYUNDAI_COMMON_RX_CHECKS(false) + HYUNDAI_CLU11_ADDR_CHECK(0) + }; - ret = BUILD_SAFETY_CFG(hyundai_long_rx_checks, HYUNDAI_LONG_TX_MSGS); - } + static RxCheck hyundai_camera_scc_long_rx_checks[] = { + HYUNDAI_COMMON_RX_CHECKS(false) + HYUNDAI_CLU11_ADDR_CHECK(2) + }; + + ret = hyundai_camera_scc ? BUILD_SAFETY_CFG(hyundai_camera_scc_long_rx_checks, HYUNDAI_CAMERA_SCC_LONG_TX_MSGS) : \ + BUILD_SAFETY_CFG(hyundai_long_rx_checks, HYUNDAI_LONG_TX_MSGS); } else if (hyundai_camera_scc) { static RxCheck hyundai_cam_scc_rx_checks[] = { HYUNDAI_COMMON_RX_CHECKS(false) From cef74708d382d29347e987604d8f8be1fbdf21d7 Mon Sep 17 00:00:00 2001 From: Jason Wen Date: Thu, 26 Sep 2024 13:15:30 -0400 Subject: [PATCH 08/10] don't check scc12 when longitudinal --- board/safety/safety_hyundai.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/board/safety/safety_hyundai.h b/board/safety/safety_hyundai.h index 754cdd27ae..1c1fea9bf2 100644 --- a/board/safety/safety_hyundai.h +++ b/board/safety/safety_hyundai.h @@ -134,7 +134,7 @@ static void hyundai_rx_hook(const CANPacket_t *to_push) { int addr = GET_ADDR(to_push); // SCC12 is on bus 2 for camera-based SCC cars, bus 0 on all others - if ((addr == 0x421) && (((bus == 0) && !hyundai_camera_scc) || ((bus == 2) && hyundai_camera_scc))) { + if ((addr == 0x421) && (((bus == 0) && !hyundai_camera_scc) || ((bus == 2) && hyundai_camera_scc && !hyundai_longitudinal))) { // 2 bits: 13-14 int cruise_engaged = (GET_BYTES(to_push, 0, 4) >> 13) & 0x3U; hyundai_common_cruise_state_check(cruise_engaged); From ac177374eea24e3f54d1fcec3ae2c26dd4eebc3d Mon Sep 17 00:00:00 2001 From: Jason Wen Date: Thu, 26 Sep 2024 13:24:26 -0400 Subject: [PATCH 09/10] wrong bus --- board/safety/safety_hyundai.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/board/safety/safety_hyundai.h b/board/safety/safety_hyundai.h index 1c1fea9bf2..d65e423546 100644 --- a/board/safety/safety_hyundai.h +++ b/board/safety/safety_hyundai.h @@ -52,8 +52,8 @@ static const CanMsg HYUNDAI_TX_MSGS[] = { {.msg = {{0x421, (scc_bus), 8, .check_checksum = true, .max_counter = 15U, .frequency = 50U}, { 0 }, { 0 }}}, \ // Use CLU11 (buttons) to manage controls allowed instead of SCC cruise state -#define HYUNDAI_CLU11_ADDR_CHECK(scc_bus) \ - {.msg = {{0x4F1, (scc_bus), 4, .check_checksum = false, .max_counter = 15U, .frequency = 50U}, { 0 }, { 0 }}}, \ +#define HYUNDAI_CLU11_ADDR_CHECK \ + {.msg = {{0x4F1, 0, 4, .check_checksum = false, .max_counter = 15U, .frequency = 50U}, { 0 }, { 0 }}}, \ static bool hyundai_legacy = false; @@ -304,12 +304,12 @@ static safety_config hyundai_init(uint16_t param) { if (hyundai_longitudinal) { static RxCheck hyundai_long_rx_checks[] = { HYUNDAI_COMMON_RX_CHECKS(false) - HYUNDAI_CLU11_ADDR_CHECK(0) + HYUNDAI_CLU11_ADDR_CHECK }; static RxCheck hyundai_camera_scc_long_rx_checks[] = { HYUNDAI_COMMON_RX_CHECKS(false) - HYUNDAI_CLU11_ADDR_CHECK(2) + HYUNDAI_CLU11_ADDR_CHECK }; ret = hyundai_camera_scc ? BUILD_SAFETY_CFG(hyundai_camera_scc_long_rx_checks, HYUNDAI_CAMERA_SCC_LONG_TX_MSGS) : \ From 8f848573240c470083e2f10119ad3fcf05c98a9f Mon Sep 17 00:00:00 2001 From: Jason Wen Date: Thu, 26 Sep 2024 23:53:05 -0400 Subject: [PATCH 10/10] simplify --- board/safety/safety_hyundai.h | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-) diff --git a/board/safety/safety_hyundai.h b/board/safety/safety_hyundai.h index d65e423546..f103fc5a14 100644 --- a/board/safety/safety_hyundai.h +++ b/board/safety/safety_hyundai.h @@ -51,10 +51,6 @@ static const CanMsg HYUNDAI_TX_MSGS[] = { #define HYUNDAI_SCC12_ADDR_CHECK(scc_bus) \ {.msg = {{0x421, (scc_bus), 8, .check_checksum = true, .max_counter = 15U, .frequency = 50U}, { 0 }, { 0 }}}, \ -// Use CLU11 (buttons) to manage controls allowed instead of SCC cruise state -#define HYUNDAI_CLU11_ADDR_CHECK \ - {.msg = {{0x4F1, 0, 4, .check_checksum = false, .max_counter = 15U, .frequency = 50U}, { 0 }, { 0 }}}, \ - static bool hyundai_legacy = false; static uint8_t hyundai_get_counter(const CANPacket_t *to_push) { @@ -304,15 +300,11 @@ static safety_config hyundai_init(uint16_t param) { if (hyundai_longitudinal) { static RxCheck hyundai_long_rx_checks[] = { HYUNDAI_COMMON_RX_CHECKS(false) - HYUNDAI_CLU11_ADDR_CHECK - }; - - static RxCheck hyundai_camera_scc_long_rx_checks[] = { - HYUNDAI_COMMON_RX_CHECKS(false) - HYUNDAI_CLU11_ADDR_CHECK + // Use CLU11 (buttons) to manage controls allowed instead of SCC cruise state + {.msg = {{0x4F1, 0, 4, .check_checksum = false, .max_counter = 15U, .frequency = 50U}, { 0 }, { 0 }}}, }; - ret = hyundai_camera_scc ? BUILD_SAFETY_CFG(hyundai_camera_scc_long_rx_checks, HYUNDAI_CAMERA_SCC_LONG_TX_MSGS) : \ + ret = hyundai_camera_scc ? BUILD_SAFETY_CFG(hyundai_long_rx_checks, HYUNDAI_CAMERA_SCC_LONG_TX_MSGS) : \ BUILD_SAFETY_CFG(hyundai_long_rx_checks, HYUNDAI_LONG_TX_MSGS); } else if (hyundai_camera_scc) { static RxCheck hyundai_cam_scc_rx_checks[] = {