Skip to content

Commit

Permalink
Hyundai safety: simplifications
Browse files Browse the repository at this point in the history
  • Loading branch information
rbiasini committed Sep 5, 2018
1 parent 56794d6 commit 1c0ffd1
Showing 1 changed file with 5 additions and 9 deletions.
14 changes: 5 additions & 9 deletions board/safety/safety_hyundai.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,8 @@ static void hyundai_rx_hook(CAN_FIFOMailBox_TypeDef *to_push) {
}

// Find out which bus the camera is on
if (bus == 1 && addr == 832) {
hyundai_camera_bus = 1;
}
if (bus == 2 && addr == 832) {
hyundai_camera_bus = 2;
if (addr == 832) {
hyundai_camera_bus = bus;
}

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

if (addr == 832 && bus_num == hyundai_camera_bus) return -1;
if (bus_num == 0) return (uint8_t)(hyundai_camera_bus);
if (bus_num == hyundai_camera_bus) return (uint8_t)(0);
if ((to_fwd->RIR>>21) == 832 && bus_num == hyundai_camera_bus) return -1;
if (bus_num == 0) return hyundai_camera_bus;
if (bus_num == hyundai_camera_bus) return 0;
}
return -1;
}
Expand Down

0 comments on commit 1c0ffd1

Please sign in to comment.