GCC Code Coverage Report


Directory: ./
File: Fw/FilePacket/EndPacket.cpp
Date: 2026-09-03 22:12:29
Exec Total Coverage
Lines: 10 34 29.4%
Functions: 2 7 28.6%
Branches: 4 14 28.6%

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