21 ComLogger(
const char* compName,
const char* incomingFilePrefix, U32 maxFileSize,
bool storeBufferLength) :
23 m_maxFileSize(maxFileSize),
26 m_writeErrorOccurred(false),
27 m_openErrorOccurred(false),
28 m_storeBufferLength(storeBufferLength),
31 this->
init_log_file(incomingFilePrefix, maxFileSize, storeBufferLength);
35 ComLogger(
const char* compName) :
43 m_writeErrorOccurred(false),
44 m_openErrorOccurred(false),
45 m_storeBufferLength(),
51 init_log_file(
const char* incomingFilePrefix, U32 maxFileSize,
bool storeBufferLength)
54 this->m_maxFileSize = maxFileSize;
55 this->m_storeBufferLength = storeBufferLength;
56 if( this->m_storeBufferLength ) {
66 this->m_initialized =
true;
79 if( OPEN == this->m_fileMode ) {
84 this->writeHashFile();
87 this->m_fileMode = CLOSED;
113 U16 size = size32 & 0xFFFF;
116 if( OPEN == this->m_fileMode ) {
117 U32 projectedByteCount = this->m_byteCount + size;
118 if( this->m_storeBufferLength ) {
119 projectedByteCount +=
static_cast<U32
>(
sizeof(size));
121 if( projectedByteCount > this->m_maxFileSize ) {
127 if( CLOSED == this->m_fileMode ){
132 if( OPEN == this->m_fileMode ) {
133 this->writeComBufferToFile(data, size);
138 CloseFile_cmdHandler(
154 this->pingOut_out(0,key);
163 if( !this->m_initialized ){
164 this->log_WARNING_LO_FileNotInitialized();
172 memset(this->m_fileName, 0,
sizeof(this->m_fileName));
173 bytesCopied =
static_cast<U32
>(snprintf(
175 sizeof(this->m_fileName),
184 FW_ASSERT( bytesCopied <
sizeof(this->m_fileName) );
187 bytesCopied =
static_cast<U32
>(snprintf(
188 this->m_hashFileName,
189 sizeof(this->m_hashFileName),
196 FW_ASSERT( bytesCopied <
sizeof(this->m_hashFileName) );
200 if( !this->m_openErrorOccurred ) {
203 this->log_WARNING_HI_FileOpenError(ret, logStringArg);
205 this->m_openErrorOccurred =
true;
208 this->m_openErrorOccurred =
false;
211 this->m_byteCount = 0;
214 this->m_fileMode = OPEN;
222 if( OPEN == this->m_fileMode ) {
224 this->m_file.close();
227 this->writeHashFile();
230 this->m_fileMode = CLOSED;
234 this->log_DIAGNOSTIC_FileClosed(logStringArg);
239 writeComBufferToFile(
244 if( this->m_storeBufferLength ) {
245 U8 buffer[
sizeof(size)];
247 serialLength.serialize(size);
248 if(this->writeToFile(serialLength.getBuffAddr(),
249 static_cast<U16
>(serialLength.getBuffLength()))) {
250 this->m_byteCount += serialLength.getBuffLength();
259 this->m_byteCount += size;
272 if( !this->m_writeErrorOccurred ) {
275 this->log_WARNING_HI_FileWriteError(ret,
static_cast<U32
>(size), length, logStringArg);
277 this->m_writeErrorOccurred =
true;
281 this->m_writeErrorOccurred =
false;
294 this->log_WARNING_LO_FileValidationError(logStringArg1, logStringArg2, validateStatus);
PlatformIntType NATIVE_INT_TYPE
uint8_t U8
8-bit unsigned integer
PlatformAssertArgType FwAssertArgType
PlatformSignedSizeType FwSignedSizeType
PlatformSizeType FwSizeType
#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
A variable-length serializable buffer.
Serializable::SizeType 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()
FwSizeType string_length(const CHAR *source, FwSizeType buffer_size)
get the length of the source string
char * string_copy(char *destination, const char *source, FwSizeType num)
copy string with null-termination guaranteed
@ VALIDATION_OK
The validation of the file passed.
Status createValidation(const char *fileName, const char *hash, Utils::HashBuffer &hashBuffer)