19 CmdSequencerComponentImpl::FPrimeSequence::CRC ::
21 m_computed(INITIAL_COMPUTED_VALUE),
27 void CmdSequencerComponentImpl::FPrimeSequence::CRC ::
30 this->m_computed = INITIAL_COMPUTED_VALUE;
33 void CmdSequencerComponentImpl::FPrimeSequence::CRC ::
38 this->m_computed =
update_crc_32(this->m_computed, buffer[index]);
42 void CmdSequencerComponentImpl::FPrimeSequence::CRC ::
45 this->m_computed = ~this->m_computed;
48 CmdSequencerComponentImpl::FPrimeSequence ::
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
69 bool CmdSequencerComponentImpl::FPrimeSequence ::
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();
87 bool CmdSequencerComponentImpl::FPrimeSequence ::
88 hasMoreRecords()
const
90 return this->m_buffer.getBuffLeft() > 0;
93 void CmdSequencerComponentImpl::FPrimeSequence ::
100 void CmdSequencerComponentImpl::FPrimeSequence ::
103 this->m_buffer.resetDeser();
106 void CmdSequencerComponentImpl::FPrimeSequence ::
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);
PlatformIntType NATIVE_INT_TYPE
uint8_t U8
8-bit unsigned integer
PlatformUIntType NATIVE_UINT_TYPE
U32 FwPacketDescriptorType
U8 * getBuffAddr()
gets buffer address for data filling
NATIVE_UINT_TYPE getBuffLeft() const
returns how much deserialization buffer is left
void resetDeser()
reset deserialization to beginning
SerializeStatus setBuffLen(NATIVE_UINT_TYPE length)
sets buffer length manually after filling with data
void resetSer()
reset to beginning of buffer to reuse for serialization
virtual NATIVE_UINT_TYPE getBuffCapacity() const =0
returns capacity, not current size, of buffer
SerializeStatus deserialize(U8 &val)
deserialize 8-bit unsigned int
virtual U8 * getBuffAddr()=0
gets buffer address for data filling
NATIVE_UINT_TYPE getBuffLength() const
returns current buffer size
void set(U32 seconds, U32 useconds)
@ DOESNT_EXIST
File doesn't exist (for read)
@ OP_OK
Operation was successful.
@ OPEN_READ
Open file for reading.
NATIVE_INT_TYPE getLastError()
read back last error code (typically errno)
Status read(void *buffer, NATIVE_INT_TYPE &size, bool waitForFull=true)
waitForFull = true to wait for all bytes to be read
@ END_OF_SEQUENCE
end of sequence
A sequence with unspecified binary format.
unsigned long update_crc_32(unsigned long crc, char c)
SerializeStatus
forward declaration for string
@ FW_DESERIALIZE_FORMAT_ERROR
Deserialization data had incorrect values (unexpected data types)
@ FW_SERIALIZE_OK
Serialization/Deserialization operation was successful.
@ FW_DESERIALIZE_SIZE_MISMATCH
Data was left in the buffer, but not enough to deserialize.