From f9c771b6823135025e3879eec21e87cfc1bafc36 Mon Sep 17 00:00:00 2001 From: zhou jielei Date: Mon, 9 Dec 2024 12:24:34 +0900 Subject: [PATCH 01/29] add odyssey RC5(japan special) support --- board/safety/safety_honda.h | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/board/safety/safety_honda.h b/board/safety/safety_honda.h index 60ccea1e16..ca36bc22e0 100644 --- a/board/safety/safety_honda.h +++ b/board/safety/safety_honda.h @@ -286,7 +286,7 @@ static bool honda_tx_hook(const CANPacket_t *to_send) { // FORCE CANCEL: safety check only relevant when spamming the cancel button in Bosch HW // ensuring that only the cancel button press is sent (VAL 2) when controls are off. // This avoids unintended engagements while still allowing resume spam - if ((addr == 0x296) && !controls_allowed && (bus == bus_buttons)) { + if ((addr == 0x296 || addr == 0x1A6) && !controls_allowed && (bus == bus_buttons)) { if (((GET_BYTE(to_send, 0) >> 5) & 0x7U) != 2U) { tx = false; } @@ -338,7 +338,7 @@ static safety_config honda_nidec_init(uint16_t param) { static safety_config honda_bosch_init(uint16_t param) { static CanMsg HONDA_BOSCH_TX_MSGS[] = {{0xE4, 0, 5}, {0xE5, 0, 8}, {0x296, 1, 4}, {0x33D, 0, 5}, {0x33DA, 0, 5}, {0x33DB, 0, 8}}; // Bosch static CanMsg HONDA_BOSCH_LONG_TX_MSGS[] = {{0xE4, 1, 5}, {0x1DF, 1, 8}, {0x1EF, 1, 8}, {0x1FA, 1, 8}, {0x30C, 1, 8}, {0x33D, 1, 5}, {0x33DA, 1, 5}, {0x33DB, 1, 8}, {0x39F, 1, 8}, {0x18DAB0F1, 1, 8}}; // Bosch w/ gas and brakes - static CanMsg HONDA_RADARLESS_TX_MSGS[] = {{0xE4, 0, 5}, {0x296, 2, 4}, {0x33D, 0, 8}}; // Bosch radarless + static CanMsg HONDA_RADARLESS_TX_MSGS[] = {{0xE4, 0, 5}, {0x296, 2, 4}, {0x1A6, 2, 4},{0x33D, 0, 8}}; // Bosch radarless static CanMsg HONDA_RADARLESS_LONG_TX_MSGS[] = {{0xE4, 0, 5}, {0x33D, 0, 8}, {0x1C8, 0, 8}, {0x30C, 0, 8}}; // Bosch radarless w/ gas and brakes const uint16_t HONDA_PARAM_ALT_BRAKE = 1; @@ -365,6 +365,11 @@ static safety_config honda_bosch_init(uint16_t param) { // Checking for alternate brake override from safety parameter honda_alt_brake_msg = GET_FLAG(param, HONDA_PARAM_ALT_BRAKE); + + // Only find one car Odyssey RC5 japanese type use this feature + const uint16_t HONDA_PARAM_NIDEC_ALT = 4; + bool enable_nidec_alt = GET_FLAG(param, HONDA_PARAM_NIDEC_ALT); + // radar disabled so allow gas/brakes #ifdef ALLOW_DEBUG const uint16_t HONDA_PARAM_BOSCH_LONG = 2; @@ -375,7 +380,16 @@ static safety_config honda_bosch_init(uint16_t param) { if (honda_bosch_radarless && honda_alt_brake_msg) { SET_RX_CHECKS(honda_common_alt_brake_rx_checks, ret); } else if (honda_bosch_radarless) { - SET_RX_CHECKS(honda_common_rx_checks, ret); + if (enable_nidec_alt) { + // for dyssey RC5 japanese type + static RxCheck honda_bosch_alt_rx_checks[] = { + HONDA_COMMON_NO_SCM_FEEDBACK_RX_CHECKS(0) + }; + + SET_RX_CHECKS(honda_bosch_alt_rx_checks, ret); + } else { + SET_RX_CHECKS(honda_common_rx_checks, ret); + } } else if (honda_alt_brake_msg) { SET_RX_CHECKS(honda_bosch_alt_brake_rx_checks, ret); } else { From 4a8ab20aee561f334af6d40fb9713950e668979c Mon Sep 17 00:00:00 2001 From: zhou jielei Date: Mon, 9 Dec 2024 13:11:24 +0900 Subject: [PATCH 02/29] fix --- board/safety/safety_honda.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/board/safety/safety_honda.h b/board/safety/safety_honda.h index ca36bc22e0..c91c5f3ee0 100644 --- a/board/safety/safety_honda.h +++ b/board/safety/safety_honda.h @@ -286,7 +286,7 @@ static bool honda_tx_hook(const CANPacket_t *to_send) { // FORCE CANCEL: safety check only relevant when spamming the cancel button in Bosch HW // ensuring that only the cancel button press is sent (VAL 2) when controls are off. // This avoids unintended engagements while still allowing resume spam - if ((addr == 0x296 || addr == 0x1A6) && !controls_allowed && (bus == bus_buttons)) { + if (((addr == 0x296) || (addr == 0x1A6))) && !controls_allowed && (bus == bus_buttons)) { if (((GET_BYTE(to_send, 0) >> 5) & 0x7U) != 2U) { tx = false; } From 13656721918b3553491c068c8b1e667809e40b74 Mon Sep 17 00:00:00 2001 From: zhou jielei Date: Mon, 9 Dec 2024 13:16:35 +0900 Subject: [PATCH 03/29] fix 2 --- board/safety/safety_honda.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/board/safety/safety_honda.h b/board/safety/safety_honda.h index c91c5f3ee0..ad0fc00281 100644 --- a/board/safety/safety_honda.h +++ b/board/safety/safety_honda.h @@ -286,7 +286,7 @@ static bool honda_tx_hook(const CANPacket_t *to_send) { // FORCE CANCEL: safety check only relevant when spamming the cancel button in Bosch HW // ensuring that only the cancel button press is sent (VAL 2) when controls are off. // This avoids unintended engagements while still allowing resume spam - if (((addr == 0x296) || (addr == 0x1A6))) && !controls_allowed && (bus == bus_buttons)) { + if (((addr == 0x296) || (addr == 0x1A6)) && !controls_allowed && (bus == bus_buttons)) { if (((GET_BYTE(to_send, 0) >> 5) & 0x7U) != 2U) { tx = false; } From 3836d0752d313ef4346b56694b82d9699e962159 Mon Sep 17 00:00:00 2001 From: zhou jielei Date: Mon, 9 Dec 2024 16:09:26 +0900 Subject: [PATCH 04/29] add panda test --- tests/safety/test_honda.py | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/tests/safety/test_honda.py b/tests/safety/test_honda.py index 082199c02b..9c3abe6f80 100755 --- a/tests/safety/test_honda.py +++ b/tests/safety/test_honda.py @@ -535,6 +535,17 @@ def setUp(self): self.safety.init_tests() +class TestHondaBoschRadarlessAltSCMSafety(HondaPcmEnableBase, TestHondaBoschRadarlessSafetyBase): + """ + Covers the Honda Bosch Radarless safety mode with stock longitudinal + """ + + def setUp(self): + super().setUp() + self.safety.set_safety_hooks(Panda.SAFETY_HONDA_BOSCH, Panda.FLAG_HONDA_RADARLESS | Panda.FLAG_HONDA_NIDEC_ALT) + self.safety.init_tests() + + class TestHondaBoschRadarlessAltBrakeSafety(HondaPcmEnableBase, TestHondaBoschRadarlessSafetyBase, TestHondaBoschAltBrakeSafetyBase): """ Covers the Honda Bosch Radarless safety mode with stock longitudinal and an alternate brake message From e11b211e7964813bd5131f152fd7b1738d8145c9 Mon Sep 17 00:00:00 2001 From: zhou jielei Date: Mon, 9 Dec 2024 16:26:33 +0900 Subject: [PATCH 05/29] add test message --- tests/safety/test_honda.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/safety/test_honda.py b/tests/safety/test_honda.py index 9c3abe6f80..a495cd56b0 100755 --- a/tests/safety/test_honda.py +++ b/tests/safety/test_honda.py @@ -537,7 +537,7 @@ def setUp(self): class TestHondaBoschRadarlessAltSCMSafety(HondaPcmEnableBase, TestHondaBoschRadarlessSafetyBase): """ - Covers the Honda Bosch Radarless safety mode with stock longitudinal + Covers the Honda Bosch Radarless safety mode with stock longitudinal and an alternate SCM message """ def setUp(self): From 8eb33fb6e8e488210d2b83d36261af18660a72f2 Mon Sep 17 00:00:00 2001 From: zhou jielei Date: Thu, 12 Dec 2024 15:12:07 +0900 Subject: [PATCH 06/29] fix 1a6 len --- board/safety/safety_honda.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/board/safety/safety_honda.h b/board/safety/safety_honda.h index ad0fc00281..0f163ce444 100644 --- a/board/safety/safety_honda.h +++ b/board/safety/safety_honda.h @@ -338,7 +338,7 @@ static safety_config honda_nidec_init(uint16_t param) { static safety_config honda_bosch_init(uint16_t param) { static CanMsg HONDA_BOSCH_TX_MSGS[] = {{0xE4, 0, 5}, {0xE5, 0, 8}, {0x296, 1, 4}, {0x33D, 0, 5}, {0x33DA, 0, 5}, {0x33DB, 0, 8}}; // Bosch static CanMsg HONDA_BOSCH_LONG_TX_MSGS[] = {{0xE4, 1, 5}, {0x1DF, 1, 8}, {0x1EF, 1, 8}, {0x1FA, 1, 8}, {0x30C, 1, 8}, {0x33D, 1, 5}, {0x33DA, 1, 5}, {0x33DB, 1, 8}, {0x39F, 1, 8}, {0x18DAB0F1, 1, 8}}; // Bosch w/ gas and brakes - static CanMsg HONDA_RADARLESS_TX_MSGS[] = {{0xE4, 0, 5}, {0x296, 2, 4}, {0x1A6, 2, 4},{0x33D, 0, 8}}; // Bosch radarless + static CanMsg HONDA_RADARLESS_TX_MSGS[] = {{0xE4, 0, 5}, {0x296, 2, 4}, {0x1A6, 2, 8},{0x33D, 0, 8}}; // Bosch radarless static CanMsg HONDA_RADARLESS_LONG_TX_MSGS[] = {{0xE4, 0, 5}, {0x33D, 0, 8}, {0x1C8, 0, 8}, {0x30C, 0, 8}}; // Bosch radarless w/ gas and brakes const uint16_t HONDA_PARAM_ALT_BRAKE = 1; From 290436b6ce26ea37fb304d335a55ba160f1e3cc2 Mon Sep 17 00:00:00 2001 From: zhou jielei Date: Thu, 12 Dec 2024 15:22:17 +0900 Subject: [PATCH 07/29] set 1a6 frequency to 20ms 50U --- board/safety/safety_honda.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/board/safety/safety_honda.h b/board/safety/safety_honda.h index 0f163ce444..15ef159e96 100644 --- a/board/safety/safety_honda.h +++ b/board/safety/safety_honda.h @@ -4,7 +4,7 @@ // All common address checks except SCM_BUTTONS which isn't on one Nidec safety configuration #define HONDA_COMMON_NO_SCM_FEEDBACK_RX_CHECKS(pt_bus) \ - {.msg = {{0x1A6, (pt_bus), 8, .check_checksum = true, .max_counter = 3U, .frequency = 25U}, /* SCM_BUTTONS */ \ + {.msg = {{0x1A6, (pt_bus), 8, .check_checksum = true, .max_counter = 3U, .frequency = 50U}, /* SCM_BUTTONS */ \ {0x296, (pt_bus), 4, .check_checksum = true, .max_counter = 3U, .frequency = 25U}, { 0 }}}, \ {.msg = {{0x158, (pt_bus), 8, .check_checksum = true, .max_counter = 3U, .frequency = 100U}, { 0 }, { 0 }}}, /* ENGINE_DATA */ \ {.msg = {{0x17C, (pt_bus), 8, .check_checksum = true, .max_counter = 3U, .frequency = 100U}, { 0 }, { 0 }}}, /* POWERTRAIN_DATA */ \ From 8ddc3b0294862e17ab9e9e2ef17c14dce5c6d444 Mon Sep 17 00:00:00 2001 From: zhou jielei Date: Thu, 12 Dec 2024 23:13:43 +0900 Subject: [PATCH 08/29] test code --- board/safety/safety_honda.h | 2 -- 1 file changed, 2 deletions(-) diff --git a/board/safety/safety_honda.h b/board/safety/safety_honda.h index 15ef159e96..9353be6883 100644 --- a/board/safety/safety_honda.h +++ b/board/safety/safety_honda.h @@ -4,8 +4,6 @@ // All common address checks except SCM_BUTTONS which isn't on one Nidec safety configuration #define HONDA_COMMON_NO_SCM_FEEDBACK_RX_CHECKS(pt_bus) \ - {.msg = {{0x1A6, (pt_bus), 8, .check_checksum = true, .max_counter = 3U, .frequency = 50U}, /* SCM_BUTTONS */ \ - {0x296, (pt_bus), 4, .check_checksum = true, .max_counter = 3U, .frequency = 25U}, { 0 }}}, \ {.msg = {{0x158, (pt_bus), 8, .check_checksum = true, .max_counter = 3U, .frequency = 100U}, { 0 }, { 0 }}}, /* ENGINE_DATA */ \ {.msg = {{0x17C, (pt_bus), 8, .check_checksum = true, .max_counter = 3U, .frequency = 100U}, { 0 }, { 0 }}}, /* POWERTRAIN_DATA */ \ From f1691dbc3d2505c81f6d9b868254d7b5fbf66fcc Mon Sep 17 00:00:00 2001 From: zhou jielei Date: Thu, 12 Dec 2024 23:43:12 +0900 Subject: [PATCH 09/29] test code2 --- board/safety.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/board/safety.h b/board/safety.h index 913109957c..4e7e106d23 100644 --- a/board/safety.h +++ b/board/safety.h @@ -116,7 +116,7 @@ static bool is_msg_valid(RxCheck addr_list[], int index) { if (index != -1) { if (!addr_list[index].status.valid_checksum || !addr_list[index].status.valid_quality_flag || (addr_list[index].status.wrong_counters >= MAX_WRONG_COUNTERS)) { valid = false; - controls_allowed = false; + //controls_allowed = false; } } return valid; From 7137316fae50adf36da59f8811440b19db4b5faa Mon Sep 17 00:00:00 2001 From: zhou jielei Date: Thu, 12 Dec 2024 23:45:31 +0900 Subject: [PATCH 10/29] add test4 --- board/safety.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/board/safety.h b/board/safety.h index 4e7e106d23..2dd792b6e9 100644 --- a/board/safety.h +++ b/board/safety.h @@ -300,7 +300,7 @@ void safety_tick(const safety_config *cfg) { bool lagging = elapsed_time > MAX(timestep * MAX_MISSED_MSGS, 1e6); cfg->rx_checks[i].status.lagging = lagging; if (lagging) { - controls_allowed = false; + //controls_allowed = false; } if (lagging || !is_msg_valid(cfg->rx_checks, i)) { From 0b1b77e73bed1f4f432ba13d1fc79951e45b72eb Mon Sep 17 00:00:00 2001 From: zhou jielei Date: Fri, 13 Dec 2024 10:02:00 +0900 Subject: [PATCH 11/29] test code 6 --- board/safety/safety_honda.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/board/safety/safety_honda.h b/board/safety/safety_honda.h index 9353be6883..29d49b5770 100644 --- a/board/safety/safety_honda.h +++ b/board/safety/safety_honda.h @@ -103,7 +103,7 @@ static void honda_rx_hook(const CANPacket_t *to_push) { // Since some Nidec cars can brake down to 0 after the PCM disengages, // we don't disengage when the PCM does. if (!cruise_engaged && (honda_hw != HONDA_NIDEC)) { - controls_allowed = false; + //controls_allowed = false; } cruise_engaged_prev = cruise_engaged; } From 2cf987c4eccd799a3c6f38cf61c5a5792a7f801f Mon Sep 17 00:00:00 2001 From: zhou jielei Date: Sat, 14 Dec 2024 08:47:22 +0900 Subject: [PATCH 12/29] add test7 --- board/safety/safety_honda.h | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/board/safety/safety_honda.h b/board/safety/safety_honda.h index 29d49b5770..c75febb532 100644 --- a/board/safety/safety_honda.h +++ b/board/safety/safety_honda.h @@ -89,6 +89,8 @@ static void honda_rx_hook(const CANPacket_t *to_push) { acc_main_on = GET_BIT(to_push, ((addr == 0x326) ? 28U : 47U)); if (!acc_main_on) { controls_allowed = false; + }else{ + controls_allowed = true; } } @@ -125,6 +127,9 @@ static void honda_rx_hook(const CANPacket_t *to_push) { controls_allowed = false; } cruise_button_prev = button; + if (acc_main_on) { + controls_allowed = true; + } } // user brake signal on 0x17C reports applied brake from computer brake on accord From 15ab855a13937b18a67d440b9dd6ef2aa2d7f8fa Mon Sep 17 00:00:00 2001 From: zhou jielei Date: Sat, 14 Dec 2024 08:47:57 +0900 Subject: [PATCH 13/29] add test7 --- board/safety/safety_honda.h | 2 -- 1 file changed, 2 deletions(-) diff --git a/board/safety/safety_honda.h b/board/safety/safety_honda.h index c75febb532..fb9c1bec57 100644 --- a/board/safety/safety_honda.h +++ b/board/safety/safety_honda.h @@ -89,8 +89,6 @@ static void honda_rx_hook(const CANPacket_t *to_push) { acc_main_on = GET_BIT(to_push, ((addr == 0x326) ? 28U : 47U)); if (!acc_main_on) { controls_allowed = false; - }else{ - controls_allowed = true; } } From f2ba5ecd14292938b4453195667bea7b24320bba Mon Sep 17 00:00:00 2001 From: zhou jielei Date: Mon, 16 Dec 2024 13:24:19 +0900 Subject: [PATCH 14/29] change button --- board/safety.h | 4 ++-- board/safety/safety_honda.h | 7 ++----- 2 files changed, 4 insertions(+), 7 deletions(-) diff --git a/board/safety.h b/board/safety.h index 2dd792b6e9..913109957c 100644 --- a/board/safety.h +++ b/board/safety.h @@ -116,7 +116,7 @@ static bool is_msg_valid(RxCheck addr_list[], int index) { if (index != -1) { if (!addr_list[index].status.valid_checksum || !addr_list[index].status.valid_quality_flag || (addr_list[index].status.wrong_counters >= MAX_WRONG_COUNTERS)) { valid = false; - //controls_allowed = false; + controls_allowed = false; } } return valid; @@ -300,7 +300,7 @@ void safety_tick(const safety_config *cfg) { bool lagging = elapsed_time > MAX(timestep * MAX_MISSED_MSGS, 1e6); cfg->rx_checks[i].status.lagging = lagging; if (lagging) { - //controls_allowed = false; + controls_allowed = false; } if (lagging || !is_msg_valid(cfg->rx_checks, i)) { diff --git a/board/safety/safety_honda.h b/board/safety/safety_honda.h index fb9c1bec57..4e14ca3f40 100644 --- a/board/safety/safety_honda.h +++ b/board/safety/safety_honda.h @@ -103,7 +103,7 @@ static void honda_rx_hook(const CANPacket_t *to_push) { // Since some Nidec cars can brake down to 0 after the PCM disengages, // we don't disengage when the PCM does. if (!cruise_engaged && (honda_hw != HONDA_NIDEC)) { - //controls_allowed = false; + controls_allowed = false; } cruise_engaged_prev = cruise_engaged; } @@ -121,13 +121,10 @@ static void honda_rx_hook(const CANPacket_t *to_push) { } // exit controls once main or cancel are pressed - if ((button == HONDA_BTN_MAIN) || (button == HONDA_BTN_CANCEL)) { + if (((button == HONDA_BTN_MAIN) || (button == HONDA_BTN_CANCEL)) && (cruise_button_prev != button)) { controls_allowed = false; } cruise_button_prev = button; - if (acc_main_on) { - controls_allowed = true; - } } // user brake signal on 0x17C reports applied brake from computer brake on accord From 5420e628852fee88fc194250077d1cb78771e29a Mon Sep 17 00:00:00 2001 From: zhou jielei Date: Mon, 16 Dec 2024 13:49:37 +0900 Subject: [PATCH 15/29] test --- board/safety/safety_honda.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/board/safety/safety_honda.h b/board/safety/safety_honda.h index 4e14ca3f40..9353be6883 100644 --- a/board/safety/safety_honda.h +++ b/board/safety/safety_honda.h @@ -121,7 +121,7 @@ static void honda_rx_hook(const CANPacket_t *to_push) { } // exit controls once main or cancel are pressed - if (((button == HONDA_BTN_MAIN) || (button == HONDA_BTN_CANCEL)) && (cruise_button_prev != button)) { + if ((button == HONDA_BTN_MAIN) || (button == HONDA_BTN_CANCEL)) { controls_allowed = false; } cruise_button_prev = button; From eed735ee4e11f2be707226358b2227bbba295fa0 Mon Sep 17 00:00:00 2001 From: zhou jielei Date: Mon, 16 Dec 2024 13:53:46 +0900 Subject: [PATCH 16/29] test2 --- board/safety/safety_honda.h | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/board/safety/safety_honda.h b/board/safety/safety_honda.h index 9353be6883..4dc757cbae 100644 --- a/board/safety/safety_honda.h +++ b/board/safety/safety_honda.h @@ -4,6 +4,8 @@ // All common address checks except SCM_BUTTONS which isn't on one Nidec safety configuration #define HONDA_COMMON_NO_SCM_FEEDBACK_RX_CHECKS(pt_bus) \ + {.msg = {{0x1A6, (pt_bus), 8, .check_checksum = true, .max_counter = 3U, .frequency = 25U}, /* SCM_BUTTONS */ \ + {0x296, (pt_bus), 4, .check_checksum = true, .max_counter = 3U, .frequency = 25U}, { 0 }}}, \ \ \ {.msg = {{0x158, (pt_bus), 8, .check_checksum = true, .max_counter = 3U, .frequency = 100U}, { 0 }, { 0 }}}, /* ENGINE_DATA */ \ {.msg = {{0x17C, (pt_bus), 8, .check_checksum = true, .max_counter = 3U, .frequency = 100U}, { 0 }, { 0 }}}, /* POWERTRAIN_DATA */ \ @@ -121,10 +123,11 @@ static void honda_rx_hook(const CANPacket_t *to_push) { } // exit controls once main or cancel are pressed - if ((button == HONDA_BTN_MAIN) || (button == HONDA_BTN_CANCEL)) { + if (((button == HONDA_BTN_MAIN) || (button == HONDA_BTN_CANCEL)) &&(cruise_button_prev != button)) { controls_allowed = false; } cruise_button_prev = button; + } // user brake signal on 0x17C reports applied brake from computer brake on accord From 66dfb98bee5d20be6adb558b7256549cddebe387 Mon Sep 17 00:00:00 2001 From: zhou jielei Date: Mon, 16 Dec 2024 13:56:12 +0900 Subject: [PATCH 17/29] fix --- board/safety/safety_honda.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/board/safety/safety_honda.h b/board/safety/safety_honda.h index 4dc757cbae..f3b5b741b5 100644 --- a/board/safety/safety_honda.h +++ b/board/safety/safety_honda.h @@ -5,7 +5,7 @@ // All common address checks except SCM_BUTTONS which isn't on one Nidec safety configuration #define HONDA_COMMON_NO_SCM_FEEDBACK_RX_CHECKS(pt_bus) \ {.msg = {{0x1A6, (pt_bus), 8, .check_checksum = true, .max_counter = 3U, .frequency = 25U}, /* SCM_BUTTONS */ \ - {0x296, (pt_bus), 4, .check_checksum = true, .max_counter = 3U, .frequency = 25U}, { 0 }}}, \ \ \ + {0x296, (pt_bus), 4, .check_checksum = true, .max_counter = 3U, .frequency = 25U}, { 0 }}}, \ {.msg = {{0x158, (pt_bus), 8, .check_checksum = true, .max_counter = 3U, .frequency = 100U}, { 0 }, { 0 }}}, /* ENGINE_DATA */ \ {.msg = {{0x17C, (pt_bus), 8, .check_checksum = true, .max_counter = 3U, .frequency = 100U}, { 0 }, { 0 }}}, /* POWERTRAIN_DATA */ \ From bfe030a0cbdb6d016622d69ab77810a26a59a085 Mon Sep 17 00:00:00 2001 From: zhou jielei Date: Tue, 7 Jan 2025 09:54:38 +0900 Subject: [PATCH 18/29] fix 326 signal problem --- board/safety/safety_honda.h | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/board/safety/safety_honda.h b/board/safety/safety_honda.h index f3b5b741b5..0814ec8f30 100644 --- a/board/safety/safety_honda.h +++ b/board/safety/safety_honda.h @@ -37,6 +37,10 @@ static bool honda_alt_brake_msg = false; static bool honda_fwd_brake = false; static bool honda_bosch_long = false; static bool honda_bosch_radarless = false; + + +static bool honda_addr_1a6_detect = false; + typedef enum {HONDA_NIDEC, HONDA_BOSCH} HondaHw; static HondaHw honda_hw = HONDA_NIDEC; @@ -87,8 +91,16 @@ static void honda_rx_hook(const CANPacket_t *to_push) { // check ACC main state // 0x326 for all Bosch and some Nidec, 0x1A6 for some Nidec - if ((addr == 0x326) || (addr == 0x1A6)) { - acc_main_on = GET_BIT(to_push, ((addr == 0x326) ? 28U : 47U)); + // Odyssey RC5 japanese type use 0x1a6 for scm_buttons and main_on signal + // But 0x326 also exist. So we need to ignore it. + if (addr == 0x1A6) { + honda_addr_1a6_detect = true; + acc_main_on = GET_BIT(to_push, 47U); + if (!acc_main_on) { + controls_allowed = false; + } + } else if (addr == 0x326 && !honda_addr_1a6_detect) { + acc_main_on = GET_BIT(to_push, 28U); if (!acc_main_on) { controls_allowed = false; } From 30a1d53a194746377d4ad42329b7673f016d1987 Mon Sep 17 00:00:00 2001 From: zhou jielei Date: Tue, 7 Jan 2025 10:24:08 +0900 Subject: [PATCH 19/29] fix some bug --- board/safety/safety_honda.h | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/board/safety/safety_honda.h b/board/safety/safety_honda.h index 0814ec8f30..458d7dae8d 100644 --- a/board/safety/safety_honda.h +++ b/board/safety/safety_honda.h @@ -37,8 +37,6 @@ static bool honda_alt_brake_msg = false; static bool honda_fwd_brake = false; static bool honda_bosch_long = false; static bool honda_bosch_radarless = false; - - static bool honda_addr_1a6_detect = false; typedef enum {HONDA_NIDEC, HONDA_BOSCH} HondaHw; @@ -99,7 +97,7 @@ static void honda_rx_hook(const CANPacket_t *to_push) { if (!acc_main_on) { controls_allowed = false; } - } else if (addr == 0x326 && !honda_addr_1a6_detect) { + } else if ((addr == 0x326) && (!honda_addr_1a6_detect)) { acc_main_on = GET_BIT(to_push, 28U); if (!acc_main_on) { controls_allowed = false; @@ -135,7 +133,7 @@ static void honda_rx_hook(const CANPacket_t *to_push) { } // exit controls once main or cancel are pressed - if (((button == HONDA_BTN_MAIN) || (button == HONDA_BTN_CANCEL)) &&(cruise_button_prev != button)) { + if (((button == HONDA_BTN_MAIN) || (button == HONDA_BTN_CANCEL))) { controls_allowed = false; } cruise_button_prev = button; From c91457fd2eecdf7fe36a749e5dade8824087f0c4 Mon Sep 17 00:00:00 2001 From: zhou jielei Date: Tue, 7 Jan 2025 10:27:49 +0900 Subject: [PATCH 20/29] fix --- board/safety/safety_honda.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/board/safety/safety_honda.h b/board/safety/safety_honda.h index 458d7dae8d..97d4d7275c 100644 --- a/board/safety/safety_honda.h +++ b/board/safety/safety_honda.h @@ -133,7 +133,7 @@ static void honda_rx_hook(const CANPacket_t *to_push) { } // exit controls once main or cancel are pressed - if (((button == HONDA_BTN_MAIN) || (button == HONDA_BTN_CANCEL))) { + if ((button == HONDA_BTN_MAIN) || (button == HONDA_BTN_CANCEL)) { controls_allowed = false; } cruise_button_prev = button; From db6c1c12f8d591efc72205459602b09c31975ad2 Mon Sep 17 00:00:00 2001 From: zhou jielei Date: Tue, 7 Jan 2025 10:38:23 +0900 Subject: [PATCH 21/29] fix --- board/safety/safety_honda.h | 16 +--------------- 1 file changed, 1 insertion(+), 15 deletions(-) diff --git a/board/safety/safety_honda.h b/board/safety/safety_honda.h index 97d4d7275c..eada1ade8e 100644 --- a/board/safety/safety_honda.h +++ b/board/safety/safety_honda.h @@ -376,11 +376,6 @@ static safety_config honda_bosch_init(uint16_t param) { // Checking for alternate brake override from safety parameter honda_alt_brake_msg = GET_FLAG(param, HONDA_PARAM_ALT_BRAKE); - - // Only find one car Odyssey RC5 japanese type use this feature - const uint16_t HONDA_PARAM_NIDEC_ALT = 4; - bool enable_nidec_alt = GET_FLAG(param, HONDA_PARAM_NIDEC_ALT); - // radar disabled so allow gas/brakes #ifdef ALLOW_DEBUG const uint16_t HONDA_PARAM_BOSCH_LONG = 2; @@ -391,16 +386,7 @@ static safety_config honda_bosch_init(uint16_t param) { if (honda_bosch_radarless && honda_alt_brake_msg) { SET_RX_CHECKS(honda_common_alt_brake_rx_checks, ret); } else if (honda_bosch_radarless) { - if (enable_nidec_alt) { - // for dyssey RC5 japanese type - static RxCheck honda_bosch_alt_rx_checks[] = { - HONDA_COMMON_NO_SCM_FEEDBACK_RX_CHECKS(0) - }; - - SET_RX_CHECKS(honda_bosch_alt_rx_checks, ret); - } else { - SET_RX_CHECKS(honda_common_rx_checks, ret); - } + SET_RX_CHECKS(honda_common_rx_checks, ret); } else if (honda_alt_brake_msg) { SET_RX_CHECKS(honda_bosch_alt_brake_rx_checks, ret); } else { From 081bbec17e22792e37681d75f0ba3fe8b235b83a Mon Sep 17 00:00:00 2001 From: zhou jielei Date: Tue, 7 Jan 2025 10:51:57 +0900 Subject: [PATCH 22/29] fix --- board/safety/safety_honda.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/board/safety/safety_honda.h b/board/safety/safety_honda.h index eada1ade8e..9064dc22b4 100644 --- a/board/safety/safety_honda.h +++ b/board/safety/safety_honda.h @@ -97,7 +97,9 @@ static void honda_rx_hook(const CANPacket_t *to_push) { if (!acc_main_on) { controls_allowed = false; } - } else if ((addr == 0x326) && (!honda_addr_1a6_detect)) { + } + + if ((addr == 0x326) && (!honda_addr_1a6_detect)) { acc_main_on = GET_BIT(to_push, 28U); if (!acc_main_on) { controls_allowed = false; From e4e330c0eedce6644e1ec5ec68f07a88b7da4125 Mon Sep 17 00:00:00 2001 From: zhou jielei Date: Tue, 7 Jan 2025 11:00:15 +0900 Subject: [PATCH 23/29] fix --- board/safety/safety_honda.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/board/safety/safety_honda.h b/board/safety/safety_honda.h index 9064dc22b4..86495ece14 100644 --- a/board/safety/safety_honda.h +++ b/board/safety/safety_honda.h @@ -37,7 +37,7 @@ static bool honda_alt_brake_msg = false; static bool honda_fwd_brake = false; static bool honda_bosch_long = false; static bool honda_bosch_radarless = false; -static bool honda_addr_1a6_detect = false; +static bool honda_signal_scm_alt = false; typedef enum {HONDA_NIDEC, HONDA_BOSCH} HondaHw; static HondaHw honda_hw = HONDA_NIDEC; @@ -92,14 +92,14 @@ static void honda_rx_hook(const CANPacket_t *to_push) { // Odyssey RC5 japanese type use 0x1a6 for scm_buttons and main_on signal // But 0x326 also exist. So we need to ignore it. if (addr == 0x1A6) { - honda_addr_1a6_detect = true; + honda_signal_scm_alt = true; acc_main_on = GET_BIT(to_push, 47U); if (!acc_main_on) { controls_allowed = false; } } - if ((addr == 0x326) && (!honda_addr_1a6_detect)) { + if ((addr == 0x326) && (!honda_signal_scm_alt)) { acc_main_on = GET_BIT(to_push, 28U); if (!acc_main_on) { controls_allowed = false; From 16862f41155938d86a407cd2c03ff23dac6207c3 Mon Sep 17 00:00:00 2001 From: zhou jielei Date: Tue, 7 Jan 2025 11:04:42 +0900 Subject: [PATCH 24/29] test --- board/safety/safety_honda.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/board/safety/safety_honda.h b/board/safety/safety_honda.h index 86495ece14..e8dcd5c734 100644 --- a/board/safety/safety_honda.h +++ b/board/safety/safety_honda.h @@ -37,7 +37,7 @@ static bool honda_alt_brake_msg = false; static bool honda_fwd_brake = false; static bool honda_bosch_long = false; static bool honda_bosch_radarless = false; -static bool honda_signal_scm_alt = false; +static bool honda_acc_scm_alt = false; typedef enum {HONDA_NIDEC, HONDA_BOSCH} HondaHw; static HondaHw honda_hw = HONDA_NIDEC; @@ -92,14 +92,14 @@ static void honda_rx_hook(const CANPacket_t *to_push) { // Odyssey RC5 japanese type use 0x1a6 for scm_buttons and main_on signal // But 0x326 also exist. So we need to ignore it. if (addr == 0x1A6) { - honda_signal_scm_alt = true; + honda_acc_scm_alt = true; acc_main_on = GET_BIT(to_push, 47U); if (!acc_main_on) { controls_allowed = false; } } - if ((addr == 0x326) && (!honda_signal_scm_alt)) { + if ((addr == 0x326) && (!honda_acc_scm_alt)) { acc_main_on = GET_BIT(to_push, 28U); if (!acc_main_on) { controls_allowed = false; From b9d09d9d11c695ee540674e845711fec664f5328 Mon Sep 17 00:00:00 2001 From: zhou jielei Date: Tue, 7 Jan 2025 11:10:36 +0900 Subject: [PATCH 25/29] test2 --- board/safety/safety_honda.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/board/safety/safety_honda.h b/board/safety/safety_honda.h index e8dcd5c734..aa6cd78108 100644 --- a/board/safety/safety_honda.h +++ b/board/safety/safety_honda.h @@ -37,7 +37,7 @@ static bool honda_alt_brake_msg = false; static bool honda_fwd_brake = false; static bool honda_bosch_long = false; static bool honda_bosch_radarless = false; -static bool honda_acc_scm_alt = false; +static bool honda_bosch_scm_alt = false; typedef enum {HONDA_NIDEC, HONDA_BOSCH} HondaHw; static HondaHw honda_hw = HONDA_NIDEC; @@ -92,14 +92,14 @@ static void honda_rx_hook(const CANPacket_t *to_push) { // Odyssey RC5 japanese type use 0x1a6 for scm_buttons and main_on signal // But 0x326 also exist. So we need to ignore it. if (addr == 0x1A6) { - honda_acc_scm_alt = true; + honda_bosch_scm_alt = true; acc_main_on = GET_BIT(to_push, 47U); if (!acc_main_on) { controls_allowed = false; } } - if ((addr == 0x326) && (!honda_acc_scm_alt)) { + if ((addr == 0x326) && (!honda_bosch_scm_alt)) { acc_main_on = GET_BIT(to_push, 28U); if (!acc_main_on) { controls_allowed = false; From 2d1770f16b81d5e1b981df603177fde3a09c70a4 Mon Sep 17 00:00:00 2001 From: zhou jielei Date: Tue, 7 Jan 2025 11:18:11 +0900 Subject: [PATCH 26/29] fix3 --- board/safety/safety_honda.h | 1 - 1 file changed, 1 deletion(-) diff --git a/board/safety/safety_honda.h b/board/safety/safety_honda.h index aa6cd78108..9597a5c4a4 100644 --- a/board/safety/safety_honda.h +++ b/board/safety/safety_honda.h @@ -38,7 +38,6 @@ static bool honda_fwd_brake = false; static bool honda_bosch_long = false; static bool honda_bosch_radarless = false; static bool honda_bosch_scm_alt = false; - typedef enum {HONDA_NIDEC, HONDA_BOSCH} HondaHw; static HondaHw honda_hw = HONDA_NIDEC; From 152f35eed9f347f33a975f1ff974b5d1c106d1ae Mon Sep 17 00:00:00 2001 From: zhou jielei Date: Tue, 7 Jan 2025 11:23:56 +0900 Subject: [PATCH 27/29] test4 --- board/safety/safety_honda.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/board/safety/safety_honda.h b/board/safety/safety_honda.h index 9597a5c4a4..ae64cc0790 100644 --- a/board/safety/safety_honda.h +++ b/board/safety/safety_honda.h @@ -326,6 +326,7 @@ static safety_config honda_nidec_init(uint16_t param) { honda_alt_brake_msg = false; honda_bosch_long = false; honda_bosch_radarless = false; + honda_bosch_scm_alt = false; safety_config ret; @@ -376,6 +377,7 @@ static safety_config honda_bosch_init(uint16_t param) { honda_bosch_radarless = GET_FLAG(param, HONDA_PARAM_RADARLESS); // Checking for alternate brake override from safety parameter honda_alt_brake_msg = GET_FLAG(param, HONDA_PARAM_ALT_BRAKE); + honda_bosch_scm_alt = false; // radar disabled so allow gas/brakes #ifdef ALLOW_DEBUG From 4561c1b6db42c63d0947edc98f405bb04a6f72ce Mon Sep 17 00:00:00 2001 From: zhou jielei Date: Tue, 7 Jan 2025 14:15:47 +0900 Subject: [PATCH 28/29] fix some code --- board/safety/safety_honda.h | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/board/safety/safety_honda.h b/board/safety/safety_honda.h index ae64cc0790..28ce3972a0 100644 --- a/board/safety/safety_honda.h +++ b/board/safety/safety_honda.h @@ -96,9 +96,7 @@ static void honda_rx_hook(const CANPacket_t *to_push) { if (!acc_main_on) { controls_allowed = false; } - } - - if ((addr == 0x326) && (!honda_bosch_scm_alt)) { + } else if ((addr == 0x326) && (!honda_bosch_scm_alt)) { acc_main_on = GET_BIT(to_push, 28U); if (!acc_main_on) { controls_allowed = false; From 92a4b8ba22431a0d18c2f9b1d16234df5e35bda8 Mon Sep 17 00:00:00 2001 From: zhou jielei Date: Tue, 7 Jan 2025 14:30:17 +0900 Subject: [PATCH 29/29] fix --- board/safety/safety_honda.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/board/safety/safety_honda.h b/board/safety/safety_honda.h index 28ce3972a0..ae64cc0790 100644 --- a/board/safety/safety_honda.h +++ b/board/safety/safety_honda.h @@ -96,7 +96,9 @@ static void honda_rx_hook(const CANPacket_t *to_push) { if (!acc_main_on) { controls_allowed = false; } - } else if ((addr == 0x326) && (!honda_bosch_scm_alt)) { + } + + if ((addr == 0x326) && (!honda_bosch_scm_alt)) { acc_main_on = GET_BIT(to_push, 28U); if (!acc_main_on) { controls_allowed = false;