15 static_assert(std::numeric_limits<U16>::max() <= std::numeric_limits<FwSizeType>::max(),
16 "U16 must fit in the positive range of FwSizeType");
22 ComLogger(
const char* compName,
const char* incomingFilePrefix, U32 maxFileSize,
bool storeBufferLength) :
24 m_maxFileSize(maxFileSize),
27 m_writeErrorOccurred(false),
28 m_openErrorOccurred(false),
29 m_storeBufferLength(storeBufferLength),
32 this->
init_log_file(incomingFilePrefix, maxFileSize, storeBufferLength);
44 m_writeErrorOccurred(false),
45 m_openErrorOccurred(false),
46 m_storeBufferLength(),
52 init_log_file(
const char* incomingFilePrefix, U32 maxFileSize,
bool storeBufferLength)
55 this->m_maxFileSize = maxFileSize;
56 this->m_storeBufferLength = storeBufferLength;
57 if( this->m_storeBufferLength ) {
58 FW_ASSERT(maxFileSize >
sizeof(U16), static_cast<FwAssertArgType>(maxFileSize));
63 this->m_initialized =
true;
76 if( OPEN == this->m_fileMode ) {
81 this->writeHashFile();
84 this->m_fileMode = CLOSED;
109 FW_ASSERT(sizeNative < 65536, static_cast<FwAssertArgType>(sizeNative));
110 U16 size = sizeNative & 0xFFFF;
113 if( OPEN == this->m_fileMode ) {
114 U32 projectedByteCount = this->m_byteCount + size;
115 if( this->m_storeBufferLength ) {
116 projectedByteCount +=
static_cast<U32
>(
sizeof(size));
118 if( projectedByteCount > this->m_maxFileSize ) {
124 if( CLOSED == this->m_fileMode ){
129 if( OPEN == this->m_fileMode ) {
130 this->writeComBufferToFile(data, size);
135 CloseFile_cmdHandler(
160 if( !this->m_initialized ){
169 this->m_filePrefix.
toChar(),
179 if( !this->m_openErrorOccurred ) {
183 this->m_openErrorOccurred =
true;
186 this->m_openErrorOccurred =
false;
189 this->m_byteCount = 0;
192 this->m_fileMode = OPEN;
200 if( OPEN == this->m_fileMode ) {
202 this->m_file.
close();
205 this->writeHashFile();
208 this->m_fileMode = CLOSED;
216 writeComBufferToFile(
221 if( this->m_storeBufferLength ) {
222 U8 buffer[
sizeof(size)];
224 serialLength.serialize(size);
225 if(this->writeToFile(serialLength.getBuffAddr(),
226 static_cast<U16
>(serialLength.getBuffLength()))) {
227 this->m_byteCount +=
static_cast<U32
>(serialLength.getBuffLength());
236 this->m_byteCount += size;
249 if( !this->m_writeErrorOccurred ) {
253 this->m_writeErrorOccurred =
true;
257 this->m_writeErrorOccurred =
false;
A variable-length serializable buffer.
PlatformSizeType FwSizeType
void log_WARNING_LO_FileNotInitialized()
Log event FileNotInitialized.
void log_DIAGNOSTIC_FileClosed(const Fw::StringBase &file) const
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.
The validation of the file passed.
Serializable::SizeType getBuffLength() const
returns current buffer size
U32 FwOpcodeType
The type of a command opcode.
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
Status write(const U8 *buffer, FwSizeType &size)
write data to this file from the supplied buffer bounded by size
static const char * getFileExtensionString()
#define PRI_FwTimeBaseStoreType
FormatStatus format(const CHAR *formatString,...)
write formatted string to buffer
Command successfully executed.
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.
PlatformIndexType FwIndexType
RateGroupDivider component implementation.
U16 FwTimeBaseStoreType
The type used to serialize a time base value.
ComLogger(const char *compName, const char *filePrefix, U32 maxFileSize, bool storeBufferLength=true)
Auto-generated base for ComLogger component.
FormatStatus
status of string format calls