diff --git a/board/safety/safety_honda.h b/board/safety/safety_honda.h index 1e446fa7..0e2acdb4 100644 --- a/board/safety/safety_honda.h +++ b/board/safety/safety_honda.h @@ -161,16 +161,25 @@ static int honda_rx_hook(CAN_FIFOMailBox_TypeDef *to_push) { } } - // if steering controls messages are received on the destination bus, it's an indication - // that the relay might be malfunctioning bool stock_ecu_detected = false; int bus_rdr_car = (honda_hw == HONDA_BH_HW) ? 0 : 2; // radar bus, car side - if ((safety_mode_cnt > RELAY_TRNS_TIMEOUT) && ((addr == 0xE4) || (addr == 0x194))) { - if (((honda_hw != HONDA_N_HW) && (bus == bus_rdr_car)) || - ((honda_hw == HONDA_N_HW) && (bus == 0))) { + int pt_bus = (honda_hw == HONDA_BH_HW) ? 1 : 0; + + if (safety_mode_cnt > RELAY_TRNS_TIMEOUT) { + // If steering controls messages are received on the destination bus, it's an indication + // that the relay might be malfunctioning + if ((addr == 0xE4) || (addr == 0x194)) { + if (((honda_hw != HONDA_N_HW) && (bus == bus_rdr_car)) || ((honda_hw == HONDA_N_HW) && (bus == 0))) { + stock_ecu_detected = true; + } + } + // If Honda Bosch longitudinal mode is selected we need to ensure the radar is turned off + // Verify this by ensuring ACC_CONTROL (0x1DF) is not received on the PT bus + if (honda_bosch_long && (bus == pt_bus) && (addr == 0x1DF)) { stock_ecu_detected = true; } } + generic_rx_checks(stock_ecu_detected); } return valid; @@ -290,6 +299,13 @@ static int honda_tx_hook(CAN_FIFOMailBox_TypeDef *to_send) { } } + // Only tester present ("\x02\x3E\x80\x00\x00\x00\x00\x00") allowed on diagnostics address + if (addr == 0x18DAB0F1) { + if ((GET_BYTES_04(to_send) != 0x00803E02) || (GET_BYTES_48(to_send) != 0x0)) { + tx = 0; + } + } + // 1 allows the message through return tx; } diff --git a/python/__init__.py b/python/__init__.py index 9ec5633c..5c2a781f 100644 --- a/python/__init__.py +++ b/python/__init__.py @@ -143,6 +143,9 @@ class Panda(object): CLOCK_SOURCE_MODE_FREE_RUNNING = 1 CLOCK_SOURCE_MODE_EXTERNAL_SYNC = 2 + FLAG_HONDA_ALT_BRAKE = 1 + FLAG_HONDA_BOSCH_LONG = 2 + def __init__(self, serial=None, claim=True): self._serial = serial self._handle = None diff --git a/tests/safety/test_honda.py b/tests/safety/test_honda.py index 11ca4065..173dbcc7 100755 --- a/tests/safety/test_honda.py +++ b/tests/safety/test_honda.py @@ -364,6 +364,19 @@ class TestHondaBoschLongSafety(TestHondaBoschSafety): } return self.packer.make_can_msg_panda("ACC_CONTROL", self.PT_BUS, values) + def test_diagnostics(self): + tester_present = common.package_can_msg((0x18DAB0F1, 0, b"\x02\x3E\x80\x00\x00\x00\x00\x00", self.PT_BUS)) + self.assertTrue(self.safety.safety_tx_hook(tester_present)) + + not_tester_present = common.package_can_msg((0x18DAB0F1, 0, b"\x03\xAA\xAA\x00\x00\x00\x00\x00", self.PT_BUS)) + self.assertFalse(self.safety.safety_tx_hook(not_tester_present)) + + def test_radar_alive(self): + # If the radar knockout failed, make sure the relay malfunction is shown + self.assertFalse(self.safety.get_relay_malfunction()) + self._rx(make_msg(self.PT_BUS, 0x1DF, 8)) + self.assertTrue(self.safety.get_relay_malfunction()) + def test_gas_safety_check(self): for controls_allowed in [True, False]: for gas in np.arange(self.NO_GAS, self.MAX_GAS + 2000, 100):