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);
43 m_writeErrorOccurred(false),
44 m_openErrorOccurred(false),
45 m_storeBufferLength(),
61 init_log_file(
const char* incomingFilePrefix, U32 maxFileSize,
bool storeBufferLength)
64 this->m_maxFileSize = maxFileSize;
65 this->m_storeBufferLength = storeBufferLength;
66 if( this->m_storeBufferLength ) {
76 this->m_initialized =
true;
89 if( OPEN == this->m_fileMode ) {
94 this->writeHashFile();
97 this->m_fileMode = CLOSED;
123 U16 size = size32 & 0xFFFF;
126 if( OPEN == this->m_fileMode ) {
127 U32 projectedByteCount = this->m_byteCount + size;
128 if( this->m_storeBufferLength ) {
129 projectedByteCount +=
static_cast<U32
>(
sizeof(size));
131 if( projectedByteCount > this->m_maxFileSize ) {
137 if( CLOSED == this->m_fileMode ){
142 if( OPEN == this->m_fileMode ) {
143 this->writeComBufferToFile(data, size);
148 CloseFile_cmdHandler(
173 if( !this->m_initialized ){
182 memset(this->m_fileName, 0,
sizeof(this->m_fileName));
183 bytesCopied =
static_cast<U32
>(snprintf(
185 sizeof(this->m_fileName),
194 FW_ASSERT( bytesCopied <
sizeof(this->m_fileName) );
197 bytesCopied =
static_cast<U32
>(snprintf(
198 this->m_hashFileName,
199 sizeof(this->m_hashFileName),
206 FW_ASSERT( bytesCopied <
sizeof(this->m_hashFileName) );
210 if( !this->m_openErrorOccurred ) {
215 this->m_openErrorOccurred =
true;
218 this->m_openErrorOccurred =
false;
221 this->m_byteCount = 0;
224 this->m_fileMode = OPEN;
232 if( OPEN == this->m_fileMode ) {
234 this->m_file.
close();
237 this->writeHashFile();
240 this->m_fileMode = CLOSED;
249 writeComBufferToFile(
254 if( this->m_storeBufferLength ) {
255 U8 buffer[
sizeof(size)];
257 serialLength.serialize(size);
258 if(this->writeToFile(serialLength.getBuffAddr(),
259 static_cast<U16
>(serialLength.getBuffLength()))) {
260 this->m_byteCount += serialLength.getBuffLength();
269 this->m_byteCount += size;
282 if( !this->m_writeErrorOccurred ) {
287 this->m_writeErrorOccurred =
true;
291 this->m_writeErrorOccurred =
false;
PlatformIntType NATIVE_INT_TYPE
uint8_t U8
8-bit unsigned integer
PlatformAssertArgType FwAssertArgType
PlatformSignedSizeType FwSignedSizeType
#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.
Serializable::SizeType getBuffLength() const
returns current buffer size
TimeBase getTimeBase() const
void close() override
close the file, if not opened then do nothing
Os::FileInterface::Status open(const char *path, Mode mode)
open file with supplied path and mode
Status write(const U8 *buffer, FwSignedSizeType &size)
write data to this file from the supplied buffer bounded by size
@ OP_OK
Operation was successful.
@ OPEN_WRITE
Open file for writing.
Auto-generated base for ComLogger component.
void log_WARNING_HI_FileWriteError(U32 errornum, U32 bytesWritten, U32 bytesToWrite, const Fw::StringBase &file)
void log_WARNING_HI_FileOpenError(U32 errornum, const Fw::StringBase &file)
void log_WARNING_LO_FileValidationError(const Fw::StringBase &validationFile, const Fw::StringBase &file, U32 status)
void log_DIAGNOSTIC_FileClosed(const Fw::StringBase &file)
void log_WARNING_LO_FileNotInitialized()
Log event FileNotInitialized.
void cmdResponse_out(FwOpcodeType opCode, U32 cmdSeq, Fw::CmdResponse response)
Emit command response.
void pingOut_out(FwIndexType portNum, U32 key)
Invoke output port pingOut.
void init_log_file(const char *filePrefix, U32 maxFileSize, bool storeBufferLength=true)
ComLogger(const char *compName, 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)