add panda safety

This commit is contained in:
George Hotz 2017-05-01 20:22:19 -07:00
parent 16f7a4e0fb
commit 2969e509c7
4 changed files with 27 additions and 1 deletions

View File

@ -7,6 +7,7 @@ OBJDUMP = arm-none-eabi-objdump
ifeq ($(RELEASE),1)
CERT = ../../pandaextra/certs/release
CFLAGS += "-DPANDA_SAFETY"
else
CERT = ../certs/debug
CFLAGS += "-DALLOW_DEBUG"

View File

@ -82,3 +82,7 @@ int safety_tx_hook(CAN_FIFOMailBox_TypeDef *to_send) {
return 1;
}
int safety_tx_lin_hook(int lin_num, uint8_t *data, int len) {
return 1;
}

View File

@ -315,7 +315,13 @@ inline int putc(uart_ring *q, char elem) {
void safety_rx_hook(CAN_FIFOMailBox_TypeDef *to_push);
int safety_tx_hook(CAN_FIFOMailBox_TypeDef *to_send);
int safety_tx_lin_hook(int lin_num, uint8_t *data, int len);
#ifdef PANDA_SAFETY
#include "panda_safety.h"
#else
#include "honda_safety.h"
#endif
// ***************************** CAN *****************************
@ -482,7 +488,9 @@ void usb_cb_ep2_out(uint8_t *usbdata, int len) {
if (len == 0) return;
uart_ring *ur = get_ring_by_number(usbdata[0]);
if (!ur) return;
for (i = 1; i < len; i++) while (!putc(ur, usbdata[i]));
if ((usbdata[0] < 2) || safety_tx_lin_hook(usbdata[0]-2, usbdata+1, len-1)) {
for (i = 1; i < len; i++) while (!putc(ur, usbdata[i]));
}
}
// send on CAN

13
board/panda_safety.h Normal file
View File

@ -0,0 +1,13 @@
// pandas by default do not allow sending in this firmware
void safety_rx_hook(CAN_FIFOMailBox_TypeDef *to_push) {
}
int safety_tx_hook(CAN_FIFOMailBox_TypeDef *to_send) {
return 0;
}
int safety_tx_lin_hook(int lin_num, uint8_t *data, int len) {
return 0;
}