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, mode);
26  if (stat != FW_SERIALIZE_OK) {
27  return stat;
28  }
29 
30  stat = buffer.serializeFrom(this->m_timeTag, mode);
31  if (stat != FW_SERIALIZE_OK) {
32  return stat;
33  }
34 
35  // We want to add data but not size for the ground software
37 }
38 
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();
58  if (stat == FW_SERIALIZE_OK) {
59  // Shouldn't fail
60  stat = this->m_logBuffer.setBuffLen(size);
61  FW_ASSERT(stat == FW_SERIALIZE_OK, static_cast<FwAssertArgType>(stat));
62  }
63  return stat;
64 }
65 
67  this->m_id = id;
68 }
69 
70 void LogPacket::setLogBuffer(const LogBuffer& buffer) {
71  this->m_logBuffer = buffer;
72 }
73 
74 void LogPacket::setTimeTag(const Fw::Time& timeTag) {
75  this->m_timeTag = timeTag;
76 }
77 
79  return this->m_id;
80 }
81 
83  return this->m_timeTag;
84 }
85 
87  return this->m_logBuffer;
88 }
89 
90 } /* namespace Fw */
Serialization/Deserialization operation was successful.
LogBuffer & getLogBuffer()
Definition: LogPacket.cpp:86
U8 * getBuffAddr()
Get buffer address for data filling (non-const version)
Definition: LogBuffer.cpp:42
PlatformSizeType FwSizeType
void setTimeTag(const Fw::Time &timeTag)
Definition: LogPacket.cpp:74
Serializable::SizeType getSize() const override
Get current buffer size.
ComPacketType m_type
Definition: ComPacket.hpp:28
SerializeStatus deserializeBase(SerialBufferBase &buffer)
Definition: ComPacket.cpp:20
Fw::Time m_timeTag
Definition: LogPacket.hpp:36
void setId(FwEventIdType id)
Definition: LogPacket.cpp:66
virtual SerializeStatus serializeFrom(U8 val, Endianness mode=Endianness::BIG)=0
Serialize an 8-bit unsigned integer value.
SerializeStatus
forward declaration for string
virtual SerializeStatus deserializeTo(U8 &val, Endianness mode=Endianness::BIG)=0
Deserialize an 8-bit unsigned integer value.
FwIdType FwEventIdType
The type of an event identifier.
Omit length from serialization.
Fw::Time & getTimeTag()
Definition: LogPacket.cpp:82
FwEventIdType m_id
Definition: LogPacket.hpp:35
virtual Serializable::SizeType getDeserializeSizeLeft() const =0
Get remaining deserialization buffer size.
void setLogBuffer(const LogBuffer &buffer)
Definition: LogPacket.cpp:70
LogBuffer m_logBuffer
Definition: LogPacket.hpp:37
SerializeStatus serializeBase(SerialBufferBase &buffer) const
Definition: ComPacket.cpp:16
virtual ~LogPacket()
Definition: LogPacket.cpp:17
SerializeStatus setBuffLen(Serializable::SizeType length) override
Set buffer length manually.
Implementation of malloc based allocator.
Endianness
FwEventIdType getId()
Definition: LogPacket.cpp:78
SerializeStatus deserializeFrom(SerialBufferBase &buffer, Fw::Endianness mode=Fw::Endianness::BIG) override
Deserialize the contents of this object from a buffer.
Definition: LogPacket.cpp:39
SerializeStatus serializeTo(SerialBufferBase &buffer, Fw::Endianness mode=Fw::Endianness::BIG) const override
serialize contents
Definition: LogPacket.cpp:19
#define FW_ASSERT(...)
Definition: Assert.hpp:14