GCC Code Coverage Report


Directory: ./
File: ApidManager.cpp
Date: 2026-09-03 22:13:20
Exec Total Coverage
Lines: 16 20 80.0%
Functions: 5 5 100.0%
Branches: 4 7 57.1%

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 2 taken 1 times.
1 ApidManager ::ApidManager(const char* const compName) : ApidManagerComponentBase(compName) {}
19
20 // ----------------------------------------------------------------------
21 // Handler implementations for typed input ports
22 // ----------------------------------------------------------------------
23
24 146 U16 ApidManager ::validateApidSeqCountIn_handler(FwIndexType portNum, const ComCfg::Apid& apid, U16 receivedSeqCount) {
25 146 const U16 expectedSequenceCount = this->getAndIncrementSeqCount(apid);
26
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 146 times.
146 if (receivedSeqCount != expectedSequenceCount) {
27 // Likely a packet was dropped or out of order
28 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 const Fw::Success insertStatus = m_apidSequences.insert(apid, this->calculateNextSeqCount(receivedSeqCount));
32 FW_ASSERT(insertStatus == Fw::Success::SUCCESS, static_cast<FwAssertArgType>(apid));
33 }
34 146 return receivedSeqCount;
35 }
36
37 668 U16 ApidManager ::getApidSeqCountIn_handler(FwIndexType portNum, const ComCfg::Apid& apid, U16 unused) {
38 668 return this->getAndIncrementSeqCount(apid);
39 }
40
41 // ----------------------------------------------------------------------
42 // Helpers
43 // ----------------------------------------------------------------------
44
45 814 U16 ApidManager ::getAndIncrementSeqCount(ComCfg::Apid::T apid) {
46 814 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 1 taken 814 times.
814 (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 2 taken 814 times.
814 const Fw::Success insertStatus = m_apidSequences.insert(apid, this->calculateNextSeqCount(seqCount));
54 814 FW_ASSERT(insertStatus == Fw::Success::SUCCESS);
55 814 return seqCount;
56 814 }
57
58 814 U16 ApidManager::calculateNextSeqCount(const U16 seqCount) const {
59 814 return static_cast<U16>((seqCount + 1) % (1 << SpacePacketSubfields::SeqCountWidth));
60 }
61
62 } // namespace Ccsds
63 } // namespace Svc
64