diff --git a/board/safety/safety_toyota.h b/board/safety/safety_toyota.h index afe65422018..dc70e9ac54a 100644 --- a/board/safety/safety_toyota.h +++ b/board/safety/safety_toyota.h @@ -31,6 +31,7 @@ const CanMsg TOYOTA_TX_MSGS[] = {{0x283, 0, 7}, {0x2E6, 0, 8}, {0x2E7, 0, 8}, {0 {0x128, 1, 6}, {0x141, 1, 4}, {0x160, 1, 8}, {0x161, 1, 7}, {0x470, 1, 4}, // DSU bus 1 {0x2E4, 0, 5}, {0x191, 0, 8}, {0x411, 0, 8}, {0x412, 0, 8}, {0x343, 0, 8}, {0x1D2, 0, 8}, // LKAS + ACC {0x750, 0, 8}, // dp - white list 0x750 for Enhanced Diagnostic Request + {0x2fd, 0, 8}, // rick - for SCI {0x200, 0, 6}}; // interceptor AddrCheckStruct toyota_addr_checks[] = { @@ -50,11 +51,13 @@ const uint32_t TOYOTA_EPS_FACTOR = (1U << TOYOTA_PARAM_OFFSET) - 1U; const uint32_t TOYOTA_PARAM_ALT_BRAKE = 1U << TOYOTA_PARAM_OFFSET; const uint32_t TOYOTA_PARAM_STOCK_LONGITUDINAL = 2U << TOYOTA_PARAM_OFFSET; const uint32_t TOYOTA_PARAM_LTA = 4U << TOYOTA_PARAM_OFFSET; +const uint32_t TOYOTA_PARAM_SCI = 8U << TOYOTA_PARAM_OFFSET; bool toyota_alt_brake = false; bool toyota_stock_longitudinal = false; bool toyota_lta = false; int toyota_dbc_eps_torque_factor = 100; // conversion factor for STEER_TORQUE_EPS in %: see dbc file +bool toyota_sci = false; static uint32_t toyota_compute_checksum(CANPacket_t *to_push) { int addr = GET_ADDR(to_push); @@ -209,6 +212,21 @@ static int toyota_tx_hook(CANPacket_t *to_send) { } } + // rick - sci, use lta rules + if (addr == 0x2fd) { + // check the STEER_REQUEST, STEER_REQUEST_2, SETME_X64 STEER_ANGLE_CMD signals + bool lta_request = GET_BIT(to_send, 0U) != 0U; + bool lta_request2 = GET_BIT(to_send, 25U) != 0U; + int setme_x64 = GET_BYTE(to_send, 5); + int lta_angle = (GET_BYTE(to_send, 1) << 8) | GET_BYTE(to_send, 2); + lta_angle = to_signed(lta_angle, 16); + + // block LTA msgs with actuation requests + if (lta_request || lta_request2 || (lta_angle != 0) || (setme_x64 != 0)) { + tx = 0; + } + } + // STEER: safety check on bytes 2-3 if (addr == 0x2E4) { int desired_torque = (GET_BYTE(to_send, 1) << 8) | GET_BYTE(to_send, 2); @@ -232,6 +250,7 @@ static const addr_checks* toyota_init(uint16_t param) { toyota_alt_brake = GET_FLAG(param, TOYOTA_PARAM_ALT_BRAKE); toyota_stock_longitudinal = GET_FLAG(param, TOYOTA_PARAM_STOCK_LONGITUDINAL); toyota_dbc_eps_torque_factor = param & TOYOTA_EPS_FACTOR; + toyota_sci = GET_FLAG(param, TOYOTA_SCI); #ifdef ALLOW_DEBUG toyota_lta = GET_FLAG(param, TOYOTA_PARAM_LTA); diff --git a/python/__init__.py b/python/__init__.py index eca9a8a87f2..567277a0706 100644 --- a/python/__init__.py +++ b/python/__init__.py @@ -229,6 +229,7 @@ class Panda: FLAG_TOYOTA_ALT_BRAKE = (1 << 8) FLAG_TOYOTA_STOCK_LONGITUDINAL = (2 << 8) FLAG_TOYOTA_LTA = (4 << 8) + FLAG_TOYOTA_SCI = (8 << 8) FLAG_HONDA_ALT_BRAKE = 1 FLAG_HONDA_BOSCH_LONG = 2