GCC Code Coverage Report


Directory: Fw/FilePacket/
File: EndPacket.cpp
Date: 2026-09-03 21:14:53
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 1 void FilePacket::EndPacket ::initialize(const U32 sequenceIndex, const CFDP::Checksum& checksum) {
21 1 this->m_header.initialize(FilePacket::T_END, sequenceIndex);
22 1 this->setChecksum(checksum);
23 1 }
24
25 1 U32 FilePacket::EndPacket ::bufferSize() const {
26 1 return static_cast<U32>(this->m_header.bufferSize() + sizeof(this->m_checksumValue));
27 }
28
29 1 SerializeStatus FilePacket::EndPacket ::toBuffer(Buffer& buffer) const {
30
3/3
✓ Branch 5 taken 1 times.
✓ Branch 11 taken 1 times.
✓ Branch 14 taken 1 times.
1 SerialBuffer serialBuffer(buffer.getData(), buffer.getSize());
31
1/1
✓ Branch 2 taken 1 times.
2 return this->toSerialBuffer(serialBuffer);
32 1 }
33
34 1 void FilePacket::EndPacket ::setChecksum(const CFDP::Checksum& checksum) {
35 1 this->m_checksumValue = checksum.getValue();
36 1 }
37
38 2 void FilePacket::EndPacket ::getChecksum(CFDP::Checksum& checksum) const {
39
1/1
✓ Branch 4 taken 2 times.
2 CFDP::Checksum c(this->m_checksumValue);
40
1/1
✓ Branch 2 taken 2 times.
2 checksum = c;
41 4 }
42
43 1 SerializeStatus FilePacket::EndPacket ::fromSerialBuffer(SerialBuffer& serialBuffer) {
44 1 FW_ASSERT(this->m_header.m_type == T_END);
45
46 1 const SerializeStatus status = serialBuffer.deserializeTo(this->m_checksumValue);
47
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
1 if (status != FW_SERIALIZE_OK) {
48 return status;
49 }
50
51
1/2
✗ Branch 5 not taken.
✓ Branch 6 taken 1 times.
1 if (serialBuffer.getDeserializeSizeLeft() != 0) {
52 return FW_DESERIALIZE_SIZE_MISMATCH;
53 }
54
55 1 return status;
56 }
57
58 1 SerializeStatus FilePacket::EndPacket ::toSerialBuffer(SerialBuffer& serialBuffer) const {
59 1 FW_ASSERT(this->m_header.m_type == T_END);
60
61 SerializeStatus status;
62
63 1 status = this->m_header.toSerialBuffer(serialBuffer);
64
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
1 if (status != FW_SERIALIZE_OK) {
65 return status;
66 }
67
68 1 status = serialBuffer.serializeFrom(this->m_checksumValue);
69
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
1 if (status != FW_SERIALIZE_OK) {
70 return status;
71 }
72
73 1 return FW_SERIALIZE_OK;
74 }
75
76 } // namespace Fw
77