23 BufferLogger::File ::File(BufferLogger& bufferLogger)
24 : m_bufferLogger(bufferLogger),
34 BufferLogger::File ::~File() {
43 const char*
const logFileSuffix,
45 const U8 sizeOfSize) {
49 this->m_prefix = logFilePrefix;
50 this->m_suffix = logFileSuffix;
51 this->m_maxSize = maxFileSize;
52 this->m_sizeOfSize = sizeOfSize;
55 FW_ASSERT(m_maxSize > sizeOfSize, static_cast<FwAssertArgType>(m_maxSize));
58 void BufferLogger::File ::setBaseName(
const Fw::StringBase& baseName) {
60 this->closeAndEmitEvent();
62 this->m_baseName = baseName;
63 this->m_fileCounter = 0;
67 void BufferLogger::File ::logBuffer(
const U8*
const data,
const FwSizeType size) {
70 const FwSizeType projectedByteCount = this->m_bytesWritten + this->m_sizeOfSize + size;
71 if (projectedByteCount > this->m_maxSize) {
72 this->closeAndEmitEvent();
81 (void)this->writeBuffer(data, size);
85 void BufferLogger::File ::closeAndEmitEvent() {
89 this->m_bufferLogger.log_DIAGNOSTIC_BL_LogFileClosed(logStringArg);
97 void BufferLogger::File ::open() {
101 if ((this->m_baseName.toChar()[0] ==
'\0') || (this->m_sizeOfSize >
sizeof(
FwSizeType)) ||
102 (this->m_maxSize <= this->m_sizeOfSize)) {
103 this->m_bufferLogger.log_WARNING_HI_BL_NoLogFileOpenInitError();
107 if (this->m_fileCounter == 0) {
108 this->m_name.format(
"%s%s%s", this->m_prefix.toChar(), this->m_baseName.toChar(), this->m_suffix.toChar());
110 this->m_name.format(
"%s%s%" PRI_FwSizeType "%s", this->m_prefix.toChar(), this->m_baseName.toChar(),
111 this->m_fileCounter, this->m_suffix.toChar());
116 this->m_fileCounter++;
118 this->m_bytesWritten = 0;
123 this->m_bufferLogger.log_WARNING_HI_BL_LogFileOpenError(status,
string);
127 bool BufferLogger::File ::writeBuffer(
const U8*
const data,
const FwSizeType size) {
128 bool status = this->writeSize(size);
130 status = this->writeBytes(data, size);
135 bool BufferLogger::File ::writeSize(
const FwSizeType size) {
139 for (
U8 i = 0; i < this->m_sizeOfSize; ++i) {
140 sizeBuffer[this->m_sizeOfSize - i - 1] = sizeRegister & 0xFF;
143 const bool status = this->writeBytes(sizeBuffer, this->m_sizeOfSize);
147 bool BufferLogger::File ::writeBytes(
const void*
const data,
const FwSizeType length) {
149 const Os::File::Status fileStatus = this->m_osFile.write(reinterpret_cast<const U8*>(data), size);
151 if (fileStatus ==
Os::File::OP_OK && static_cast<FwSizeType>(size) == length) {
152 this->m_bytesWritten += length;
157 this->m_bufferLogger.log_WARNING_HI_BL_LogFileWriteError(fileStatus, static_cast<U32>(size),
158 static_cast<U32>(length),
string);
164 void BufferLogger::File ::writeHashFile() {
168 const Fw::StringBase& hashFileName = validatedFile.getHashFileName();
170 this->m_bufferLogger.log_WARNING_HI_BL_LogFileValidationError(logStringArg, status);
174 bool BufferLogger::File ::flush() {
193 void BufferLogger::File ::close() {
196 this->m_osFile.close();
198 this->writeHashFile();
PlatformSizeType FwSizeType
The validation of the file passed.
Os::ValidateFile::Status createHashFile()
void init()
Initialize the OS Abstraction Layer (OSAL)
uint8_t U8
8-bit unsigned integer
Operation was successful.
Defines a file class to validate files or generate a file validator file.
RateGroupDivider component implementation.
virtual const CHAR * toChar() const =0