Merge branch 'testing' into devel-i18n

This commit is contained in:
Rick Lan
2020-03-31 15:07:19 +10:00
8 changed files with 13 additions and 10 deletions

View File

@@ -92,7 +92,7 @@ static int gm_rx_hook(CAN_FIFOMailBox_TypeDef *to_push) {
if (addr == 417) {
bool gas_pressed = GET_BYTE(to_push, 6) != 0;
if (gas_pressed && !gas_pressed_prev) {
controls_allowed = 0;
controls_allowed = 1;
}
gas_pressed_prev = gas_pressed;
}
@@ -138,7 +138,8 @@ static int gm_tx_hook(CAN_FIFOMailBox_TypeDef *to_send) {
// disallow actuator commands if gas or brake (with vehicle moving) are pressed
// and the the latching controls_allowed flag is True
int pedal_pressed = gas_pressed_prev || (brake_pressed_prev && gm_moving);
//int pedal_pressed = gas_pressed_prev || (brake_pressed_prev && gm_moving);
int pedal_pressed = brake_pressed_prev && gm_moving;
bool current_controls_allowed = controls_allowed && !pedal_pressed;
// BRAKE: safety check

View File

@@ -343,4 +343,4 @@ const safety_hooks honda_bosch_harness_hooks = {
.fwd = honda_bosch_fwd_hook,
.addr_check = honda_bh_rx_checks,
.addr_check_len = sizeof(honda_bh_rx_checks) / sizeof(honda_bh_rx_checks[0]),
};
};

View File

@@ -56,7 +56,7 @@ static int hyundai_rx_hook(CAN_FIFOMailBox_TypeDef *to_push) {
if (addr == 608) {
bool gas_pressed = (GET_BYTE(to_push, 7) >> 6) != 0;
if (gas_pressed && !gas_pressed_prev) {
controls_allowed = 0;
controls_allowed = 1;
}
gas_pressed_prev = gas_pressed;
}

View File

@@ -64,7 +64,7 @@ static int nissan_rx_hook(CAN_FIFOMailBox_TypeDef *to_push) {
if (addr == 0x15c) {
bool gas_pressed = ((GET_BYTE(to_push, 5) << 2) | ((GET_BYTE(to_push, 6) >> 6) & 0x3));
if (gas_pressed && !gas_pressed_prev) {
controls_allowed = 0;
controls_allowed = 1;
}
gas_pressed_prev = gas_pressed;
}

View File

@@ -117,7 +117,7 @@ static int subaru_rx_hook(CAN_FIFOMailBox_TypeDef *to_push) {
int byte = subaru_global ? 4 : 0;
bool gas_pressed = GET_BYTE(to_push, byte) != 0;
if (gas_pressed && !gas_pressed_prev) {
controls_allowed = 0;
controls_allowed = 1;
}
gas_pressed_prev = gas_pressed;
}

View File

@@ -87,7 +87,7 @@ static int toyota_rx_hook(CAN_FIFOMailBox_TypeDef *to_push) {
// 5th bit is CRUISE_ACTIVE
int cruise_engaged = GET_BYTE(to_push, 0) & 0x20;
if (!cruise_engaged) {
controls_allowed = 1;
controls_allowed = 0;
}
if (cruise_engaged && !toyota_cruise_engaged_last) {
controls_allowed = 1;
@@ -112,7 +112,7 @@ static int toyota_rx_hook(CAN_FIFOMailBox_TypeDef *to_push) {
int byte = (addr == 0x224) ? 0 : 4;
bool brake_pressed = ((GET_BYTE(to_push, byte) >> 5) & 1) != 0;
if (brake_pressed && (!brake_pressed_prev || toyota_moving)) {
controls_allowed = 1;
controls_allowed = 0;
}
brake_pressed_prev = brake_pressed;
}
@@ -275,4 +275,4 @@ const safety_hooks toyota_hooks = {
.fwd = toyota_fwd_hook,
.addr_check = toyota_rx_checks,
.addr_check_len = sizeof(toyota_rx_checks)/sizeof(toyota_rx_checks[0]),
};
};

View File

@@ -137,7 +137,7 @@ static int volkswagen_mqb_rx_hook(CAN_FIFOMailBox_TypeDef *to_push) {
if (addr == MSG_MOTOR_20) {
bool gas_pressed = ((GET_BYTES_04(to_push) >> 12) & 0xFF) != 0;
if (gas_pressed && !gas_pressed_prev) {
controls_allowed = 0;
controls_allowed = 1;
}
gas_pressed_prev = gas_pressed;
}

View File

@@ -136,6 +136,8 @@ class CarState(CarStateBase):
enable_acc = False
if ret.seatbeltUnlatched or ret.doorOpen:
enable_acc = False
if ret.brakePressed:
enable_acc = False
ret.cruiseState.enabled = enable_acc
return ret