-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Expand file tree
/
Copy pathLogPacket.cpp
More file actions
91 lines (72 loc) · 2.27 KB
/
LogPacket.cpp
File metadata and controls
91 lines (72 loc) · 2.27 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
/*
* LogPacket.cpp
*
* Created on: May 24, 2014
* Author: Timothy Canham
*/
#include <Fw/Log/LogPacket.hpp>
#include <Fw/Types/Assert.hpp>
namespace Fw {
LogPacket::LogPacket() : m_id(0) {
this->m_type = ComPacketType::FW_PACKET_LOG;
}
LogPacket::~LogPacket() {}
SerializeStatus LogPacket::serializeTo(SerialBufferBase& buffer, Fw::Endianness mode) const {
SerializeStatus stat = ComPacket::serializeBase(buffer);
if (stat != FW_SERIALIZE_OK) {
return stat;
}
stat = buffer.serializeFrom(this->m_id, mode);
if (stat != FW_SERIALIZE_OK) {
return stat;
}
stat = buffer.serializeFrom(this->m_timeTag, mode);
if (stat != FW_SERIALIZE_OK) {
return stat;
}
// We want to add data but not size for the ground software
return buffer.serializeFrom(this->m_logBuffer.getBuffAddr(), m_logBuffer.getSize(), Fw::Serialization::OMIT_LENGTH);
}
SerializeStatus LogPacket::deserializeFrom(SerialBufferBase& buffer, Fw::Endianness mode) {
SerializeStatus stat = deserializeBase(buffer);
if (stat != FW_SERIALIZE_OK) {
return stat;
}
stat = buffer.deserializeTo(this->m_id, mode);
if (stat != FW_SERIALIZE_OK) {
return stat;
}
stat = buffer.deserializeTo(this->m_timeTag, mode);
if (stat != FW_SERIALIZE_OK) {
return stat;
}
// remainder of buffer must be telemetry value
FwSizeType size = buffer.getDeserializeSizeLeft();
stat = buffer.deserializeTo(this->m_logBuffer.getBuffAddr(), this->m_logBuffer.getCapacity(), size,
Fw::Serialization::OMIT_LENGTH);
if (stat == FW_SERIALIZE_OK) {
// Shouldn't fail
stat = this->m_logBuffer.setBuffLen(size);
FW_ASSERT(stat == FW_SERIALIZE_OK, static_cast<FwAssertArgType>(stat));
}
return stat;
}
void LogPacket::setId(FwEventIdType id) {
this->m_id = id;
}
void LogPacket::setLogBuffer(const LogBuffer& buffer) {
this->m_logBuffer = buffer;
}
void LogPacket::setTimeTag(const Fw::Time& timeTag) {
this->m_timeTag = timeTag;
}
FwEventIdType LogPacket::getId() {
return this->m_id;
}
Fw::Time& LogPacket::getTimeTag() {
return this->m_timeTag;
}
LogBuffer& LogPacket::getLogBuffer() {
return this->m_logBuffer;
}
} /* namespace Fw */