From 16a6e65b81162dbe6626f07f36421e82a025caae Mon Sep 17 00:00:00 2001 From: Shane Smiskol Date: Tue, 18 Oct 2022 11:22:04 -0700 Subject: [PATCH] GM: match ECM standstill check (#1105) * match ECM check * fix * needs to be <= 10 to avoid a fault, fix for safety tests * fix --- board/safety/safety_gm.h | 9 ++++++--- tests/safety/test_gm.py | 2 +- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/board/safety/safety_gm.h b/board/safety/safety_gm.h index 534e28362c..80aafef428 100644 --- a/board/safety/safety_gm.h +++ b/board/safety/safety_gm.h @@ -16,6 +16,8 @@ const int GM_MAX_RATE_DOWN = 17; const int GM_DRIVER_TORQUE_ALLOWANCE = 50; const int GM_DRIVER_TORQUE_FACTOR = 4; +const int GM_STANDSTILL_THRSLD = 10; // 0.311kph + const int GM_MAX_GAS = 3072; const int GM_MAX_REGEN = 1404; const int GM_MAX_BRAKE = 400; @@ -67,10 +69,11 @@ static int gm_rx_hook(CANPacket_t *to_push) { update_sample(&torque_driver, torque_driver_new); } - // sample speed, really only care if car is moving or not - // rear left wheel speed + // sample rear wheel speeds if (addr == 842) { - vehicle_moving = GET_BYTE(to_push, 0) | GET_BYTE(to_push, 1); + int left_rear_speed = (GET_BYTE(to_push, 0) << 8) | GET_BYTE(to_push, 1); + int right_rear_speed = (GET_BYTE(to_push, 2) << 8) | GET_BYTE(to_push, 3); + vehicle_moving = (left_rear_speed > GM_STANDSTILL_THRSLD) || (right_rear_speed > GM_STANDSTILL_THRSLD); } // ACC steering wheel buttons (GM_CAM is tied to the PCM) diff --git a/tests/safety/test_gm.py b/tests/safety/test_gm.py index 0ac2999170..60ddfb99cd 100755 --- a/tests/safety/test_gm.py +++ b/tests/safety/test_gm.py @@ -19,7 +19,7 @@ class Buttons: class TestGmSafetyBase(common.PandaSafetyTest, common.DriverTorqueSteeringSafetyTest): - STANDSTILL_THRESHOLD = 0 + STANDSTILL_THRESHOLD = 10 * 0.0311 RELAY_MALFUNCTION_ADDR = 384 RELAY_MALFUNCTION_BUS = 0 BUTTONS_BUS = 0