21 m_computed(INITIAL_COMPUTED_VALUE),
30 this->m_computed = INITIAL_COMPUTED_VALUE;
37 for(
FwSizeType index = 0; index < bufferSize; index++) {
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();
151 const FwSizeType buffLen = this->m_buffer.getBuffLength();
152 this->m_crc.update(buffAddr, buffLen);
153 this->m_crc.finalize();
158 bool CmdSequencerComponentImpl::FPrimeSequence ::
162 Os::File& file = this->m_sequenceFile;
171 static_cast<FwAssertArgType>(capacity),
172 static_cast<FwAssertArgType>(readLen)
180 this->m_events.fileInvalid(
188 this->m_events.fileInvalid(
190 static_cast<I32>(readLen)
197 buffer.
setBuffLen(static_cast<Fw::Serializable::SizeType>(readLen));
207 bool CmdSequencerComponentImpl::FPrimeSequence ::
211 Header& header = this->m_header;
216 this->m_events.fileInvalid(
223 this->m_events.fileSizeError(header.m_fileSize);
227 serializeStatus = buffer.
deserialize(header.m_numRecords);
229 this->m_events.fileInvalid(
239 this->m_events.fileInvalid(
245 header.m_timeBase =
static_cast<TimeBase>(tbase);
247 serializeStatus = buffer.
deserialize(header.m_timeContext);
249 this->m_events.fileInvalid(
258 bool CmdSequencerComponentImpl::FPrimeSequence ::
261 Os::File& file = this->m_sequenceFile;
262 const FwSizeType size = this->m_header.m_fileSize;
272 this->m_events.fileInvalid(
279 if (size != static_cast<FwSizeType>(readLen)) {
280 this->m_events.fileInvalid(
282 static_cast<I32>(readLen)
293 bool CmdSequencerComponentImpl::FPrimeSequence ::
297 U32& crc = this->m_crc.m_stored;
303 if (buffSize < crcSize) {
304 this->m_events.fileInvalid(
306 static_cast<I32>(buffSize)
310 FW_ASSERT(buffSize >= crcSize, static_cast<FwAssertArgType>(buffSize), crcSize);
311 const FwSizeType dataSize = buffSize - crcSize;
317 status = crcBuff.deserialize(crc);
326 deserializeRecord(Record& record)
331 this->deserializeDescriptor(record.m_descriptor);
335 record.m_descriptor == Record::END_OF_SEQUENCE
341 status = this->deserializeTimeTag(record.m_timeTag);
344 status = this->deserializeRecordSize(recordSize);
347 status = this->copyCommand(record.m_command, recordSize);
354 deserializeDescriptor(Record::Descriptor& descriptor)
368 descriptor =
static_cast<Record::Descriptor
>(descEntry);
373 deserializeTimeTag(
Fw::Time& timeTag)
376 U32 seconds, useconds;
382 timeTag.
set(seconds,useconds);
388 deserializeRecordSize(U32& recordSize)
418 bool CmdSequencerComponentImpl::FPrimeSequence ::
422 const U32 numRecords = this->m_header.m_numRecords;
423 Sequence::Record record;
427 this->m_events.noRecords();
432 for (U32 recordNumber = 0; recordNumber < numRecords; recordNumber++) {
435 this->m_events.recordInvalid(recordNumber, status);
441 if (buffLeftSize > 0) {
442 this->m_events.recordMismatch(numRecords, static_cast<U32>(buffLeftSize));
Serialization/Deserialization operation was successful.
bool hasMoreRecords() const
PlatformSizeType FwSizeType
void resetSer()
reset to beginning of buffer to reuse for serialization
bool loadFile(const Fw::StringBase &fileName)
Deserialization data had incorrect values (unexpected data types)
SerializeStatus
forward declaration for string
unsigned long update_crc_32(unsigned long crc, char c)
Serializable::SizeType getBuffLength() const
returns current buffer size
Serializable::SizeType getBuffLeft() const
returns how much deserialization buffer is left
void set(U32 seconds, U32 useconds)
A sequence with unspecified binary format.
File doesn't exist (for read)
void update(const BYTE *buffer, FwSizeType bufferSize)
Update computed CRC.
Data was left in the buffer, but not enough to deserialize.
External serialize buffer with no copy semantics.
void nextRecord(Record &record)
U8 * getBuffAddr()
gets buffer address for data filling
void resetDeser()
reset deserialization to beginning
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
virtual Serializable::SizeType getBuffCapacity() const =0
returns capacity, not current size, of buffer
Operation was successful.
U32 FwPacketDescriptorType
The type of a com packet descriptor.
void init()
Initialize computed CRC.
SerializeStatus deserialize(U8 &val)
deserialize 8-bit unsigned int
RateGroupDivider component implementation.
U16 FwTimeBaseStoreType
The type used to serialize a time base value.
virtual U8 * getBuffAddr()=0
gets buffer address for data filling
void finalize()
Finalize computed CRC.
SerializeStatus setBuffLen(Serializable::SizeType length)
sets buffer length manually after filling with data