GCC Code Coverage Report


Directory: ./
File: Fw/FilePacket/EndPacket.cpp
Date: 2026-09-03 21:13:48
Exec Total Coverage
Lines: 30 34 88.2%
Functions: 7 7 100.0%
Branches: 10 14 71.4%

Line Branch Exec Source
1 // ======================================================================
2 // \title EndPacket.cpp
3 // \author bocchino
4 // \brief cpp file for FilePacket::EndPacket
5 //
6 // \copyright
7 // Copyright 2009-2016, by the California Institute of Technology.
8 // ALL RIGHTS RESERVED. United States Government Sponsorship
9 // acknowledged.
10 //
11 // ======================================================================
12
13 #include <cstring>
14
15 #include <Fw/FilePacket/FilePacket.hpp>
16 #include <Fw/Types/Assert.hpp>
17
18 namespace Fw {
19
20 5 void FilePacket::EndPacket ::initialize(const U32 sequenceIndex, const CFDP::Checksum& checksum) {
21 5 this->m_header.initialize(FilePacket::T_END, sequenceIndex);
22 5 this->setChecksum(checksum);
23 5 }
24
25 8 U32 FilePacket::EndPacket ::bufferSize() const {
26 8 return static_cast<U32>(this->m_header.bufferSize() + sizeof(this->m_checksumValue));
27 }
28
29 8 SerializeStatus FilePacket::EndPacket ::toBuffer(Buffer& buffer) const {
30
3/3
✓ Branch 5 taken 8 times.
✓ Branch 11 taken 8 times.
✓ Branch 14 taken 8 times.
8 SerialBuffer serialBuffer(buffer.getData(), buffer.getSize());
31
1/1
✓ Branch 2 taken 8 times.
16 return this->toSerialBuffer(serialBuffer);
32 8 }
33
34 8 void FilePacket::EndPacket ::setChecksum(const CFDP::Checksum& checksum) {
35 8 this->m_checksumValue = checksum.getValue();
36 8 }
37
38 8 void FilePacket::EndPacket ::getChecksum(CFDP::Checksum& checksum) const {
39
1/1
✓ Branch 4 taken 8 times.
8 CFDP::Checksum c(this->m_checksumValue);
40
1/1
✓ Branch 2 taken 8 times.
8 checksum = c;
41 16 }
42
43 8 SerializeStatus FilePacket::EndPacket ::fromSerialBuffer(SerialBuffer& serialBuffer) {
44 8 FW_ASSERT(this->m_header.m_type == T_END);
45
46 8 const SerializeStatus status = serialBuffer.deserializeTo(this->m_checksumValue);
47
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8 times.
8 if (status != FW_SERIALIZE_OK) {
48 return status;
49 }
50
51
1/2
✗ Branch 5 not taken.
✓ Branch 6 taken 8 times.
8 if (serialBuffer.getDeserializeSizeLeft() != 0) {
52 return FW_DESERIALIZE_SIZE_MISMATCH;
53 }
54
55 8 return status;
56 }
57
58 8 SerializeStatus FilePacket::EndPacket ::toSerialBuffer(SerialBuffer& serialBuffer) const {
59 8 FW_ASSERT(this->m_header.m_type == T_END);
60
61 SerializeStatus status;
62
63 8 status = this->m_header.toSerialBuffer(serialBuffer);
64
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8 times.
8 if (status != FW_SERIALIZE_OK) {
65 return status;
66 }
67
68 8 status = serialBuffer.serializeFrom(this->m_checksumValue);
69
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8 times.
8 if (status != FW_SERIALIZE_OK) {
70 return status;
71 }
72
73 8 return FW_SERIALIZE_OK;
74 }
75
76 } // namespace Fw
77