GCC Code Coverage Report


Directory: Svc/Ccsds/ApidManager/
File: ApidManager.cpp
Date: 2026-09-03 21:16:22
Exec Total Coverage
Lines: 20 20 100.0%
Functions: 5 5 100.0%
Branches: 7 7 100.0%

Line Branch Exec Source
1 // ======================================================================
2 // \title ApidManager.cpp
3 // \author thomas-bc
4 // \brief cpp file for ApidManager component implementation class
5 // ======================================================================
6
7 #include "Svc/Ccsds/ApidManager/ApidManager.hpp"
8 #include "Svc/Ccsds/Types/FppConstantsAc.hpp"
9
10 namespace Svc {
11
12 namespace Ccsds {
13
14 // ----------------------------------------------------------------------
15 // Component construction and destruction
16 // ----------------------------------------------------------------------
17
18
1/1
✓ Branch 10 taken 3 times.
3 ApidManager ::ApidManager(const char* const compName) : ApidManagerComponentBase(compName) {}
19
20 // ----------------------------------------------------------------------
21 // Handler implementations for typed input ports
22 // ----------------------------------------------------------------------
23
24 5085 U16 ApidManager ::validateApidSeqCountIn_handler(FwIndexType portNum, const ComCfg::Apid& apid, U16 receivedSeqCount) {
25 5085 const U16 expectedSequenceCount = this->getAndIncrementSeqCount(apid);
26
2/2
✓ Branch 0 taken 2506 times.
✓ Branch 1 taken 2579 times.
5085 if (receivedSeqCount != expectedSequenceCount) {
27 // Likely a packet was dropped or out of order
28
1/1
✓ Branch 5 taken 2506 times.
2506 this->log_WARNING_LO_UnexpectedSequenceCount(receivedSeqCount, expectedSequenceCount);
29 // Sync onboard count to what was received so counting can keep going. Insert cannot fail:
30 // getAndIncrementSeqCount above inserted the APID already (asserting on failure)
31
1/1
✓ Branch 16 taken 2506 times.
2506 const Fw::Success insertStatus = m_apidSequences.insert(apid, this->calculateNextSeqCount(receivedSeqCount));
32 2506 FW_ASSERT(insertStatus == Fw::Success::SUCCESS, static_cast<FwAssertArgType>(apid));
33 2506 }
34 5085 return receivedSeqCount;
35 }
36
37 4920 U16 ApidManager ::getApidSeqCountIn_handler(FwIndexType portNum, const ComCfg::Apid& apid, U16 unused) {
38 4920 return this->getAndIncrementSeqCount(apid);
39 }
40
41 // ----------------------------------------------------------------------
42 // Helpers
43 // ----------------------------------------------------------------------
44
45 10005 U16 ApidManager ::getAndIncrementSeqCount(ComCfg::Apid::T apid) {
46 10005 U16 seqCount = 0;
47 // Find current sequence count if APID is tracked; otherwise default to 0 (first count for a new APID)
48
1/1
✓ Branch 4 taken 10005 times.
10005 (void)m_apidSequences.find(apid, seqCount);
49 // Store the next sequence count for this APID. If the APID is not yet tracked, this
50 // also registers it.
51 // Insert should never fail because the apid should be a valid enum value and
52 // the table should be large enough to hold all the enum values
53
1/1
✓ Branch 10 taken 10005 times.
10005 const Fw::Success insertStatus = m_apidSequences.insert(apid, this->calculateNextSeqCount(seqCount));
54 10005 FW_ASSERT(insertStatus == Fw::Success::SUCCESS);
55 10005 return seqCount;
56 10005 }
57
58 12511 U16 ApidManager::calculateNextSeqCount(const U16 seqCount) const {
59 12511 return static_cast<U16>((seqCount + 1) % (1 << SpacePacketSubfields::SeqCountWidth));
60 }
61
62 } // namespace Ccsds
63 } // namespace Svc
64