Skip to content

Commit

Permalink
VW safety: allow cancel spam on both buses to be compatible with came…
Browse files Browse the repository at this point in the history
…ra and gateway integration
  • Loading branch information
rbiasini committed Dec 4, 2019
1 parent d5f7a28 commit 6bbae7b
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
5 changes: 3 additions & 2 deletions board/safety/safety_volkswagen.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ const int VOLKSWAGEN_MAX_RATE_DOWN = 10; // 5.0 Nm/s available rate o
const int VOLKSWAGEN_DRIVER_TORQUE_ALLOWANCE = 80;
const int VOLKSWAGEN_DRIVER_TORQUE_FACTOR = 3;

const AddrBus VOLKSWAGEN_TX_MSGS[] = {{MSG_HCA_01, 0}, {MSG_GRA_ACC_01, 2}, {MSG_LDW_02, 0}};
// MSG_GRA_ACC_01 is allowed on bus 0 and 2 to keep compatibility with gateway and camera integration
const AddrBus VOLKSWAGEN_TX_MSGS[] = {{MSG_HCA_01, 0}, {MSG_GRA_ACC_01, 0}, {MSG_GRA_ACC_01, 2}, {MSG_LDW_02, 0}};

struct sample_t volkswagen_torque_driver; // last few driver torques measured
int volkswagen_rt_torque_last = 0;
Expand Down Expand Up @@ -126,7 +127,7 @@ static int volkswagen_tx_hook(CAN_FIFOMailBox_TypeDef *to_send) {

// FORCE CANCEL: ensuring that only the cancel button press is sent when controls are off.
// This avoids unintended engagements while still allowing resume spam
if ((bus == 2) && (addr == MSG_GRA_ACC_01) && !controls_allowed) {
if ((addr == MSG_GRA_ACC_01) && !controls_allowed) {
// disallow resume and set: bits 16 and 19
if ((GET_BYTE(to_send, 2) & 0x9) != 0) {
tx = 0;
Expand Down
2 changes: 1 addition & 1 deletion tests/safety/test_volkswagen.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
DRIVER_TORQUE_ALLOWANCE = 80
DRIVER_TORQUE_FACTOR = 3

TX_MSGS = [[0x126, 0], [0x12B, 2], [0x397, 0]]
TX_MSGS = [[0x126, 0], [0x12B, 0], [0x12B, 2], [0x397, 0]]

def sign(a):
if a > 0:
Expand Down

0 comments on commit 6bbae7b

Please sign in to comment.