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 ) {
57 FW_ASSERT(maxFileSize >
sizeof(U16), static_cast<FwAssertArgType>(maxFileSize));
62 this->m_initialized =
true;
75 if( OPEN == this->m_fileMode ) {
80 this->writeHashFile();
83 this->m_fileMode = CLOSED;
108 FW_ASSERT(sizeNative < 65536, static_cast<FwAssertArgType>(sizeNative));
109 U16 size = sizeNative & 0xFFFF;
112 if( OPEN == this->m_fileMode ) {
113 U32 projectedByteCount = this->m_byteCount + size;
114 if( this->m_storeBufferLength ) {
115 projectedByteCount +=
static_cast<U32
>(
sizeof(size));
117 if( projectedByteCount > this->m_maxFileSize ) {
123 if( CLOSED == this->m_fileMode ){
128 if( OPEN == this->m_fileMode ) {
129 this->writeComBufferToFile(data, size);
134 CloseFile_cmdHandler(
159 if( !this->m_initialized ){
168 this->m_filePrefix.
toChar(),
178 if( !this->m_openErrorOccurred ) {
182 this->m_openErrorOccurred =
true;
185 this->m_openErrorOccurred =
false;
188 this->m_byteCount = 0;
191 this->m_fileMode = OPEN;
199 if( OPEN == this->m_fileMode ) {
201 this->m_file.
close();
204 this->writeHashFile();
207 this->m_fileMode = CLOSED;
215 writeComBufferToFile(
220 if( this->m_storeBufferLength ) {
221 U8 buffer[
sizeof(size)];
223 serialLength.serialize(size);
224 if(this->writeToFile(serialLength.getBuffAddr(),
225 static_cast<U16
>(serialLength.getBuffLength()))) {
226 this->m_byteCount +=
static_cast<U32
>(serialLength.getBuffLength());
235 this->m_byteCount += size;
247 if(
Os::File::OP_OK != ret || size != static_cast<NATIVE_INT_TYPE>(length) ) {
248 if( !this->m_writeErrorOccurred ) {
252 this->m_writeErrorOccurred =
true;
256 this->m_writeErrorOccurred =
false;
A variable-length serializable buffer.
void log_WARNING_LO_FileNotInitialized()
Log event FileNotInitialized.
void log_DIAGNOSTIC_FileClosed(const Fw::StringBase &file) const
#define PRI_FwTimeBaseStoreType
PlatformSizeType FwSizeType
TimeBase getTimeBase() const
Os::FileInterface::Status open(const char *path, Mode mode)
open file with supplied path and mode
void init_log_file(const char *filePrefix, U32 maxFileSize, bool storeBufferLength=true)
void pingOut_out(FwIndexType portNum, U32 key)
Invoke output port pingOut.
PlatformIndexType FwIndexType
The validation of the file passed.
Serializable::SizeType getBuffLength() const
returns current buffer size
const char * toChar() const
void log_WARNING_HI_FileOpenError(U32 errornum, const Fw::StringBase &file) const
void cmdResponse_out(FwOpcodeType opCode, U32 cmdSeq, Fw::CmdResponse response)
Emit command response.
U8 * getBuffAddr()
gets buffer address for data filling
void log_WARNING_HI_FileWriteError(U32 errornum, U32 bytesWritten, U32 bytesToWrite, const Fw::StringBase &file) const
void close() override
close the file, if not opened then do nothing
static const char * getFileExtensionString()
FormatStatus format(const CHAR *formatString,...)
write formatted string to buffer
Command successfully executed.
C++-compatible configuration header for fprime configuration.
uint8_t U8
8-bit unsigned integer
Status createValidation(const char *fileName, const char *hash, Utils::HashBuffer &hashBuffer)
void log_WARNING_LO_FileValidationError(const Fw::StringBase &validationFile, const Fw::StringBase &file, U32 status) const
Operation was successful.
Defines a file class to validate files or generate a file validator file.
PlatformSignedSizeType FwSignedSizeType
ComLogger(const char *compName, const char *filePrefix, U32 maxFileSize, bool storeBufferLength=true)
Status write(const U8 *buffer, FwSignedSizeType &size)
write data to this file from the supplied buffer bounded by size
Auto-generated base for ComLogger component.
FormatStatus
status of string format calls