25 BufferLogger& bufferLogger
27 bufferLogger(bufferLogger),
49 void BufferLogger::File ::
51 const char *
const logFilePrefix,
52 const char *
const logFileSuffix,
53 const U32 maxFileSize,
58 FW_ASSERT(this->mode == File::Mode::CLOSED);
60 this->prefix = logFilePrefix;
61 this->suffix = logFileSuffix;
62 this->maxSize = maxFileSize;
63 this->sizeOfSize = sizeOfSize;
65 FW_ASSERT(sizeOfSize <=
sizeof(U32), sizeOfSize);
69 void BufferLogger::File ::
74 if (this->mode == File::Mode::OPEN) {
75 this->closeAndEmitEvent();
77 this->baseName = baseName;
78 this->fileCounter = 0;
82 void BufferLogger::File ::
89 if (this->mode == File::Mode::OPEN) {
90 const U32 projectedByteCount =
91 this->bytesWritten + this->sizeOfSize + size;
92 if (projectedByteCount > this->maxSize) {
93 this->closeAndEmitEvent();
97 if (this->mode == File::Mode::CLOSED) {
101 if (this->mode == File::Mode::OPEN) {
102 (void) this->writeBuffer(data, size);
106 void BufferLogger::File ::
109 if (this->mode == File::Mode::OPEN) {
112 this->bufferLogger.log_DIAGNOSTIC_BL_LogFileClosed(logStringArg);
120 void BufferLogger::File ::
123 FW_ASSERT(this->mode == File::Mode::CLOSED);
126 if ((this->baseName.
toChar()[0] ==
'\0') ||
127 (this->sizeOfSize >
sizeof(U32)) ||
128 (this->maxSize <= this->sizeOfSize)) {
129 this->bufferLogger.log_WARNING_HI_BL_NoLogFileOpenInitError();
133 if (this->fileCounter == 0) {
136 this->prefix.toChar(),
137 this->baseName.toChar(),
138 this->suffix.toChar()
144 this->prefix.toChar(),
145 this->baseName.toChar(),
147 this->suffix.toChar()
158 this->bytesWritten = 0;
160 this->mode = File::Mode::OPEN;
164 this->bufferLogger.log_WARNING_HI_BL_LogFileOpenError(status,
string);
168 bool BufferLogger::File ::
170 const U8 *
const data,
174 bool status = this->writeSize(size);
176 status = this->writeBytes(data, size);
181 bool BufferLogger::File ::
182 writeSize(
const U32 size)
184 FW_ASSERT(this->sizeOfSize <=
sizeof(U32));
185 U8 sizeBuffer[
sizeof(U32)];
186 U32 sizeRegister = size;
187 for (
U8 i = 0; i < this->sizeOfSize; ++i) {
188 sizeBuffer[this->sizeOfSize - i - 1] = sizeRegister & 0xFF;
191 const bool status = this->writeBytes(
198 bool BufferLogger::File ::
200 const void *
const data,
209 this->bytesWritten += length;
215 this->bufferLogger.log_WARNING_HI_BL_LogFileWriteError(fileStatus, size, length,
string);
221 void BufferLogger::File ::
226 validatedFile.createHashFile();
228 const Fw::String &hashFileName = validatedFile.getHashFileName();
230 this->bufferLogger.log_WARNING_HI_BL_LogFileValidationError(
237 bool BufferLogger::File ::
258 void BufferLogger::File ::
261 if (this->mode == File::Mode::OPEN) {
263 this->osFile.close();
265 this->writeHashFile();
267 this->mode = File::Mode::CLOSED;
PlatformIntType NATIVE_INT_TYPE
uint8_t U8
8-bit unsigned integer
Defines a file class to validate files or generate a file validator file.
virtual const CHAR * toChar() const =0
const char * toChar() const
gets char buffer
@ OP_OK
Operation was successful.
@ OPEN_WRITE
Open file for writing.
@ VALIDATION_OK
The validation of the file passed.