21 ComLogger(
const char* compName,
const char* incomingFilePrefix, U32 maxFileSize,
bool storeBufferLength) :
23 maxFileSize(maxFileSize),
26 writeErrorOccurred(false),
27 openErrorOccurred(false),
28 storeBufferLength(storeBufferLength),
31 this->
init_log_file(incomingFilePrefix, maxFileSize, storeBufferLength);
35 ComLogger(
const char* compName) :
43 writeErrorOccurred(false),
44 openErrorOccurred(false),
61 init_log_file(
const char* incomingFilePrefix, U32 maxFileSize,
bool storeBufferLength)
64 this->maxFileSize = maxFileSize;
65 this->storeBufferLength = storeBufferLength;
66 if( this->storeBufferLength ) {
67 FW_ASSERT(maxFileSize >
sizeof(U16), maxFileSize);
75 this->initialized =
true;
88 if( OPEN == this->fileMode ) {
93 this->writeHashFile();
96 this->fileMode = CLOSED;
122 U16 size = size32 & 0xFFFF;
125 if( OPEN == this->fileMode ) {
126 U32 projectedByteCount = this->byteCount + size;
127 if( this->storeBufferLength ) {
128 projectedByteCount +=
sizeof(size);
130 if( projectedByteCount > this->maxFileSize ) {
136 if( CLOSED == this->fileMode ){
141 if( OPEN == this->fileMode ) {
142 this->writeComBufferToFile(data, size);
147 CloseFile_cmdHandler(
163 this->pingOut_out(0,key);
172 if( !this->initialized ){
173 this->log_WARNING_LO_FileNotInitialized();
181 memset(this->fileName, 0,
sizeof(this->fileName));
182 bytesCopied = snprintf(this->fileName,
sizeof(this->fileName),
"%s_%" PRI_FwTimeBaseStoreType "_%" PRIu32
"_%06" PRIu32
".com",
187 FW_ASSERT( bytesCopied <
sizeof(this->fileName) );
190 bytesCopied = snprintf(this->hashFileName,
sizeof(this->hashFileName),
"%s_%" PRI_FwTimeBaseStoreType "_%" PRIu32
"_%06" PRIu32
".com%s",
192 FW_ASSERT( bytesCopied <
sizeof(this->hashFileName) );
196 if( !this->openErrorOccurred ) {
199 this->log_WARNING_HI_FileOpenError(ret, logStringArg);
201 this->openErrorOccurred =
true;
204 this->openErrorOccurred =
false;
210 this->fileMode = OPEN;
218 if( OPEN == this->fileMode ) {
223 this->writeHashFile();
226 this->fileMode = CLOSED;
230 this->log_DIAGNOSTIC_FileClosed(logStringArg);
235 writeComBufferToFile(
240 if( this->storeBufferLength ) {
241 U8 buffer[
sizeof(size)];
243 serialLength.serialize(size);
244 if(this->writeToFile(serialLength.getBuffAddr(),
245 static_cast<U16
>(serialLength.getBuffLength()))) {
246 this->byteCount += serialLength.getBuffLength();
255 this->byteCount += size;
268 if( !this->writeErrorOccurred ) {
271 this->log_WARNING_HI_FileWriteError(ret, size, length, logStringArg);
273 this->writeErrorOccurred =
true;
277 this->writeErrorOccurred =
false;
290 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.
@ OK
Command successfully executed.
U8 * getBuffAddr()
gets buffer address for data filling
void init()
Object initializer.
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.
Auto-generated base for ComLogger component.
void init_log_file(const char *filePrefix, U32 maxFileSize, bool storeBufferLength=true)
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)