21 m_computed(INITIAL_COMPUTED_VALUE),
30 this->m_computed = INITIAL_COMPUTED_VALUE;
38 this->m_computed =
static_cast<U32
>(
update_crc_32(this->m_computed,
static_cast<char>(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(
189 this->m_events.fileInvalid(
191 static_cast<I32
>(readLen)
208 bool CmdSequencerComponentImpl::FPrimeSequence ::
212 Header& header = this->m_header;
217 this->m_events.fileInvalid(
224 this->m_events.fileSizeError(header.m_fileSize);
228 serializeStatus = buffer.
deserialize(header.m_numRecords);
230 this->m_events.fileInvalid(
240 this->m_events.fileInvalid(
246 header.m_timeBase =
static_cast<TimeBase>(tbase);
248 serializeStatus = buffer.
deserialize(header.m_timeContext);
250 this->m_events.fileInvalid(
259 bool CmdSequencerComponentImpl::FPrimeSequence ::
262 Os::File& file = this->m_sequenceFile;
273 this->m_events.fileInvalid(
281 this->m_events.fileInvalid(
283 static_cast<I32
>(readLen)
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(
307 static_cast<I32
>(buffSize)
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
PlatformAssertArgType FwAssertArgType
PlatformSignedSizeType FwSignedSizeType
U32 FwPacketDescriptorType
U8 * getBuffAddr()
gets buffer address for data filling
External serialize buffer with no copy semantics.
NATIVE_UINT_TYPE SizeType
virtual U8 * getBuffAddr()=0
gets buffer address for data filling
SerializeStatus setBuffLen(Serializable::SizeType length)
sets buffer length manually after filling with data
void resetDeser()
reset deserialization to beginning
Serializable::SizeType getBuffLeft() const
returns how much deserialization buffer is left
void resetSer()
reset to beginning of buffer to reuse for serialization
Serializable::SizeType getBuffLength() const
returns current buffer size
SerializeStatus deserialize(U8 &val)
deserialize 8-bit unsigned int
virtual Serializable::SizeType getBuffCapacity() const =0
returns capacity, not current size, of buffer
void set(U32 seconds, U32 useconds)
Status read(U8 *buffer, FwSignedSizeType &size)
read data from this file into supplied buffer bounded by size
@ OP_OK
Operation was successful.
@ DOESNT_EXIST
File doesn't exist (for read)
@ OPEN_READ
Open file for reading.
FPrimeSequence(CmdSequencerComponentImpl &component)
Construct an FPrimeSequence.
bool loadFile(const Fw::StringBase &fileName)
void nextRecord(Record &record)
bool hasMoreRecords() const
@ 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.
void finalize()
Finalize computed CRC.
void init()
Initialize computed CRC.
void update(const BYTE *buffer, NATIVE_UINT_TYPE bufferSize)
Update computed CRC.