| Line | Branch | Decision | Exec | Source |
|---|---|---|---|---|
| 1 | #include "pch.h" | |||
| 2 | #include "can_filter.h" | |||
| 3 | #include "can_hw.h" | |||
| 4 | ||||
| 5 | #ifndef LUA_RX_MAX_FILTER_COUNT | |||
| 6 | #define LUA_RX_MAX_FILTER_COUNT 48 | |||
| 7 | #endif | |||
| 8 | ||||
| 9 | static size_t filterCount = 0; | |||
| 10 | static CanFilter filters[LUA_RX_MAX_FILTER_COUNT]; | |||
| 11 | ||||
| 12 | 4 | CanFilter* getFilterForId(size_t busIndex, int Id) { | ||
| 13 |
1/2✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
|
1/2✓ Decision 'true' taken 5 times.
✗ Decision 'false' not taken.
|
5 | for (size_t i = 0; i < filterCount; i++) { |
| 14 | 5 | auto& filter = filters[i]; | ||
| 15 | ||||
| 16 |
2/2✓ Branch 1 taken 4 times.
✓ Branch 2 taken 1 time.
|
2/2✓ Decision 'true' taken 4 times.
✓ Decision 'false' taken 1 time.
|
5 | if (filter.accept(Id)) { |
| 17 |
1/4✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
|
1/2✓ Decision 'true' taken 4 times.
✗ Decision 'false' not taken.
|
4 | if (filter.Bus == ANY_BUS || filter.Bus == (int)busIndex) { |
| 18 | 4 | return &filter; | ||
| 19 | } | |||
| 20 | } | |||
| 21 | } | |||
| 22 | ||||
| 23 | ✗ | return nullptr; | ||
| 24 | } | |||
| 25 | ||||
| 26 | 2 | void resetLuaCanRx() { | ||
| 27 | // Clear all lua filters - reloading the script will reinit them | |||
| 28 | 2 | filterCount = 0; | ||
| 29 | 2 | } | ||
| 30 | ||||
| 31 | 4 | void addLuaCanRxFilter(int32_t eid, uint32_t mask, int bus, int callback) { | ||
| 32 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
|
1/2✗ Decision 'true' not taken.
✓ Decision 'false' taken 4 times.
|
4 | if (filterCount >= LUA_RX_MAX_FILTER_COUNT) { |
| 33 | ✗ | criticalError("Too many Lua CAN RX filters"); | ||
| 34 | } | |||
| 35 | ||||
| 36 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
|
4 | efiPrintf("Added Lua CAN RX filter id 0x%x mask 0x%x with%s custom function", (unsigned int)eid, (unsigned int)mask, (callback == -1 ? "out" : "")); | |
| 37 | ||||
| 38 | 4 | filters[filterCount].Id = eid; | ||
| 39 | 4 | filters[filterCount].Mask = mask; | ||
| 40 | 4 | filters[filterCount].Bus = bus; | ||
| 41 | 4 | filters[filterCount].Callback = callback; | ||
| 42 | ||||
| 43 | 4 | filterCount++; | ||
| 44 | 4 | } | ||
| 45 |