GCC Code Coverage Report


Directory: Fw/FilePacket/
File: DataPacket.cpp
Date: 2026-09-03 21:14:53
Exec Total Coverage
Lines: 35 41 85.4%
Functions: 6 6 100.0%
Branches: 10 16 62.5%

Line Branch Exec Source
1 // ======================================================================
2 // \title DataPacket.cpp
3 // \author bocchino
4 // \brief cpp file for FilePacket::DataPacket
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 <Fw/FilePacket/FilePacket.hpp>
14 #include <Fw/Types/Assert.hpp>
15
16 namespace Fw {
17
18 1 void FilePacket::DataPacket ::initialize(const U32 sequenceIndex,
19 const U32 byteOffset,
20 const U16 dataSize,
21 const U8* const data) {
22 1 this->m_header.initialize(FilePacket::T_DATA, sequenceIndex);
23 1 this->m_byteOffset = byteOffset;
24 1 this->m_dataSize = dataSize;
25 1 this->m_data = data;
26 1 }
27
28 1 U32 FilePacket::DataPacket ::bufferSize() const {
29 1 return static_cast<U32>(this->m_header.bufferSize() + sizeof(this->m_byteOffset) + sizeof(this->m_dataSize) +
30 1 this->m_dataSize);
31 }
32
33 1 SerializeStatus FilePacket::DataPacket ::toBuffer(Buffer& buffer) const {
34
3/3
✓ Branch 5 taken 1 times.
✓ Branch 11 taken 1 times.
✓ Branch 14 taken 1 times.
1 SerialBuffer serialBuffer(buffer.getData(), buffer.getSize());
35
1/1
✓ Branch 2 taken 1 times.
2 return this->toSerialBuffer(serialBuffer);
36 1 }
37
38 1 SerializeStatus FilePacket::DataPacket ::fromSerialBuffer(SerialBuffer& serialBuffer) {
39 1 FW_ASSERT(this->m_header.m_type == T_DATA);
40
41 1 SerializeStatus status = serialBuffer.deserializeTo(this->m_byteOffset);
42
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
1 if (status != FW_SERIALIZE_OK) {
43 return status;
44 }
45
46 1 status = serialBuffer.deserializeTo(this->m_dataSize);
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 7 not taken.
✓ Branch 8 taken 1 times.
1 if (serialBuffer.getDeserializeSizeLeft() != this->m_dataSize) {
52 return FW_DESERIALIZE_SIZE_MISMATCH;
53 }
54
55 1 U8* const addr = serialBuffer.getBuffAddr();
56 1 this->m_data = &addr[this->fixedLengthSize()];
57
58 1 return FW_SERIALIZE_OK;
59 }
60
61 1 U32 FilePacket::DataPacket ::fixedLengthSize() const {
62 1 return static_cast<U32>(this->m_header.bufferSize() + sizeof(this->m_byteOffset) + sizeof(this->m_dataSize));
63 }
64
65 1 SerializeStatus FilePacket::DataPacket ::toSerialBuffer(SerialBuffer& serialBuffer) const {
66 1 FW_ASSERT(this->m_header.m_type == T_DATA);
67
68 SerializeStatus status;
69
70 1 status = this->m_header.toSerialBuffer(serialBuffer);
71
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
1 if (status != FW_SERIALIZE_OK) {
72 return status;
73 }
74
75 1 status = serialBuffer.serializeFrom(this->m_byteOffset);
76
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
1 if (status != FW_SERIALIZE_OK) {
77 return status;
78 }
79
80 1 status = serialBuffer.serializeFrom(this->m_dataSize);
81
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
1 if (status != FW_SERIALIZE_OK) {
82 return status;
83 }
84
85 1 status = serialBuffer.pushBytes(this->m_data, this->m_dataSize);
86
87 1 return status;
88 }
89
90 } // namespace Fw
91