Skip to content

Commit

Permalink
skip tx_hook if a message is forwarded (#379)
Browse files Browse the repository at this point in the history
  • Loading branch information
rbiasini authored Nov 14, 2019
1 parent df2ff04 commit 4d1edc0
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
8 changes: 4 additions & 4 deletions board/drivers/can.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ void can_set_forwarding(int from, int to);

void can_init(uint8_t can_number);
void can_init_all(void);
void can_send(CAN_FIFOMailBox_TypeDef *to_push, uint8_t bus_number);
void can_send(CAN_FIFOMailBox_TypeDef *to_push, uint8_t bus_number, bool skip_tx_hook);
bool can_pop(can_ring *q, CAN_FIFOMailBox_TypeDef *elem);

// Ignition detected from CAN meessages
Expand Down Expand Up @@ -394,7 +394,7 @@ void can_rx(uint8_t can_number) {
to_send.RDTR = to_push.RDTR;
to_send.RDLR = to_push.RDLR;
to_send.RDHR = to_push.RDHR;
can_send(&to_send, bus_fwd_num);
can_send(&to_send, bus_fwd_num, true);
}

safety_rx_hook(&to_push);
Expand All @@ -420,8 +420,8 @@ void CAN3_TX_IRQHandler(void) { process_can(2); }
void CAN3_RX0_IRQHandler(void) { can_rx(2); }
void CAN3_SCE_IRQHandler(void) { can_sce(CAN3); }

void can_send(CAN_FIFOMailBox_TypeDef *to_push, uint8_t bus_number) {
if (safety_tx_hook(to_push) != 0) {
void can_send(CAN_FIFOMailBox_TypeDef *to_push, uint8_t bus_number, bool skip_tx_hook) {
if (skip_tx_hook || safety_tx_hook(to_push) != 0) {
if (bus_number < BUS_MAX) {
// add CAN packet to send queue
// bus number isn't passed through
Expand Down
2 changes: 1 addition & 1 deletion board/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@ void usb_cb_ep3_out(void *usbdata, int len, bool hardwired) {
to_push.RIR = d32[dpkt];

uint8_t bus_number = (to_push.RDTR >> 4) & CAN_BUS_NUM_MASK;
can_send(&to_push, bus_number);
can_send(&to_push, bus_number, false);
}
}

Expand Down

0 comments on commit 4d1edc0

Please sign in to comment.