GCC Code Coverage Report


Directory: ./
File: Fw/Log/LogPacket.cpp
Date: 2026-09-03 21:13:48
Exec Total Coverage
Lines: 42 48 87.5%
Functions: 10 10 100.0%
Branches: 17 24 70.8%

Line Branch Exec Source
1 /*
2 * LogPacket.cpp
3 *
4 * Created on: May 24, 2014
5 * Author: Timothy Canham
6 */
7
8 #include <Fw/Log/LogPacket.hpp>
9 #include <Fw/Types/Assert.hpp>
10
11 namespace Fw {
12
13
2/2
✓ Branch 14 taken 11 times.
✓ Branch 20 taken 11 times.
11 LogPacket::LogPacket() : m_id(0) {
14 11 this->m_type = ComPacketType::FW_PACKET_LOG;
15 11 }
16
17 22 LogPacket::~LogPacket() {}
18
19 22 SerializeStatus LogPacket::serializeTo(SerialBufferBase& buffer, Fw::Endianness mode) const {
20 22 SerializeStatus stat = ComPacket::serializeBase(buffer);
21
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 22 times.
22 if (stat != FW_SERIALIZE_OK) {
22 return stat;
23 }
24
25 22 stat = buffer.serializeFrom(this->m_id, mode);
26
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 22 times.
22 if (stat != FW_SERIALIZE_OK) {
27 return stat;
28 }
29
30 22 stat = buffer.serializeFrom(this->m_timeTag, mode);
31
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 22 times.
22 if (stat != FW_SERIALIZE_OK) {
32 return stat;
33 }
34
35 // We want to add data but not size for the ground software
36 22 return buffer.serializeFrom(this->m_logBuffer.getBuffAddr(), m_logBuffer.getSize(), Fw::Serialization::OMIT_LENGTH);
37 }
38
39 2 SerializeStatus LogPacket::deserializeFrom(SerialBufferBase& buffer, Fw::Endianness mode) {
40
1/1
✓ Branch 5 taken 2 times.
2 SerializeStatus stat = deserializeBase(buffer);
41
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
2 if (stat != FW_SERIALIZE_OK) {
42 return stat;
43 }
44
45
1/1
✓ Branch 10 taken 2 times.
2 stat = buffer.deserializeTo(this->m_id, mode);
46
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
2 if (stat != FW_SERIALIZE_OK) {
47 return stat;
48 }
49
50
1/1
✓ Branch 10 taken 2 times.
2 stat = buffer.deserializeTo(this->m_timeTag, mode);
51
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
2 if (stat != FW_SERIALIZE_OK) {
52 return stat;
53 }
54
55 // remainder of buffer must be telemetry value
56
1/1
✓ Branch 8 taken 2 times.
2 FwSizeType size = buffer.getDeserializeSizeLeft();
57
2/2
✓ Branch 6 taken 1 times.
✓ Branch 7 taken 1 times.
2 if (size > this->m_logBuffer.getCapacity()) {
58 1 return FW_DESERIALIZE_SIZE_MISMATCH;
59 }
60
1/1
✓ Branch 13 taken 1 times.
1 stat = buffer.deserializeTo(this->m_logBuffer.getBuffAddr(), size, Fw::Serialization::OMIT_LENGTH);
61
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 if (stat == FW_SERIALIZE_OK) {
62 // Shouldn't fail
63
1/1
✓ Branch 6 taken 1 times.
1 stat = this->m_logBuffer.setBuffLen(size);
64 1 FW_ASSERT(stat == FW_SERIALIZE_OK, static_cast<FwAssertArgType>(stat));
65 }
66 1 return stat;
67 }
68
69 22 void LogPacket::setId(FwEventIdType id) {
70 22 this->m_id = id;
71 22 }
72
73 22 void LogPacket::setLogBuffer(const LogBuffer& buffer) {
74 22 this->m_logBuffer = buffer;
75 22 }
76
77 22 void LogPacket::setTimeTag(const Fw::Time& timeTag) {
78 22 this->m_timeTag = timeTag;
79 22 }
80
81 1 FwEventIdType LogPacket::getId() {
82 1 return this->m_id;
83 }
84
85 1 Fw::Time& LogPacket::getTimeTag() {
86 1 return this->m_timeTag;
87 }
88
89 1 LogBuffer& LogPacket::getLogBuffer() {
90 1 return this->m_logBuffer;
91 }
92
93 } /* namespace Fw */
94