fprime/Fw/Log/LogPacket.cpp
Vince Woo 48e4720419
Created new SerialBufferBase as a parent of SerializeBufferBase (now renamed LinearBufferBase). (#4288)
* Created new SerialBufferBase as a parent of SerializeBufferBase. Renaming interface functions to be less confusing.

* Deprecating copyRawOffset. No direct use-cases in F' core.

* Make SerialBufferBase a true pure virtual interface.

* Changing Serializable to work with SerialBufferBase parent interface.

* Changing copyRaw and copyRawOffset to work with SerialBufferBase

* Updating documentation for SerialBufferBase usage

* Adding some documentation. Adding missing ASSERT in copyRaw. Fixing some bugs that new ASSERT uncovered.

* Renaming SerializeBufferBase to LinearBufferBase. Add a using declaration to maintain backwards compatability. Properly mark LinearBufferBase functions as override.

* Filling in the rest of the docstrings for the classes in Serializable

* Removing redundant virtual keyword on override function

* Applying clang formatting

* Incorporating PR comments

* Fix compile issues

* Bump version to alpha

* Format

* v

---------

Co-authored-by: M Starch <LeStarch@googlemail.com>
2025-11-06 16:23:20 -08:00

91 lines
2.2 KiB
C++

/*
* 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(), 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 */