From 53f2722a3d475dea865a4ff3a68946edc3921990 Mon Sep 17 00:00:00 2001 From: Rick Lan Date: Fri, 9 Nov 2018 13:31:33 +1000 Subject: [PATCH] Cruise state on lexus and toyota are both in 0:1D2 @ 0x20, so we can mergee lexus specific safety check with toyota. --- opendbc/lexus_ish_2017_pt_generated.dbc | 2 +- panda/board/safety.h | 2 -- panda/board/safety/safety_toyota.h | 26 +++---------------------- panda/python/__init__.py | 1 - selfdrive/boardd/boardd.cc | 6 +----- selfdrive/car/toyota/interface.py | 5 +---- 6 files changed, 6 insertions(+), 36 deletions(-) diff --git a/opendbc/lexus_ish_2017_pt_generated.dbc b/opendbc/lexus_ish_2017_pt_generated.dbc index 33ae4f05f..157a27b23 100644 --- a/opendbc/lexus_ish_2017_pt_generated.dbc +++ b/opendbc/lexus_ish_2017_pt_generated.dbc @@ -56,7 +56,7 @@ BO_ 180 SPEED: 8 XXX BO_ 466 PCM_CRUISE: 8 XXX SG_ GAS_RELEASED : 4|1@0+ (1,0) [0|1] "" XXX - SG_ CRUISE_STATE : 15|3@0+ (1,0) [0|0] "" DS1 + SG_ CRUISE_STATE : 5|1@0+ (1,0) [0|1] "" XXX BO_ 552 ACCELEROMETER: 8 XXX SG_ ACCEL_Z : 22|15@0- (1,0) [0|32767] "" XXX diff --git a/panda/board/safety.h b/panda/board/safety.h index 48c5bb301..51a2bb896 100644 --- a/panda/board/safety.h +++ b/panda/board/safety.h @@ -102,7 +102,6 @@ typedef struct { #define SAFETY_CADILLAC 6 #define SAFETY_HYUNDAI 7 #define SAFETY_TESLA 8 -#define SAFETY_LEXUS_ISH 9 #define SAFETY_TOYOTA_IPAS 0x1335 #define SAFETY_TOYOTA_NOLIMITS 0x1336 #define SAFETY_ALLOUTPUT 0x1337 @@ -118,7 +117,6 @@ const safety_hook_config safety_hook_registry[] = { {SAFETY_CADILLAC, &cadillac_hooks}, {SAFETY_HYUNDAI, &hyundai_hooks}, {SAFETY_TOYOTA_NOLIMITS, &toyota_nolimits_hooks}, - {SAFETY_LEXUS_ISH, &lexus_ish_hooks}, #ifdef PANDA {SAFETY_TOYOTA_IPAS, &toyota_ipas_hooks}, {SAFETY_TESLA, &tesla_hooks}, diff --git a/panda/board/safety/safety_toyota.h b/panda/board/safety/safety_toyota.h index e814fe46a..9c624926f 100644 --- a/panda/board/safety/safety_toyota.h +++ b/panda/board/safety/safety_toyota.h @@ -30,7 +30,6 @@ uint32_t toyota_ts_last = 0; int toyota_cruise_engaged_last = 0; // cruise state struct sample_t toyota_torque_meas; // last 3 motor torques produced by the eps -int is_lexus_ish = 0; // is a lexus is hybrid model? static void toyota_rx_hook(CAN_FIFOMailBox_TypeDef *to_push) { // get eps motor torque (0.66 factor in dbc) @@ -50,8 +49,8 @@ static void toyota_rx_hook(CAN_FIFOMailBox_TypeDef *to_push) { // enter controls on rising edge of ACC, exit controls on ACC off if ((to_push->RIR>>21) == 0x1D2) { - // toyota: 4 bits: 55-52 - int cruise_engaged = is_lexus_ish == 1? to_push->RDLR & 0x2000 : to_push->RDHR & 0xF00000; + // 6th bit + int cruise_engaged = to_push->RDLR & 0x20; if (cruise_engaged && !toyota_cruise_engaged_last) { controls_allowed = 1; } else if (!cruise_engaged) { @@ -152,15 +151,6 @@ static void toyota_init(int16_t param) { toyota_actuation_limits = 1; toyota_giraffe_switch_1 = 0; toyota_dbc_eps_torque_factor = param; - is_lexus_ish = 0; -} - -static void lexus_ish_init(int16_t param) { - controls_allowed = 0; - toyota_actuation_limits = 1; - toyota_giraffe_switch_1 = 0; - toyota_dbc_eps_torque_factor = param; - is_lexus_ish = 1; } static int toyota_fwd_hook(int bus_num, CAN_FIFOMailBox_TypeDef *to_fwd) { @@ -188,7 +178,6 @@ static void toyota_nolimits_init(int16_t param) { toyota_actuation_limits = 0; toyota_giraffe_switch_1 = 0; toyota_dbc_eps_torque_factor = param; - is_lexus_ish = 0; } const safety_hooks toyota_nolimits_hooks = { @@ -198,13 +187,4 @@ const safety_hooks toyota_nolimits_hooks = { .tx_lin = nooutput_tx_lin_hook, .ignition = default_ign_hook, .fwd = toyota_fwd_hook, -}; - -const safety_hooks lexus_ish_hooks = { - .init = lexus_ish_init, - .rx = toyota_rx_hook, - .tx = toyota_tx_hook, - .tx_lin = nooutput_tx_lin_hook, - .ignition = default_ign_hook, - .fwd = toyota_fwd_hook, -}; +}; \ No newline at end of file diff --git a/panda/python/__init__.py b/panda/python/__init__.py index 691df8b40..86b76285e 100644 --- a/panda/python/__init__.py +++ b/panda/python/__init__.py @@ -106,7 +106,6 @@ class Panda(object): SAFETY_HONDA = 1 SAFETY_TOYOTA = 2 SAFETY_HONDA_BOSCH = 4 - SAFETY_LEXUS_ISH = 9 SAFETY_TOYOTA_NOLIMITS = 0x1336 SAFETY_ALLOUTPUT = 0x1337 SAFETY_ELM327 = 0xE327 diff --git a/selfdrive/boardd/boardd.cc b/selfdrive/boardd/boardd.cc index af634e73a..7f3387891 100644 --- a/selfdrive/boardd/boardd.cc +++ b/selfdrive/boardd/boardd.cc @@ -41,7 +41,6 @@ #define SAFETY_CADILLAC 6 #define SAFETY_HYUNDAI 7 #define SAFETY_TESLA 8 -#define SAFETY_LEXUS_ISH 9 #define SAFETY_TOYOTA_IPAS 0x1335 #define SAFETY_TOYOTA_NOLIMITS 0x1336 #define SAFETY_ALLOUTPUT 0x1337 @@ -121,9 +120,6 @@ void *safety_setter_thread(void *s) { case (int)cereal::CarParams::SafetyModels::HYUNDAI: safety_setting = SAFETY_HYUNDAI; break; - case (int)cereal::CarParams::SafetyModels::LEXUS_ISH: - safety_setting = SAFETY_LEXUS_ISH; - break; default: LOGE("unknown safety model: %d", safety_model); } @@ -693,4 +689,4 @@ int main() { libusb_close(dev_handle); libusb_exit(ctx); -} +} \ No newline at end of file diff --git a/selfdrive/car/toyota/interface.py b/selfdrive/car/toyota/interface.py index 2013147cb..d601f823e 100755 --- a/selfdrive/car/toyota/interface.py +++ b/selfdrive/car/toyota/interface.py @@ -54,10 +54,7 @@ class CarInterface(object): ret.carName = "toyota" ret.carFingerprint = candidate - if candidate == CAR.LEXUS_ISH: - ret.safetyModel = car.CarParams.SafetyModels.lexusIsh - else: - ret.safetyModel = car.CarParams.SafetyModels.toyota + ret.safetyModel = car.CarParams.SafetyModels.toyota # pedal ret.enableCruise = True