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

63 lines
2.1 KiB
C++

// ======================================================================
// \title BadCRCFile.cpp
// \author Rob Bocchino
// \brief BadCRCFile implementation
//
// \copyright
// Copyright (C) 2009-2018 California Institute of Technology.
// ALL RIGHTS RESERVED. United States Government Sponsorship
// acknowledged.
// ======================================================================
#include "Svc/CmdSequencer/test/ut/SequenceFiles/BadCRCFile.hpp"
#include "Svc/CmdSequencer/test/ut/SequenceFiles/AMPCS/AMPCS.hpp"
#include "Svc/CmdSequencer/test/ut/SequenceFiles/Buffers.hpp"
#include "Svc/CmdSequencer/test/ut/SequenceFiles/FPrime/FPrime.hpp"
#include "gtest/gtest.h"
namespace Svc {
namespace SequenceFiles {
BadCRCFile ::BadCRCFile(const Format::t a_format) : File("bad_crc", a_format) {}
void BadCRCFile ::serializeFPrime(Fw::SerializeBufferBase& buffer) {
// Header
const U32 recordData = 0x10;
const U32 dataSize = sizeof recordData + FPrime::CRCs::SIZE;
const U32 numRecords = 1;
const TimeBase timeBase = TimeBase::TB_WORKSTATION_TIME;
const U32 timeContext = 0;
FPrime::Headers::serialize(dataSize, numRecords, timeBase, timeContext, buffer);
// Records
ASSERT_EQ(Fw::FW_SERIALIZE_OK, buffer.serializeFrom(recordData));
// CRC
const U8* const addr = buffer.getBuffAddr();
const U32 size = buffer.getSize();
this->crc.init();
this->crc.update(addr, size);
this->crc.finalize();
crc.m_stored = this->crc.m_computed + 1;
ASSERT_EQ(Fw::FW_SERIALIZE_OK, buffer.serializeFrom(this->crc.m_stored));
}
void BadCRCFile ::serializeAMPCS(Fw::SerializeBufferBase& buffer) {
// Header
AMPCS::Headers::serialize(buffer);
// Records
const U32 recordData = 0x10;
ASSERT_EQ(Fw::FW_SERIALIZE_OK, buffer.serializeFrom(recordData));
// CRC
AMPCS::CRCs::computeCRC(buffer, this->crc);
this->crc.m_stored = this->crc.m_computed + 1;
AMPCS::CRCs::writeCRC(this->crc.m_stored, this->getName().toChar());
}
const CmdSequencerComponentImpl::FPrimeSequence::CRC& BadCRCFile ::getCRC() const {
return this->crc;
}
} // namespace SequenceFiles
} // namespace Svc