F´ Flight Software - C/C++ Documentation  NASA-v1.6.0
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 */
Fw::LogPacket::getId
FwEventIdType getId()
Definition: LogPacket.cpp:81
Fw::LogPacket::LogPacket
LogPacket()
Definition: LogPacket.cpp:13
Fw::ComPacket::deserializeBase
SerializeStatus deserializeBase(SerializeBufferBase &buffer)
Definition: ComPacket.cpp:22
Fw::Time
Definition: Time.hpp:10
Fw::LogPacket::serialize
SerializeStatus serialize(SerializeBufferBase &buffer) const
serialize contents
Definition: LogPacket.cpp:20
Fw::LogPacket::m_timeTag
Fw::Time m_timeTag
Definition: LogPacket.hpp:36
Fw::SerializeBufferBase
Definition: Serializable.hpp:43
Fw::SerializeStatus
SerializeStatus
forward declaration for string
Definition: Serializable.hpp:14
Fw::LogBuffer::getBuffAddr
U8 * getBuffAddr()
gets buffer address for data filling
Definition: LogBuffer.cpp:36
Fw::LogPacket::getTimeTag
Fw::Time & getTimeTag()
Definition: LogPacket.cpp:85
Fw::SerializeBufferBase::serialize
SerializeStatus serialize(U8 val)
serialize 8-bit unsigned int
Definition: Serializable.cpp:67
Fw::LogBuffer
Definition: LogBuffer.hpp:22
Fw::ComPacket::FW_PACKET_LOG
@ FW_PACKET_LOG
Definition: ComPacket.hpp:24
Fw::LogPacket::m_logBuffer
LogBuffer m_logBuffer
Definition: LogPacket.hpp:37
Fw::ComPacket::serializeBase
SerializeStatus serializeBase(SerializeBufferBase &buffer) const
Definition: ComPacket.cpp:18
Assert.hpp
Fw::FW_SERIALIZE_OK
@ FW_SERIALIZE_OK
Serialization/Deserialization operation was successful.
Definition: Serializable.hpp:15
Fw::SerializeBufferBase::getBuffLeft
NATIVE_UINT_TYPE getBuffLeft() const
returns how much deserialization buffer is left
Definition: Serializable.cpp:618
Fw::LogPacket::setTimeTag
void setTimeTag(const Fw::Time &timeTag)
Definition: LogPacket.cpp:77
Fw::LogPacket::m_id
FwEventIdType m_id
Definition: LogPacket.hpp:35
Fw::LogPacket::getLogBuffer
LogBuffer & getLogBuffer()
Definition: LogPacket.cpp:89
Fw::SerializeBufferBase::setBuffLen
SerializeStatus setBuffLen(NATIVE_UINT_TYPE length)
sets buffer length manually after filling with data
Definition: Serializable.cpp:608
NATIVE_UINT_TYPE
unsigned int NATIVE_UINT_TYPE
native unsigned integer type declaration
Definition: BasicTypes.hpp:30
FW_ASSERT
#define FW_ASSERT(...)
Definition: Assert.hpp:8
Fw::SerializeBufferBase::getBuffLength
NATIVE_UINT_TYPE getBuffLength() const
returns current buffer size
Definition: Serializable.cpp:591
Fw::ComPacket::m_type
ComPacketType m_type
Definition: ComPacket.hpp:35
Fw::SerializeBufferBase::deserialize
SerializeStatus deserialize(U8 &val)
deserialize 8-bit unsigned int
Definition: Serializable.cpp:290
Fw::LogPacket::setId
void setId(FwEventIdType id)
Definition: LogPacket.cpp:69
Fw::LogPacket::setLogBuffer
void setLogBuffer(const LogBuffer &buffer)
Definition: LogPacket.cpp:73
LogPacket.hpp
FwEventIdType
#define FwEventIdType
Type representation for an event id.
Definition: FpConfig.hpp:66
Fw::LogPacket::~LogPacket
virtual ~LogPacket()
Definition: LogPacket.cpp:17
NATIVE_INT_TYPE
int NATIVE_INT_TYPE
native integer type declaration
Definition: BasicTypes.hpp:29
Fw::LogPacket::deserialize
SerializeStatus deserialize(SerializeBufferBase &buffer)
deserialize to contents
Definition: LogPacket.cpp:42
Fw
Definition: Buffer.cpp:21