F´ Flight Software - C/C++ Documentation  NASA-v1.6.0
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 
15  m_eventID(0),
16  m_overSeqNum(0),
17  m_catSeqNum(0) {
18  this->m_type = FW_PACKET_LOG;
19  }
20 
22  }
23 
25 
26  SerializeStatus stat;
27 
28  stat = buffer.serialize(this->m_taskName, AMPCS_EVR_TASK_NAME_LEN, true);
29  if (stat != FW_SERIALIZE_OK) {
30  return stat;
31  }
32 
33  stat = buffer.serialize(this->m_eventID);
34  if (stat != FW_SERIALIZE_OK) {
35  return stat;
36  }
37 
38  stat = buffer.serialize(this->m_overSeqNum);
39  if (stat != FW_SERIALIZE_OK) {
40  return stat;
41  }
42 
43  stat = buffer.serialize(this->m_catSeqNum);
44  if (stat != FW_SERIALIZE_OK) {
45  return stat;
46  }
47 
48  return buffer.serialize(this->m_logBuffer.getBuffAddr(),m_logBuffer.getBuffLength(),true);
49 
50  }
51 
53  NATIVE_UINT_TYPE len;
54 
55  SerializeStatus stat;
56 
58  stat = buffer.deserialize(this->m_taskName, len, true);
59  if (stat != FW_SERIALIZE_OK) {
60  return stat;
61  }
62 
63  stat = buffer.deserialize(this->m_eventID);
64  if (stat != FW_SERIALIZE_OK) {
65  return stat;
66  }
67 
68  stat = buffer.deserialize(this->m_overSeqNum);
69  if (stat != FW_SERIALIZE_OK) {
70  return stat;
71  }
72 
73  stat = buffer.deserialize(this->m_catSeqNum);
74  if (stat != FW_SERIALIZE_OK) {
75  return stat;
76  }
77 
78  NATIVE_UINT_TYPE size = buffer.getBuffLeft();
79  stat = buffer.deserialize(this->m_logBuffer.getBuffAddr(),size,true);
80  if (stat == FW_SERIALIZE_OK) {
81  // Shouldn't fail
82  stat = this->m_logBuffer.setBuffLen(size);
83  FW_ASSERT(stat == FW_SERIALIZE_OK,static_cast<NATIVE_INT_TYPE>(stat));
84  }
85  return stat;
86  }
87 
88  void AmpcsEvrLogPacket::setTaskName(U8 *taskName, U8 len) {
89  FW_ASSERT(taskName != nullptr);
91 
92  memcpy(this->m_taskName, (const void*)taskName, len);
93  }
94 
95  void AmpcsEvrLogPacket::setId(U32 eventID) {
96  this->m_eventID = eventID;
97  }
98 
99  void AmpcsEvrLogPacket::setOverSeqNum(U32 overSeqNum) {
100  this->m_overSeqNum = overSeqNum;
101  }
102 
103  void AmpcsEvrLogPacket::setCatSeqNum(U32 catSeqNum) {
104  this->m_catSeqNum = catSeqNum;
105  }
106 
108  this->m_logBuffer = buffer;
109  }
110 
112  return this->m_taskName;
113  }
114 
116  return this->m_eventID;
117  }
118 
120  return this->m_overSeqNum;
121  }
122 
124  return this->m_catSeqNum;
125  }
126 
128  return this->m_logBuffer;
129  }
130 
131 
132 } /* namespace Fw */
Fw::AmpcsEvrLogPacket::~AmpcsEvrLogPacket
virtual ~AmpcsEvrLogPacket()
Definition: AmpcsEvrLogPacket.cpp:21
Fw::AmpcsEvrLogPacket::getLogBuffer
LogBuffer & getLogBuffer()
Definition: AmpcsEvrLogPacket.cpp:127
Fw::AmpcsEvrLogPacket::m_overSeqNum
U32 m_overSeqNum
Definition: AmpcsEvrLogPacket.hpp:45
Fw::AmpcsEvrLogPacket::getId
U32 getId() const
Definition: AmpcsEvrLogPacket.cpp:115
Fw::AmpcsEvrLogPacket::deserialize
SerializeStatus deserialize(SerializeBufferBase &buffer)
deserialize to contents
Definition: AmpcsEvrLogPacket.cpp:52
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::AmpcsEvrLogPacket::getTaskName
const U8 * getTaskName() const
Definition: AmpcsEvrLogPacket.cpp:111
Fw::SerializeBufferBase::serialize
SerializeStatus serialize(U8 val)
serialize 8-bit unsigned int
Definition: Serializable.cpp:69
U8
uint8_t U8
8-bit unsigned integer
Definition: BasicTypes.hpp:73
NATIVE_UINT_TYPE
unsigned int NATIVE_UINT_TYPE
native unsigned integer type declaration
Definition: BasicTypes.hpp:28
Fw::LogBuffer
Definition: LogBuffer.hpp:22
Fw::AmpcsEvrLogPacket::getCatSeqNum
U32 getCatSeqNum() const
Definition: AmpcsEvrLogPacket.cpp:123
Fw::ComPacket::FW_PACKET_LOG
@ FW_PACKET_LOG
Definition: ComPacket.hpp:24
Fw::AmpcsEvrLogPacket::m_taskName
U8 m_taskName[AMPCS_EVR_TASK_NAME_LEN]
Definition: AmpcsEvrLogPacket.hpp:43
Fw::SerializeBufferBase::getBuffLeft
NATIVE_UINT_TYPE getBuffLeft() const
returns how much deserialization buffer is left
Definition: Serializable.cpp:621
AMPCS_EVR_TASK_NAME_LEN
#define AMPCS_EVR_TASK_NAME_LEN
Definition: AmpcsEvrLogPacket.hpp:17
NATIVE_INT_TYPE
int NATIVE_INT_TYPE
native integer type declaration
Definition: BasicTypes.hpp:27
Fw::AmpcsEvrLogPacket::serialize
SerializeStatus serialize(SerializeBufferBase &buffer) const
serialize contents
Definition: AmpcsEvrLogPacket.cpp:24
Fw::AmpcsEvrLogPacket::setTaskName
void setTaskName(U8 *taskName, U8 len)
Definition: AmpcsEvrLogPacket.cpp:88
AmpcsEvrLogPacket.hpp
Fw::AmpcsEvrLogPacket::AmpcsEvrLogPacket
AmpcsEvrLogPacket()
Definition: AmpcsEvrLogPacket.cpp:14
Fw::AmpcsEvrLogPacket::setLogBuffer
void setLogBuffer(LogBuffer &buffer)
Definition: AmpcsEvrLogPacket.cpp:107
Fw::SerializeBufferBase::setBuffLen
SerializeStatus setBuffLen(NATIVE_UINT_TYPE length)
sets buffer length manually after filling with data
Definition: Serializable.cpp:611
Fw::AmpcsEvrLogPacket::getOverSeqNum
U32 getOverSeqNum() const
Definition: AmpcsEvrLogPacket.cpp:119
Fw::AmpcsEvrLogPacket::m_catSeqNum
U32 m_catSeqNum
Definition: AmpcsEvrLogPacket.hpp:46
Fw::SerializeBufferBase::getBuffLength
NATIVE_UINT_TYPE getBuffLength() const
returns current buffer size
Definition: Serializable.cpp:594
Fw::AmpcsEvrLogPacket::setOverSeqNum
void setOverSeqNum(U32 overSeqNum)
Definition: AmpcsEvrLogPacket.cpp:99
Fw::ComPacket::m_type
ComPacketType m_type
Definition: ComPacket.hpp:35
Fw::AmpcsEvrLogPacket::setCatSeqNum
void setCatSeqNum(U32 catSeqNum)
Definition: AmpcsEvrLogPacket.cpp:103
FW_ASSERT
#define FW_ASSERT(...)
Definition: Assert.hpp:9
Fw::SerializeBufferBase::deserialize
SerializeStatus deserialize(U8 &val)
deserialize 8-bit unsigned int
Definition: Serializable.cpp:294
Fw::AmpcsEvrLogPacket::m_eventID
U32 m_eventID
Definition: AmpcsEvrLogPacket.hpp:44
Fw::AmpcsEvrLogPacket::m_logBuffer
LogBuffer m_logBuffer
Definition: AmpcsEvrLogPacket.hpp:47
Fw::AmpcsEvrLogPacket::setId
void setId(U32 eventID)
Definition: AmpcsEvrLogPacket.cpp:95
Fw::FW_SERIALIZE_OK
@ FW_SERIALIZE_OK
Serialization/Deserialization operation was successful.
Definition: Serializable.hpp:15
Fw
Definition: SerIds.hpp:20