Hyundai safety: simplifications

master
Riccardo 2018-09-05 16:08:42 -07:00
parent 56794d6e1a
commit 1c0ffd1a4d
1 changed files with 5 additions and 9 deletions

View File

@ -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
@ -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;
}