mirror of https://github.com/commaai/panda.git
Hyundai: added initial safety files which just fwd bus 0 to 2 and viceversa, except for lkas msgs
This commit is contained in:
parent
905a93583a
commit
594863cea3
|
@ -60,6 +60,7 @@ int controls_allowed = 0;
|
|||
#include "safety/safety_gm.h"
|
||||
#include "safety/safety_ford.h"
|
||||
#include "safety/safety_cadillac.h"
|
||||
#include "safety/safety_hyundai.h"
|
||||
#include "safety/safety_elm327.h"
|
||||
|
||||
const safety_hooks *current_hooks = &nooutput_hooks;
|
||||
|
@ -98,6 +99,7 @@ typedef struct {
|
|||
#define SAFETY_HONDA_BOSCH 4
|
||||
#define SAFETY_FORD 5
|
||||
#define SAFETY_CADILLAC 6
|
||||
#define SAFETY_HYUNDAI 7
|
||||
#define SAFETY_TOYOTA_IPAS 0x1335
|
||||
#define SAFETY_TOYOTA_NOLIMITS 0x1336
|
||||
#define SAFETY_ALLOUTPUT 0x1337
|
||||
|
@ -111,6 +113,7 @@ const safety_hook_config safety_hook_registry[] = {
|
|||
{SAFETY_GM, &gm_hooks},
|
||||
{SAFETY_FORD, &ford_hooks},
|
||||
{SAFETY_CADILLAC, &cadillac_hooks},
|
||||
{SAFETY_HYUNDAI, &hyundai_hooks},
|
||||
{SAFETY_TOYOTA_NOLIMITS, &toyota_nolimits_hooks},
|
||||
#ifdef PANDA
|
||||
{SAFETY_TOYOTA_IPAS, &toyota_ipas_hooks},
|
||||
|
|
|
@ -0,0 +1,36 @@
|
|||
int hyundai_giraffe_switch_1 = 0; // is giraffe switch 1 high?
|
||||
|
||||
|
||||
static void hyundai_rx_hook(CAN_FIFOMailBox_TypeDef *to_push) {
|
||||
|
||||
int bus = (to_push->RDTR >> 4) & 0xF;
|
||||
// 832 is lkas cmd. If it is on bus 0, then giraffe switch 1 is high
|
||||
if ((to_push->RIR>>21) == 832 && (bus == 0)) {
|
||||
hyundai_giraffe_switch_1 = 1;
|
||||
}
|
||||
}
|
||||
|
||||
static void hyundai_init(int16_t param) {
|
||||
controls_allowed = 0;
|
||||
hyundai_giraffe_switch_1 = 0;
|
||||
}
|
||||
|
||||
static int hyundai_fwd_hook(int bus_num, CAN_FIFOMailBox_TypeDef *to_fwd) {
|
||||
|
||||
// forward cam to radar and viceversa if car is dsu-less, except lkas cmd and hud
|
||||
if ((bus_num == 0 || bus_num == 2) && !hyundai_giraffe_switch_1) {
|
||||
int addr = to_fwd->RIR>>21;
|
||||
bool is_lkas_msg = (addr == 832 || addr == 1342) && bus_num == 2;
|
||||
return is_lkas_msg? -1 : (uint8_t)(~bus_num & 0x2);
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
const safety_hooks hyundai_hooks = {
|
||||
.init = hyundai_init,
|
||||
.rx = hyundai_rx_hook,
|
||||
.tx = nooutput_tx_hook,
|
||||
.tx_lin = nooutput_tx_lin_hook,
|
||||
.ignition = default_ign_hook,
|
||||
.fwd = hyundai_fwd_hook,
|
||||
};
|
Loading…
Reference in New Issue