From f9c771b6823135025e3879eec21e87cfc1bafc36 Mon Sep 17 00:00:00 2001 From: zhou jielei Date: Mon, 9 Dec 2024 12:24:34 +0900 Subject: [PATCH 01/13] 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/13] 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/13] 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/13] 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/13] 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/13] 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/13] 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/13] 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/13] 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/13] 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/13] 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/13] 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/13] 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; } }