36 crcFileName +=
".CRC32";
41 const bool status = this->readCRCFile(crcFileName)
42 and this->getFileSize(fileName)
43 and this->readSequenceFile(fileName)
44 and this->validateCRC()
46 and this->validateRecords();
65 result = this->readCRC() and this->deserializeCRC();
66 } else if (status ==
Os::File::DOESNT_EXIST) {
74 this->m_crcFile.
close();
88 bool overflow =
static_cast<FwSizeType>(
static_cast<U32
>(fileSize)) != fileSize;
91 fileSize >=
sizeof(this->m_sequenceHeader) and
94 this->
m_header.
m_fileSize =
static_cast<U32
>(fileSize -
sizeof(this->m_sequenceHeader));
106 bool AMPCSSequence ::
119 result = this->readOpenSequenceFile();
128 this->m_sequenceFile.
close();
133 bool AMPCSSequence ::
137 if (this->m_crc.
m_stored != this->m_crc.m_computed) {
140 this->m_crc.m_computed
147 bool AMPCSSequence ::
151 Sequence::Record record;
156 for ( ; numRecords < loopBound; ++numRecords) {
199 bool AMPCSSequence ::
229 bool AMPCSSequence ::
245 bool AMPCSSequence ::
246 readOpenSequenceFile()
250 bool status = this->readSequenceHeader();
253 this->m_sequenceHeader,
254 sizeof(this->m_sequenceHeader)
256 status = this->readRecords();
264 this->m_header.m_fileSize
266 this->m_crc.
update(buffAddr, buffLen);
272 bool AMPCSSequence ::
276 Os::File& file = this->m_sequenceFile;
282 this->m_sequenceHeader,
294 if (status and readLen !=
sizeof this->m_sequenceHeader) {
307 bool AMPCSSequence ::
310 Os::File& file = this->m_sequenceFile;
333 if (readLenUint != size) {
347 deserializeRecord(Sequence::Record& record)
353 this->deserializeTimeFlag(record.m_descriptor);
356 status = this->deserializeTime(record.m_timeTag);
359 status = this->deserializeCmdLength(cmdLength);
362 status = this->translateCommand(record.m_command, cmdLength);
370 deserializeTimeFlag(Sequence::Record::Descriptor& descriptor)
376 switch (timeFlagSerial) {
378 descriptor = Sequence::Record::ABSOLUTE;
381 descriptor = Sequence::Record::RELATIVE;
398 timeTag.
set(time, 0);
441 fixedBuffLen ==
sizeof(cmdDescriptor) +
sizeof(zeros),
444 const U32 totalBuffLen = fixedBuffLen + cmdLength;
452 status = buffer.
deserialize(&addr[fixedBuffLen], size,
true);
PlatformIntType NATIVE_INT_TYPE
uint8_t U8
8-bit unsigned integer
PlatformUIntType NATIVE_UINT_TYPE
@ TB_DONT_CARE
Don't care value for sequences. If FwTimeBaseStoreType is changed, value should be changed.
#define FW_CONTEXT_DONT_CARE
Don't care value for time contexts in sequences.
U32 FwPacketDescriptorType
PlatformSizeType FwSizeType
const char * toChar() const
U8 * getBuffAddr()
gets buffer address for data filling
NATIVE_UINT_TYPE getBuffCapacity() const
returns capacity, not current size, of buffer
U8 * getBuffAddr()
gets buffer address for data filling
NATIVE_UINT_TYPE getBuffLeft() const
returns how much deserialization buffer is left
virtual U8 * getBuffAddr()=0
gets buffer address for data filling
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
SerializeStatus deserialize(U8 &val)
deserialize 8-bit unsigned int
SerializeStatus serialize(U8 val)
serialize 8-bit unsigned int
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 open(const char *fileName, Mode mode)
open file. Writing creates file if it doesn't exist
Status read(void *buffer, NATIVE_INT_TYPE &size, bool waitForFull=true)
waitForFull = true to wait for all bytes to be read
bool hasMoreRecords() const
AMPCSSequence(CmdSequencerComponentImpl &component)
Construct an AMPCSSequence.
bool loadFile(const Fw::CmdStringArg &fileName)
void nextRecord(Sequence::Record &record)
void fileNotFound()
File not found.
void fileSizeError(const U32 size)
File size error.
void fileReadError()
File read error.
void fileCRCFailure(const U32 storedCRC, const U32 computedCRC)
File CRC failure.
void recordInvalid(const U32 recordNumber, const I32 error)
Record invalid.
void fileInvalid(const CmdSequencer_FileReadStage::t stage, const I32 error)
File invalid.
Events m_events
Event reporting.
Header m_header
The sequence header.
Fw::ExternalSerializeBuffer m_buffer
Serialize buffer to hold the binary sequence data.
CmdSequencerComponentImpl & m_component
The enclosing component.
void setFileName(const Fw::CmdStringArg &fileName)
Set the file name. Also sets the log file name.
Fw::CmdStringArg m_fileName
The sequence file name.
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.
Status getFileSize(const char *path, FwSizeType &size)
append file origin to destination file. If boolean true, creates a brand new file if the destination ...
@ OP_OK
Operation was successful.
@ OTHER_ERROR
other OS-specific error
U16 t
The type of the command length field.
U32 t
The type of the time field.
void finalize()
Finalize computed CRC.
void init()
Initialize computed CRC.
void update(const BYTE *buffer, NATIVE_UINT_TYPE bufferSize)
Update computed CRC.