20 ComLogger(
const char* compName,
const char* incomingFilePrefix, U32 maxFileSize,
bool storeBufferLength) :
21 ComLoggerComponentBase(compName),
22 maxFileSize(maxFileSize),
25 writeErrorOccurred(false),
26 openErrorOccurred(false),
27 storeBufferLength(storeBufferLength)
29 if( this->storeBufferLength ) {
30 FW_ASSERT(maxFileSize >
sizeof(U16), maxFileSize);
33 FW_ASSERT(maxFileSize >
sizeof(0), maxFileSize);
39 memset(this->filePrefix, 0,
sizeof(this->filePrefix));
40 U8* dest = (
U8*) strncpy((
char*) this->filePrefix, incomingFilePrefix,
sizeof(this->filePrefix));
41 FW_ASSERT(dest == this->filePrefix,
reinterpret_cast<U64>(dest),
reinterpret_cast<U64>(this->filePrefix));
50 ComLoggerComponentBase::init(queueDepth, instance);
62 if( OPEN == this->fileMode ) {
67 this->writeHashFile();
70 this->fileMode = CLOSED;
96 U16 size = size32 & 0xFFFF;
99 if( OPEN == this->fileMode ) {
100 U32 projectedByteCount = this->byteCount + size;
101 if( this->storeBufferLength ) {
102 projectedByteCount +=
sizeof(size);
104 if( projectedByteCount > this->maxFileSize ) {
110 if( CLOSED == this->fileMode ){
115 if( OPEN == this->fileMode ) {
116 this->writeComBufferToFile(data, size);
121 CloseFile_cmdHandler(
127 this->cmdResponse_out(opCode, cmdSeq, Fw::COMMAND_OK);
137 this->pingOut_out(0,key);
150 memset(this->fileName, 0,
sizeof(this->fileName));
151 bytesCopied = snprintf((
char*) this->fileName,
sizeof(this->fileName),
"%s_%d_%d_%06d.com",
156 FW_ASSERT( bytesCopied <
sizeof(this->fileName) );
159 bytesCopied = snprintf((
char*) this->hashFileName,
sizeof(this->hashFileName),
"%s_%d_%d_%06d.com%s",
161 FW_ASSERT( bytesCopied <
sizeof(this->hashFileName) );
165 if( !this->openErrorOccurred ) {
168 this->log_WARNING_HI_FileOpenError(ret, logStringArg);
170 this->openErrorOccurred =
true;
173 this->openErrorOccurred =
false;
179 this->fileMode = OPEN;
187 if( OPEN == this->fileMode ) {
192 this->writeHashFile();
195 this->fileMode = CLOSED;
199 this->log_DIAGNOSTIC_FileClosed(logStringArg);
204 writeComBufferToFile(
209 if( this->storeBufferLength ) {
210 U8 buffer[
sizeof(size)];
212 serialLength.serialize(size);
213 if(this->writeToFile(serialLength.getBuffAddr(),
214 static_cast<U16
>(serialLength.getBuffLength()))) {
215 this->byteCount += serialLength.getBuffLength();
224 this->byteCount += size;
237 if( !this->writeErrorOccurred ) {
240 this->log_WARNING_HI_FileWriteError(ret, size, length, logStringArg);
242 this->writeErrorOccurred =
true;
246 this->writeErrorOccurred =
false;
259 this->log_WARNING_LO_FileValidationError(logStringArg1, logStringArg2, validateStatus);