Skip to content

Commit d0c2634

Browse files
committed
added gas safety checks
1 parent d378e4a commit d0c2634

File tree

1 file changed

+15
-11
lines changed

1 file changed

+15
-11
lines changed

board/safety/safety_honda.h

+15-11
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ static void honda_rx_hook(CAN_FIFOMailBox_TypeDef *to_push) {
5858
}
5959

6060
// exit controls on rising edge of gas press if no interceptor
61-
if (!bosch_hardware && !gas_interceptor_detected) {
61+
if (!gas_interceptor_detected) {
6262
if ((to_push->RIR>>21) == 0x17C) {
6363
int gas = to_push->RDLR & 0xFF;
6464
if (gas && !(gas_prev)) {
@@ -83,7 +83,7 @@ static int honda_tx_hook(CAN_FIFOMailBox_TypeDef *to_send) {
8383
int current_controls_allowed = controls_allowed && !(pedal_pressed);
8484

8585
// BRAKE: safety check
86-
if (!bosch_hardware && (to_send->RIR>>21) == 0x1FA) {
86+
if ((to_send->RIR>>21) == 0x1FA) {
8787
if (current_controls_allowed) {
8888
if ((to_send->RDLR & 0xFFFFFF3F) != to_send->RDLR) return 0;
8989
} else {
@@ -92,7 +92,7 @@ static int honda_tx_hook(CAN_FIFOMailBox_TypeDef *to_send) {
9292
}
9393

9494
// STEER: safety check
95-
if ((to_send->RIR>>21) == 0xE4 || (!bosch_hardware && (to_send->RIR>>21) == 0x194)) {
95+
if ((to_send->RIR>>21) == 0xE4 || (to_send->RIR>>21) == 0x194) {
9696
if (current_controls_allowed) {
9797
// all messages are fine here
9898
} else {
@@ -101,7 +101,7 @@ static int honda_tx_hook(CAN_FIFOMailBox_TypeDef *to_send) {
101101
}
102102

103103
// GAS: safety check
104-
if (!bosch_hardware && (to_send->RIR>>21) == 0x200) {
104+
if ((to_send->RIR>>21) == 0x200) {
105105
if (current_controls_allowed) {
106106
// all messages are fine here
107107
} else {
@@ -120,15 +120,11 @@ static int honda_tx_lin_hook(int lin_num, uint8_t *data, int len) {
120120

121121
static void honda_init(int16_t param) {
122122
controls_allowed = 0;
123+
bosch_hardware = false;
123124
}
124125

125126
static int honda_fwd_hook(int bus_num, CAN_FIFOMailBox_TypeDef *to_fwd) {
126-
int bus_fwd_num = -1;
127-
if (bosch_hardware && (bus_num == 1 || bus_num == 2)) {
128-
int addr = to_fwd->RIR>>21;
129-
bus_fwd_num = addr != 0xE4 && addr != 0x33D ? (uint8_t)(~bus_num & 0x3) : -1;
130-
}
131-
return bus_fwd_num;
127+
return -1;
132128
}
133129

134130
const safety_hooks honda_hooks = {
@@ -144,10 +140,18 @@ static void honda_bosch_init(int16_t param) {
144140
bosch_hardware = true;
145141
}
146142

143+
static int honda_bosch_fwd_hook(int bus_num, CAN_FIFOMailBox_TypeDef *to_fwd) {
144+
if (bus_num == 1 || bus_num == 2) {
145+
int addr = to_fwd->RIR>>21;
146+
return addr != 0xE4 && addr != 0x33D ? (uint8_t)(~bus_num & 0x3) : -1;
147+
}
148+
return -1;
149+
}
150+
147151
const safety_hooks honda_bosch_hooks = {
148152
.init = honda_bosch_init,
149153
.rx = honda_rx_hook,
150154
.tx = honda_tx_hook,
151155
.tx_lin = honda_tx_lin_hook,
152-
.fwd = honda_fwd_hook,
156+
.fwd = honda_bosch_fwd_hook,
153157
};

0 commit comments

Comments
 (0)