19 this->m_computed.init();
24 this->m_computed.update(buffer, bufferSize);
29 this->m_computed.finalize(computed);
36 bool CmdSequencerComponentImpl::FPrimeSequence ::validateCRC() {
38 U32 computed = this->m_crc.finalize();
39 if (this->m_crc.m_stored != computed) {
40 this->m_events.fileCRCFailure(this->m_crc.m_stored, computed);
50 this->setFileName(fileName);
52 const bool status = this->readFile() and this->validateCRC() and this->m_header.validateTime(this->m_component) and
53 this->validateRecords();
59 return this->m_buffer.getDeserializeSizeLeft() > 0;
68 this->m_buffer.resetDeser();
72 this->m_buffer.resetSer();
75 bool CmdSequencerComponentImpl::FPrimeSequence ::readFile() {
81 result = this->readOpenFile();
83 this->m_events.fileNotFound();
86 this->m_events.fileReadError();
90 this->m_sequenceFile.close();
94 bool CmdSequencerComponentImpl::FPrimeSequence ::readOpenFile() {
95 U8*
const buffAddr = this->m_buffer.getBuffAddr();
97 bool status = this->readHeader();
100 status = this->deserializeHeader() and this->readRecordsAndCRC() and this->extractCRC();
103 const FwSizeType buffLen = this->m_buffer.getSize();
104 this->m_crc.update(buffAddr, buffLen);
109 bool CmdSequencerComponentImpl::FPrimeSequence ::readHeader() {
110 Os::File& file = this->m_sequenceFile;
117 FW_ASSERT(capacity >= readLen, static_cast<FwAssertArgType>(capacity), static_cast<FwAssertArgType>(readLen));
138 bool CmdSequencerComponentImpl::FPrimeSequence ::deserializeHeader() {
140 Header& header = this->m_header;
149 this->m_events.fileSizeError(header.m_fileSize);
165 header.m_timeBase = (tbase);
167 serializeStatus = buffer.
deserializeTo(header.m_timeContext);
175 bool CmdSequencerComponentImpl::FPrimeSequence ::readRecordsAndCRC() {
176 Os::File& file = this->m_sequenceFile;
177 const FwSizeType size = this->m_header.m_fileSize;
188 if (size != static_cast<FwSizeType>(readLen)) {
198 bool CmdSequencerComponentImpl::FPrimeSequence ::extractCRC() {
200 U32& crc = this->m_crc.m_stored;
206 if (buffSize < crcSize) {
210 FW_ASSERT(buffSize >= crcSize, static_cast<FwAssertArgType>(buffSize), crcSize);
211 const FwSizeType dataSize = buffSize - crcSize;
217 status = crcBuff.deserializeTo(crc);
225 Fw::SerializeStatus CmdSequencerComponentImpl::FPrimeSequence ::deserializeRecord(Record& record) {
235 status = this->deserializeTimeTag(record.m_timeTag);
238 status = this->deserializeRecordSize(recordSize);
241 status = this->copyCommand(record.m_command, recordSize);
247 Fw::SerializeStatus CmdSequencerComponentImpl::FPrimeSequence ::deserializeDescriptor(Record::Descriptor& descriptor) {
260 descriptor =
static_cast<Record::Descriptor
>(descEntry);
266 U32 seconds, useconds;
272 timeTag.
set(seconds, useconds);
277 Fw::SerializeStatus CmdSequencerComponentImpl::FPrimeSequence ::deserializeRecordSize(U32& recordSize) {
293 const U32 recordSize) {
303 bool CmdSequencerComponentImpl::FPrimeSequence ::validateRecords() {
305 const U32 numRecords = this->m_header.m_numRecords;
306 Sequence::Record record;
308 if (numRecords == 0) {
309 this->m_events.noRecords();
314 for (U32 recordNumber = 0; recordNumber < numRecords; recordNumber++) {
317 this->m_events.recordInvalid(recordNumber, status);
323 if (buffLeftSize > 0) {
324 this->m_events.recordMismatch(numRecords, static_cast<U32>(buffLeftSize));
Serialization/Deserialization operation was successful.
U16 FwPacketDescriptorType
The width of packet descriptors when they are serialized by the framework.
bool hasMoreRecords() const
PlatformSizeType FwSizeType
Serializable::SizeType getSize() const override
Get current buffer size.
U32 finalize()
Return the finalized CRC.
virtual U8 * getBuffAddr()=0
Get buffer address for data filling (non-const version)
Deserialization data had incorrect values (unexpected data types)
SerializeStatus
forward declaration for string
void set(U32 seconds, U32 useconds)
Omit length from serialization.
A sequence with unspecified binary format.
File doesn't exist (for read)
bool loadFile(const Fw::ConstStringBase &fileName)
void update(const BYTE *buffer, FwSizeType bufferSize)
Update computed CRC.
Data was left in the buffer, but not enough to deserialize.
Serializable::SizeType getDeserializeSizeLeft() const override
Get remaining deserialization buffer size.
External serialize buffer with no copy semantics.
void nextRecord(Record &record)
void resetDeser() override
Reset deserialization pointer to beginning of buffer.
void resetSer() override
Reset serialization pointer to beginning of buffer.
Serializable::SizeType getCapacity() const override=0
Get buffer capacity.
FPrimeSequence(CmdSequencerComponentImpl &component)
Construct an FPrimeSequence.
uint8_t U8
8-bit unsigned integer
Status read(U8 *buffer, FwSizeType &size)
read data from this file into supplied buffer bounded by size
size when serialized: buffer + stored size
Operation was successful.
void init()
Initialize computed CRC.
A read-only abstract superclass for StringBase.
RateGroupDivider component implementation.
U8 * getBuffAddr() override
Get buffer address for data filling (non-const version)
SerializeStatus deserializeTo(U8 &val, Endianness mode=Endianness::BIG) override
Deserialize an 8-bit unsigned integer value.
SerializeStatus setBuffLen(Serializable::SizeType length) override
Set buffer length manually.
Define enumeration for Time base types.