21 ComLogger(
const char* compName,
const char* incomingFilePrefix, U32 maxFileSize,
bool storeBufferLength) :
22 ComLoggerComponentBase(compName),
23 maxFileSize(maxFileSize),
26 writeErrorOccurred(false),
27 openErrorOccurred(false),
28 storeBufferLength(storeBufferLength)
30 if( this->storeBufferLength ) {
31 FW_ASSERT(maxFileSize >
sizeof(U16), maxFileSize);
34 FW_ASSERT(maxFileSize >
sizeof(0), maxFileSize);
49 ComLoggerComponentBase::init(queueDepth, instance);
61 if( OPEN == this->fileMode ) {
66 this->writeHashFile();
69 this->fileMode = CLOSED;
95 U16 size = size32 & 0xFFFF;
98 if( OPEN == this->fileMode ) {
99 U32 projectedByteCount = this->byteCount + size;
100 if( this->storeBufferLength ) {
101 projectedByteCount +=
sizeof(size);
103 if( projectedByteCount > this->maxFileSize ) {
109 if( CLOSED == this->fileMode ){
114 if( OPEN == this->fileMode ) {
115 this->writeComBufferToFile(data, size);
120 CloseFile_cmdHandler(
126 this->cmdResponse_out(opCode, cmdSeq, Fw::COMMAND_OK);
136 this->pingOut_out(0,key);
149 memset(this->fileName, 0,
sizeof(this->fileName));
150 bytesCopied = snprintf((
char*) this->fileName,
sizeof(this->fileName),
"%s_%d_%d_%06d.com",
155 FW_ASSERT( bytesCopied <
sizeof(this->fileName) );
158 bytesCopied = snprintf((
char*) this->hashFileName,
sizeof(this->hashFileName),
"%s_%d_%d_%06d.com%s",
160 FW_ASSERT( bytesCopied <
sizeof(this->hashFileName) );
164 if( !this->openErrorOccurred ) {
167 this->log_WARNING_HI_FileOpenError(ret, logStringArg);
169 this->openErrorOccurred =
true;
172 this->openErrorOccurred =
false;
178 this->fileMode = OPEN;
186 if( OPEN == this->fileMode ) {
191 this->writeHashFile();
194 this->fileMode = CLOSED;
198 this->log_DIAGNOSTIC_FileClosed(logStringArg);
203 writeComBufferToFile(
208 if( this->storeBufferLength ) {
209 U8 buffer[
sizeof(size)];
211 serialLength.serialize(size);
212 if(this->writeToFile(serialLength.getBuffAddr(),
213 static_cast<U16
>(serialLength.getBuffLength()))) {
214 this->byteCount += serialLength.getBuffLength();
223 this->byteCount += size;
236 if( !this->writeErrorOccurred ) {
239 this->log_WARNING_HI_FileWriteError(ret, size, length, logStringArg);
241 this->writeErrorOccurred =
true;
245 this->writeErrorOccurred =
false;
258 this->log_WARNING_LO_FileValidationError(logStringArg1, logStringArg2, validateStatus);