Skip to content

Commit

Permalink
GM: allow TX PSCMStatus message (commaai#1111)
Browse files Browse the repository at this point in the history
* forwarding

* add to tx msgs

* don't block

* Revert "don't block"

This reverts commit b1ca52f.

* fix forwarding tests

* comment

* add comment
  • Loading branch information
sshane authored Oct 20, 2022
1 parent 723e60c commit 54f9390
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
10 changes: 7 additions & 3 deletions board/safety/safety_gm.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ const CanMsg GM_ASCM_TX_MSGS[] = {{384, 0, 4}, {1033, 0, 7}, {1034, 0, 7}, {715,
{0x104c006c, 3, 3}, {0x10400060, 3, 5}}; // gmlan

const CanMsg GM_CAM_TX_MSGS[] = {{384, 0, 4}, // pt bus
{481, 2, 7}}; // camera bus
{481, 2, 7}, {388, 2, 8}}; // camera bus

// TODO: do checksum and counter checks. Add correct timestep, 0.1s for now.
AddrCheckStruct gm_addr_checks[] = {
Expand Down Expand Up @@ -260,13 +260,17 @@ static int gm_fwd_hook(int bus_num, CANPacket_t *to_fwd) {
int bus_fwd = -1;

if (gm_hw == GM_CAM) {
int addr = GET_ADDR(to_fwd);
if (bus_num == 0) {
bus_fwd = 2;
// block PSCMStatus; forwarded through openpilot to hide an alert from the camera
bool is_pscm_msg = (addr == 388);
if (!is_pscm_msg) {
bus_fwd = 2;
}
}

if (bus_num == 2) {
// block lkas message, forward all others
int addr = GET_ADDR(to_fwd);
bool is_lkas_msg = (addr == 384);
if (!is_lkas_msg) {
bus_fwd = 0;
Expand Down
5 changes: 3 additions & 2 deletions tests/safety/test_gm.py
Original file line number Diff line number Diff line change
Expand Up @@ -208,8 +208,9 @@ def test_cancel_button(self):


class TestGmCameraSafety(TestGmSafetyBase):
TX_MSGS = [[384, 0]] # pt bus
FWD_BLACKLISTED_ADDRS = {2: [384]} # LKAS message, ACC messages are (715, 880, 789)
TX_MSGS = [[384, 0], # pt bus
[388, 2]] # camera bus
FWD_BLACKLISTED_ADDRS = {2: [384], 0: [388]} # block LKAS message and PSCMStatus
FWD_BUS_LOOKUP = {0: 2, 2: 0}
BUTTONS_BUS = 2 # tx only
USER_BRAKE_THRESHOLD = 20
Expand Down

0 comments on commit 54f9390

Please sign in to comment.