Skip to content

Commit

Permalink
expose TX messages blocked by safety hook (#742)
Browse files Browse the repository at this point in the history
* expose tx messages blocked by safety hook

* update unit tests

* preserve bus of original message

* update tests
  • Loading branch information
gregjhogan authored Oct 18, 2021
1 parent c5adfa4 commit 80260c6
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
6 changes: 5 additions & 1 deletion board/drivers/can_common.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ typedef struct {
} can_ring;

#define CAN_BUS_RET_FLAG 0x80U
#define CAN_BUS_NUM_MASK 0x7FU
#define CAN_BUS_BLK_FLAG 0x40U
#define CAN_BUS_NUM_MASK 0x3FU

#define BUS_MAX 4U

Expand Down Expand Up @@ -235,6 +236,9 @@ void can_send(CAN_FIFOMailBox_TypeDef *to_push, uint8_t bus_number, bool skip_tx
process_can(CAN_NUM_FROM_BUS_NUM(bus_number));
}
}
} else {
to_push->RDTR = (to_push->RDTR & 0xFFFF000FU) | ((CAN_BUS_RET_FLAG | CAN_BUS_BLK_FLAG | bus_number) << 4);
can_send_errs += can_push(&can_rx_q, to_push) ? 0U : 1U;
}
}

Expand Down
4 changes: 3 additions & 1 deletion tests/automated/3_usb_to_can.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,9 @@ def test_safety_nooutput(p):
# confirm receive nothing
time.sleep(0.05)
r = p.can_recv()
assert len(r) == 0
# bus 192 is messages blocked by TX safety hook on bus 0
assert len([x for x in r if x[3] != 192]) == 0
assert len([x for x in r if x[3] == 192]) == 1

@test_all_pandas
@panda_connect_and_init
Expand Down

0 comments on commit 80260c6

Please sign in to comment.