Cruise state on lexus and toyota are both in 0:1D2 @ 0x20, so we can mergee lexus specific safety check with toyota.

This commit is contained in:
Rick Lan
2018-11-09 13:31:33 +10:00
parent 0d62ee7598
commit 53f2722a3d
6 changed files with 6 additions and 36 deletions
+1 -1
View File
@@ -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
-2
View File
@@ -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},
+3 -23
View File
@@ -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,
};
};
-1
View File
@@ -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
+1 -5
View File
@@ -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);
}
}
+1 -4
View File
@@ -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