Line | Branch | Exec | Source |
---|---|---|---|
1 | #pragma once | ||
2 | |||
3 | #include "safety_declarations.h" | ||
4 | |||
5 | 2 | static void body_rx_hook(const CANPacket_t *to_push) { | |
6 | // body is never at standstill | ||
7 | 2 | vehicle_moving = true; | |
8 | |||
9 |
2/2✓ Branch 0 taken 1 times.
✓ Branch 1 taken 1 times.
|
2 | if (GET_ADDR(to_push) == 0x201U) { |
10 | 1 | controls_allowed = true; | |
11 | } | ||
12 | 2 | } | |
13 | |||
14 | 7 | static bool body_tx_hook(const CANPacket_t *to_send) { | |
15 | 7 | bool tx = true; | |
16 | 7 | int addr = GET_ADDR(to_send); | |
17 | 7 | int len = GET_LEN(to_send); | |
18 | |||
19 |
4/4✓ Branch 0 taken 5 times.
✓ Branch 1 taken 2 times.
✓ Branch 2 taken 4 times.
✓ Branch 3 taken 1 times.
|
7 | if (!controls_allowed && (addr != 0x1)) { |
20 | 4 | tx = false; | |
21 | } | ||
22 | |||
23 | // Allow going into CAN flashing mode for base & knee even if controls are not allowed | ||
24 |
6/6✓ Branch 0 taken 4 times.
✓ Branch 1 taken 3 times.
✓ Branch 2 taken 3 times.
✓ Branch 3 taken 1 times.
✓ Branch 4 taken 2 times.
✓ Branch 5 taken 4 times.
|
7 | bool flash_msg = ((addr == 0x250) || (addr == 0x350)) && (len == 8); |
25 |
6/8✓ Branch 0 taken 5 times.
✓ Branch 1 taken 2 times.
✓ Branch 3 taken 2 times.
✓ Branch 4 taken 3 times.
✓ Branch 6 taken 2 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 2 times.
✗ Branch 9 not taken.
|
7 | if (!controls_allowed && (GET_BYTES(to_send, 0, 4) == 0xdeadfaceU) && (GET_BYTES(to_send, 4, 4) == 0x0ab00b1eU) && flash_msg) { |
26 | 2 | tx = true; | |
27 | } | ||
28 | |||
29 | 7 | return tx; | |
30 | } | ||
31 | |||
32 | 9 | static safety_config body_init(uint16_t param) { | |
33 | static RxCheck body_rx_checks[] = { | ||
34 | {.msg = {{0x201, 0, 8, .check_checksum = false, .max_counter = 0U, .frequency = 100U}, { 0 }, { 0 }}}, | ||
35 | }; | ||
36 | |||
37 | static const CanMsg BODY_TX_MSGS[] = {{0x250, 0, 8}, {0x250, 0, 6}, {0x251, 0, 5}, // body | ||
38 | {0x350, 0, 8}, {0x350, 0, 6}, {0x351, 0, 5}, // knee | ||
39 | {0x1, 0, 8}}; // CAN flasher | ||
40 | |||
41 | UNUSED(param); | ||
42 | 9 | return BUILD_SAFETY_CFG(body_rx_checks, BODY_TX_MSGS); | |
43 | } | ||
44 | |||
45 | const safety_hooks body_hooks = { | ||
46 | .init = body_init, | ||
47 | .rx = body_rx_hook, | ||
48 | .tx = body_tx_hook, | ||
49 | .fwd = default_fwd_hook, | ||
50 | }; | ||
51 |