22 this->m_computed = INITIAL_COMPUTED_VALUE;
27 for (
FwSizeType index = 0; index < bufferSize; index++) {
28 this->m_computed =
static_cast<U32
>(
update_crc_32(this->m_computed, static_cast<char>(buffer[index])));
33 this->m_computed = ~this->m_computed;
39 bool CmdSequencerComponentImpl::FPrimeSequence ::validateCRC() {
41 if (this->m_crc.m_stored != this->m_crc.m_computed) {
42 this->m_events.fileCRCFailure(this->m_crc.m_stored, this->m_crc.m_computed);
52 this->setFileName(fileName);
54 const bool status = this->readFile() and this->validateCRC() and this->m_header.validateTime(this->m_component) and
55 this->validateRecords();
61 return this->m_buffer.getBuffLeft() > 0;
70 this->m_buffer.resetDeser();
74 this->m_buffer.resetSer();
77 bool CmdSequencerComponentImpl::FPrimeSequence ::readFile() {
83 result = this->readOpenFile();
85 this->m_events.fileNotFound();
88 this->m_events.fileReadError();
92 this->m_sequenceFile.close();
96 bool CmdSequencerComponentImpl::FPrimeSequence ::readOpenFile() {
97 U8*
const buffAddr = this->m_buffer.getBuffAddr();
99 bool status = this->readHeader();
102 status = this->deserializeHeader() and this->readRecordsAndCRC() and this->extractCRC();
105 const FwSizeType buffLen = this->m_buffer.getBuffLength();
106 this->m_crc.update(buffAddr, buffLen);
107 this->m_crc.finalize();
112 bool CmdSequencerComponentImpl::FPrimeSequence ::readHeader() {
113 Os::File& file = this->m_sequenceFile;
120 FW_ASSERT(capacity >= readLen, static_cast<FwAssertArgType>(capacity), static_cast<FwAssertArgType>(readLen));
141 bool CmdSequencerComponentImpl::FPrimeSequence ::deserializeHeader() {
143 Header& header = this->m_header;
152 this->m_events.fileSizeError(header.m_fileSize);
156 serializeStatus = buffer.
deserialize(header.m_numRecords);
168 header.m_timeBase = (tbase);
170 serializeStatus = buffer.
deserialize(header.m_timeContext);
178 bool CmdSequencerComponentImpl::FPrimeSequence ::readRecordsAndCRC() {
179 Os::File& file = this->m_sequenceFile;
180 const FwSizeType size = this->m_header.m_fileSize;
191 if (size != static_cast<FwSizeType>(readLen)) {
201 bool CmdSequencerComponentImpl::FPrimeSequence ::extractCRC() {
203 U32& crc = this->m_crc.m_stored;
209 if (buffSize < crcSize) {
213 FW_ASSERT(buffSize >= crcSize, static_cast<FwAssertArgType>(buffSize), crcSize);
214 const FwSizeType dataSize = buffSize - crcSize;
220 status = crcBuff.deserialize(crc);
228 Fw::SerializeStatus CmdSequencerComponentImpl::FPrimeSequence ::deserializeRecord(Record& record) {
238 status = this->deserializeTimeTag(record.m_timeTag);
241 status = this->deserializeRecordSize(recordSize);
244 status = this->copyCommand(record.m_command, recordSize);
250 Fw::SerializeStatus CmdSequencerComponentImpl::FPrimeSequence ::deserializeDescriptor(Record::Descriptor& descriptor) {
263 descriptor =
static_cast<Record::Descriptor
>(descEntry);
269 U32 seconds, useconds;
275 timeTag.
set(seconds, useconds);
280 Fw::SerializeStatus CmdSequencerComponentImpl::FPrimeSequence ::deserializeRecordSize(U32& recordSize) {
296 const U32 recordSize) {
306 bool CmdSequencerComponentImpl::FPrimeSequence ::validateRecords() {
308 const U32 numRecords = this->m_header.m_numRecords;
309 Sequence::Record record;
311 if (numRecords == 0) {
312 this->m_events.noRecords();
317 for (U32 recordNumber = 0; recordNumber < numRecords; recordNumber++) {
320 this->m_events.recordInvalid(recordNumber, status);
326 if (buffLeftSize > 0) {
327 this->m_events.recordMismatch(numRecords, static_cast<U32>(buffLeftSize));
Serialization/Deserialization operation was successful.
FwIdType FwPacketDescriptorType
The type of a com packet descriptor.
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
Omit length from serialization.
Operation was successful.
void init()
Initialize computed CRC.
SerializeStatus deserialize(U8 &val)
RateGroupDivider component implementation.
virtual U8 * getBuffAddr()=0
gets buffer address for data filling
Define enumeration for Time base types.
void finalize()
Finalize computed CRC.
SerializeStatus setBuffLen(Serializable::SizeType length)
sets buffer length manually after filling with data