F´ Flight Software - C/C++ Documentation NASA-v1.6.0
A framework for building embedded system applications to NASA flight quality standards.
Loading...
Searching...
No Matches
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
12namespace 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
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
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 */
#define AMPCS_EVR_TASK_NAME_LEN
#define FW_ASSERT(...)
Definition Assert.hpp:7
PlatformIntType NATIVE_INT_TYPE
Definition BasicTypes.h:51
uint8_t U8
8-bit unsigned integer
Definition BasicTypes.h:26
PlatformUIntType NATIVE_UINT_TYPE
Definition BasicTypes.h:52
SerializeStatus deserialize(SerializeBufferBase &buffer)
deserialize to contents
const U8 * getTaskName() const
SerializeStatus serialize(SerializeBufferBase &buffer) const
serialize contents
void setOverSeqNum(U32 overSeqNum)
void setLogBuffer(LogBuffer &buffer)
void setCatSeqNum(U32 catSeqNum)
void setTaskName(U8 *taskName, U8 len)
U8 m_taskName[AMPCS_EVR_TASK_NAME_LEN]
ComPacketType m_type
Definition ComPacket.hpp:35
U8 * getBuffAddr()
gets buffer address for data filling
Definition LogBuffer.cpp:40
NATIVE_UINT_TYPE getBuffLeft() const
returns how much deserialization buffer is left
SerializeStatus setBuffLen(NATIVE_UINT_TYPE length)
sets buffer length manually after filling with data
SerializeStatus deserialize(U8 &val)
deserialize 8-bit unsigned int
SerializeStatus serialize(U8 val)
serialize 8-bit unsigned int
NATIVE_UINT_TYPE getBuffLength() const
returns current buffer size
Definition Buffer.cpp:21
SerializeStatus
forward declaration for string
@ FW_SERIALIZE_OK
Serialization/Deserialization operation was successful.