Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master' into h90d-canfd
Browse files Browse the repository at this point in the history
  • Loading branch information
sshane committed Oct 15, 2022
2 parents aa98c2a + 5962bcd commit e0b18df
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
8 changes: 6 additions & 2 deletions board/safety/safety_gm.h
Original file line number Diff line number Diff line change
Expand Up @@ -93,9 +93,13 @@ static int gm_rx_hook(CANPacket_t *to_push) {
}

if (addr == 190) {
// Reference for signal and threshold:
// Reference for signal and thresholds:
// https://github.com/commaai/openpilot/blob/master/selfdrive/car/gm/carstate.py
brake_pressed = GET_BYTE(to_push, 1) >= 8U;
if (gm_hw == GM_ASCM) {
brake_pressed = GET_BYTE(to_push, 1) >= 8U;
} else {
brake_pressed = GET_BYTE(to_push, 1) >= 20U;
}
}

if (addr == 452) {
Expand Down
5 changes: 4 additions & 1 deletion tests/safety/test_gm.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ class TestGmSafetyBase(common.PandaSafetyTest, common.DriverTorqueSteeringSafety
RELAY_MALFUNCTION_ADDR = 384
RELAY_MALFUNCTION_BUS = 0
BUTTONS_BUS = 0
USER_BRAKE_THRESHOLD = 0

MAX_RATE_UP = 7
MAX_RATE_DOWN = 17
Expand Down Expand Up @@ -55,7 +56,7 @@ def _speed_msg(self, speed):

def _user_brake_msg(self, brake):
# GM safety has a brake threshold of 8
values = {"BrakePedalPos": 8 if brake else 0}
values = {"BrakePedalPos": self.USER_BRAKE_THRESHOLD if brake else 0}
return self.packer.make_can_msg_panda("ECMAcceleratorPos", 0, values)

def _user_regen_msg(self, regen):
Expand Down Expand Up @@ -163,6 +164,7 @@ class TestGmAscmSafety(TestGmSafetyBase):
[0x104c006c, 3], [0x10400060, 3]] # gmlan
FWD_BLACKLISTED_ADDRS: Dict[int, List[int]] = {}
FWD_BUS_LOOKUP: Dict[int, int] = {}
USER_BRAKE_THRESHOLD = 8

def setUp(self):
self.packer = CANPackerPanda("gm_global_a_powertrain_generated")
Expand Down Expand Up @@ -210,6 +212,7 @@ class TestGmCameraSafety(TestGmSafetyBase):
FWD_BLACKLISTED_ADDRS = {2: [384]} # LKAS message, ACC messages are (715, 880, 789)
FWD_BUS_LOOKUP = {0: 2, 2: 0}
BUTTONS_BUS = 2 # tx only
USER_BRAKE_THRESHOLD = 20

def setUp(self):
self.packer = CANPackerPanda("gm_global_a_powertrain_generated")
Expand Down

0 comments on commit e0b18df

Please sign in to comment.