Skip to content

Commit

Permalink
Toyota: ACC message relay check (commaai#1612)
Browse files Browse the repository at this point in the history
* toyota: add safety for tester present

* block ACC_HUD

* check stock ECU

* clean up

* not this

* test new addr

* comment

* rm

* cmt
  • Loading branch information
sshane authored Aug 27, 2023
1 parent 0eb04fa commit 5a9d8cf
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
7 changes: 6 additions & 1 deletion board/safety/safety_toyota.h
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,12 @@ static int toyota_rx_hook(CANPacket_t *to_push) {
gas_interceptor_prev = gas_interceptor;
}

generic_rx_checks((addr == 0x2E4));
bool stock_ecu_detected = (addr == 0x2E4);
// Also check ACC_CONTROL (0x343) if openpilot is controlling longitudinal (radar is disabled or camera sends ACC messages)
if (!toyota_stock_longitudinal && (addr == 0x343)) {
stock_ecu_detected = true;
}
generic_rx_checks(stock_ecu_detected);
}
return valid;
}
Expand Down
5 changes: 3 additions & 2 deletions tests/safety/test_toyota.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ class TestToyotaSafetyBase(common.PandaSafetyTest, common.InterceptorSafetyTest,
[0x2E4, 0], [0x191, 0], [0x411, 0], [0x412, 0], [0x343, 0], [0x1D2, 0], # LKAS + ACC
[0x200, 0], [0x750, 0]] # interceptor + blindspot monitor
STANDSTILL_THRESHOLD = 0 # kph
RELAY_MALFUNCTION_ADDR = 0x2E4
RELAY_MALFUNCTION_ADDR = 0x343 # ACC_CONTROL
RELAY_MALFUNCTION_BUS = 0
FWD_BLACKLISTED_ADDRS = {2: [0x2E4, 0x412, 0x191, 0x343]}
FWD_BUS_LOOKUP = {0: 2, 2: 0}
Expand Down Expand Up @@ -180,7 +180,8 @@ def test_lta_steer_cmd(self):

class TestToyotaStockLongitudinalBase(TestToyotaSafetyBase):

# Base fwd addresses minus ACC_CONTROL (0x343)
# Forwarding: base addresses minus ACC_CONTROL (0x343), relay malfunction: STEERING_LKA
RELAY_MALFUNCTION_ADDR = 0x2E4
FWD_BLACKLISTED_ADDRS = {2: [0x2E4, 0x412, 0x191]}

def test_accel_actuation_limits(self, stock_longitudinal=True):
Expand Down

0 comments on commit 5a9d8cf

Please sign in to comment.