mirror of
https://github.com/commaai/panda.git
synced 2026-06-12 23:27:23 +08:00
safety: common interceptor checks (#1178)
* interceptor checks * only one line needed for now * whoops * misra * misread as |
This commit is contained in:
@@ -511,6 +511,10 @@ bool longitudinal_brake_checks(int desired_brake, const LongitudinalLimits limit
|
||||
return violation;
|
||||
}
|
||||
|
||||
bool longitudinal_interceptor_checks(CANPacket_t *to_send, bool longitudinal_allowed) {
|
||||
return !longitudinal_allowed && (GET_BYTE(to_send, 0) || GET_BYTE(to_send, 1));
|
||||
}
|
||||
|
||||
// Safety checks for torque-based steering commands
|
||||
bool steer_torque_cmd_checks(int desired_torque, int steer_req, const SteeringLimits limits) {
|
||||
bool violation = false;
|
||||
|
||||
@@ -333,10 +333,8 @@ static int honda_tx_hook(CANPacket_t *to_send, bool longitudinal_allowed) {
|
||||
|
||||
// GAS: safety check (interceptor)
|
||||
if (addr == 0x200) {
|
||||
if (!longitudinal_allowed) {
|
||||
if (GET_BYTE(to_send, 0) || GET_BYTE(to_send, 1)) {
|
||||
tx = 0;
|
||||
}
|
||||
if (longitudinal_interceptor_checks(to_send, longitudinal_allowed)) {
|
||||
tx = 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -147,10 +147,8 @@ static int toyota_tx_hook(CANPacket_t *to_send, bool longitudinal_allowed) {
|
||||
|
||||
// GAS PEDAL: safety check
|
||||
if (addr == 0x200) {
|
||||
if (!longitudinal_allowed) {
|
||||
if (GET_BYTE(to_send, 0) || GET_BYTE(to_send, 1)) {
|
||||
tx = 0;
|
||||
}
|
||||
if (longitudinal_interceptor_checks(to_send, longitudinal_allowed)) {
|
||||
tx = 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -130,6 +130,7 @@ bool steer_torque_cmd_checks(int desired_torque, int steer_req, const SteeringLi
|
||||
bool longitudinal_accel_checks(int desired_accel, const LongitudinalLimits limits, const bool longitudinal_allowed);
|
||||
bool longitudinal_gas_checks(int desired_gas, const LongitudinalLimits limits, const bool longitudinal_allowed);
|
||||
bool longitudinal_brake_checks(int desired_brake, const LongitudinalLimits limits, const bool longitudinal_allowed);
|
||||
bool longitudinal_interceptor_checks(CANPacket_t *to_send, const bool longitudinal_allowed);
|
||||
void pcm_cruise_check(bool cruise_engaged);
|
||||
|
||||
typedef const addr_checks* (*safety_hook_init)(uint16_t param);
|
||||
|
||||
Reference in New Issue
Block a user