F´ Flight Software - C/C++ Documentation  devel
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 = FW_PACKET_LOG;
15  }
16 
18  }
19 
21 
23  if (stat != FW_SERIALIZE_OK) {
24  return stat;
25  }
26 
27  stat = buffer.serialize(this->m_id);
28  if (stat != FW_SERIALIZE_OK) {
29  return stat;
30  }
31 
32  stat = buffer.serialize(this->m_timeTag);
33  if (stat != FW_SERIALIZE_OK) {
34  return stat;
35  }
36 
37  // We want to add data but not size for the ground software
38  return buffer.serialize(this->m_logBuffer.getBuffAddr(),m_logBuffer.getBuffLength(),true);
39 
40  }
41 
43  SerializeStatus stat = deserializeBase(buffer);
44  if (stat != FW_SERIALIZE_OK) {
45  return stat;
46  }
47 
48  stat = buffer.deserialize(this->m_id);
49  if (stat != FW_SERIALIZE_OK) {
50  return stat;
51  }
52 
53  stat = buffer.deserialize(this->m_timeTag);
54  if (stat != FW_SERIALIZE_OK) {
55  return stat;
56  }
57 
58  // remainder of buffer must be telemetry value
59  NATIVE_UINT_TYPE size = buffer.getBuffLeft();
60  stat = buffer.deserialize(this->m_logBuffer.getBuffAddr(),size,true);
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<NATIVE_INT_TYPE>(stat));
65  }
66  return stat;
67  }
68 
70  this->m_id = id;
71  }
72 
73  void LogPacket::setLogBuffer(const LogBuffer& buffer) {
74  this->m_logBuffer = buffer;
75  }
76 
77  void LogPacket::setTimeTag(const Fw::Time& timeTag) {
78  this->m_timeTag = timeTag;
79  }
80 
82  return this->m_id;
83  }
84 
86  return this->m_timeTag;
87  }
88 
90  return this->m_logBuffer;
91  }
92 
93 
94 } /* namespace Fw */
#define FW_ASSERT(...)
Definition: Assert.hpp:14
PlatformIntType NATIVE_INT_TYPE
Definition: BasicTypes.h:51
PlatformUIntType NATIVE_UINT_TYPE
Definition: BasicTypes.h:52
U32 FwEventIdType
Definition: FpConfig.h:86
SerializeStatus serializeBase(SerializeBufferBase &buffer) const
Definition: ComPacket.cpp:18
ComPacketType m_type
Definition: ComPacket.hpp:36
SerializeStatus deserializeBase(SerializeBufferBase &buffer)
Definition: ComPacket.cpp:22
U8 * getBuffAddr()
gets buffer address for data filling
Definition: LogBuffer.cpp:40
SerializeStatus serialize(SerializeBufferBase &buffer) const
serialize contents
Definition: LogPacket.cpp:20
SerializeStatus deserialize(SerializeBufferBase &buffer)
deserialize to contents
Definition: LogPacket.cpp:42
FwEventIdType m_id
Definition: LogPacket.hpp:35
Fw::Time m_timeTag
Definition: LogPacket.hpp:36
void setId(FwEventIdType id)
Definition: LogPacket.cpp:69
void setTimeTag(const Fw::Time &timeTag)
Definition: LogPacket.cpp:77
void setLogBuffer(const LogBuffer &buffer)
Definition: LogPacket.cpp:73
FwEventIdType getId()
Definition: LogPacket.cpp:81
virtual ~LogPacket()
Definition: LogPacket.cpp:17
LogBuffer m_logBuffer
Definition: LogPacket.hpp:37
Fw::Time & getTimeTag()
Definition: LogPacket.cpp:85
LogBuffer & getLogBuffer()
Definition: LogPacket.cpp:89
SerializeStatus setBuffLen(Serializable::SizeType length)
sets buffer length manually after filling with data
Serializable::SizeType getBuffLeft() const
returns how much deserialization buffer is left
Serializable::SizeType getBuffLength() const
returns current buffer size
SerializeStatus deserialize(U8 &val)
deserialize 8-bit unsigned int
SerializeStatus serialize(U8 val)
serialize 8-bit unsigned int
Definition: Time.hpp:9
SerializeStatus
forward declaration for string
@ FW_SERIALIZE_OK
Serialization/Deserialization operation was successful.