F´ Flight Software - C/C++ Documentation
A framework for building embedded system applications to NASA flight quality standards.
LogPacket.cpp
Go to the documentation of this file.
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 LogPacket::LogPacket() : m_id(0) {
14  this->m_type = ComPacketType::FW_PACKET_LOG;
15 }
16 
18 
21  if (stat != FW_SERIALIZE_OK) {
22  return stat;
23  }
24 
25  stat = buffer.serializeFrom(this->m_id);
26  if (stat != FW_SERIALIZE_OK) {
27  return stat;
28  }
29 
30  stat = buffer.serializeFrom(this->m_timeTag);
31  if (stat != FW_SERIALIZE_OK) {
32  return stat;
33  }
34 
35  // We want to add data but not size for the ground software
38 }
39 
41  SerializeStatus stat = deserializeBase(buffer);
42  if (stat != FW_SERIALIZE_OK) {
43  return stat;
44  }
45 
46  stat = buffer.deserializeTo(this->m_id);
47  if (stat != FW_SERIALIZE_OK) {
48  return stat;
49  }
50 
51  stat = buffer.deserializeTo(this->m_timeTag);
52  if (stat != FW_SERIALIZE_OK) {
53  return stat;
54  }
55 
56  // remainder of buffer must be telemetry value
57  FwSizeType size = buffer.getBuffLeft();
59  if (stat == FW_SERIALIZE_OK) {
60  // Shouldn't fail
61  stat = this->m_logBuffer.setBuffLen(size);
62  FW_ASSERT(stat == FW_SERIALIZE_OK, static_cast<FwAssertArgType>(stat));
63  }
64  return stat;
65 }
66 
68  this->m_id = id;
69 }
70 
71 void LogPacket::setLogBuffer(const LogBuffer& buffer) {
72  this->m_logBuffer = buffer;
73 }
74 
75 void LogPacket::setTimeTag(const Fw::Time& timeTag) {
76  this->m_timeTag = timeTag;
77 }
78 
80  return this->m_id;
81 }
82 
84  return this->m_timeTag;
85 }
86 
88  return this->m_logBuffer;
89 }
90 
91 } /* namespace Fw */
Serialization/Deserialization operation was successful.
SerializeStatus serializeTo(SerializeBufferBase &buffer) const override
serialize contents
Definition: LogPacket.cpp:19
LogBuffer & getLogBuffer()
Definition: LogPacket.cpp:87
U8 * getBuffAddr()
gets buffer address for data filling
Definition: LogBuffer.cpp:38
PlatformSizeType FwSizeType
void setTimeTag(const Fw::Time &timeTag)
Definition: LogPacket.cpp:75
ComPacketType m_type
Definition: ComPacket.hpp:28
Fw::Time m_timeTag
Definition: LogPacket.hpp:35
void setId(FwEventIdType id)
Definition: LogPacket.cpp:67
SerializeStatus
forward declaration for string
FwIdType FwEventIdType
The type of an event identifier.
Serializable::SizeType getBuffLength() const
returns current buffer size
SerializeStatus serializeBase(SerializeBufferBase &buffer) const
Definition: ComPacket.cpp:16
Serializable::SizeType getBuffLeft() const
returns how much deserialization buffer is left
Fw::Time & getTimeTag()
Definition: LogPacket.cpp:83
FwEventIdType m_id
Definition: LogPacket.hpp:34
void setLogBuffer(const LogBuffer &buffer)
Definition: LogPacket.cpp:71
SerializeStatus deserializeBase(SerializeBufferBase &buffer)
Definition: ComPacket.cpp:20
LogBuffer m_logBuffer
Definition: LogPacket.hpp:36
Omit length from serialization.
virtual ~LogPacket()
Definition: LogPacket.cpp:17
SerializeStatus serializeFrom(U8 val)
serialize 8-bit unsigned int
FwEventIdType getId()
Definition: LogPacket.cpp:79
#define FW_ASSERT(...)
Definition: Assert.hpp:14
SerializeStatus deserializeFrom(SerializeBufferBase &buffer) override
deserialize contents from buffer
Definition: LogPacket.cpp:40
SerializeStatus setBuffLen(Serializable::SizeType length)
sets buffer length manually after filling with data
SerializeStatus deserializeTo(U8 &val)
deserialize 8-bit unsigned int