| Line | Branch | Exec | Source |
|---|---|---|---|
| 1 | #pragma once | ||
| 2 | |||
| 3 | #include "safety_declarations.h" | ||
| 4 | #include "safety_defaults.h" | ||
| 5 | |||
| 6 | 19719 | static bool elm327_tx_hook(const CANPacket_t *to_send) { | |
| 7 | 19719 | const int GM_CAMERA_DIAG_ADDR = 0x24B; | |
| 8 | |||
| 9 | 19719 | bool tx = true; | |
| 10 | 19719 | int addr = GET_ADDR(to_send); | |
| 11 | 19719 | int len = GET_LEN(to_send); | |
| 12 | |||
| 13 | // All ISO 15765-4 messages must be 8 bytes long | ||
| 14 |
2/2✓ Branch 0 taken 15 times.
✓ Branch 1 taken 19704 times.
|
19719 | if (len != 8) { |
| 15 | 15 | tx = false; | |
| 16 | } | ||
| 17 | |||
| 18 | // Check valid 29 bit send addresses for ISO 15765-4 | ||
| 19 | // Check valid 11 bit send addresses for ISO 15765-4 | ||
| 20 |
4/4✓ Branch 0 taken 19715 times.
✓ Branch 1 taken 4 times.
✓ Branch 2 taken 18691 times.
✓ Branch 3 taken 1024 times.
|
19719 | if ((addr != 0x18DB33F1) && ((addr & 0x1FFF00FF) != 0x18DA00F1) && |
| 21 |
6/6✓ Branch 0 taken 17667 times.
✓ Branch 1 taken 1024 times.
✓ Branch 2 taken 16627 times.
✓ Branch 3 taken 1040 times.
✓ Branch 4 taken 16368 times.
✓ Branch 5 taken 259 times.
|
18691 | ((addr & 0x1FFFFF00) != 0x600) && ((addr & 0x1FFFFF00) != 0x700) && |
| 22 | (addr != GM_CAMERA_DIAG_ADDR)) { | ||
| 23 | 16368 | tx = false; | |
| 24 | } | ||
| 25 | |||
| 26 | // GM camera uses non-standard diagnostic address, this has no control message address collisions | ||
| 27 |
3/4✓ Branch 0 taken 259 times.
✓ Branch 1 taken 19460 times.
✓ Branch 2 taken 259 times.
✗ Branch 3 not taken.
|
19719 | if ((addr == GM_CAMERA_DIAG_ADDR) && (len == 8)) { |
| 28 | // Only allow known frame types for ISO 15765-2 | ||
| 29 |
2/2✓ Branch 0 taken 191 times.
✓ Branch 1 taken 68 times.
|
259 | if ((GET_BYTE(to_send, 0) & 0xF0U) > 0x30U) { |
| 30 | 191 | tx = false; | |
| 31 | } | ||
| 32 | } | ||
| 33 | 19719 | return tx; | |
| 34 | } | ||
| 35 | |||
| 36 | // If current_board->has_obd and safety_param == 0, bus 1 is multiplexed to the OBD-II port | ||
| 37 | const safety_hooks elm327_hooks = { | ||
| 38 | .init = nooutput_init, | ||
| 39 | .rx = default_rx_hook, | ||
| 40 | .tx = elm327_tx_hook, | ||
| 41 | .fwd = default_fwd_hook, | ||
| 42 | }; | ||
| 43 |