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(),
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(
163 if( !this->m_initialized ){
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 ) {
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;
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 ) {
277 this->m_writeErrorOccurred =
true;
281 this->m_writeErrorOccurred =
false;
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
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()
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)