@@ -12,6 +12,7 @@ const AddrBus SUBARU_TX_MSGS[] = {{0x122, 0}, {0x164, 0}, {0x221, 0}, {0x322, 0}
12
12
13
13
// TODO: do checksum and counter checks after adding the signals to the outback dbc file
14
14
AddrCheckStruct subaru_rx_checks [] = {
15
+ {.addr = { 0x40 , 0x140 }, .bus = 0 , .expected_timestep = 10000U },
15
16
{.addr = {0x119 , 0x371 }, .bus = 0 , .expected_timestep = 20000U },
16
17
{.addr = {0x240 , 0x144 }, .bus = 0 , .expected_timestep = 50000U },
17
18
};
@@ -21,6 +22,7 @@ int subaru_cruise_engaged_last = 0;
21
22
int subaru_rt_torque_last = 0 ;
22
23
int subaru_desired_torque_last = 0 ;
23
24
uint32_t subaru_ts_last = 0 ;
25
+ bool subaru_gas_last = false;
24
26
struct sample_t subaru_torque_driver ; // last few driver torques measured
25
27
26
28
static int subaru_rx_hook (CAN_FIFOMailBox_TypeDef * to_push ) {
@@ -53,7 +55,15 @@ static int subaru_rx_hook(CAN_FIFOMailBox_TypeDef *to_push) {
53
55
subaru_cruise_engaged_last = cruise_engaged ;
54
56
}
55
57
56
- // TODO: enforce cancellation on gas pressed
58
+ // exit controls on rising edge of gas press
59
+ if (((addr == 0x40 ) || (addr == 0x140 )) && (bus == 0 )) {
60
+ int byte = (addr == 0x40 ) ? 4 : 0 ;
61
+ bool gas = GET_BYTE (to_push , byte ) != 0 ;
62
+ if (gas && !subaru_gas_last ) {
63
+ controls_allowed = 0 ;
64
+ }
65
+ subaru_gas_last = gas ;
66
+ }
57
67
58
68
if ((safety_mode_cnt > RELAY_TRNS_TIMEOUT ) && (bus == 0 ) && ((addr == 0x122 ) || (addr == 0x164 ))) {
59
69
relay_malfunction = true;
0 commit comments