@@ -5,6 +5,7 @@ const int CHRYSLER_MAX_RATE_UP = 3;
5
5
const int CHRYSLER_MAX_RATE_DOWN = 3 ;
6
6
const int CHRYSLER_MAX_TORQUE_ERROR = 80 ; // max torque cmd in excess of torque motor
7
7
const int CHRYSLER_GAS_THRSLD = 30 ; // 7% more than 2m/s
8
+ const int CHRYSLER_STANDSTILL_THRSLD = 10 ; // about 1m/s
8
9
const AddrBus CHRYSLER_TX_MSGS [] = {{571 , 0 }, {658 , 0 }, {678 , 0 }};
9
10
10
11
// TODO: do checksum and counter checks
@@ -13,13 +14,15 @@ AddrCheckStruct chrysler_rx_checks[] = {
13
14
{.addr = {514 }, .bus = 0 , .check_checksum = false, .max_counter = 0U , .expected_timestep = 10000U },
14
15
{.addr = {500 }, .bus = 0 , .check_checksum = true, .max_counter = 15U , .expected_timestep = 20000U },
15
16
{.addr = {308 }, .bus = 0 , .check_checksum = false, .max_counter = 15U , .expected_timestep = 20000U },
17
+ {.addr = {320 }, .bus = 0 , .check_checksum = true, .max_counter = 15U , .expected_timestep = 20000U },
16
18
};
17
19
const int CHRYSLER_RX_CHECK_LEN = sizeof (chrysler_rx_checks ) / sizeof (chrysler_rx_checks [0 ]);
18
20
19
21
int chrysler_rt_torque_last = 0 ;
20
22
int chrysler_desired_torque_last = 0 ;
21
23
int chrysler_cruise_engaged_last = 0 ;
22
24
bool chrysler_gas_prev = false;
25
+ bool chrysler_brake_prev = false;
23
26
int chrysler_speed = 0 ;
24
27
uint32_t chrysler_ts_last = 0 ;
25
28
struct sample_t chrysler_torque_meas ; // last few torques measured
@@ -113,6 +116,15 @@ static int chrysler_rx_hook(CAN_FIFOMailBox_TypeDef *to_push) {
113
116
chrysler_gas_prev = gas ;
114
117
}
115
118
119
+ // exit controls on rising edge of brake press
120
+ if ((addr == 320 ) && (bus == 0 )) {
121
+ bool brake = (GET_BYTE (to_push , 0 ) & 0x7 ) == 5 ;
122
+ if (brake && (!chrysler_brake_prev || (chrysler_speed > CHRYSLER_STANDSTILL_THRSLD ))) {
123
+ controls_allowed = 0 ;
124
+ }
125
+ chrysler_brake_prev = brake ;
126
+ }
127
+
116
128
// check if stock camera ECU is on bus 0
117
129
if ((safety_mode_cnt > RELAY_TRNS_TIMEOUT ) && (bus == 0 ) && (addr == 0x292 )) {
118
130
relay_malfunction = true;
0 commit comments