11 #include "Fw/Types/Assert.hpp"
21 m_computed(INITIAL_COMPUTED_VALUE),
30 this->m_computed = INITIAL_COMPUTED_VALUE;
38 this->m_computed =
update_crc_32(this->m_computed, buffer[index]);
45 this->m_computed = ~this->m_computed;
55 bool CmdSequencerComponentImpl::FPrimeSequence ::
59 if (this->m_crc.m_stored != this->m_crc.m_computed) {
60 this->m_events.fileCRCFailure(
62 this->m_crc.m_computed
76 this->setFileName(fileName);
78 const bool status = this->readFile()
79 and this->validateCRC()
80 and this->m_header.validateTime(this->m_component)
81 and this->validateRecords();
90 return this->m_buffer.getBuffLeft() > 0;
103 this->m_buffer.resetDeser();
109 this->m_buffer.resetSer();
112 bool CmdSequencerComponentImpl::FPrimeSequence ::
119 this->m_fileName.toChar(),
124 result = this->readOpenFile();
126 this->m_events.fileNotFound();
129 this->m_events.fileReadError();
133 this->m_sequenceFile.close();
138 bool CmdSequencerComponentImpl::FPrimeSequence ::
141 U8 *
const buffAddr = this->m_buffer.getBuffAddr();
143 bool status = this->readHeader();
146 status = this->deserializeHeader()
147 and this->readRecordsAndCRC()
148 and this->extractCRC();
152 this->m_crc.update(buffAddr, buffLen);
153 this->m_crc.finalize();
158 bool CmdSequencerComponentImpl::FPrimeSequence ::
162 Os::File& file = this->m_sequenceFile;
181 this->m_events.fileInvalid(
182 CmdSequencer_FileReadStage::READ_HEADER,
189 this->m_events.fileInvalid(
190 CmdSequencer_FileReadStage::READ_HEADER_SIZE,
208 bool CmdSequencerComponentImpl::FPrimeSequence ::
212 Header& header = this->m_header;
217 this->m_events.fileInvalid(
218 CmdSequencer_FileReadStage::DESER_SIZE,
224 this->m_events.fileSizeError(header.m_fileSize);
228 serializeStatus = buffer.
deserialize(header.m_numRecords);
230 this->m_events.fileInvalid(
231 CmdSequencer_FileReadStage::DESER_NUM_RECORDS,
240 this->m_events.fileInvalid(
241 CmdSequencer_FileReadStage::DESER_TIME_BASE,
246 header.m_timeBase =
static_cast<TimeBase>(tbase);
248 serializeStatus = buffer.
deserialize(header.m_timeContext);
250 this->m_events.fileInvalid(
251 CmdSequencer_FileReadStage::DESER_TIME_CONTEXT,
259 bool CmdSequencerComponentImpl::FPrimeSequence ::
262 Os::File& file = this->m_sequenceFile;
273 this->m_events.fileInvalid(
274 CmdSequencer_FileReadStage::READ_SEQ_DATA,
281 this->m_events.fileInvalid(
282 CmdSequencer_FileReadStage::READ_SEQ_DATA_SIZE,
294 bool CmdSequencerComponentImpl::FPrimeSequence ::
298 U32& crc = this->m_crc.m_stored;
302 const U32 crcSize =
sizeof(crc);
304 if (buffSize < crcSize) {
305 this->m_events.fileInvalid(
306 CmdSequencer_FileReadStage::READ_SEQ_CRC,
311 FW_ASSERT(buffSize >= crcSize, buffSize, crcSize);
318 status = crcBuff.deserialize(crc);
327 deserializeRecord(Record& record)
332 this->deserializeDescriptor(record.m_descriptor);
336 record.m_descriptor == Record::END_OF_SEQUENCE
342 status = this->deserializeTimeTag(record.m_timeTag);
345 status = this->deserializeRecordSize(recordSize);
348 status = this->copyCommand(record.m_command, recordSize);
355 deserializeDescriptor(Record::Descriptor& descriptor)
369 descriptor =
static_cast<Record::Descriptor
>(descEntry);
374 deserializeTimeTag(
Fw::Time& timeTag)
377 U32 seconds, useconds;
383 timeTag.
set(seconds,useconds);
389 deserializeRecordSize(U32& recordSize)
419 bool CmdSequencerComponentImpl::FPrimeSequence ::
423 const U32 numRecords = this->m_header.m_numRecords;
424 Sequence::Record record;
427 for (
NATIVE_UINT_TYPE recordNumber = 0; recordNumber < numRecords; recordNumber++) {
430 this->m_events.recordInvalid(recordNumber, status);
436 if (buffLeftSize > 0) {
437 this->m_events.recordMismatch(numRecords, buffLeftSize);