From 46593af6190a09aea8a1a734e6b3cdcd4227cb98 Mon Sep 17 00:00:00 2001 From: Chris Souers Date: Sun, 22 Aug 2021 02:34:51 -0400 Subject: [PATCH] Honda Bosch: Support extended LKAS_HUD IDs (#615) * Add support for new Honda Bosch vehicles - Support extended LKAS_HUD IDs on Honda Bosch - Support extended ID checksum on incoming frames in safety hook (currently unused). condense Cleaner. Don't need to store the value in checksum at the return. Co-Authored-By: Adeeb Shihadeh * revert checksum change * use full space Co-authored-by: Adeeb Shihadeh Co-authored-by: Adeeb Shihadeh --- board/safety/safety_honda.h | 8 ++++---- tests/safety/common.py | 5 ++--- tests/safety/test_honda.py | 12 ++++++------ tests/safety_replay/helpers.py | 2 +- 4 files changed, 13 insertions(+), 14 deletions(-) diff --git a/board/safety/safety_honda.h b/board/safety/safety_honda.h index 0e2acdb46..8566f06a8 100644 --- a/board/safety/safety_honda.h +++ b/board/safety/safety_honda.h @@ -7,8 +7,8 @@ // brake rising edge // brake > 0mph const CanMsg HONDA_N_TX_MSGS[] = {{0xE4, 0, 5}, {0x194, 0, 4}, {0x1FA, 0, 8}, {0x200, 0, 6}, {0x30C, 0, 8}, {0x33D, 0, 5}}; -const CanMsg HONDA_BG_TX_MSGS[] = {{0xE4, 2, 5}, {0xE5, 2, 8}, {0x296, 0, 4}, {0x33D, 2, 5}}; // Bosch Giraffe -const CanMsg HONDA_BH_TX_MSGS[] = {{0xE4, 0, 5}, {0xE5, 0, 8}, {0x296, 1, 4}, {0x33D, 0, 5}}; // Bosch Harness +const CanMsg HONDA_BG_TX_MSGS[] = {{0xE4, 2, 5}, {0xE5, 2, 8}, {0x296, 0, 4}, {0x33D, 2, 5}, {0x33DA, 2, 5}, {0x33DB, 2, 8}}; // Bosch Giraffe +const CanMsg HONDA_BH_TX_MSGS[] = {{0xE4, 0, 5}, {0xE5, 0, 8}, {0x296, 1, 4}, {0x33D, 0, 5}, {0x33DA, 0, 5}, {0x33DB, 0, 8}}; // Bosch Harness const CanMsg HONDA_BG_LONG_TX_MSGS[] = {{0xE4, 0, 5}, {0x1DF, 0, 8}, {0x1EF, 0, 8}, {0x1FA, 0, 8}, {0x30C, 0, 8}, {0x33D, 0, 5}, {0x39F, 0, 8}, {0x18DAB0F1, 0, 8}}; // Bosch Giraffe w/ gas and brakes const CanMsg HONDA_BH_LONG_TX_MSGS[] = {{0xE4, 1, 5}, {0x1DF, 1, 8}, {0x1EF, 1, 8}, {0x1FA, 1, 8}, {0x30C, 1, 8}, {0x33D, 1, 5}, {0x39F, 1, 8}, {0x18DAB0F1, 1, 8}}; // Bosch Harness w/ gas and brakes @@ -274,7 +274,7 @@ static int honda_tx_hook(CAN_FIFOMailBox_TypeDef *to_send) { } } - // Bosch supplemental control check + // Bosch supplemental control check if (addr == 0xE5) { if ((GET_BYTES_04(to_send) != 0x10800004) || ((GET_BYTES_48(to_send) & 0x00FFFFFF) != 0x0)) { tx = 0; @@ -376,7 +376,7 @@ static int honda_bosch_fwd_hook(int bus_num, CAN_FIFOMailBox_TypeDef *to_fwd) { } if (bus_num == bus_rdr_cam) { int addr = GET_ADDR(to_fwd); - int is_lkas_msg = (addr == 0xE4) || (addr == 0xE5) || (addr == 0x33D); + int is_lkas_msg = (addr == 0xE4) || (addr == 0xE5) || (addr == 0x33D) || (addr == 0x33DA) || (addr == 0x33DB); if (!is_lkas_msg) { bus_fwd = bus_rdr_car; } diff --git a/tests/safety/common.py b/tests/safety/common.py index 9083f0837..eeeb30e79 100644 --- a/tests/safety/common.py +++ b/tests/safety/common.py @@ -297,7 +297,7 @@ class PandaSafetyTest(PandaSafetyTestBase): def test_fwd_hook(self): # some safety modes don't forward anything, while others blacklist msgs for bus in range(0x0, 0x3): - for addr in range(0x1, 0x800): + for addr in range(0x1, 0x40000): # assume len 8 msg = make_msg(bus, addr, 8) fwd_bus = self.FWD_BUS_LOOKUP.get(bus, -1) @@ -306,7 +306,7 @@ class PandaSafetyTest(PandaSafetyTestBase): self.assertEqual(fwd_bus, self.safety.safety_fwd_hook(bus, msg)) def test_spam_can_buses(self): - for addr in range(1, 0x800): + for addr in range(1, 0x40000): for bus in range(0, 4): if all(addr != m[0] or bus != m[1] for m in self.TX_MSGS): self.assertFalse(self._tx(make_msg(bus, addr, 8))) @@ -437,4 +437,3 @@ class PandaSafetyTest(PandaSafetyTestBase): msg = make_msg(addr, bus) self.safety.set_controls_allowed(1) self.assertFalse(self._tx(msg)) - diff --git a/tests/safety/test_honda.py b/tests/safety/test_honda.py index 173dbcc7e..3efb16d8f 100755 --- a/tests/safety/test_honda.py +++ b/tests/safety/test_honda.py @@ -306,9 +306,9 @@ class TestHondaBoschSafety(TestHondaSafety): class TestHondaBoschHarnessSafety(TestHondaBoschSafety): - TX_MSGS = [[0xE4, 0], [0xE5, 0], [0x296, 1], [0x33D, 0]] # Bosch Harness + TX_MSGS = [[0xE4, 0], [0xE5, 0], [0x296, 1], [0x33D, 0], [0x33DA, 0], [0x33DB, 0]] # Bosch Harness RELAY_MALFUNCTION_BUS = 0 - FWD_BLACKLISTED_ADDRS = {2: [0xE4, 0xE5, 0x33D]} + FWD_BLACKLISTED_ADDRS = {2: [0xE4, 0xE5, 0x33D, 0x33DA, 0x33DB]} FWD_BUS_LOOKUP = {0: 2, 2: 0} PT_BUS = 1 @@ -330,9 +330,9 @@ class TestHondaBoschHarnessSafety(TestHondaBoschSafety): class TestHondaBoschGiraffeSafety(TestHondaBoschHarnessSafety): - TX_MSGS = [[0xE4, 2], [0xE5, 2], [0x296, 0], [0x33D, 2]] # Bosch Giraffe + TX_MSGS = [[0xE4, 2], [0xE5, 2], [0x296, 0], [0x33D, 2], [0x33DA, 2], [0x33DB, 2]] # Bosch Giraffe RELAY_MALFUNCTION_BUS = 2 - FWD_BLACKLISTED_ADDRS = {1: [0xE4, 0xE5, 0x33D]} + FWD_BLACKLISTED_ADDRS = {1: [0xE4, 0xE5, 0x33D, 0x33DA, 0x33DB]} FWD_BUS_LOOKUP = {1: 2, 2: 1} PT_BUS = 0 @@ -395,7 +395,7 @@ class TestHondaBoschLongSafety(TestHondaBoschSafety): class TestHondaBoschLongHarnessSafety(TestHondaBoschLongSafety): TX_MSGS = [[0xE4, 1], [0x1DF, 1], [0x1EF, 1], [0x1FA, 1], [0x30C, 1], [0x33D, 1], [0x39F, 1], [0x18DAB0F1, 1]] # Bosch Harness w/ gas and brakes RELAY_MALFUNCTION_BUS = 0 - FWD_BLACKLISTED_ADDRS = {2: [0xE4, 0xE5, 0x33D]} + FWD_BLACKLISTED_ADDRS = {2: [0xE4, 0xE5, 0x33D, 0x33DA, 0x33DB]} FWD_BUS_LOOKUP = {0: 2, 2: 0} PT_BUS = 1 @@ -410,7 +410,7 @@ class TestHondaBoschLongHarnessSafety(TestHondaBoschLongSafety): class TestHondaBoschLongGiraffeSafety(TestHondaBoschLongSafety): TX_MSGS = [[0xE4, 0], [0x1DF, 0], [0x1EF, 0], [0x1FA, 0], [0x30C, 0], [0x33D, 0], [0x39F, 0], [0x18DAB0F1, 0]] # Bosch Giraffe w/ gas and brakes RELAY_MALFUNCTION_BUS = 2 - FWD_BLACKLISTED_ADDRS = {1: [0xE4, 0xE5, 0x33D]} + FWD_BLACKLISTED_ADDRS = {1: [0xE4, 0xE5, 0x33D, 0x33DA, 0x33DB]} FWD_BUS_LOOKUP = {1: 2, 2: 1} PT_BUS = 0 diff --git a/tests/safety_replay/helpers.py b/tests/safety_replay/helpers.py index 572ab7d38..026c7ac53 100644 --- a/tests/safety_replay/helpers.py +++ b/tests/safety_replay/helpers.py @@ -12,7 +12,7 @@ def to_signed(d, bits): def is_steering_msg(mode, addr): ret = False if mode in [Panda.SAFETY_HONDA_NIDEC, Panda.SAFETY_HONDA_BOSCH_GIRAFFE, Panda.SAFETY_HONDA_BOSCH_HARNESS]: - ret = (addr == 0xE4) or (addr == 0x194) or (addr == 0x33D) + ret = (addr == 0xE4) or (addr == 0x194) or (addr == 0x33D) or (addr == 0x33DA) or (addr == 0x33DB) elif mode == Panda.SAFETY_TOYOTA: ret = addr == 0x2E4 elif mode == Panda.SAFETY_GM: