25 BufferLogger& bufferLogger
27 m_bufferLogger(bufferLogger),
51 const char *
const logFilePrefix,
52 const char *
const logFileSuffix,
53 const U32 maxFileSize,
58 FW_ASSERT(this->m_mode == File::Mode::CLOSED);
60 this->m_prefix = logFilePrefix;
61 this->m_suffix = logFileSuffix;
62 this->m_maxSize = maxFileSize;
63 this->m_sizeOfSize = sizeOfSize;
65 FW_ASSERT(sizeOfSize <=
sizeof(U32), sizeOfSize);
69 void BufferLogger::File ::
74 if (this->m_mode == File::Mode::OPEN) {
75 this->closeAndEmitEvent();
77 this->m_baseName = baseName;
78 this->m_fileCounter = 0;
82 void BufferLogger::File ::
89 if (this->m_mode == File::Mode::OPEN) {
90 const U32 projectedByteCount =
91 this->m_bytesWritten + this->m_sizeOfSize + size;
92 if (projectedByteCount > this->m_maxSize) {
93 this->closeAndEmitEvent();
97 if (this->m_mode == File::Mode::CLOSED) {
101 if (this->m_mode == File::Mode::OPEN) {
102 (void) this->writeBuffer(data, size);
106 void BufferLogger::File ::
109 if (this->m_mode == File::Mode::OPEN) {
112 this->m_bufferLogger.log_DIAGNOSTIC_BL_LogFileClosed(logStringArg);
120 void BufferLogger::File ::
123 FW_ASSERT(this->m_mode == File::Mode::CLOSED);
126 if ((this->m_baseName.toChar()[0] ==
'\0') ||
127 (this->m_sizeOfSize >
sizeof(U32)) ||
128 (this->m_maxSize <= this->m_sizeOfSize)) {
129 this->m_bufferLogger.log_WARNING_HI_BL_NoLogFileOpenInitError();
133 if (this->m_fileCounter == 0) {
136 this->m_prefix.toChar(),
137 this->m_baseName.toChar(),
138 this->m_suffix.toChar()
144 this->m_prefix.toChar(),
145 this->m_baseName.toChar(),
147 this->m_suffix.toChar()
152 this->m_name.toChar(),
156 this->m_fileCounter++;
158 this->m_bytesWritten = 0;
160 this->m_mode = File::Mode::OPEN;
164 this->m_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->m_sizeOfSize <=
sizeof(U32));
185 U8 sizeBuffer[
sizeof(U32)];
186 U32 sizeRegister = size;
187 for (
U8 i = 0; i < this->m_sizeOfSize; ++i) {
188 sizeBuffer[this->m_sizeOfSize - i - 1] = sizeRegister & 0xFF;
191 const bool status = this->writeBytes(
198 bool BufferLogger::File ::
200 const void *
const data,
206 const Os::File::Status fileStatus = this->m_osFile.write(
reinterpret_cast<const U8*
>(data), size);
209 this->m_bytesWritten += length;
215 this->m_bufferLogger.log_WARNING_HI_BL_LogFileWriteError(fileStatus,
static_cast<U32
>(size), length,
string);
221 void BufferLogger::File ::
226 validatedFile.createHashFile();
228 const Fw::StringBase &hashFileName = validatedFile.getHashFileName();
230 this->m_bufferLogger.log_WARNING_HI_BL_LogFileValidationError(
237 bool BufferLogger::File ::
258 void BufferLogger::File ::
261 if (this->m_mode == File::Mode::OPEN) {
263 this->m_osFile.close();
265 this->writeHashFile();
267 this->m_mode = File::Mode::CLOSED;
PlatformIntType NATIVE_INT_TYPE
uint8_t U8
8-bit unsigned integer
PlatformAssertArgType FwAssertArgType
PlatformSignedSizeType FwSignedSizeType
Defines a file class to validate files or generate a file validator file.
virtual const CHAR * toChar() const =0
@ OP_OK
Operation was successful.
@ OPEN_WRITE
Open file for writing.
@ VALIDATION_OK
The validation of the file passed.
void init()
Initialize the OS Abstraction Layer (OSAL)