F´ Flight Software - C/C++ Documentation
A framework for building embedded system applications to NASA flight quality standards.
AmpcsEvrLogPacket.cpp
Go to the documentation of this file.
1 /*
2  * AmpcsEvrLogPacket.cpp
3  *
4  * Created on: October 07, 2016
5  * Author: Kevin F. Ortega
6  * Aadil Rizvi
7  */
8 
10 #include <Fw/Types/Assert.hpp>
11 
12 namespace Fw {
13 
14 AmpcsEvrLogPacket::AmpcsEvrLogPacket() : m_eventID(0), m_overSeqNum(0), m_catSeqNum(0) {
15  this->m_type = FW_PACKET_LOG;
16 }
18 
20  SerializeStatus stat;
21 
23  if (stat != FW_SERIALIZE_OK) {
24  return stat;
25  }
26 
27  stat = buffer.serializeFrom(this->m_eventID);
28  if (stat != FW_SERIALIZE_OK) {
29  return stat;
30  }
31 
32  stat = buffer.serializeFrom(this->m_overSeqNum);
33  if (stat != FW_SERIALIZE_OK) {
34  return stat;
35  }
36 
37  stat = buffer.serializeFrom(this->m_catSeqNum);
38  if (stat != FW_SERIALIZE_OK) {
39  return stat;
40  }
41 
44 }
45 
47  FwSizeType len;
48 
49  SerializeStatus stat;
50  SerializeStatus stat;
51 
53  stat = buffer.deserializeTo(this->m_taskName, len, true);
54  if (stat != FW_SERIALIZE_OK) {
55  return stat;
56  }
57 
58  stat = buffer.deserializeTo(this->m_eventID);
59  if (stat != FW_SERIALIZE_OK) {
60  return stat;
61  }
62 
63  stat = buffer.deserializeTo(this->m_overSeqNum);
64  if (stat != FW_SERIALIZE_OK) {
65  return stat;
66  }
67 
68  stat = buffer.deserializeTo(this->m_catSeqNum);
69  if (stat != FW_SERIALIZE_OK) {
70  return stat;
71  }
72 
73  FwSizeType size = buffer.getBuffLeft();
74  stat = buffer.deserializeTo(this->m_logBuffer.getBuffAddr(), size, true);
75  if (stat == FW_SERIALIZE_OK) {
76  // Shouldn't fail
77  stat = this->m_logBuffer.setBuffLen(size);
78  FW_ASSERT(stat == FW_SERIALIZE_OK, static_cast<FwAssertArgType>(stat));
79  }
80  return stat;
81 }
82 
83 void AmpcsEvrLogPacket::setTaskName(U8* taskName, U8 len) {
84  FW_ASSERT(taskName != nullptr);
86 
87  memcpy(this->m_taskName, (const void*)taskName, len);
88 }
89 
90 void AmpcsEvrLogPacket::setId(U32 eventID) {
91  this->m_eventID = eventID;
92 }
93 
94 void AmpcsEvrLogPacket::setOverSeqNum(U32 overSeqNum) {
95  this->m_overSeqNum = overSeqNum;
96 }
97 
98 void AmpcsEvrLogPacket::setCatSeqNum(U32 catSeqNum) {
99  this->m_catSeqNum = catSeqNum;
100 }
101 
103  this->m_logBuffer = buffer;
104 }
105 
107  return this->m_taskName;
108 }
109 
111  return this->m_eventID;
112 }
113 
115  return this->m_overSeqNum;
116 }
117 
119  return this->m_catSeqNum;
120 }
121 
123  return this->m_logBuffer;
124 }
125 
126 } /* namespace Fw */
Serialization/Deserialization operation was successful.
void setTaskName(U8 *taskName, U8 len)
void setCatSeqNum(U32 catSeqNum)
U8 * getBuffAddr()
gets buffer address for data filling
Definition: LogBuffer.cpp:38
PlatformSizeType FwSizeType
ComPacketType m_type
Definition: ComPacket.hpp:28
void setOverSeqNum(U32 overSeqNum)
SerializeStatus
forward declaration for string
Serializable::SizeType getBuffLength() const
returns current buffer size
Serializable::SizeType getBuffLeft() const
returns how much deserialization buffer is left
#define AMPCS_EVR_TASK_NAME_LEN
void setId(U32 eventID)
uint8_t U8
8-bit unsigned integer
Definition: BasicTypes.h:53
Omit length from serialization.
SerializeStatus deserializeFrom(SerializeBufferBase &buffer)
deserialize contents from buffer
const U8 * getTaskName() const
SerializeStatus serializeFrom(U8 val)
serialize 8-bit unsigned int
SerializeStatus serializeTo(SerializeBufferBase &buffer) const
serialize contents
U8 m_taskName[AMPCS_EVR_TASK_NAME_LEN]
#define FW_ASSERT(...)
Definition: Assert.hpp:14
void setLogBuffer(LogBuffer &buffer)
SerializeStatus setBuffLen(Serializable::SizeType length)
sets buffer length manually after filling with data
SerializeStatus deserializeTo(U8 &val)
deserialize 8-bit unsigned int