Skip to content

Commit

Permalink
GM: match ECM standstill check (commaai#1105)
Browse files Browse the repository at this point in the history
* match ECM check

* fix

* needs to be <= 10 to avoid a fault, fix for safety tests

* fix
  • Loading branch information
sshane authored Oct 18, 2022
1 parent 9ed3f75 commit b95a65d
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
9 changes: 6 additions & 3 deletions board/safety/safety_gm.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion tests/safety/test_gm.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit b95a65d

Please sign in to comment.