GCC Code Coverage Report


Directory: ./
File: firmware/controllers/can/can_listener.h
Date: 2025-12-07 16:27:22
Coverage Exec Excl Total
Lines: 69.2% 9 0 13
Functions: 60.0% 3 0 5
Branches: 75.0% 3 0 4
Decisions: 100.0% 2 - 2

Line Branch Decision Exec Source
1 /**
2 * @file can_listener.h
3 *
4 * @date March 31, 2021
5 * @author Matthew Kennedy, (c) 2021
6 */
7
8 #pragma once
9
10 #include "can.h"
11
12 class CanListener {
13 public:
14 12 CanListener(uint32_t id)
15 12 : m_id(id)
16 {
17 12 }
18
19 14 CanListener* processFrame(const size_t busIndex, const CANRxFrame& frame, efitick_t nowNt) {
20
2/2
✓ Branch 1 taken 13 times.
✓ Branch 2 taken 1 time.
2/2
✓ Decision 'true' taken 13 times.
✓ Decision 'false' taken 1 time.
14 if (acceptFrame(busIndex, frame)) {
21 13 decodeFrame(frame, nowNt);
22 }
23
24 13 return m_next;
25 }
26
27 uint32_t getId() {
28 return m_id;
29 }
30
31 void setNext(CanListener* next) {
32 m_next = next;
33 }
34
35 virtual CanListener* request() {
36 // NOP and return next in list
37 return getNext();
38 }
39
40 CanListener* getNext() const {
41 return m_next;
42 }
43
44 // Return true if the provided frame should be accepted for processing by the listener.
45 // Override if you need more complex logic than comparing to a single ID.
46 2 virtual bool acceptFrame(const size_t busIndex, const CANRxFrame& frame) const {
47 /* accept from all buses */
48 (void)busIndex;
49
50
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
2 return CAN_ID(frame) == m_id;
51 }
52
53 protected:
54 virtual void decodeFrame(const CANRxFrame& frame, efitick_t nowNt) = 0;
55
56 private:
57 CanListener* m_next = nullptr;
58
59 const uint32_t m_id;
60 };
61