21 ComLogger(
const char* compName,
const char* incomingFilePrefix, U32 maxFileSize,
bool storeBufferLength) :
22 ComLoggerComponentBase(compName),
23 maxFileSize(maxFileSize),
26 writeErrorOccurred(false),
27 openErrorOccurred(false),
28 storeBufferLength(storeBufferLength)
30 if( this->storeBufferLength ) {
31 FW_ASSERT(maxFileSize >
sizeof(U16), maxFileSize);
49 ComLoggerComponentBase::init(queueDepth, instance);
61 if( OPEN == this->fileMode ) {
66 this->writeHashFile();
69 this->fileMode = CLOSED;
95 U16 size = size32 & 0xFFFF;
98 if( OPEN == this->fileMode ) {
99 U32 projectedByteCount = this->byteCount + size;
100 if( this->storeBufferLength ) {
101 projectedByteCount +=
sizeof(size);
103 if( projectedByteCount > this->maxFileSize ) {
109 if( CLOSED == this->fileMode ){
114 if( OPEN == this->fileMode ) {
115 this->writeComBufferToFile(data, size);
120 CloseFile_cmdHandler(
126 this->cmdResponse_out(opCode, cmdSeq, Fw::CmdResponse::OK);
136 this->pingOut_out(0,key);
149 memset(this->fileName, 0,
sizeof(this->fileName));
150 bytesCopied = snprintf(this->fileName,
sizeof(this->fileName),
"%s_%" PRI_FwTimeBaseStoreType "_%" PRIu32
"_%06" PRIu32
".com",
155 FW_ASSERT( bytesCopied <
sizeof(this->fileName) );
158 bytesCopied = snprintf(this->hashFileName,
sizeof(this->hashFileName),
"%s_%" PRI_FwTimeBaseStoreType "_%" PRIu32
"_%06" PRIu32
".com%s",
160 FW_ASSERT( bytesCopied <
sizeof(this->hashFileName) );
164 if( !this->openErrorOccurred ) {
167 this->log_WARNING_HI_FileOpenError(ret, logStringArg);
169 this->openErrorOccurred =
true;
172 this->openErrorOccurred =
false;
178 this->fileMode = OPEN;
186 if( OPEN == this->fileMode ) {
191 this->writeHashFile();
194 this->fileMode = CLOSED;
198 this->log_DIAGNOSTIC_FileClosed(logStringArg);
203 writeComBufferToFile(
208 if( this->storeBufferLength ) {
209 U8 buffer[
sizeof(size)];
211 serialLength.serialize(size);
212 if(this->writeToFile(serialLength.getBuffAddr(),
213 static_cast<U16
>(serialLength.getBuffLength()))) {
214 this->byteCount += serialLength.getBuffLength();
223 this->byteCount += size;
236 if( !this->writeErrorOccurred ) {
239 this->log_WARNING_HI_FileWriteError(ret, size, length, logStringArg);
241 this->writeErrorOccurred =
true;
245 this->writeErrorOccurred =
false;
258 this->log_WARNING_LO_FileValidationError(logStringArg1, logStringArg2, validateStatus);
PlatformIntType NATIVE_INT_TYPE
uint8_t U8
8-bit unsigned integer
#define PRI_FwTimeBaseStoreType
C++-compatible configuration header for fprime configuration.
Defines a file class to validate files or generate a file validator file.
U8 * getBuffAddr()
gets buffer address for data filling
A variable-length serializable buffer.
NATIVE_UINT_TYPE getBuffLength() const
returns current buffer size
TimeBase getTimeBase() const
@ OP_OK
Operation was successful.
@ OPEN_WRITE
Open file for writing.
static const char * getFileExtensionString()
char * string_copy(char *destination, const char *source, U32 num)
copy string with null-termination guaranteed
U32 string_length(const CHAR *source, U32 max_len)
get the length of the source string or max_len if the string is longer than max_len.
@ VALIDATION_OK
The validation of the file passed.
Status createValidation(const char *fileName, const char *hash, Utils::HashBuffer &hashBuffer)