Skip to content

Commit 1c0ffd1

Browse files
committed
Hyundai safety: simplifications
1 parent 56794d6 commit 1c0ffd1

File tree

1 file changed

+5
-9
lines changed

1 file changed

+5
-9
lines changed

board/safety/safety_hyundai.h

+5-9
Original file line numberDiff line numberDiff line change
@@ -41,11 +41,8 @@ static void hyundai_rx_hook(CAN_FIFOMailBox_TypeDef *to_push) {
4141
}
4242

4343
// Find out which bus the camera is on
44-
if (bus == 1 && addr == 832) {
45-
hyundai_camera_bus = 1;
46-
}
47-
if (bus == 2 && addr == 832) {
48-
hyundai_camera_bus = 2;
44+
if (addr == 832) {
45+
hyundai_camera_bus = bus;
4946
}
5047

5148
// enter controls on rising edge of ACC, exit controls on ACC off
@@ -143,11 +140,10 @@ static int hyundai_tx_hook(CAN_FIFOMailBox_TypeDef *to_send) {
143140
static int hyundai_fwd_hook(int bus_num, CAN_FIFOMailBox_TypeDef *to_fwd) {
144141
// forward cam to ccan and viceversa, except lkas cmd
145142
if ((bus_num == 0 || bus_num == hyundai_camera_bus) && hyundai_giraffe_switch_2) {
146-
int addr = to_fwd->RIR>>21;
147143

148-
if (addr == 832 && bus_num == hyundai_camera_bus) return -1;
149-
if (bus_num == 0) return (uint8_t)(hyundai_camera_bus);
150-
if (bus_num == hyundai_camera_bus) return (uint8_t)(0);
144+
if ((to_fwd->RIR>>21) == 832 && bus_num == hyundai_camera_bus) return -1;
145+
if (bus_num == 0) return hyundai_camera_bus;
146+
if (bus_num == hyundai_camera_bus) return 0;
151147
}
152148
return -1;
153149
}

0 commit comments

Comments
 (0)