GCC Code Coverage Report


Directory: ./
File: Ref/RecvBuffApp/RecvBuffComponentImpl.cpp
Date: 2026-09-03 22:12:29
Exec Total Coverage
Lines: 24 57 42.1%
Functions: 3 4 75.0%
Branches: 14 37 37.8%

Line Branch Exec Source
1 #include <Fw/FPrimeBasicTypes.hpp>
2 #include <Fw/Types/Assert.hpp>
3 #include <Os/Console.hpp>
4 #include <Ref/RecvBuffApp/RecvBuffComponentImpl.hpp>
5
6 #include <cstdio>
7
8 #define DEBUG_LVL 1
9
10 namespace Ref {
11
12
1/1
✓ Branch 2 taken 1 times.
1 RecvBuffImpl::RecvBuffImpl(const char* compName) : RecvBuffComponentBase(compName) {
13 1 this->m_buffsReceived = 0;
14 1 this->m_errBuffs = 0;
15 1 this->m_firstBuffReceived = 0;
16 1 this->m_sensor1 = 1000.0;
17 1 this->m_sensor2 = 10.0;
18
1/1
✓ Branch 1 taken 1 times.
1 this->m_stats.set_BuffRecv(0);
19
1/1
✓ Branch 1 taken 1 times.
1 this->m_stats.set_BuffErr(0);
20
1/1
✓ Branch 1 taken 1 times.
1 this->m_stats.set_PacketStatus(PacketRecvStatus::PACKET_STATE_NO_PACKETS);
21 1 }
22
23 2 RecvBuffImpl::~RecvBuffImpl() {}
24
25 void RecvBuffImpl::Data_handler(FwIndexType portNum, Drv::DataBuffer& buff) {
26 this->m_stats.set_BuffRecv(++this->m_buffsReceived);
27 // reset deserialization of buffer
28 buff.resetDeser();
29 // deserialize packet ID
30 U32 id = 0;
31 Fw::SerializeStatus stat = buff.deserializeTo(id);
32 FW_ASSERT(stat == Fw::FW_SERIALIZE_OK, static_cast<FwAssertArgType>(stat));
33 // deserialize data
34 U8 testData[24] = {0};
35 FwSizeType size = sizeof(testData);
36 stat = buff.deserializeTo(testData, size);
37 FW_ASSERT(stat == Fw::FW_SERIALIZE_OK, static_cast<FwAssertArgType>(stat));
38 // deserialize checksum
39 U32 csum = 0;
40 stat = buff.deserializeTo(csum);
41 FW_ASSERT(stat == Fw::FW_SERIALIZE_OK, static_cast<FwAssertArgType>(stat));
42 // if first packet, send event
43 if (not this->m_firstBuffReceived) {
44 this->log_ACTIVITY_LO_FirstPacketReceived(id);
45 this->m_stats.set_PacketStatus(PacketRecvStatus::PACKET_STATE_OK);
46 this->m_firstBuffReceived = true;
47 }
48
49 // compute checksum
50 U32 sum = 0;
51 for (U32 byte = 0; byte < size; byte++) {
52 sum += testData[byte];
53 }
54 // check checksum
55 if (sum != csum) {
56 // increment error count
57 this->m_stats.set_BuffErr(++this->m_errBuffs);
58 // send error event
59 this->log_WARNING_HI_PacketChecksumError(id);
60 // update stats
61 this->m_stats.set_PacketStatus(PacketRecvStatus::PACKET_STATE_ERRORS);
62 }
63 // update sensor values
64 this->m_sensor1 += 5.0;
65 this->m_sensor2 += 1.2;
66 // update channels
67 this->tlmWrite_Sensor1(this->m_sensor1);
68 this->tlmWrite_Sensor2(this->m_sensor2);
69 this->tlmWrite_PktState(this->m_stats);
70 }
71
72 4 void RecvBuffImpl::parameterUpdated(FwPrmIdType id) {
73
1/1
✓ Branch 1 taken 4 times.
4 this->log_ACTIVITY_LO_BuffRecvParameterUpdated(id);
74
1/1
✓ Branch 1 taken 4 times.
4 Fw::ParamValid valid;
75
2/3
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
4 switch (id) {
76 2 case PARAMID_PARAMETER1: {
77
1/1
✓ Branch 1 taken 2 times.
2 U32 val = this->paramGet_parameter1(valid);
78
2/2
✓ Branch 1 taken 2 times.
✓ Branch 4 taken 2 times.
2 this->tlmWrite_Parameter1(val);
79 2 break;
80 }
81 2 case PARAMID_PARAMETER2: {
82
1/1
✓ Branch 1 taken 2 times.
2 I16 val = this->paramGet_parameter2(valid);
83
2/2
✓ Branch 1 taken 2 times.
✓ Branch 4 taken 2 times.
2 this->tlmWrite_Parameter2(val);
84 2 break;
85 }
86 default:
87 FW_ASSERT(0, id);
88 break;
89 }
90 4 }
91
92 } // namespace Ref
93