@@ -28,8 +28,6 @@ AddrCheckStruct honda_bh_rx_checks[] = {
28
28
const int HONDA_BH_RX_CHECKS_LEN = sizeof (honda_bh_rx_checks ) / sizeof (honda_bh_rx_checks [0 ]);
29
29
30
30
int honda_brake = 0 ;
31
- int honda_gas_prev = 0 ;
32
- bool honda_brake_pressed_prev = false;
33
31
bool honda_moving = false;
34
32
bool honda_alt_brake_msg = false;
35
33
bool honda_fwd_brake = false;
@@ -112,10 +110,10 @@ static int honda_rx_hook(CAN_FIFOMailBox_TypeDef *to_push) {
112
110
bool is_user_brake_msg = honda_alt_brake_msg ? ((addr ) == 0x1BE ) : ((addr ) == 0x17C );
113
111
if (is_user_brake_msg ) {
114
112
bool brake_pressed = honda_alt_brake_msg ? (GET_BYTE ((to_push ), 0 ) & 0x10 ) : (GET_BYTE ((to_push ), 6 ) & 0x20 );
115
- if (brake_pressed && (!( honda_brake_pressed_prev ) || honda_moving )) {
113
+ if (brake_pressed && (!brake_pressed_prev || honda_moving )) {
116
114
controls_allowed = 0 ;
117
115
}
118
- honda_brake_pressed_prev = brake_pressed ;
116
+ brake_pressed_prev = brake_pressed ;
119
117
}
120
118
121
119
// exit controls on rising edge of gas press if interceptor (0x201 w/ len = 6)
@@ -133,11 +131,11 @@ static int honda_rx_hook(CAN_FIFOMailBox_TypeDef *to_push) {
133
131
// exit controls on rising edge of gas press if no interceptor
134
132
if (!gas_interceptor_detected ) {
135
133
if (addr == 0x17C ) {
136
- int gas = GET_BYTE (to_push , 0 );
137
- if (gas && !honda_gas_prev ) {
134
+ bool gas_pressed = GET_BYTE (to_push , 0 ) != 0 ;
135
+ if (gas_pressed && !gas_pressed_prev ) {
138
136
controls_allowed = 0 ;
139
137
}
140
- honda_gas_prev = gas ;
138
+ gas_pressed_prev = gas_pressed ;
141
139
}
142
140
}
143
141
if ((bus == 2 ) && (addr == 0x1FA )) {
@@ -194,8 +192,8 @@ static int honda_tx_hook(CAN_FIFOMailBox_TypeDef *to_send) {
194
192
195
193
// disallow actuator commands if gas or brake (with vehicle moving) are pressed
196
194
// and the the latching controls_allowed flag is True
197
- int pedal_pressed = honda_gas_prev || (gas_interceptor_prev > HONDA_GAS_INTERCEPTOR_THRESHOLD ) ||
198
- (honda_brake_pressed_prev && honda_moving );
195
+ int pedal_pressed = gas_pressed_prev || (gas_interceptor_prev > HONDA_GAS_INTERCEPTOR_THRESHOLD ) ||
196
+ (brake_pressed_prev && honda_moving );
199
197
bool current_controls_allowed = controls_allowed && !(pedal_pressed );
200
198
201
199
// BRAKE: safety check
0 commit comments