GCC Code Coverage Report


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