Fix shadow variables (#2482)

* Fixed shadow warnings from Fprime

* Fix unit tests

* Fix missing shadow warnings

* Fix condition in cmake

* Fix cmake

* Fixes from review

* Fixed mistake in PathName

* Fixing comment

---------

Co-authored-by: M Starch <LeStarch@googlemail.com>
This commit is contained in:
Johan Bertrand 2024-02-01 19:18:10 +01:00 committed by GitHub
parent a3578a03fe
commit f0f19baafb
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
45 changed files with 820 additions and 806 deletions

View File

@ -20,13 +20,13 @@ static U32 min(const U32 a, const U32 b) {
namespace CFDP { namespace CFDP {
Checksum :: Checksum ::
Checksum() : value(0) Checksum() : m_value(0)
{ {
} }
Checksum :: Checksum ::
Checksum(const U32 value) : value(value) Checksum(const U32 value) : m_value(value)
{ {
} }
@ -34,7 +34,7 @@ namespace CFDP {
Checksum :: Checksum ::
Checksum(const Checksum &original) Checksum(const Checksum &original)
{ {
this->value = original.getValue(); this->m_value = original.getValue();
} }
Checksum :: Checksum ::
@ -46,14 +46,14 @@ namespace CFDP {
Checksum& Checksum :: Checksum& Checksum ::
operator=(const Checksum& checksum) operator=(const Checksum& checksum)
{ {
this->value = checksum.value; this->m_value = checksum.m_value;
return *this; return *this;
} }
bool Checksum :: bool Checksum ::
operator==(const Checksum& checksum) const operator==(const Checksum& checksum) const
{ {
return this->value == checksum.value; return this->m_value == checksum.m_value;
} }
bool Checksum :: bool Checksum ::
@ -65,7 +65,7 @@ namespace CFDP {
U32 Checksum :: U32 Checksum ::
getValue() const getValue() const
{ {
return this->value; return this->m_value;
} }
void Checksum :: void Checksum ::
@ -137,7 +137,7 @@ namespace CFDP {
{ {
FW_ASSERT(offset < 4); FW_ASSERT(offset < 4);
const U32 addend = byte << (8*(3-offset)); const U32 addend = byte << (8*(3-offset));
this->value += addend; this->m_value += addend;
} }
} }

View File

@ -102,7 +102,7 @@ namespace CFDP {
// ---------------------------------------------------------------------- // ----------------------------------------------------------------------
//! The accumulated checksum value //! The accumulated checksum value
U32 value; U32 m_value;
}; };

View File

@ -25,6 +25,14 @@ add_compile_options(
-Wno-unused-parameter -Wno-unused-parameter
) )
# Add -Wshadow only for framework code, not the unit tests
# TODO: Next lines to be uncommented once FPP is not generating files with shadow variables
# if (NOT BUILD_TESTING)
# add_compile_options(
# -Wshadow
# )
# endif()
# Turn on pedantic checks for clang, but disable specific checks that F' doesn't comply with. # Turn on pedantic checks for clang, but disable specific checks that F' doesn't comply with.
# GCC doesn't support disabling specific pedantic checks, so skip pedantic on GCC for now. # GCC doesn't support disabling specific pedantic checks, so skip pedantic on GCC for now.
# #

View File

@ -122,7 +122,7 @@ bool LinuxUartDriver::open(const char* const device,
if (fc == HW_FLOW) { if (fc == HW_FLOW) {
struct termios t; struct termios t;
int stat = tcgetattr(fd, &t); stat = tcgetattr(fd, &t);
if (-1 == stat) { if (-1 == stat) {
DEBUG_PRINT("tcgetattr UART fd %d failed\n", fd); DEBUG_PRINT("tcgetattr UART fd %d failed\n", fd);
close(fd); close(fd);

View File

@ -18,15 +18,15 @@ namespace Fw {
void FilePacket::DataPacket :: void FilePacket::DataPacket ::
initialize( initialize(
const U32 sequenceIndex, const U32 sequenceIndex,
const U32 byteOffset, const U32 a_byteOffset,
const U16 dataSize, const U16 a_dataSize,
const U8 *const data const U8 *const a_data
) )
{ {
this->header.initialize(FilePacket::T_DATA, sequenceIndex); this->header.initialize(FilePacket::T_DATA, sequenceIndex);
this->byteOffset = byteOffset; this->byteOffset = a_byteOffset;
this->dataSize = dataSize; this->dataSize = a_dataSize;
this->data = data; this->data = a_data;
} }
U32 FilePacket::DataPacket :: U32 FilePacket::DataPacket ::

View File

@ -30,7 +30,7 @@ namespace Fw {
U32 FilePacket::EndPacket :: U32 FilePacket::EndPacket ::
bufferSize() const bufferSize() const
{ {
return this->header.bufferSize() + sizeof(this->checksumValue); return this->header.bufferSize() + sizeof(this->m_checksumValue);
} }
SerializeStatus FilePacket::EndPacket :: SerializeStatus FilePacket::EndPacket ::
@ -46,14 +46,14 @@ namespace Fw {
void FilePacket::EndPacket :: void FilePacket::EndPacket ::
setChecksum(const CFDP::Checksum& checksum) setChecksum(const CFDP::Checksum& checksum)
{ {
this->checksumValue = checksum.getValue(); this->m_checksumValue = checksum.getValue();
} }
void FilePacket::EndPacket :: void FilePacket::EndPacket ::
getChecksum(CFDP::Checksum& checksum) const getChecksum(CFDP::Checksum& checksum) const
{ {
CFDP::Checksum c(this->checksumValue); CFDP::Checksum c(this->m_checksumValue);
checksum = c; checksum = c;
} }
@ -64,7 +64,7 @@ namespace Fw {
FW_ASSERT(this->header.type == T_END); FW_ASSERT(this->header.type == T_END);
const SerializeStatus status = const SerializeStatus status =
serialBuffer.deserialize(this->checksumValue); serialBuffer.deserialize(this->m_checksumValue);
return status; return status;
@ -82,7 +82,7 @@ namespace Fw {
if (status != FW_SERIALIZE_OK) if (status != FW_SERIALIZE_OK)
return status; return status;
status = serialBuffer.serialize(this->checksumValue); status = serialBuffer.serialize(this->m_checksumValue);
if (status != FW_SERIALIZE_OK) if (status != FW_SERIALIZE_OK)
return status; return status;

View File

@ -34,77 +34,77 @@ namespace Fw {
const FilePacket::Header& FilePacket :: const FilePacket::Header& FilePacket ::
asHeader() const asHeader() const
{ {
return this->header; return this->m_header;
} }
const FilePacket::StartPacket& FilePacket :: const FilePacket::StartPacket& FilePacket ::
asStartPacket() const asStartPacket() const
{ {
FW_ASSERT(this->header.type == T_START); FW_ASSERT(this->m_header.type == T_START);
return this->startPacket; return this->m_startPacket;
} }
const FilePacket::DataPacket& FilePacket :: const FilePacket::DataPacket& FilePacket ::
asDataPacket() const asDataPacket() const
{ {
FW_ASSERT(this->header.type == T_DATA); FW_ASSERT(this->m_header.type == T_DATA);
return this->dataPacket; return this->m_dataPacket;
} }
const FilePacket::EndPacket& FilePacket :: const FilePacket::EndPacket& FilePacket ::
asEndPacket() const asEndPacket() const
{ {
FW_ASSERT(this->header.type == T_END); FW_ASSERT(this->m_header.type == T_END);
return this->endPacket; return this->m_endPacket;
} }
const FilePacket::CancelPacket& FilePacket :: const FilePacket::CancelPacket& FilePacket ::
asCancelPacket() const asCancelPacket() const
{ {
FW_ASSERT(this->header.type == T_CANCEL); FW_ASSERT(this->m_header.type == T_CANCEL);
return this->cancelPacket; return this->m_cancelPacket;
} }
void FilePacket :: void FilePacket ::
fromStartPacket(const StartPacket& startPacket) fromStartPacket(const StartPacket& startPacket)
{ {
this->startPacket = startPacket; this->m_startPacket = startPacket;
this->header.type = T_START; this->m_header.type = T_START;
} }
void FilePacket :: void FilePacket ::
fromDataPacket(const DataPacket& dataPacket) fromDataPacket(const DataPacket& dataPacket)
{ {
this->dataPacket = dataPacket; this->m_dataPacket = dataPacket;
this->header.type = T_DATA; this->m_header.type = T_DATA;
} }
void FilePacket :: void FilePacket ::
fromEndPacket(const EndPacket& endPacket) fromEndPacket(const EndPacket& endPacket)
{ {
this->endPacket = endPacket; this->m_endPacket = endPacket;
this->header.type = T_END; this->m_header.type = T_END;
} }
void FilePacket :: void FilePacket ::
fromCancelPacket(const CancelPacket& cancelPacket) fromCancelPacket(const CancelPacket& cancelPacket)
{ {
this->cancelPacket = cancelPacket; this->m_cancelPacket = cancelPacket;
this->header.type = T_CANCEL; this->m_header.type = T_CANCEL;
} }
U32 FilePacket :: U32 FilePacket ::
bufferSize() const bufferSize() const
{ {
switch (this->header.type) { switch (this->m_header.type) {
case T_START: case T_START:
return this->startPacket.bufferSize(); return this->m_startPacket.bufferSize();
case T_DATA: case T_DATA:
return this->dataPacket.bufferSize(); return this->m_dataPacket.bufferSize();
case T_END: case T_END:
return this->endPacket.bufferSize(); return this->m_endPacket.bufferSize();
case T_CANCEL: case T_CANCEL:
return this->cancelPacket.bufferSize(); return this->m_cancelPacket.bufferSize();
case T_NONE: case T_NONE:
return 0; return 0;
default: default:
@ -116,15 +116,15 @@ namespace Fw {
SerializeStatus FilePacket :: SerializeStatus FilePacket ::
toBuffer(Buffer& buffer) const toBuffer(Buffer& buffer) const
{ {
switch (this->header.type) { switch (this->m_header.type) {
case T_START: case T_START:
return this->startPacket.toBuffer(buffer); return this->m_startPacket.toBuffer(buffer);
case T_DATA: case T_DATA:
return this->dataPacket.toBuffer(buffer); return this->m_dataPacket.toBuffer(buffer);
case T_END: case T_END:
return this->endPacket.toBuffer(buffer); return this->m_endPacket.toBuffer(buffer);
case T_CANCEL: case T_CANCEL:
return this->cancelPacket.toBuffer(buffer); return this->m_cancelPacket.toBuffer(buffer);
default: default:
FW_ASSERT(0); FW_ASSERT(0);
return static_cast<SerializeStatus>(0); return static_cast<SerializeStatus>(0);
@ -139,21 +139,21 @@ namespace Fw {
fromSerialBuffer(SerialBuffer& serialBuffer) fromSerialBuffer(SerialBuffer& serialBuffer)
{ {
SerializeStatus status; SerializeStatus status;
status = this->header.fromSerialBuffer(serialBuffer); status = this->m_header.fromSerialBuffer(serialBuffer);
if (status != FW_SERIALIZE_OK) if (status != FW_SERIALIZE_OK)
return status; return status;
switch (this->header.type) { switch (this->m_header.type) {
case T_START: case T_START:
status = this->startPacket.fromSerialBuffer(serialBuffer); status = this->m_startPacket.fromSerialBuffer(serialBuffer);
break; break;
case T_DATA: case T_DATA:
status = this->dataPacket.fromSerialBuffer(serialBuffer); status = this->m_dataPacket.fromSerialBuffer(serialBuffer);
break; break;
case T_END: case T_END:
status = this->endPacket.fromSerialBuffer(serialBuffer); status = this->m_endPacket.fromSerialBuffer(serialBuffer);
break; break;
case T_CANCEL: case T_CANCEL:
status = this->cancelPacket.fromSerialBuffer(serialBuffer); status = this->m_cancelPacket.fromSerialBuffer(serialBuffer);
break; break;
case T_NONE: case T_NONE:
status = FW_DESERIALIZE_TYPE_MISMATCH; status = FW_DESERIALIZE_TYPE_MISMATCH;

View File

@ -63,7 +63,7 @@ namespace Fw {
//! Initialize a PathName //! Initialize a PathName
void initialize( void initialize(
const char *const value //! The path value const char *const a_value //! The path value
); );
//! Compute the buffer size needed to hold this PathName //! Compute the buffer size needed to hold this PathName
@ -99,8 +99,8 @@ namespace Fw {
//! Initialize a file packet header //! Initialize a file packet header
void initialize( void initialize(
const Type type, //!< The packet type const Type a_type, //!< The packet type
const U32 sequenceIndex //!< The sequence index const U32 a_sequenceIndex //!< The sequence index
); );
//! Compute the buffer size needed to hold this Header //! Compute the buffer size needed to hold this Header
@ -137,9 +137,9 @@ namespace Fw {
//! Initialize a StartPacket with sequence number 0 //! Initialize a StartPacket with sequence number 0
void initialize( void initialize(
const U32 fileSize, //!< The file size const U32 a_fileSize, //!< The file size
const char *const sourcePath, //!< The source path const char *const a_sourcePath, //!< The source path
const char *const destinationPath //!< The destination path const char *const a_destinationPath //!< The destination path
); );
//! Compute the buffer size needed to hold this StartPacket //! Compute the buffer size needed to hold this StartPacket
@ -188,9 +188,9 @@ namespace Fw {
//! Initialize a data packet //! Initialize a data packet
void initialize( void initialize(
const U32 sequenceIndex, //!< The sequence index const U32 sequenceIndex, //!< The sequence index
const U32 byteOffset, //!< The byte offset const U32 a_byteOffset, //!< The byte offset
const U16 dataSize, //!< The data size const U16 a_dataSize, //!< The data size
const U8 *const data //!< The file data const U8 *const a_data //!< The file data
); );
//! Compute the buffer size needed to hold this DataPacket //! Compute the buffer size needed to hold this DataPacket
@ -245,7 +245,7 @@ namespace Fw {
PRIVATE: PRIVATE:
//! The checksum //! The checksum
U32 checksumValue; U32 m_checksumValue;
//! Initialize this EndPacket from a SerialBuffer //! Initialize this EndPacket from a SerialBuffer
SerializeStatus fromSerialBuffer(SerialBuffer& serialBuffer); SerializeStatus fromSerialBuffer(SerialBuffer& serialBuffer);
@ -291,7 +291,7 @@ namespace Fw {
// Constructor // Constructor
// ---------------------------------------------------------------------- // ----------------------------------------------------------------------
FilePacket() { this->header.type = T_NONE; } FilePacket() { this->m_header.type = T_NONE; }
public: public:
@ -365,23 +365,23 @@ namespace Fw {
//! this, seen as a header //! this, seen as a header
//! //!
Header header; Header m_header;
//! this, seen as a Start packet //! this, seen as a Start packet
//! //!
StartPacket startPacket; StartPacket m_startPacket;
//! this, seen as a Data packet //! this, seen as a Data packet
//! //!
DataPacket dataPacket; DataPacket m_dataPacket;
//! this, seen as an End packet //! this, seen as an End packet
//! //!
EndPacket endPacket; EndPacket m_endPacket;
//! this, seen as a Cancel packet //! this, seen as a Cancel packet
//! //!
CancelPacket cancelPacket; CancelPacket m_cancelPacket;
}; };

View File

@ -17,12 +17,12 @@ namespace Fw {
void FilePacket::Header :: void FilePacket::Header ::
initialize( initialize(
const Type type, const Type a_type,
const U32 sequenceIndex const U32 a_sequenceIndex
) )
{ {
this->type = type; this->type = a_type;
this->sequenceIndex = sequenceIndex; this->sequenceIndex = a_sequenceIndex;
} }
U32 FilePacket::Header :: U32 FilePacket::Header ::
@ -35,14 +35,14 @@ namespace Fw {
fromSerialBuffer(SerialBuffer& serialBuffer) fromSerialBuffer(SerialBuffer& serialBuffer)
{ {
U8 type; U8 new_type;
SerializeStatus status; SerializeStatus status;
status = serialBuffer.deserialize(type); status = serialBuffer.deserialize(new_type);
if (status != FW_SERIALIZE_OK) { if (status != FW_SERIALIZE_OK) {
return status; return status;
} }
this->type = static_cast<Type>(type); this->type = static_cast<Type>(new_type);
status = serialBuffer.deserialize(this->sequenceIndex); status = serialBuffer.deserialize(this->sequenceIndex);
@ -54,10 +54,10 @@ namespace Fw {
toSerialBuffer(SerialBuffer& serialBuffer) const toSerialBuffer(SerialBuffer& serialBuffer) const
{ {
const U8 type = static_cast<U8>(this->type); const U8 type_casted = static_cast<U8>(this->type);
SerializeStatus status; SerializeStatus status;
status = serialBuffer.serialize(type); status = serialBuffer.serialize(type_casted);
if (status != FW_SERIALIZE_OK) if (status != FW_SERIALIZE_OK)
return status; return status;

View File

@ -19,11 +19,11 @@
namespace Fw { namespace Fw {
void FilePacket::PathName :: void FilePacket::PathName ::
initialize(const char *const value) initialize(const char *const a_value)
{ {
const U8 length = static_cast<U8>(StringUtils::string_length(value, MAX_LENGTH)); const U8 new_length = static_cast<U8>(StringUtils::string_length(a_value, MAX_LENGTH));
this->length = length; this->length = new_length;
this->value = value; this->value = a_value;
} }
U32 FilePacket::PathName :: U32 FilePacket::PathName ::

View File

@ -17,16 +17,16 @@ namespace Fw {
void FilePacket::StartPacket :: void FilePacket::StartPacket ::
initialize( initialize(
const U32 fileSize, const U32 a_fileSize,
const char *const sourcePath, const char *const a_sourcePath,
const char *const destinationPath const char *const a_destinationPath
) )
{ {
const FilePacket::Header header = { FilePacket::T_START, 0 }; const FilePacket::Header new_header = { FilePacket::T_START, 0 };
this->header = header; this->header = new_header;
this->fileSize = fileSize; this->fileSize = a_fileSize;
this->sourcePath.initialize(sourcePath); this->sourcePath.initialize(a_sourcePath);
this->destinationPath.initialize(destinationPath); this->destinationPath.initialize(a_destinationPath);
} }
U32 FilePacket::StartPacket :: U32 FilePacket::StartPacket ::

View File

@ -17,18 +17,18 @@
namespace Fw { namespace Fw {
SerializableFile::SerializableFile(MemAllocator* allocator, NATIVE_UINT_TYPE maxSerializedSize) : SerializableFile::SerializableFile(MemAllocator* allocator, NATIVE_UINT_TYPE maxSerializedSize) :
allocator(allocator), m_allocator(allocator),
recoverable(false), // for compiler; not used m_recoverable(false), // for compiler; not used
actualSize(maxSerializedSize), m_actualSize(maxSerializedSize),
buffer(static_cast<U8*>(this->allocator->allocate(0, actualSize, recoverable)), actualSize) m_buffer(static_cast<U8*>(this->m_allocator->allocate(0, m_actualSize, m_recoverable)), m_actualSize)
{ {
// assert if allocator returns smaller size // assert if allocator returns smaller size
FW_ASSERT(maxSerializedSize == actualSize,maxSerializedSize,actualSize); FW_ASSERT(maxSerializedSize == m_actualSize,maxSerializedSize,m_actualSize);
FW_ASSERT(nullptr != buffer.getBuffAddr()); FW_ASSERT(nullptr != m_buffer.getBuffAddr());
} }
SerializableFile::~SerializableFile() { SerializableFile::~SerializableFile() {
this->allocator->deallocate(0, this->buffer.getBuffAddr()); this->m_allocator->deallocate(0, this->m_buffer.getBuffAddr());
} }
SerializableFile::Status SerializableFile::load(const char* fileName, Serializable& serializable) { SerializableFile::Status SerializableFile::load(const char* fileName, Serializable& serializable) {
@ -39,9 +39,9 @@ namespace Fw {
return FILE_OPEN_ERROR; return FILE_OPEN_ERROR;
} }
NATIVE_INT_TYPE capacity = this->buffer.getBuffCapacity(); NATIVE_INT_TYPE capacity = this->m_buffer.getBuffCapacity();
NATIVE_INT_TYPE length = capacity; NATIVE_INT_TYPE length = capacity;
status = file.read(this->buffer.getBuffAddr(), length, false); status = file.read(this->m_buffer.getBuffAddr(), length, false);
if( Os::File::OP_OK != status ) { if( Os::File::OP_OK != status ) {
file.close(); file.close();
return FILE_READ_ERROR; return FILE_READ_ERROR;
@ -50,9 +50,9 @@ namespace Fw {
this->reset(); this->reset();
SerializeStatus serStatus; SerializeStatus serStatus;
serStatus = this->buffer.setBuffLen(static_cast<NATIVE_UINT_TYPE>(length)); serStatus = this->m_buffer.setBuffLen(static_cast<NATIVE_UINT_TYPE>(length));
FW_ASSERT(FW_SERIALIZE_OK == serStatus, serStatus); FW_ASSERT(FW_SERIALIZE_OK == serStatus, serStatus);
serStatus = serializable.deserialize(this->buffer); serStatus = serializable.deserialize(this->m_buffer);
if(FW_SERIALIZE_OK != serStatus) { if(FW_SERIALIZE_OK != serStatus) {
return DESERIALIZATION_ERROR; return DESERIALIZATION_ERROR;
} }
@ -62,7 +62,7 @@ namespace Fw {
SerializableFile::Status SerializableFile::save(const char* fileName, Serializable& serializable) { SerializableFile::Status SerializableFile::save(const char* fileName, Serializable& serializable) {
this->reset(); this->reset();
SerializeStatus serStatus = serializable.serialize(this->buffer); SerializeStatus serStatus = serializable.serialize(this->m_buffer);
FW_ASSERT(FW_SERIALIZE_OK == serStatus, serStatus); FW_ASSERT(FW_SERIALIZE_OK == serStatus, serStatus);
Os::File file; Os::File file;
@ -72,9 +72,9 @@ namespace Fw {
return FILE_OPEN_ERROR; return FILE_OPEN_ERROR;
} }
NATIVE_INT_TYPE length = this->buffer.getBuffLength(); NATIVE_INT_TYPE length = this->m_buffer.getBuffLength();
NATIVE_INT_TYPE size = length; NATIVE_INT_TYPE size = length;
status = file.write(this->buffer.getBuffAddr(), length); status = file.write(this->m_buffer.getBuffAddr(), length);
if( (Os::File::OP_OK != status) || if( (Os::File::OP_OK != status) ||
(length != size) ) (length != size) )
{ {
@ -88,7 +88,7 @@ namespace Fw {
} }
void SerializableFile::reset() { void SerializableFile::reset() {
this->buffer.resetSer(); //!< reset to beginning of buffer to reuse for serialization this->m_buffer.resetSer(); //!< reset to beginning of buffer to reuse for serialization
this->buffer.resetDeser(); //!< reset deserialization to beginning this->m_buffer.resetDeser(); //!< reset deserialization to beginning
} }
} }

View File

@ -1,4 +1,4 @@
// ====================================================================== // ======================================================================
// \title SerializableFile.hpp // \title SerializableFile.hpp
// \author dinkel // \author dinkel
// \brief hpp file for SerializableFile // \brief hpp file for SerializableFile
@ -7,8 +7,8 @@
// Copyright 2009-2016, by the California Institute of Technology. // Copyright 2009-2016, by the California Institute of Technology.
// ALL RIGHTS RESERVED. United States Government Sponsorship // ALL RIGHTS RESERVED. United States Government Sponsorship
// acknowledged. // acknowledged.
// //
// ====================================================================== // ======================================================================
#ifndef Fw_SerializableFile_HPP #ifndef Fw_SerializableFile_HPP
#define Fw_SerializableFile_HPP #define Fw_SerializableFile_HPP
@ -34,16 +34,16 @@ namespace Fw {
// NOTE!: This should not be used with an allocator that can return a smaller buffer than requested // NOTE!: This should not be used with an allocator that can return a smaller buffer than requested
SerializableFile(MemAllocator* allocator, NATIVE_UINT_TYPE maxSerializedSize); SerializableFile(MemAllocator* allocator, NATIVE_UINT_TYPE maxSerializedSize);
~SerializableFile(); ~SerializableFile();
Status load(const char* fileName, Serializable& serializable); Status load(const char* fileName, Serializable& serializable);
Status save(const char* fileName, Serializable& serializable); Status save(const char* fileName, Serializable& serializable);
PRIVATE: PRIVATE:
void reset(); void reset();
MemAllocator* allocator; MemAllocator* m_allocator;
bool recoverable; // don't care; for allocator bool m_recoverable; // don't care; for allocator
NATIVE_UINT_TYPE actualSize; // for checking NATIVE_UINT_TYPE m_actualSize; // for checking
SerialBuffer buffer; SerialBuffer m_buffer;
}; };
} }

View File

@ -20,8 +20,8 @@ namespace Fw {
U8 *const data, U8 *const data,
const U32 capacity const U32 capacity
) : ) :
data(data), m_data(data),
capacity(capacity) m_capacity(capacity)
{ {
} }
@ -29,25 +29,25 @@ namespace Fw {
NATIVE_UINT_TYPE SerialBuffer :: NATIVE_UINT_TYPE SerialBuffer ::
getBuffCapacity() const getBuffCapacity() const
{ {
return capacity; return m_capacity;
} }
U8* SerialBuffer :: U8* SerialBuffer ::
getBuffAddr() getBuffAddr()
{ {
return data; return m_data;
} }
const U8* SerialBuffer :: const U8* SerialBuffer ::
getBuffAddr() const getBuffAddr() const
{ {
return data; return m_data;
} }
void SerialBuffer :: void SerialBuffer ::
fill() fill()
{ {
const SerializeStatus status = this->setBuffLen(this->capacity); const SerializeStatus status = this->setBuffLen(this->m_capacity);
FW_ASSERT(status == FW_SERIALIZE_OK); FW_ASSERT(status == FW_SERIALIZE_OK);
} }

View File

@ -78,10 +78,10 @@ namespace Fw {
// ---------------------------------------------------------------------- // ----------------------------------------------------------------------
//! The data //! The data
U8 *const data; U8 *const m_data;
//! The capacity //! The capacity
const U32 capacity; const U32 m_capacity;
}; };

View File

@ -121,11 +121,11 @@ namespace Os {
NATIVE_UINT_TYPE getBufferIndex(NATIVE_INT_TYPE index); NATIVE_UINT_TYPE getBufferIndex(NATIVE_INT_TYPE index);
// Member variables: // Member variables:
void* queue; // The queue can be implemented in various ways void* m_queue; // The queue can be implemented in various ways
NATIVE_UINT_TYPE msgSize; // Max size of message on the queue NATIVE_UINT_TYPE m_msgSize; // Max size of message on the queue
NATIVE_UINT_TYPE depth; // Max number of messages on the queue NATIVE_UINT_TYPE m_depth; // Max number of messages on the queue
NATIVE_UINT_TYPE count; // Current number of messages on the queue NATIVE_UINT_TYPE m_count; // Current number of messages on the queue
NATIVE_UINT_TYPE maxCount; // Maximum number of messages ever seen on the queue NATIVE_UINT_TYPE m_maxCount; // Maximum number of messages ever seen on the queue
}; };
} }

View File

@ -24,11 +24,11 @@ namespace Os {
BufferQueue::BufferQueue() { BufferQueue::BufferQueue() {
// Set member variables: // Set member variables:
this->queue = nullptr; this->m_queue = nullptr;
this->msgSize = 0; this->m_msgSize = 0;
this->depth = 0; this->m_depth = 0;
this->count = 0; this->m_count = 0;
this->maxCount = 0; this->m_maxCount = 0;
} }
BufferQueue::~BufferQueue() { BufferQueue::~BufferQueue() {
@ -37,20 +37,20 @@ namespace Os {
bool BufferQueue::create(NATIVE_UINT_TYPE depth, NATIVE_UINT_TYPE msgSize) { bool BufferQueue::create(NATIVE_UINT_TYPE depth, NATIVE_UINT_TYPE msgSize) {
// Queue is already set up. destroy it and try again: // Queue is already set up. destroy it and try again:
if (nullptr != this->queue) { if (nullptr != this->m_queue) {
this->finalize(); this->finalize();
} }
FW_ASSERT(nullptr == this->queue, reinterpret_cast<POINTER_CAST>(this->queue)); FW_ASSERT(nullptr == this->m_queue, reinterpret_cast<POINTER_CAST>(this->m_queue));
// Set member variables: // Set member variables:
this->msgSize = msgSize; this->m_msgSize = msgSize;
this->depth = depth; this->m_depth = depth;
return this->initialize(depth, msgSize); return this->initialize(depth, msgSize);
} }
bool BufferQueue::push(const U8* buffer, NATIVE_UINT_TYPE size, NATIVE_INT_TYPE priority) { bool BufferQueue::push(const U8* buffer, NATIVE_UINT_TYPE size, NATIVE_INT_TYPE priority) {
FW_ASSERT(size <= this->msgSize); FW_ASSERT(size <= this->m_msgSize);
if( this->isFull() ) { if( this->isFull() ) {
return false; return false;
} }
@ -62,9 +62,9 @@ namespace Os {
} }
// Increment count: // Increment count:
++this->count; ++this->m_count;
if( this->count > this->maxCount ) { if( this->m_count > this->m_maxCount ) {
this->maxCount = this->count; this->m_maxCount = this->m_count;
} }
return true; return true;
} }
@ -83,38 +83,38 @@ namespace Os {
} }
// Decrement count: // Decrement count:
--this->count; --this->m_count;
return true; return true;
} }
bool BufferQueue::isFull() { bool BufferQueue::isFull() {
return (this->count == this->depth); return (this->m_count == this->m_depth);
} }
bool BufferQueue::isEmpty() { bool BufferQueue::isEmpty() {
return (this->count == 0); return (this->m_count == 0);
} }
NATIVE_UINT_TYPE BufferQueue::getCount() { NATIVE_UINT_TYPE BufferQueue::getCount() {
return this->count; return this->m_count;
} }
NATIVE_UINT_TYPE BufferQueue::getMaxCount() { NATIVE_UINT_TYPE BufferQueue::getMaxCount() {
return this->maxCount; return this->m_maxCount;
} }
NATIVE_UINT_TYPE BufferQueue::getMsgSize() { NATIVE_UINT_TYPE BufferQueue::getMsgSize() {
return this->msgSize; return this->m_msgSize;
} }
NATIVE_UINT_TYPE BufferQueue::getDepth() { NATIVE_UINT_TYPE BufferQueue::getDepth() {
return this->depth; return this->m_depth;
} }
NATIVE_UINT_TYPE BufferQueue::getBufferIndex(NATIVE_INT_TYPE index) { NATIVE_UINT_TYPE BufferQueue::getBufferIndex(NATIVE_INT_TYPE index) {
return (index % this->depth) * (sizeof(NATIVE_INT_TYPE) + this->msgSize); return (index % this->m_depth) * (sizeof(NATIVE_INT_TYPE) + this->m_msgSize);
} }
void BufferQueue::enqueueBuffer(const U8* buffer, NATIVE_UINT_TYPE size, U8* data, NATIVE_UINT_TYPE index) { void BufferQueue::enqueueBuffer(const U8* buffer, NATIVE_UINT_TYPE size, U8* data, NATIVE_UINT_TYPE index) {

View File

@ -31,31 +31,31 @@ namespace Os {
MaxHeap::MaxHeap() { MaxHeap::MaxHeap() {
// Initialize the heap: // Initialize the heap:
this->capacity = 0; this->m_capacity = 0;
this->heap = nullptr; this->m_heap = nullptr;
this->size = 0; this->m_size = 0;
this->order = 0; this->m_order = 0;
} }
MaxHeap::~MaxHeap() { MaxHeap::~MaxHeap() {
delete [] this->heap; delete [] this->m_heap;
this->heap = nullptr; this->m_heap = nullptr;
} }
bool MaxHeap::create(NATIVE_UINT_TYPE capacity) bool MaxHeap::create(NATIVE_UINT_TYPE capacity)
{ {
// The heap has already been created.. so delete // The heap has already been created.. so delete
// it and try again. // it and try again.
if( nullptr != this->heap ) { if( nullptr != this->m_heap ) {
delete [] this->heap; delete [] this->m_heap;
this->heap = nullptr; this->m_heap = nullptr;
} }
this->heap = new(std::nothrow) Node[capacity]; this->m_heap = new(std::nothrow) Node[capacity];
if( nullptr == this->heap ) { if( nullptr == this->m_heap ) {
return false; return false;
} }
this->capacity = capacity; this->m_capacity = capacity;
return true; return true;
} }
@ -67,10 +67,10 @@ namespace Os {
// Heap indexes: // Heap indexes:
NATIVE_UINT_TYPE parent; NATIVE_UINT_TYPE parent;
NATIVE_UINT_TYPE index = this->size; NATIVE_UINT_TYPE index = this->m_size;
// Max loop bounds for bit flip protection: // Max loop bounds for bit flip protection:
NATIVE_UINT_TYPE maxIter = this->size+1; NATIVE_UINT_TYPE maxIter = this->m_size+1;
NATIVE_UINT_TYPE maxCount = 0; NATIVE_UINT_TYPE maxCount = 0;
// Start at the bottom of the heap and work our ways // Start at the bottom of the heap and work our ways
@ -85,26 +85,26 @@ namespace Os {
// If the current value is less than the parent, // If the current value is less than the parent,
// then the current index is in the correct place, // then the current index is in the correct place,
// so break out of the loop: // so break out of the loop:
if(value <= this->heap[parent].value) { if(value <= this->m_heap[parent].value) {
break; break;
} }
// Swap the parent and child: // Swap the parent and child:
this->heap[index] = this->heap[parent]; this->m_heap[index] = this->m_heap[parent];
index = parent; index = parent;
++maxCount; ++maxCount;
} }
// Check for programming errors or bit flips: // Check for programming errors or bit flips:
FW_ASSERT(maxCount < maxIter, maxCount, maxIter); FW_ASSERT(maxCount < maxIter, maxCount, maxIter);
FW_ASSERT(index <= this->size, index); FW_ASSERT(index <= this->m_size, index);
// Set the values of the new element: // Set the values of the new element:
this->heap[index].value = value; this->m_heap[index].value = value;
this->heap[index].order = order; this->m_heap[index].order = m_order;
this->heap[index].id = id; this->m_heap[index].id = id;
++this->size; ++this->m_size;
++this->order; ++this->m_order;
return true; return true;
} }
@ -117,17 +117,17 @@ namespace Os {
// Set the return values to the top (max) of // Set the return values to the top (max) of
// the heap: // the heap:
value = this->heap[0].value; value = this->m_heap[0].value;
id = this->heap[0].id; id = this->m_heap[0].id;
// Now place the last element on the heap in // Now place the last element on the heap in
// the root position, and resize the heap. // the root position, and resize the heap.
// This will put the smallest value in the // This will put the smallest value in the
// heap on the top, violating the heap property. // heap on the top, violating the heap property.
NATIVE_UINT_TYPE index = this->size-1; NATIVE_UINT_TYPE index = this->m_size-1;
// Fw::Logger::logMsg("Putting on top: i: %u v: %d\n", index, this->heap[index].value); // Fw::Logger::logMsg("Putting on top: i: %u v: %d\n", index, this->m_heap[index].value);
this->heap[0]= this->heap[index]; this->m_heap[0]= this->m_heap[index];
--this->size; --this->m_size;
// Now that the heap property is violated, we // Now that the heap property is violated, we
// need to reorganize the heap to restore it's // need to reorganize the heap to restore it's
@ -138,17 +138,17 @@ namespace Os {
// Is the heap full: // Is the heap full:
bool MaxHeap::isFull() { bool MaxHeap::isFull() {
return (this->size == this->capacity); return (this->m_size == this->m_capacity);
} }
// Is the heap empty: // Is the heap empty:
bool MaxHeap::isEmpty() { bool MaxHeap::isEmpty() {
return (this->size == 0); return (this->m_size == 0);
} }
// Get the current size of the heap: // Get the current size of the heap:
NATIVE_UINT_TYPE MaxHeap::getSize() { NATIVE_UINT_TYPE MaxHeap::getSize() {
return this->size; return this->m_size;
} }
// A non-recursive heapify method. // A non-recursive heapify method.
@ -162,10 +162,10 @@ namespace Os {
NATIVE_UINT_TYPE largest; NATIVE_UINT_TYPE largest;
// Max loop bounds for bit flip protection: // Max loop bounds for bit flip protection:
NATIVE_UINT_TYPE maxIter = this->size+1; NATIVE_UINT_TYPE maxIter = this->m_size+1;
NATIVE_UINT_TYPE maxCount = 0; NATIVE_UINT_TYPE maxCount = 0;
while(index <= this->size && maxCount < maxIter) { while(index <= this->m_size && maxCount < maxIter) {
// Get the children indexes for this node: // Get the children indexes for this node:
left = LCHILD(index); left = LCHILD(index);
right = RCHILD(index); right = RCHILD(index);
@ -175,7 +175,7 @@ namespace Os {
// If the left node is bigger than the heap // If the left node is bigger than the heap
// size, we have reached the end of the heap // size, we have reached the end of the heap
// so we can stop: // so we can stop:
if (left >= this->size) { if (left >= this->m_size) {
break; break;
} }
@ -188,7 +188,7 @@ namespace Os {
largest = this->max(left, largest); largest = this->max(left, largest);
// Make sure the right node exists before checking it: // Make sure the right node exists before checking it:
if (right < this->size) { if (right < this->m_size) {
// Which one is larger, the current largest // Which one is larger, the current largest
// node or the right node? // node or the right node?
largest = this->max(right, largest); largest = this->max(right, largest);
@ -203,8 +203,8 @@ namespace Os {
// Swap the largest node with the current node: // Swap the largest node with the current node:
// Fw::Logger::logMsg("Swapping: i: %u v: %d with i: %u v: %d\n", // Fw::Logger::logMsg("Swapping: i: %u v: %d with i: %u v: %d\n",
// index, this->heap[index].value, // index, this->m_heap[index].value,
// largest, this->heap[largest].value); // largest, this->m_heap[largest].value);
this->swap(index, largest); this->swap(index, largest);
// Set the new index to whichever child was larger: // Set the new index to whichever child was larger:
@ -213,18 +213,18 @@ namespace Os {
// Check for programming errors or bit flips: // Check for programming errors or bit flips:
FW_ASSERT(maxCount < maxIter, maxCount, maxIter); FW_ASSERT(maxCount < maxIter, maxCount, maxIter);
FW_ASSERT(index <= this->size, index); FW_ASSERT(index <= this->m_size, index);
} }
// Return the maximum priority index between two nodes. If their // Return the maximum priority index between two nodes. If their
// priorities are equal, return the oldest to keep the heap stable // priorities are equal, return the oldest to keep the heap stable
NATIVE_UINT_TYPE MaxHeap::max(NATIVE_UINT_TYPE a, NATIVE_UINT_TYPE b) { NATIVE_UINT_TYPE MaxHeap::max(NATIVE_UINT_TYPE a, NATIVE_UINT_TYPE b) {
FW_ASSERT(a < this->size, a, this->size); FW_ASSERT(a < this->m_size, a, this->m_size);
FW_ASSERT(b < this->size, b, this->size); FW_ASSERT(b < this->m_size, b, this->m_size);
// Extract the priorities: // Extract the priorities:
NATIVE_INT_TYPE aValue = this->heap[a].value; NATIVE_INT_TYPE aValue = this->m_heap[a].value;
NATIVE_INT_TYPE bValue = this->heap[b].value; NATIVE_INT_TYPE bValue = this->m_heap[b].value;
// If the priorities are equal, the "larger" one will be // If the priorities are equal, the "larger" one will be
// the "older" one as determined by order pushed on to the // the "older" one as determined by order pushed on to the
@ -233,8 +233,8 @@ namespace Os {
// Note: We check this first, because it is the most common // Note: We check this first, because it is the most common
// case. Let's save as many ticks as we can... // case. Let's save as many ticks as we can...
if(aValue == bValue) { if(aValue == bValue) {
NATIVE_UINT_TYPE aAge = this->order - this->heap[a].order; NATIVE_UINT_TYPE aAge = this->m_order - this->m_heap[a].order;
NATIVE_UINT_TYPE bAge = this->order - this->heap[b].order; NATIVE_UINT_TYPE bAge = this->m_order - this->m_heap[b].order;
if(aAge > bAge) { if(aAge > bAge) {
return a; return a;
} }
@ -251,11 +251,11 @@ namespace Os {
// Swap two nodes in the heap: // Swap two nodes in the heap:
void MaxHeap::swap(NATIVE_UINT_TYPE a, NATIVE_UINT_TYPE b) { void MaxHeap::swap(NATIVE_UINT_TYPE a, NATIVE_UINT_TYPE b) {
FW_ASSERT(a < this->size, a, this->size); FW_ASSERT(a < this->m_size, a, this->m_size);
FW_ASSERT(b < this->size, b, this->size); FW_ASSERT(b < this->m_size, b, this->m_size);
Node temp = this->heap[a]; Node temp = this->m_heap[a];
this->heap[a] = this->heap[b]; this->m_heap[a] = this->m_heap[b];
this->heap[b] = temp; this->m_heap[b] = temp;
} }
// Print heap, for debugging purposes only: // Print heap, for debugging purposes only:
@ -263,25 +263,25 @@ namespace Os {
NATIVE_UINT_TYPE index = 0; NATIVE_UINT_TYPE index = 0;
NATIVE_UINT_TYPE left; NATIVE_UINT_TYPE left;
NATIVE_UINT_TYPE right; NATIVE_UINT_TYPE right;
Fw::Logger::logMsg("Printing Heap of Size: %d\n", this->size); Fw::Logger::logMsg("Printing Heap of Size: %d\n", this->m_size);
while(index < this->size) { while(index < this->m_size) {
left = LCHILD(index); left = LCHILD(index);
right = RCHILD(index); right = RCHILD(index);
if( left >= size && index == 0) { if( left >= m_size && index == 0) {
Fw::Logger::logMsg("i: %u v: %d d: %u -> (NULL, NULL)\n", Fw::Logger::logMsg("i: %u v: %d d: %u -> (NULL, NULL)\n",
index, this->heap[index].value, this->heap[index].id); index, this->m_heap[index].value, this->m_heap[index].id);
} }
else if( right >= size && left < size ) { else if( right >= m_size && left < m_size ) {
Fw::Logger::logMsg("i: %u v: %d d: %u -> (i: %u v: %d d: %u, NULL)\n", Fw::Logger::logMsg("i: %u v: %d d: %u -> (i: %u v: %d d: %u, NULL)\n",
index, this->heap[index].value, this->heap[index].id, index, this->m_heap[index].value, this->m_heap[index].id,
left, this->heap[left].value, this->heap[left].id); left, this->m_heap[left].value, this->m_heap[left].id);
} }
else if( right < size && left < size ) { else if( right < m_size && left < m_size ) {
Fw::Logger::logMsg("i: %u v: %d d: %u -> (i: %u v: %d d: %u, i: %u v: %d d: %u)\n", Fw::Logger::logMsg("i: %u v: %d d: %u -> (i: %u v: %d d: %u, i: %u v: %d d: %u)\n",
index, this->heap[index].value, this->heap[index].id, index, this->m_heap[index].value, this->m_heap[index].id,
left, this->heap[left].value,this->heap[left].id, left, this->m_heap[left].value,this->m_heap[left].id,
right, this->heap[right].value, this->heap[right].id); right, this->m_heap[right].value, this->m_heap[right].id);
} }
++index; ++index;

View File

@ -25,7 +25,7 @@ namespace Os {
//! off in FIFO order. Insertion and deletion from the heap are both //! off in FIFO order. Insertion and deletion from the heap are both
//! O(log(n)) time. //! O(log(n)) time.
class MaxHeap { class MaxHeap {
public: public:
//! \brief MaxHeap constructor //! \brief MaxHeap constructor
//! //!
@ -47,7 +47,7 @@ namespace Os {
//! \brief Push an item onto the heap. //! \brief Push an item onto the heap.
//! //!
//! The item will be put into the heap according to its value. The //! The item will be put into the heap according to its value. The
//! id field is a data field set by the user which can be used to //! id field is a data field set by the user which can be used to
//! identify the element when it is popped off the heap. //! identify the element when it is popped off the heap.
//! //!
//! \param value the value of the element to push onto the heap //! \param value the value of the element to push onto the heap
@ -87,7 +87,7 @@ namespace Os {
//! This function here is for debugging purposes. //! This function here is for debugging purposes.
//! //!
void print(); void print();
private: private:
// Private functions: // Private functions:
// Ensure the heap meets the heap property: // Ensure the heap meets the heap property:
@ -101,14 +101,14 @@ namespace Os {
struct Node { struct Node {
NATIVE_INT_TYPE value; // the priority of the node NATIVE_INT_TYPE value; // the priority of the node
NATIVE_UINT_TYPE order; // order in which node was pushed NATIVE_UINT_TYPE order; // order in which node was pushed
NATIVE_UINT_TYPE id; // unique id for this node NATIVE_UINT_TYPE id; // unique id for this node
}; };
// Private members: // Private members:
Node* heap; // the heap itself Node* m_heap; // the heap itself
NATIVE_UINT_TYPE size; // the current size of the heap NATIVE_UINT_TYPE m_size; // the current size of the heap
NATIVE_UINT_TYPE order; // the current count of heap pushes NATIVE_UINT_TYPE m_order; // the current count of heap pushes
NATIVE_UINT_TYPE capacity; // the maximum capacity of the heap NATIVE_UINT_TYPE m_capacity; // the maximum capacity of the heap
}; };
} }

View File

@ -102,12 +102,12 @@ namespace Os {
priorityQueue->indexes = indexes; priorityQueue->indexes = indexes;
priorityQueue->startIndex = 0; priorityQueue->startIndex = 0;
priorityQueue->stopIndex = depth; priorityQueue->stopIndex = depth;
this->queue = priorityQueue; this->m_queue = priorityQueue;
return true; return true;
} }
void BufferQueue::finalize() { void BufferQueue::finalize() {
PriorityQueue* pQueue = static_cast<PriorityQueue*>(this->queue); PriorityQueue* pQueue = static_cast<PriorityQueue*>(this->m_queue);
if (nullptr != pQueue) if (nullptr != pQueue)
{ {
MaxHeap* heap = pQueue->heap; MaxHeap* heap = pQueue->heap;
@ -125,18 +125,18 @@ namespace Os {
} }
delete pQueue; delete pQueue;
} }
this->queue = nullptr; this->m_queue = nullptr;
} }
bool BufferQueue::enqueue(const U8* buffer, NATIVE_UINT_TYPE size, NATIVE_INT_TYPE priority) { bool BufferQueue::enqueue(const U8* buffer, NATIVE_UINT_TYPE size, NATIVE_INT_TYPE priority) {
// Extract queue handle variables: // Extract queue handle variables:
PriorityQueue* pQueue = static_cast<PriorityQueue*>(this->queue); PriorityQueue* pQueue = static_cast<PriorityQueue*>(this->m_queue);
MaxHeap* heap = pQueue->heap; MaxHeap* heap = pQueue->heap;
U8* data = pQueue->data; U8* data = pQueue->data;
// Get an available data index: // Get an available data index:
NATIVE_UINT_TYPE index = checkoutIndex(pQueue, this->depth); NATIVE_UINT_TYPE index = checkoutIndex(pQueue, this->m_depth);
// Insert the data into the heap: // Insert the data into the heap:
bool ret = heap->push(priority, index); bool ret = heap->push(priority, index);
@ -151,7 +151,7 @@ namespace Os {
bool BufferQueue::dequeue(U8* buffer, NATIVE_UINT_TYPE& size, NATIVE_INT_TYPE &priority) { bool BufferQueue::dequeue(U8* buffer, NATIVE_UINT_TYPE& size, NATIVE_INT_TYPE &priority) {
// Extract queue handle variables: // Extract queue handle variables:
PriorityQueue* pQueue = static_cast<PriorityQueue*>(this->queue); PriorityQueue* pQueue = static_cast<PriorityQueue*>(this->m_queue);
MaxHeap* heap = pQueue->heap; MaxHeap* heap = pQueue->heap;
U8* data = pQueue->data; U8* data = pQueue->data;
@ -170,7 +170,7 @@ namespace Os {
} }
// Return the index to the available indexes: // Return the index to the available indexes:
returnIndex(pQueue, this->depth, index); returnIndex(pQueue, this->m_depth, index);
return true; return true;
} }

View File

@ -113,7 +113,7 @@ namespace Os {
if(pushSucceeded) { if(pushSucceeded) {
// Push worked - wake up a thread that might be waiting on // Push worked - wake up a thread that might be waiting on
// the other end of the queue: // the other end of the queue:
NATIVE_INT_TYPE ret = pthread_cond_signal(queueNotEmpty); ret = pthread_cond_signal(queueNotEmpty);
FW_ASSERT(ret == 0, errno); // If this fails, something horrible happened. FW_ASSERT(ret == 0, errno); // If this fails, something horrible happened.
} }
else { else {
@ -147,7 +147,7 @@ namespace Os {
// If the queue is full, wait until a message is taken off the queue: // If the queue is full, wait until a message is taken off the queue:
while( queue->isFull() ) { while( queue->isFull() ) {
NATIVE_INT_TYPE ret = pthread_cond_wait(queueNotFull, queueLock); ret = pthread_cond_wait(queueNotFull, queueLock);
FW_ASSERT(ret == 0, errno); FW_ASSERT(ret == 0, errno);
} }
@ -227,7 +227,7 @@ namespace Os {
// Pop worked - wake up a thread that might be waiting on // Pop worked - wake up a thread that might be waiting on
// the send end of the queue: // the send end of the queue:
NATIVE_INT_TYPE ret = pthread_cond_signal(queueNotFull); ret = pthread_cond_signal(queueNotFull);
FW_ASSERT(ret == 0, errno); // If this fails, something horrible happened. FW_ASSERT(ret == 0, errno); // If this fails, something horrible happened.
} }
else { else {
@ -276,7 +276,7 @@ namespace Os {
// If the queue is empty, wait until a message is put on the queue: // If the queue is empty, wait until a message is put on the queue:
while( queue->isEmpty() ) { while( queue->isEmpty() ) {
NATIVE_INT_TYPE ret = pthread_cond_wait(queueNotEmpty, queueLock); ret = pthread_cond_wait(queueNotEmpty, queueLock);
FW_ASSERT(ret == 0, errno); FW_ASSERT(ret == 0, errno);
} }
@ -290,7 +290,7 @@ namespace Os {
// Pop worked - wake up a thread that might be waiting on // Pop worked - wake up a thread that might be waiting on
// the send end of the queue: // the send end of the queue:
NATIVE_INT_TYPE ret = pthread_cond_signal(queueNotFull); ret = pthread_cond_signal(queueNotFull);
FW_ASSERT(ret == 0, errno); // If this fails, something horrible happened. FW_ASSERT(ret == 0, errno); // If this fails, something horrible happened.
} }
else { else {

View File

@ -17,11 +17,11 @@ namespace Os {
ValidatedFile :: ValidatedFile ::
ValidatedFile(const char *const fileName) : ValidatedFile(const char *const fileName) :
fileName(fileName), m_fileName(fileName),
hashFileName(""), m_hashFileName(""),
hashBuffer() m_hashBuffer()
{ {
Utils::Hash::addFileExtension(this->fileName, this->hashFileName); Utils::Hash::addFileExtension(this->m_fileName, this->m_hashFileName);
} }
Os::ValidateFile::Status ValidatedFile :: Os::ValidateFile::Status ValidatedFile ::
@ -29,9 +29,9 @@ namespace Os {
{ {
const Os::ValidateFile::Status status = const Os::ValidateFile::Status status =
Os::ValidateFile::validate( Os::ValidateFile::validate(
this->fileName.toChar(), this->m_fileName.toChar(),
this->hashFileName.toChar(), this->m_hashFileName.toChar(),
this->hashBuffer this->m_hashBuffer
); );
return status; return status;
} }
@ -41,9 +41,9 @@ namespace Os {
{ {
const Os::ValidateFile::Status status = const Os::ValidateFile::Status status =
Os::ValidateFile::createValidation( Os::ValidateFile::createValidation(
this->fileName.toChar(), this->m_fileName.toChar(),
this->hashFileName.toChar(), this->m_hashFileName.toChar(),
this->hashBuffer this->m_hashBuffer
); );
return status; return status;
} }
@ -51,19 +51,19 @@ namespace Os {
const Fw::StringBase& ValidatedFile :: const Fw::StringBase& ValidatedFile ::
getFileName() const getFileName() const
{ {
return this->fileName; return this->m_fileName;
} }
const Fw::StringBase& ValidatedFile :: const Fw::StringBase& ValidatedFile ::
getHashFileName() const getHashFileName() const
{ {
return this->hashFileName; return this->m_hashFileName;
} }
const Utils::HashBuffer& ValidatedFile :: const Utils::HashBuffer& ValidatedFile ::
getHashBuffer() const getHashBuffer() const
{ {
return this->hashBuffer; return this->m_hashBuffer;
} }
} }

View File

@ -56,13 +56,13 @@ namespace Os {
PRIVATE: PRIVATE:
//! The file name //! The file name
Fw::String fileName; Fw::String m_fileName;
//! The hash file name //! The hash file name
Fw::String hashFileName; Fw::String m_hashFileName;
//! The hash value after creating or loading a validation file //! The hash value after creating or loading a validation file
Utils::HashBuffer hashBuffer; Utils::HashBuffer m_hashBuffer;
}; };
} }

View File

@ -57,7 +57,7 @@ target_compile_options("${PROJECT_NAME}" PUBLIC -Wall)
target_compile_options("${PROJECT_NAME}" PUBLIC -Wextra) target_compile_options("${PROJECT_NAME}" PUBLIC -Wextra)
target_compile_options("${PROJECT_NAME}" PUBLIC -Werror) target_compile_options("${PROJECT_NAME}" PUBLIC -Werror)
target_compile_options("${PROJECT_NAME}" PUBLIC -pedantic) target_compile_options("${PROJECT_NAME}" PUBLIC -pedantic)
#target_compile_options("${PROJECT_NAME}" PUBLIC -Wshadow) target_compile_options("${PROJECT_NAME}" PUBLIC -Wshadow)
target_compile_options("${PROJECT_NAME}" PUBLIC -Wconversion) target_compile_options("${PROJECT_NAME}" PUBLIC -Wconversion)
target_compile_options("${PROJECT_NAME}" PUBLIC -Wsign-conversion) target_compile_options("${PROJECT_NAME}" PUBLIC -Wsign-conversion)
target_compile_options("${PROJECT_NAME}" PUBLIC -Wformat-security) target_compile_options("${PROJECT_NAME}" PUBLIC -Wformat-security)

View File

@ -27,9 +27,9 @@ namespace STest {
//! Construct object Rule //! Construct object Rule
Rule( Rule(
const char *const name //!< The name of the rule const char *const a_name //!< The name of the rule
) : ) :
name(name) name(a_name)
{ {
} }

View File

@ -22,11 +22,11 @@ namespace Svc {
// ---------------------------------------------------------------------- // ----------------------------------------------------------------------
BufferAccumulator::ArrayFIFOBuffer ::ArrayFIFOBuffer() BufferAccumulator::ArrayFIFOBuffer ::ArrayFIFOBuffer()
: elements(nullptr), : m_elements(nullptr),
capacity(0), m_capacity(0),
enqueueIndex(0), m_enqueueIndex(0),
dequeueIndex(0), m_dequeueIndex(0),
size(0) m_size(0)
{ {
} }
@ -38,29 +38,29 @@ BufferAccumulator::ArrayFIFOBuffer ::~ArrayFIFOBuffer() {}
void BufferAccumulator::ArrayFIFOBuffer ::init(Fw::Buffer* const elements, void BufferAccumulator::ArrayFIFOBuffer ::init(Fw::Buffer* const elements,
NATIVE_UINT_TYPE capacity) { NATIVE_UINT_TYPE capacity) {
this->elements = elements; this->m_elements = elements;
this->capacity = capacity; this->m_capacity = capacity;
// Construct all elements // Construct all elements
for (NATIVE_UINT_TYPE idx = 0; idx < capacity; idx++) { for (NATIVE_UINT_TYPE idx = 0; idx < capacity; idx++) {
new (&this->elements[idx]) Fw::Buffer; new (&this->m_elements[idx]) Fw::Buffer;
} }
} }
bool BufferAccumulator::ArrayFIFOBuffer ::enqueue(const Fw::Buffer& e) { bool BufferAccumulator::ArrayFIFOBuffer ::enqueue(const Fw::Buffer& e) {
if (this->elements == nullptr) { if (this->m_elements == nullptr) {
return false; return false;
} }
bool status; bool status;
if (this->size < this->capacity) { if (this->m_size < this->m_capacity) {
// enqueueIndex is unsigned, no need to compare with 0 // enqueueIndex is unsigned, no need to compare with 0
FW_ASSERT(enqueueIndex < this->capacity, enqueueIndex); FW_ASSERT(m_enqueueIndex < this->m_capacity, m_enqueueIndex);
this->elements[this->enqueueIndex] = e; this->m_elements[this->m_enqueueIndex] = e;
this->enqueueIndex = (this->enqueueIndex + 1) % this->capacity; this->m_enqueueIndex = (this->m_enqueueIndex + 1) % this->m_capacity;
status = true; status = true;
this->size++; this->m_size++;
} else { } else {
status = false; status = false;
} }
@ -70,19 +70,19 @@ bool BufferAccumulator::ArrayFIFOBuffer ::enqueue(const Fw::Buffer& e) {
bool BufferAccumulator::ArrayFIFOBuffer ::dequeue(Fw::Buffer& e) { bool BufferAccumulator::ArrayFIFOBuffer ::dequeue(Fw::Buffer& e) {
if (this->elements == nullptr) { if (this->m_elements == nullptr) {
return false; return false;
} }
FW_ASSERT(this->elements); FW_ASSERT(this->m_elements);
bool status; bool status;
if (this->size > 0) { if (this->m_size > 0) {
// dequeueIndex is unsigned, no need to compare with 0 // dequeueIndex is unsigned, no need to compare with 0
FW_ASSERT(dequeueIndex < this->capacity, dequeueIndex); FW_ASSERT(m_dequeueIndex < this->m_capacity, m_dequeueIndex);
e = this->elements[this->dequeueIndex]; e = this->m_elements[this->m_dequeueIndex];
this->dequeueIndex = (this->dequeueIndex + 1) % this->capacity; this->m_dequeueIndex = (this->m_dequeueIndex + 1) % this->m_capacity;
this->size--; this->m_size--;
status = true; status = true;
} else { } else {
status = false; status = false;
@ -92,11 +92,11 @@ bool BufferAccumulator::ArrayFIFOBuffer ::dequeue(Fw::Buffer& e) {
} }
U32 BufferAccumulator::ArrayFIFOBuffer ::getSize() const { U32 BufferAccumulator::ArrayFIFOBuffer ::getSize() const {
return this->size; return this->m_size;
} }
U32 BufferAccumulator::ArrayFIFOBuffer ::getCapacity() const { U32 BufferAccumulator::ArrayFIFOBuffer ::getCapacity() const {
return this->capacity; return this->m_capacity;
} }
} // namespace Svc } // namespace Svc

View File

@ -26,17 +26,17 @@ namespace Svc {
BufferAccumulator :: BufferAccumulator ::
BufferAccumulator(const char* const compName) BufferAccumulator(const char* const compName)
: BufferAccumulatorComponentBase(compName), //!< The component name : BufferAccumulatorComponentBase(compName), //!< The component name
mode(BufferAccumulator_OpState::ACCUMULATE), m_mode(BufferAccumulator_OpState::ACCUMULATE),
bufferMemory(nullptr), m_bufferMemory(nullptr),
bufferQueue(), m_bufferQueue(),
send(false), m_send(false),
waitForBuffer(false), m_waitForBuffer(false),
numWarnings(0u), m_numWarnings(0u),
numDrained(0u), m_numDrained(0u),
numToDrain(0u), m_numToDrain(0u),
opCode(), m_opCode(),
cmdSeq(0u), m_cmdSeq(0u),
allocatorId(0) { m_allocatorId(0) {
} }
void BufferAccumulator ::init(const NATIVE_INT_TYPE queueDepth, void BufferAccumulator ::init(const NATIVE_INT_TYPE queueDepth,
@ -55,17 +55,17 @@ void BufferAccumulator ::allocateQueue(
NATIVE_UINT_TYPE maxNumBuffers //!< The maximum number of buffers NATIVE_UINT_TYPE maxNumBuffers //!< The maximum number of buffers
) { ) {
this->allocatorId = identifier; this->m_allocatorId = identifier;
NATIVE_UINT_TYPE memSize = sizeof(Fw::Buffer) * maxNumBuffers; NATIVE_UINT_TYPE memSize = sizeof(Fw::Buffer) * maxNumBuffers;
bool recoverable = false; bool recoverable = false;
this->bufferMemory = static_cast<Fw::Buffer*>( this->m_bufferMemory = static_cast<Fw::Buffer*>(
allocator.allocate(identifier, memSize, recoverable)); allocator.allocate(identifier, memSize, recoverable));
//TODO: Fail gracefully here //TODO: Fail gracefully here
bufferQueue.init(this->bufferMemory, maxNumBuffers); m_bufferQueue.init(this->m_bufferMemory, maxNumBuffers);
} }
void BufferAccumulator ::deallocateQueue(Fw::MemAllocator& allocator) { void BufferAccumulator ::deallocateQueue(Fw::MemAllocator& allocator) {
allocator.deallocate(this->allocatorId, this->bufferMemory); allocator.deallocate(this->m_allocatorId, this->m_bufferMemory);
} }
// ---------------------------------------------------------------------- // ----------------------------------------------------------------------
@ -75,34 +75,34 @@ void BufferAccumulator ::deallocateQueue(Fw::MemAllocator& allocator) {
void BufferAccumulator ::bufferSendInFill_handler(const NATIVE_INT_TYPE portNum, void BufferAccumulator ::bufferSendInFill_handler(const NATIVE_INT_TYPE portNum,
Fw::Buffer& buffer) { Fw::Buffer& buffer) {
const bool status = this->bufferQueue.enqueue(buffer); const bool status = this->m_bufferQueue.enqueue(buffer);
if (status) { if (status) {
if (this->numWarnings > 0) { if (this->m_numWarnings > 0) {
this->log_ACTIVITY_HI_BA_BufferAccepted(); this->log_ACTIVITY_HI_BA_BufferAccepted();
} }
this->numWarnings = 0; this->m_numWarnings = 0;
} else { } else {
if (this->numWarnings == 0) { if (this->m_numWarnings == 0) {
this->log_WARNING_HI_BA_QueueFull(); this->log_WARNING_HI_BA_QueueFull();
} }
numWarnings++; m_numWarnings++;
} }
if (this->send) { if (this->m_send) {
this->sendStoredBuffer(); this->sendStoredBuffer();
} }
this->tlmWrite_BA_NumQueuedBuffers(this->bufferQueue.getSize()); this->tlmWrite_BA_NumQueuedBuffers(this->m_bufferQueue.getSize());
} }
void BufferAccumulator ::bufferSendInReturn_handler( void BufferAccumulator ::bufferSendInReturn_handler(
const NATIVE_INT_TYPE portNum, Fw::Buffer& buffer) { const NATIVE_INT_TYPE portNum, Fw::Buffer& buffer) {
this->bufferSendOutReturn_out(0, buffer); this->bufferSendOutReturn_out(0, buffer);
this->waitForBuffer = false; this->m_waitForBuffer = false;
if ((this->mode == BufferAccumulator_OpState::DRAIN) || // we are draining ALL buffers if ((this->m_mode == BufferAccumulator_OpState::DRAIN) || // we are draining ALL buffers
(this->numDrained < this->numToDrain)) { // OR we aren't done draining some buffers (this->m_numDrained < this->m_numToDrain)) { // OR we aren't done draining some buffers
// in a partial drain // in a partial drain
this->send = true; this->m_send = true;
this->sendStoredBuffer(); this->sendStoredBuffer();
} }
} }
@ -121,22 +121,22 @@ void BufferAccumulator ::BA_SetMode_cmdHandler(const FwOpcodeType opCode,
BufferAccumulator_OpState mode) { BufferAccumulator_OpState mode) {
// cancel an in-progress partial drain // cancel an in-progress partial drain
if (this->numToDrain > 0) { if (this->m_numToDrain > 0) {
// reset counters for partial buffer drain // reset counters for partial buffer drain
this->numToDrain = 0; this->m_numToDrain = 0;
this->numDrained = 0; this->m_numDrained = 0;
// respond to the original command // respond to the original command
this->cmdResponse_out(this->opCode, this->cmdSeq, Fw::CmdResponse::OK); this->cmdResponse_out(this->m_opCode, this->m_cmdSeq, Fw::CmdResponse::OK);
} }
this->mode = mode; this->m_mode = mode;
if (mode == BufferAccumulator_OpState::DRAIN) { if (mode == BufferAccumulator_OpState::DRAIN) {
if (!this->waitForBuffer) { if (!this->m_waitForBuffer) {
this->send = true; this->m_send = true;
this->sendStoredBuffer(); this->sendStoredBuffer();
} }
} else { } else {
this->send = false; this->m_send = false;
} }
this->cmdResponse_out(opCode, cmdSeq, Fw::CmdResponse::OK); this->cmdResponse_out(opCode, cmdSeq, Fw::CmdResponse::OK);
} }
@ -145,13 +145,13 @@ void BufferAccumulator ::BA_DrainBuffers_cmdHandler(
const FwOpcodeType opCode, const U32 cmdSeq, U32 numToDrain, const FwOpcodeType opCode, const U32 cmdSeq, U32 numToDrain,
BufferAccumulator_BlockMode blockMode) { BufferAccumulator_BlockMode blockMode) {
if (this->numDrained < this->numToDrain) { if (this->m_numDrained < this->m_numToDrain) {
this->log_WARNING_HI_BA_StillDraining(this->numDrained, this->numToDrain); this->log_WARNING_HI_BA_StillDraining(this->m_numDrained, this->m_numToDrain);
this->cmdResponse_out(opCode, cmdSeq, Fw::CmdResponse::BUSY); this->cmdResponse_out(opCode, cmdSeq, Fw::CmdResponse::BUSY);
return; return;
} }
if (this->mode == BufferAccumulator_OpState::DRAIN) { if (this->m_mode == BufferAccumulator_OpState::DRAIN) {
this->log_WARNING_HI_BA_AlreadyDraining(); this->log_WARNING_HI_BA_AlreadyDraining();
this->cmdResponse_out(opCode, cmdSeq, Fw::CmdResponse::VALIDATION_ERROR); this->cmdResponse_out(opCode, cmdSeq, Fw::CmdResponse::VALIDATION_ERROR);
return; return;
@ -163,23 +163,23 @@ void BufferAccumulator ::BA_DrainBuffers_cmdHandler(
return; return;
} }
this->opCode = opCode; this->m_opCode = opCode;
this->cmdSeq = cmdSeq; this->m_cmdSeq = cmdSeq;
this->numDrained = 0; this->m_numDrained = 0;
this->numToDrain = numToDrain; this->m_numToDrain = numToDrain;
if (blockMode == BufferAccumulator_BlockMode::NOBLOCK) { if (blockMode == BufferAccumulator_BlockMode::NOBLOCK) {
U32 numBuffers = this->bufferQueue.getSize(); U32 numBuffers = this->m_bufferQueue.getSize();
if (numBuffers < numToDrain) { if (numBuffers < numToDrain) {
this->numToDrain = numBuffers; this->m_numToDrain = numBuffers;
this->log_WARNING_LO_BA_NonBlockDrain(this->numToDrain, numToDrain); this->log_WARNING_LO_BA_NonBlockDrain(this->m_numToDrain, numToDrain);
} }
/* OK if there were 0 buffers queued, and we /* OK if there were 0 buffers queued, and we
* end up setting numToDrain to 0 * end up setting numToDrain to 0
*/ */
if (0 == this->numToDrain) { if (0 == this->m_numToDrain) {
this->log_ACTIVITY_HI_BA_PartialDrainDone(0); this->log_ACTIVITY_HI_BA_PartialDrainDone(0);
this->cmdResponse_out(opCode, cmdSeq, Fw::CmdResponse::OK); this->cmdResponse_out(opCode, cmdSeq, Fw::CmdResponse::OK);
return; return;
@ -187,8 +187,8 @@ void BufferAccumulator ::BA_DrainBuffers_cmdHandler(
} }
// We are still waiting for a buffer from last time // We are still waiting for a buffer from last time
if (!this->waitForBuffer) { if (!this->m_waitForBuffer) {
this->send = true; this->m_send = true;
this->sendStoredBuffer(); // kick off the draining; this->sendStoredBuffer(); // kick off the draining;
} }
} }
@ -199,19 +199,19 @@ void BufferAccumulator ::BA_DrainBuffers_cmdHandler(
void BufferAccumulator ::sendStoredBuffer() { void BufferAccumulator ::sendStoredBuffer() {
FW_ASSERT(this->send); FW_ASSERT(this->m_send);
Fw::Buffer buffer; Fw::Buffer buffer;
if ((this->numToDrain == 0) || // we are draining ALL buffers if ((this->m_numToDrain == 0) || // we are draining ALL buffers
(this->numDrained < this->numToDrain)) { // OR we aren't done draining some buffers in a (this->m_numDrained < this->m_numToDrain)) { // OR we aren't done draining some buffers in a
// partial drain // partial drain
const bool status = this->bufferQueue.dequeue(buffer); const bool status = this->m_bufferQueue.dequeue(buffer);
if (status) { // a buffer was dequeued if (status) { // a buffer was dequeued
this->numDrained++; this->m_numDrained++;
this->bufferSendOutDrain_out(0, buffer); this->bufferSendOutDrain_out(0, buffer);
this->waitForBuffer = true; this->m_waitForBuffer = true;
this->send = false; this->m_send = false;
} else if (this->numToDrain > 0) { } else if (this->m_numToDrain > 0) {
this->log_WARNING_HI_BA_DrainStalled(this->numDrained, this->numToDrain); this->log_WARNING_HI_BA_DrainStalled(this->m_numDrained, this->m_numToDrain);
} }
} }
@ -219,18 +219,18 @@ void BufferAccumulator ::sendStoredBuffer() {
* drained buffers in a partial drain to be RETURNED before returning OK. * drained buffers in a partial drain to be RETURNED before returning OK.
* Correct thing is to return OK once they are SENT * Correct thing is to return OK once they are SENT
*/ */
if ((this->numToDrain > 0) && // we are doing a partial drain if ((this->m_numToDrain > 0) && // we are doing a partial drain
(this->numDrained == this->numToDrain)) { // AND we just finished draining (this->m_numDrained == this->m_numToDrain)) { // AND we just finished draining
// //
this->log_ACTIVITY_HI_BA_PartialDrainDone(this->numDrained); this->log_ACTIVITY_HI_BA_PartialDrainDone(this->m_numDrained);
// reset counters for partial buffer drain // reset counters for partial buffer drain
this->numToDrain = 0; this->m_numToDrain = 0;
this->numDrained = 0; this->m_numDrained = 0;
this->send = false; this->m_send = false;
this->cmdResponse_out(this->opCode, this->cmdSeq, Fw::CmdResponse::OK); this->cmdResponse_out(this->m_opCode, this->m_cmdSeq, Fw::CmdResponse::OK);
} }
this->tlmWrite_BA_NumQueuedBuffers(this->bufferQueue.getSize()); this->tlmWrite_BA_NumQueuedBuffers(this->m_bufferQueue.getSize());
} }
} // namespace Svc } // namespace Svc

View File

@ -66,19 +66,19 @@ namespace Svc {
// ---------------------------------------------------------------------- // ----------------------------------------------------------------------
//! The memory for the elements //! The memory for the elements
Fw::Buffer* elements; Fw::Buffer* m_elements;
//! The capacity of the queue //! The capacity of the queue
NATIVE_UINT_TYPE capacity; NATIVE_UINT_TYPE m_capacity;
//! The enqueue index //! The enqueue index
NATIVE_UINT_TYPE enqueueIndex; NATIVE_UINT_TYPE m_enqueueIndex;
//! The dequeue index //! The dequeue index
NATIVE_UINT_TYPE dequeueIndex; NATIVE_UINT_TYPE m_dequeueIndex;
//! The size of the queue //! The size of the queue
NATIVE_UINT_TYPE size; NATIVE_UINT_TYPE m_size;
}; // class ArrayFIFOBuffer }; // class ArrayFIFOBuffer
public: public:
@ -178,39 +178,39 @@ namespace Svc {
// ---------------------------------------------------------------------- // ----------------------------------------------------------------------
//! The mode //! The mode
BufferAccumulator_OpState mode; BufferAccumulator_OpState m_mode;
//! Memory for the buffer array //! Memory for the buffer array
Fw::Buffer* bufferMemory; Fw::Buffer* m_bufferMemory;
//! The FIFO queue of buffers //! The FIFO queue of buffers
ArrayFIFOBuffer bufferQueue; ArrayFIFOBuffer m_bufferQueue;
//! Whether to send a buffer to the downstream client //! Whether to send a buffer to the downstream client
bool send; bool m_send;
//! If we are switched to ACCUMULATE then back to DRAIN, whether we were //! If we are switched to ACCUMULATE then back to DRAIN, whether we were
//! waiting on a buffer //! waiting on a buffer
bool waitForBuffer; bool m_waitForBuffer;
//! The number of QueueFull warnings sent since the last successful enqueue //! The number of QueueFull warnings sent since the last successful enqueue
//! operation //! operation
U32 numWarnings; U32 m_numWarnings;
//! The number of buffers drained in a partial drain command //! The number of buffers drained in a partial drain command
U32 numDrained; U32 m_numDrained;
//! The number of buffers TO drain in a partial drain command //! The number of buffers TO drain in a partial drain command
U32 numToDrain; U32 m_numToDrain;
//! The DrainBuffers opcode to respond to //! The DrainBuffers opcode to respond to
FwOpcodeType opCode; FwOpcodeType m_opCode;
//! The DrainBuffers cmdSeq to respond to //! The DrainBuffers cmdSeq to respond to
U32 cmdSeq; U32 m_cmdSeq;
//! The allocator ID //! The allocator ID
NATIVE_INT_TYPE allocatorId; NATIVE_INT_TYPE m_allocatorId;
}; };
} // namespace Svc } // namespace Svc

View File

@ -116,37 +116,37 @@ namespace Svc {
PRIVATE: PRIVATE:
//! The enclosing BufferLogger instance //! The enclosing BufferLogger instance
BufferLogger& bufferLogger; BufferLogger& m_bufferLogger;
//! The prefix to use for file names //! The prefix to use for file names
Fw::String prefix; Fw::String m_prefix;
//! The suffix to use for file names //! The suffix to use for file names
Fw::String suffix; Fw::String m_suffix;
//! The file name base //! The file name base
Fw::String baseName; Fw::String m_baseName;
//! The counter to use for the same file name //! The counter to use for the same file name
NATIVE_UINT_TYPE fileCounter; NATIVE_UINT_TYPE m_fileCounter;
//! The maximum file size //! The maximum file size
U32 maxSize; U32 m_maxSize;
//! The number of bytes to use when storing the size field at the start of each buffer //! The number of bytes to use when storing the size field at the start of each buffer
U8 sizeOfSize; U8 m_sizeOfSize;
//! The name of the currently open file //! The name of the currently open file
Fw::String name; Fw::String m_name;
// The current mode // The current mode
Mode::t mode; Mode::t m_mode;
//! The underlying Os::File representation //! The underlying Os::File representation
Os::File osFile; Os::File m_osFile;
//! The number of bytes written to the current file //! The number of bytes written to the current file
U32 bytesWritten; U32 m_bytesWritten;
}; // class File }; // class File

View File

@ -24,15 +24,15 @@ namespace Svc {
File( File(
BufferLogger& bufferLogger BufferLogger& bufferLogger
) : ) :
bufferLogger(bufferLogger), m_bufferLogger(bufferLogger),
prefix(""), m_prefix(""),
suffix(""), m_suffix(""),
baseName(""), m_baseName(""),
fileCounter(0), m_fileCounter(0),
maxSize(0), m_maxSize(0),
sizeOfSize(0), m_sizeOfSize(0),
mode(Mode::CLOSED), m_mode(Mode::CLOSED),
bytesWritten(0) m_bytesWritten(0)
{ {
} }
@ -55,15 +55,15 @@ namespace Svc {
) )
{ {
//NOTE(mereweth) - only call this before opening the file //NOTE(mereweth) - only call this before opening the file
FW_ASSERT(this->mode == File::Mode::CLOSED); FW_ASSERT(this->m_mode == File::Mode::CLOSED);
this->prefix = logFilePrefix; this->m_prefix = logFilePrefix;
this->suffix = logFileSuffix; this->m_suffix = logFileSuffix;
this->maxSize = maxFileSize; this->m_maxSize = maxFileSize;
this->sizeOfSize = sizeOfSize; this->m_sizeOfSize = sizeOfSize;
FW_ASSERT(sizeOfSize <= sizeof(U32), sizeOfSize); FW_ASSERT(sizeOfSize <= sizeof(U32), sizeOfSize);
FW_ASSERT(maxSize > sizeOfSize, maxSize); FW_ASSERT(m_maxSize > sizeOfSize, m_maxSize);
} }
void BufferLogger::File :: void BufferLogger::File ::
@ -71,11 +71,11 @@ namespace Svc {
const Fw::StringBase& baseName const Fw::StringBase& baseName
) )
{ {
if (this->mode == File::Mode::OPEN) { if (this->m_mode == File::Mode::OPEN) {
this->closeAndEmitEvent(); this->closeAndEmitEvent();
} }
this->baseName = baseName; this->m_baseName = baseName;
this->fileCounter = 0; this->m_fileCounter = 0;
this->open(); this->open();
} }
@ -86,19 +86,19 @@ namespace Svc {
) )
{ {
// Close the file if it will be too big // Close the file if it will be too big
if (this->mode == File::Mode::OPEN) { if (this->m_mode == File::Mode::OPEN) {
const U32 projectedByteCount = const U32 projectedByteCount =
this->bytesWritten + this->sizeOfSize + size; this->m_bytesWritten + this->m_sizeOfSize + size;
if (projectedByteCount > this->maxSize) { if (projectedByteCount > this->m_maxSize) {
this->closeAndEmitEvent(); this->closeAndEmitEvent();
} }
} }
// Open a file if necessary // Open a file if necessary
if (this->mode == File::Mode::CLOSED) { if (this->m_mode == File::Mode::CLOSED) {
this->open(); this->open();
} }
// Write to the file if it is open // Write to the file if it is open
if (this->mode == File::Mode::OPEN) { if (this->m_mode == File::Mode::OPEN) {
(void) this->writeBuffer(data, size); (void) this->writeBuffer(data, size);
} }
} }
@ -106,10 +106,10 @@ namespace Svc {
void BufferLogger::File :: void BufferLogger::File ::
closeAndEmitEvent() closeAndEmitEvent()
{ {
if (this->mode == File::Mode::OPEN) { if (this->m_mode == File::Mode::OPEN) {
this->close(); this->close();
Fw::LogStringArg logStringArg(this->name.toChar()); Fw::LogStringArg logStringArg(this->m_name.toChar());
this->bufferLogger.log_DIAGNOSTIC_BL_LogFileClosed(logStringArg); this->m_bufferLogger.log_DIAGNOSTIC_BL_LogFileClosed(logStringArg);
} }
} }
@ -120,48 +120,48 @@ namespace Svc {
void BufferLogger::File :: void BufferLogger::File ::
open() open()
{ {
FW_ASSERT(this->mode == File::Mode::CLOSED); FW_ASSERT(this->m_mode == File::Mode::CLOSED);
// NOTE(mereweth) - check that file path has been set and that initLog has been called // NOTE(mereweth) - check that file path has been set and that initLog has been called
if ((this->baseName.toChar()[0] == '\0') || if ((this->m_baseName.toChar()[0] == '\0') ||
(this->sizeOfSize > sizeof(U32)) || (this->m_sizeOfSize > sizeof(U32)) ||
(this->maxSize <= this->sizeOfSize)) { (this->m_maxSize <= this->m_sizeOfSize)) {
this->bufferLogger.log_WARNING_HI_BL_NoLogFileOpenInitError(); this->m_bufferLogger.log_WARNING_HI_BL_NoLogFileOpenInitError();
return; return;
} }
if (this->fileCounter == 0) { if (this->m_fileCounter == 0) {
this->name.format( this->m_name.format(
"%s%s%s", "%s%s%s",
this->prefix.toChar(), this->m_prefix.toChar(),
this->baseName.toChar(), this->m_baseName.toChar(),
this->suffix.toChar() this->m_suffix.toChar()
); );
} }
else { else {
this->name.format( this->m_name.format(
"%s%s%d%s", "%s%s%d%s",
this->prefix.toChar(), this->m_prefix.toChar(),
this->baseName.toChar(), this->m_baseName.toChar(),
this->fileCounter, this->m_fileCounter,
this->suffix.toChar() this->m_suffix.toChar()
); );
} }
const Os::File::Status status = this->osFile.open( const Os::File::Status status = this->m_osFile.open(
this->name.toChar(), this->m_name.toChar(),
Os::File::OPEN_WRITE Os::File::OPEN_WRITE
); );
if (status == Os::File::OP_OK) { if (status == Os::File::OP_OK) {
this->fileCounter++; this->m_fileCounter++;
// Reset bytes written // Reset bytes written
this->bytesWritten = 0; this->m_bytesWritten = 0;
// Set mode // Set mode
this->mode = File::Mode::OPEN; this->m_mode = File::Mode::OPEN;
} }
else { else {
Fw::LogStringArg string(this->name.toChar()); Fw::LogStringArg string(this->m_name.toChar());
this->bufferLogger.log_WARNING_HI_BL_LogFileOpenError(status, string); this->m_bufferLogger.log_WARNING_HI_BL_LogFileOpenError(status, string);
} }
} }
@ -181,16 +181,16 @@ namespace Svc {
bool BufferLogger::File :: bool BufferLogger::File ::
writeSize(const U32 size) writeSize(const U32 size)
{ {
FW_ASSERT(this->sizeOfSize <= sizeof(U32)); FW_ASSERT(this->m_sizeOfSize <= sizeof(U32));
U8 sizeBuffer[sizeof(U32)]; U8 sizeBuffer[sizeof(U32)];
U32 sizeRegister = size; U32 sizeRegister = size;
for (U8 i = 0; i < this->sizeOfSize; ++i) { for (U8 i = 0; i < this->m_sizeOfSize; ++i) {
sizeBuffer[this->sizeOfSize - i - 1] = sizeRegister & 0xFF; sizeBuffer[this->m_sizeOfSize - i - 1] = sizeRegister & 0xFF;
sizeRegister >>= 8; sizeRegister >>= 8;
} }
const bool status = this->writeBytes( const bool status = this->writeBytes(
sizeBuffer, sizeBuffer,
this->sizeOfSize this->m_sizeOfSize
); );
return status; return status;
} }
@ -203,16 +203,16 @@ namespace Svc {
{ {
FW_ASSERT(length > 0, length); FW_ASSERT(length > 0, length);
NATIVE_INT_TYPE size = length; NATIVE_INT_TYPE size = length;
const Os::File::Status fileStatus = this->osFile.write(data, size); const Os::File::Status fileStatus = this->m_osFile.write(data, size);
bool status; bool status;
if (fileStatus == Os::File::OP_OK && size == static_cast<NATIVE_INT_TYPE>(length)) { if (fileStatus == Os::File::OP_OK && size == static_cast<NATIVE_INT_TYPE>(length)) {
this->bytesWritten += length; this->m_bytesWritten += length;
status = true; status = true;
} }
else { else {
Fw::LogStringArg string(this->name.toChar()); Fw::LogStringArg string(this->m_name.toChar());
this->bufferLogger.log_WARNING_HI_BL_LogFileWriteError(fileStatus, size, length, string); this->m_bufferLogger.log_WARNING_HI_BL_LogFileWriteError(fileStatus, size, length, string);
status = false; status = false;
} }
return status; return status;
@ -221,13 +221,13 @@ namespace Svc {
void BufferLogger::File :: void BufferLogger::File ::
writeHashFile() writeHashFile()
{ {
Os::ValidatedFile validatedFile(this->name.toChar()); Os::ValidatedFile validatedFile(this->m_name.toChar());
const Os::ValidateFile::Status status = const Os::ValidateFile::Status status =
validatedFile.createHashFile(); validatedFile.createHashFile();
if (status != Os::ValidateFile::VALIDATION_OK) { if (status != Os::ValidateFile::VALIDATION_OK) {
const Fw::String &hashFileName = validatedFile.getHashFileName(); const Fw::String &hashFileName = validatedFile.getHashFileName();
Fw::LogStringArg logStringArg(hashFileName.toChar()); Fw::LogStringArg logStringArg(hashFileName.toChar());
this->bufferLogger.log_WARNING_HI_BL_LogFileValidationError( this->m_bufferLogger.log_WARNING_HI_BL_LogFileValidationError(
logStringArg, logStringArg,
status status
); );
@ -258,13 +258,13 @@ namespace Svc {
void BufferLogger::File :: void BufferLogger::File ::
close() close()
{ {
if (this->mode == File::Mode::OPEN) { if (this->m_mode == File::Mode::OPEN) {
// Close file // Close file
this->osFile.close(); this->m_osFile.close();
// Write out the hash file to disk // Write out the hash file to disk
this->writeHashFile(); this->writeHashFile();
// Update mode // Update mode
this->mode = File::Mode::CLOSED; this->m_mode = File::Mode::CLOSED;
} }
} }

View File

@ -64,7 +64,7 @@ namespace Svc {
void BufferLoggerTester :: void BufferLoggerTester ::
LogNoInit() LogNoInit()
{ {
this->component.m_file.baseName = Fw::String("LogNoInit"); this->component.m_file.m_baseName = Fw::String("LogNoInit");
// NOTE (mereweth) - make something sensible happen when no-one calls initLog() // NOTE (mereweth) - make something sensible happen when no-one calls initLog()
// Send data // Send data
this->sendComBuffers(3); this->sendComBuffers(3);

View File

@ -25,10 +25,10 @@ namespace Svc {
// Remove buf directory // Remove buf directory
(void) system("rm -rf buf"); (void) system("rm -rf buf");
this->component.m_file.baseName = Fw::String("LogFileOpen"); this->component.m_file.m_baseName = Fw::String("LogFileOpen");
// Check initial state // Check initial state
ASSERT_EQ(BufferLogger::File::Mode::CLOSED, this->component.m_file.mode); ASSERT_EQ(BufferLogger::File::Mode::CLOSED, this->component.m_file.m_mode);
ASSERT_EVENTS_SIZE(0); ASSERT_EVENTS_SIZE(0);
// Send data // Send data
@ -42,13 +42,13 @@ namespace Svc {
ASSERT_EVENTS_BL_LogFileOpenError( ASSERT_EVENTS_BL_LogFileOpenError(
i, i,
Os::File::DOESNT_EXIST, Os::File::DOESNT_EXIST,
this->component.m_file.name.toChar() this->component.m_file.m_name.toChar()
); );
} }
// Create buf directory and try again // Create buf directory and try again
(void) system("mkdir buf"); (void) system("mkdir buf");
ASSERT_EQ(BufferLogger::File::Mode::CLOSED, this->component.m_file.mode); ASSERT_EQ(BufferLogger::File::Mode::CLOSED, this->component.m_file.m_mode);
// Send data // Send data
this->sendComBuffers(3); this->sendComBuffers(3);
@ -61,7 +61,7 @@ namespace Svc {
// Remove buf directory and try again // Remove buf directory and try again
(void) system("rm -rf buf"); (void) system("rm -rf buf");
ASSERT_EQ(BufferLogger::File::Mode::CLOSED, this->component.m_file.mode); ASSERT_EQ(BufferLogger::File::Mode::CLOSED, this->component.m_file.m_mode);
// Send data // Send data
this->sendComBuffers(3); this->sendComBuffers(3);
@ -74,7 +74,7 @@ namespace Svc {
ASSERT_EVENTS_BL_LogFileOpenError( ASSERT_EVENTS_BL_LogFileOpenError(
i, i,
Os::File::DOESNT_EXIST, Os::File::DOESNT_EXIST,
this->component.m_file.name.toChar() this->component.m_file.m_name.toChar()
); );
} }
@ -83,16 +83,16 @@ namespace Svc {
void BufferLoggerTester :: void BufferLoggerTester ::
LogFileWrite() LogFileWrite()
{ {
ASSERT_EQ(BufferLogger::File::Mode::CLOSED, this->component.m_file.mode); ASSERT_EQ(BufferLogger::File::Mode::CLOSED, this->component.m_file.m_mode);
ASSERT_EVENTS_SIZE(0); ASSERT_EVENTS_SIZE(0);
this->component.m_file.baseName = Fw::String("LogFileWrite"); this->component.m_file.m_baseName = Fw::String("LogFileWrite");
// Send data // Send data
this->sendComBuffers(1); this->sendComBuffers(1);
// Force close the file // Force close the file
this->component.m_file.osFile.close(); this->component.m_file.m_osFile.close();
// Send data // Send data
this->sendComBuffers(1); this->sendComBuffers(1);
@ -101,9 +101,9 @@ namespace Svc {
Fw::String fileName; Fw::String fileName;
fileName.format( fileName.format(
"%s%s%s", "%s%s%s",
this->component.m_file.prefix.toChar(), this->component.m_file.m_prefix.toChar(),
this->component.m_file.baseName.toChar(), this->component.m_file.m_baseName.toChar(),
this->component.m_file.suffix.toChar() this->component.m_file.m_suffix.toChar()
); );
// Check events // Check events
@ -119,16 +119,16 @@ namespace Svc {
); );
// Make comlogger open a new file: // Make comlogger open a new file:
this->component.m_file.mode = BufferLogger::File::Mode::CLOSED; this->component.m_file.m_mode = BufferLogger::File::Mode::CLOSED;
this->component.m_file.open(); this->component.m_file.open();
// NOTE(mereweth) - new file; counter has incremented // NOTE(mereweth) - new file; counter has incremented
fileName.format( fileName.format(
"%s%s%d%s", "%s%s%d%s",
this->component.m_file.prefix.toChar(), this->component.m_file.m_prefix.toChar(),
this->component.m_file.baseName.toChar(), this->component.m_file.m_baseName.toChar(),
1, 1,
this->component.m_file.suffix.toChar() this->component.m_file.m_suffix.toChar()
); );
// Try to write and make sure it succeeds // Try to write and make sure it succeeds
@ -140,7 +140,7 @@ namespace Svc {
ASSERT_EVENTS_BL_LogFileWriteError_SIZE(1); ASSERT_EVENTS_BL_LogFileWriteError_SIZE(1);
// Force close the file from underneath the component // Force close the file from underneath the component
component.m_file.osFile.close(); component.m_file.m_osFile.close();
// Send data // Send data
this->sendComBuffers(3); this->sendComBuffers(3);
@ -164,7 +164,7 @@ namespace Svc {
void BufferLoggerTester :: void BufferLoggerTester ::
LogFileValidation() LogFileValidation()
{ {
this->component.m_file.baseName = Fw::String("LogFileValidation"); this->component.m_file.m_baseName = Fw::String("LogFileValidation");
// Send data // Send data
this->sendComBuffers(1); this->sendComBuffers(1);
@ -178,9 +178,9 @@ namespace Svc {
Fw::String fileName; Fw::String fileName;
fileName.format( fileName.format(
"%s%s%s", "%s%s%s",
this->component.m_file.prefix.toChar(), this->component.m_file.m_prefix.toChar(),
this->component.m_file.baseName.toChar(), this->component.m_file.m_baseName.toChar(),
this->component.m_file.suffix.toChar() this->component.m_file.m_suffix.toChar()
); );
ASSERT_EVENTS_BL_LogFileClosed( ASSERT_EVENTS_BL_LogFileClosed(
0, 0,

View File

@ -52,7 +52,7 @@ namespace Svc {
//! Check that files exist //! Check that files exist
void checkFilesExist() { void checkFilesExist() {
const Fw::String& fileName = this->component.m_file.name; const Fw::String& fileName = this->component.m_file.m_name;
this->checkFileExists(fileName); this->checkFileExists(fileName);
this->checkHashFileExists(fileName); this->checkHashFileExists(fileName);
} }
@ -60,14 +60,14 @@ namespace Svc {
public: public:
void test() { void test() {
this->component.m_file.baseName = Fw::String("CloseFileTester"); this->component.m_file.m_baseName = Fw::String("CloseFileTester");
ASSERT_EVENTS_SIZE(0); ASSERT_EVENTS_SIZE(0);
this->sendCloseFileCommands(3); this->sendCloseFileCommands(3);
this->sendComBuffers(3); this->sendComBuffers(3);
this->sendCloseFileCommands(3); this->sendCloseFileCommands(3);
ASSERT_EVENTS_SIZE(1); ASSERT_EVENTS_SIZE(1);
ASSERT_EVENTS_BL_LogFileClosed_SIZE(1); ASSERT_EVENTS_BL_LogFileClosed_SIZE(1);
ASSERT_EVENTS_BL_LogFileClosed(0, component.m_file.name.toChar()); ASSERT_EVENTS_BL_LogFileClosed(0, component.m_file.m_name.toChar());
this->checkFilesExist(); this->checkFilesExist();
} }
@ -104,32 +104,32 @@ namespace Svc {
Fw::String currentFileName; Fw::String currentFileName;
currentFileName.format( currentFileName.format(
"%s%s%s", "%s%s%s",
this->component.m_file.prefix.toChar(), this->component.m_file.m_prefix.toChar(),
baseName, baseName,
this->component.m_file.suffix.toChar() this->component.m_file.m_suffix.toChar()
); );
this->sendBuffers(1); this->sendBuffers(1);
// 0th event has already happened (file open) // 0th event has already happened (file open)
for (U32 i = 1; i < numFiles+1; ++i) { for (U32 i = 1; i < numFiles+1; ++i) {
// File was just created and name set // File was just created and name set
ASSERT_EQ(currentFileName, this->component.m_file.name); ASSERT_EQ(currentFileName, this->component.m_file.m_name);
// Write data to the file // Write data to the file
this->sendBuffers(MAX_ENTRIES_PER_FILE-1); this->sendBuffers(MAX_ENTRIES_PER_FILE-1);
// File still should have same name // File still should have same name
ASSERT_EQ(currentFileName, this->component.m_file.name); ASSERT_EQ(currentFileName, this->component.m_file.m_name);
// Send more data // Send more data
// This should open a new file with the updated counter // This should open a new file with the updated counter
this->sendBuffers(1); this->sendBuffers(1);
currentFileName.format( currentFileName.format(
"%s%s%d%s", "%s%s%d%s",
this->component.m_file.prefix.toChar(), this->component.m_file.m_prefix.toChar(),
baseName, baseName,
i, i,
this->component.m_file.suffix.toChar() this->component.m_file.m_suffix.toChar()
); );
// Assert file state // Assert file state
ASSERT_EQ(BufferLogger::File::Mode::OPEN, component.m_file.mode); ASSERT_EQ(BufferLogger::File::Mode::OPEN, component.m_file.m_mode);
ASSERT_EQ(currentFileName, this->component.m_file.name); ASSERT_EQ(currentFileName, this->component.m_file.m_name);
// Assert events // Assert events
ASSERT_EVENTS_SIZE(i); ASSERT_EVENTS_SIZE(i);
ASSERT_EVENTS_BL_LogFileClosed_SIZE(i); ASSERT_EVENTS_BL_LogFileClosed_SIZE(i);
@ -146,18 +146,18 @@ namespace Svc {
if (i == 0) { if (i == 0) {
fileName.format( fileName.format(
"%s%s%s", "%s%s%s",
this->component.m_file.prefix.toChar(), this->component.m_file.m_prefix.toChar(),
baseName, baseName,
this->component.m_file.suffix.toChar() this->component.m_file.m_suffix.toChar()
); );
} }
else { else {
fileName.format( fileName.format(
"%s%s%d%s", "%s%s%d%s",
this->component.m_file.prefix.toChar(), this->component.m_file.m_prefix.toChar(),
baseName, baseName,
i, i,
this->component.m_file.suffix.toChar() this->component.m_file.m_suffix.toChar()
); );
} }
// Check events // Check events
@ -240,11 +240,11 @@ namespace Svc {
//! Test logging on //! Test logging on
void testLoggingOn() { void testLoggingOn() {
this->component.m_file.baseName = Fw::String("OnOffTester"); this->component.m_file.m_baseName = Fw::String("OnOffTester");
this->sendData(); this->sendData();
this->setState(BufferLogger_LogState::LOGGING_OFF); this->setState(BufferLogger_LogState::LOGGING_OFF);
this->checkLogFileIntegrity( this->checkLogFileIntegrity(
this->component.m_file.name.toChar(), this->component.m_file.m_name.toChar(),
MAX_BYTES_PER_FILE, MAX_BYTES_PER_FILE,
MAX_ENTRIES_PER_FILE MAX_ENTRIES_PER_FILE
); );

View File

@ -20,13 +20,13 @@ namespace Svc {
ComLogger :: ComLogger ::
ComLogger(const char* compName, const char* incomingFilePrefix, U32 maxFileSize, bool storeBufferLength) : ComLogger(const char* compName, const char* incomingFilePrefix, U32 maxFileSize, bool storeBufferLength) :
ComLoggerComponentBase(compName), ComLoggerComponentBase(compName),
maxFileSize(maxFileSize), m_maxFileSize(maxFileSize),
fileMode(CLOSED), m_fileMode(CLOSED),
byteCount(0), m_byteCount(0),
writeErrorOccurred(false), m_writeErrorOccurred(false),
openErrorOccurred(false), m_openErrorOccurred(false),
storeBufferLength(storeBufferLength), m_storeBufferLength(storeBufferLength),
initialized(true) m_initialized(true)
{ {
this->init_log_file(incomingFilePrefix, maxFileSize, storeBufferLength); this->init_log_file(incomingFilePrefix, maxFileSize, storeBufferLength);
} }
@ -34,16 +34,16 @@ namespace Svc {
ComLogger :: ComLogger ::
ComLogger(const char* compName) : ComLogger(const char* compName) :
ComLoggerComponentBase(compName), ComLoggerComponentBase(compName),
filePrefix(), m_filePrefix(),
maxFileSize(0), m_maxFileSize(0),
fileMode(CLOSED), m_fileMode(CLOSED),
fileName(), m_fileName(),
hashFileName(), m_hashFileName(),
byteCount(0), m_byteCount(0),
writeErrorOccurred(false), m_writeErrorOccurred(false),
openErrorOccurred(false), m_openErrorOccurred(false),
storeBufferLength(), m_storeBufferLength(),
initialized(false) m_initialized(false)
{ {
} }
@ -61,18 +61,18 @@ namespace Svc {
init_log_file(const char* incomingFilePrefix, U32 maxFileSize, bool storeBufferLength) init_log_file(const char* incomingFilePrefix, U32 maxFileSize, bool storeBufferLength)
{ {
FW_ASSERT(incomingFilePrefix != nullptr); FW_ASSERT(incomingFilePrefix != nullptr);
this->maxFileSize = maxFileSize; this->m_maxFileSize = maxFileSize;
this->storeBufferLength = storeBufferLength; this->m_storeBufferLength = storeBufferLength;
if( this->storeBufferLength ) { if( this->m_storeBufferLength ) {
FW_ASSERT(maxFileSize > sizeof(U16), maxFileSize); FW_ASSERT(maxFileSize > sizeof(U16), maxFileSize);
} }
FW_ASSERT(Fw::StringUtils::string_length(incomingFilePrefix, sizeof(this->filePrefix)) < sizeof(this->filePrefix), FW_ASSERT(Fw::StringUtils::string_length(incomingFilePrefix, sizeof(this->m_filePrefix)) < sizeof(this->m_filePrefix),
Fw::StringUtils::string_length(incomingFilePrefix, sizeof(this->filePrefix)), sizeof(this->filePrefix)); // ensure that file prefix is not too big Fw::StringUtils::string_length(incomingFilePrefix, sizeof(this->m_filePrefix)), sizeof(this->m_filePrefix)); // ensure that file prefix is not too big
(void)Fw::StringUtils::string_copy(this->filePrefix, incomingFilePrefix, sizeof(this->filePrefix)); (void)Fw::StringUtils::string_copy(this->m_filePrefix, incomingFilePrefix, sizeof(this->m_filePrefix));
this->initialized = true; this->m_initialized = true;
} }
@ -85,15 +85,15 @@ namespace Svc {
// in the destructor. This can cause "virtual method called" segmentation // in the destructor. This can cause "virtual method called" segmentation
// faults. // faults.
// So I am copying part of that function here. // So I am copying part of that function here.
if( OPEN == this->fileMode ) { if( OPEN == this->m_fileMode ) {
// Close file: // Close file:
this->file.close(); this->m_file.close();
// Write out the hash file to disk: // Write out the hash file to disk:
this->writeHashFile(); this->writeHashFile();
// Update mode: // Update mode:
this->fileMode = CLOSED; this->m_fileMode = CLOSED;
// Send event: // Send event:
//Fw::LogStringArg logStringArg((char*) fileName); //Fw::LogStringArg logStringArg((char*) fileName);
@ -122,23 +122,23 @@ namespace Svc {
U16 size = size32 & 0xFFFF; U16 size = size32 & 0xFFFF;
// Close the file if it will be too big: // Close the file if it will be too big:
if( OPEN == this->fileMode ) { if( OPEN == this->m_fileMode ) {
U32 projectedByteCount = this->byteCount + size; U32 projectedByteCount = this->m_byteCount + size;
if( this->storeBufferLength ) { if( this->m_storeBufferLength ) {
projectedByteCount += sizeof(size); projectedByteCount += sizeof(size);
} }
if( projectedByteCount > this->maxFileSize ) { if( projectedByteCount > this->m_maxFileSize ) {
this->closeFile(); this->closeFile();
} }
} }
// Open the file if it there is not one open: // Open the file if it there is not one open:
if( CLOSED == this->fileMode ){ if( CLOSED == this->m_fileMode ){
this->openFile(); this->openFile();
} }
// Write to the file if it is open: // Write to the file if it is open:
if( OPEN == this->fileMode ) { if( OPEN == this->m_fileMode ) {
this->writeComBufferToFile(data, size); this->writeComBufferToFile(data, size);
} }
} }
@ -167,9 +167,9 @@ namespace Svc {
openFile( openFile(
) )
{ {
FW_ASSERT( CLOSED == this->fileMode ); FW_ASSERT( CLOSED == this->m_fileMode );
if( !this->initialized ){ if( !this->m_initialized ){
this->log_WARNING_LO_FileNotInitialized(); this->log_WARNING_LO_FileNotInitialized();
return; return;
} }
@ -178,36 +178,36 @@ namespace Svc {
// Create filename: // Create filename:
Fw::Time timestamp = getTime(); Fw::Time timestamp = getTime();
memset(this->fileName, 0, sizeof(this->fileName)); memset(this->m_fileName, 0, sizeof(this->m_fileName));
bytesCopied = snprintf(this->fileName, sizeof(this->fileName), "%s_%" PRI_FwTimeBaseStoreType "_%" PRIu32 "_%06" PRIu32 ".com", bytesCopied = snprintf(this->m_fileName, sizeof(this->m_fileName), "%s_%" PRI_FwTimeBaseStoreType "_%" PRIu32 "_%06" PRIu32 ".com",
this->filePrefix, static_cast<FwTimeBaseStoreType>(timestamp.getTimeBase()), timestamp.getSeconds(), timestamp.getUSeconds()); this->m_filePrefix, static_cast<FwTimeBaseStoreType>(timestamp.getTimeBase()), timestamp.getSeconds(), timestamp.getUSeconds());
// "A return value of size or more means that the output was truncated" // "A return value of size or more means that the output was truncated"
// See here: http://linux.die.net/man/3/snprintf // See here: http://linux.die.net/man/3/snprintf
FW_ASSERT( bytesCopied < sizeof(this->fileName) ); FW_ASSERT( bytesCopied < sizeof(this->m_fileName) );
// Create sha filename: // Create sha filename:
bytesCopied = snprintf(this->hashFileName, sizeof(this->hashFileName), "%s_%" PRI_FwTimeBaseStoreType "_%" PRIu32 "_%06" PRIu32 ".com%s", bytesCopied = snprintf(this->m_hashFileName, sizeof(this->m_hashFileName), "%s_%" PRI_FwTimeBaseStoreType "_%" PRIu32 "_%06" PRIu32 ".com%s",
this->filePrefix, static_cast<FwTimeBaseStoreType>(timestamp.getTimeBase()), timestamp.getSeconds(), timestamp.getUSeconds(), Utils::Hash::getFileExtensionString()); this->m_filePrefix, static_cast<FwTimeBaseStoreType>(timestamp.getTimeBase()), timestamp.getSeconds(), timestamp.getUSeconds(), Utils::Hash::getFileExtensionString());
FW_ASSERT( bytesCopied < sizeof(this->hashFileName) ); FW_ASSERT( bytesCopied < sizeof(this->m_hashFileName) );
Os::File::Status ret = file.open(this->fileName, Os::File::OPEN_WRITE); Os::File::Status ret = m_file.open(this->m_fileName, Os::File::OPEN_WRITE);
if( Os::File::OP_OK != ret ) { if( Os::File::OP_OK != ret ) {
if( !this->openErrorOccurred ) { // throttle this event, otherwise a positive if( !this->m_openErrorOccurred ) { // throttle this event, otherwise a positive
// feedback event loop can occur! // feedback event loop can occur!
Fw::LogStringArg logStringArg(this->fileName); Fw::LogStringArg logStringArg(this->m_fileName);
this->log_WARNING_HI_FileOpenError(ret, logStringArg); this->log_WARNING_HI_FileOpenError(ret, logStringArg);
} }
this->openErrorOccurred = true; this->m_openErrorOccurred = true;
} else { } else {
// Reset event throttle: // Reset event throttle:
this->openErrorOccurred = false; this->m_openErrorOccurred = false;
// Reset byte count: // Reset byte count:
this->byteCount = 0; this->m_byteCount = 0;
// Set mode: // Set mode:
this->fileMode = OPEN; this->m_fileMode = OPEN;
} }
} }
@ -215,18 +215,18 @@ namespace Svc {
closeFile( closeFile(
) )
{ {
if( OPEN == this->fileMode ) { if( OPEN == this->m_fileMode ) {
// Close file: // Close file:
this->file.close(); this->m_file.close();
// Write out the hash file to disk: // Write out the hash file to disk:
this->writeHashFile(); this->writeHashFile();
// Update mode: // Update mode:
this->fileMode = CLOSED; this->m_fileMode = CLOSED;
// Send event: // Send event:
Fw::LogStringArg logStringArg(this->fileName); Fw::LogStringArg logStringArg(this->m_fileName);
this->log_DIAGNOSTIC_FileClosed(logStringArg); this->log_DIAGNOSTIC_FileClosed(logStringArg);
} }
} }
@ -237,13 +237,13 @@ namespace Svc {
U16 size U16 size
) )
{ {
if( this->storeBufferLength ) { if( this->m_storeBufferLength ) {
U8 buffer[sizeof(size)]; U8 buffer[sizeof(size)];
Fw::SerialBuffer serialLength(&buffer[0], sizeof(size)); Fw::SerialBuffer serialLength(&buffer[0], sizeof(size));
serialLength.serialize(size); serialLength.serialize(size);
if(this->writeToFile(serialLength.getBuffAddr(), if(this->writeToFile(serialLength.getBuffAddr(),
static_cast<U16>(serialLength.getBuffLength()))) { static_cast<U16>(serialLength.getBuffLength()))) {
this->byteCount += serialLength.getBuffLength(); this->m_byteCount += serialLength.getBuffLength();
} }
else { else {
return; return;
@ -252,7 +252,7 @@ namespace Svc {
// Write buffer to file: // Write buffer to file:
if(this->writeToFile(data.getBuffAddr(), size)) { if(this->writeToFile(data.getBuffAddr(), size)) {
this->byteCount += size; this->m_byteCount += size;
} }
} }
@ -263,18 +263,18 @@ namespace Svc {
) )
{ {
NATIVE_INT_TYPE size = length; NATIVE_INT_TYPE size = length;
Os::File::Status ret = file.write(data, size); Os::File::Status ret = m_file.write(data, size);
if( Os::File::OP_OK != ret || size != static_cast<NATIVE_INT_TYPE>(length) ) { if( Os::File::OP_OK != ret || size != static_cast<NATIVE_INT_TYPE>(length) ) {
if( !this->writeErrorOccurred ) { // throttle this event, otherwise a positive if( !this->m_writeErrorOccurred ) { // throttle this event, otherwise a positive
// feedback event loop can occur! // feedback event loop can occur!
Fw::LogStringArg logStringArg(this->fileName); Fw::LogStringArg logStringArg(this->m_fileName);
this->log_WARNING_HI_FileWriteError(ret, size, length, logStringArg); this->log_WARNING_HI_FileWriteError(ret, size, length, logStringArg);
} }
this->writeErrorOccurred = true; this->m_writeErrorOccurred = true;
return false; return false;
} }
this->writeErrorOccurred = false; this->m_writeErrorOccurred = false;
return true; return true;
} }
@ -283,10 +283,10 @@ namespace Svc {
) )
{ {
Os::ValidateFile::Status validateStatus; Os::ValidateFile::Status validateStatus;
validateStatus = Os::ValidateFile::createValidation(this->fileName, this->hashFileName); validateStatus = Os::ValidateFile::createValidation(this->m_fileName, this->m_hashFileName);
if( Os::ValidateFile::VALIDATION_OK != validateStatus ) { if( Os::ValidateFile::VALIDATION_OK != validateStatus ) {
Fw::LogStringArg logStringArg1(this->fileName); Fw::LogStringArg logStringArg1(this->m_fileName);
Fw::LogStringArg logStringArg2(this->hashFileName); Fw::LogStringArg logStringArg2(this->m_hashFileName);
this->log_WARNING_LO_FileValidationError(logStringArg1, logStringArg2, validateStatus); this->log_WARNING_LO_FileValidationError(logStringArg1, logStringArg2, validateStatus);
} }
} }

View File

@ -105,8 +105,8 @@ namespace Svc {
}; };
// The filename data: // The filename data:
CHAR filePrefix[MAX_FILENAME_SIZE + MAX_PATH_SIZE]; CHAR m_filePrefix[MAX_FILENAME_SIZE + MAX_PATH_SIZE];
U32 maxFileSize; U32 m_maxFileSize;
// ---------------------------------------------------------------------- // ----------------------------------------------------------------------
// Internal state: // Internal state:
@ -116,15 +116,15 @@ namespace Svc {
OPEN = 1 OPEN = 1
}; };
FileMode fileMode; FileMode m_fileMode;
Os::File file; Os::File m_file;
CHAR fileName[MAX_FILENAME_SIZE + MAX_PATH_SIZE]; CHAR m_fileName[MAX_FILENAME_SIZE + MAX_PATH_SIZE];
CHAR hashFileName[MAX_FILENAME_SIZE + MAX_PATH_SIZE]; CHAR m_hashFileName[MAX_FILENAME_SIZE + MAX_PATH_SIZE];
U32 byteCount; U32 m_byteCount;
bool writeErrorOccurred; bool m_writeErrorOccurred;
bool openErrorOccurred; bool m_openErrorOccurred;
bool storeBufferLength; bool m_storeBufferLength;
bool initialized; bool m_initialized;
// ---------------------------------------------------------------------- // ----------------------------------------------------------------------
// File functions: // File functions:

View File

@ -92,7 +92,7 @@ namespace Svc {
Os::File::Status ret; Os::File::Status ret;
Os::File file; Os::File file;
ASSERT_TRUE(comLogger.fileMode == ComLogger::CLOSED); ASSERT_TRUE(comLogger.m_fileMode == ComLogger::CLOSED);
ASSERT_EVENTS_SIZE(0); ASSERT_EVENTS_SIZE(0);
U8 data[COM_BUFFER_LENGTH] = {0xde,0xad,0xbe,0xef}; U8 data[COM_BUFFER_LENGTH] = {0xde,0xad,0xbe,0xef};
@ -125,7 +125,7 @@ namespace Svc {
{ {
invoke_to_comIn(0, buffer, 0); invoke_to_comIn(0, buffer, 0);
dispatchAll(); dispatchAll();
ASSERT_TRUE(comLogger.fileMode == ComLogger::OPEN); ASSERT_TRUE(comLogger.m_fileMode == ComLogger::OPEN);
} }
// OK a new file should be opened after this final invoke, set a new test time so that a file // OK a new file should be opened after this final invoke, set a new test time so that a file
@ -133,12 +133,12 @@ namespace Svc {
setTestTime(testTimeNext); setTestTime(testTimeNext);
invoke_to_comIn(0, buffer, 0); invoke_to_comIn(0, buffer, 0);
dispatchAll(); dispatchAll();
ASSERT_TRUE(comLogger.fileMode == ComLogger::OPEN); ASSERT_TRUE(comLogger.m_fileMode == ComLogger::OPEN);
// A new file should have been opened from the previous loop iteration: // A new file should have been opened from the previous loop iteration:
if( j > 0 ) { if( j > 0 ) {
ASSERT_TRUE(comLogger.fileMode == ComLogger::OPEN); ASSERT_TRUE(comLogger.m_fileMode == ComLogger::OPEN);
ASSERT_TRUE(strcmp(static_cast<char*>(comLogger.fileName), fileName) == 0 ); ASSERT_TRUE(strcmp(static_cast<char*>(comLogger.m_fileName), fileName) == 0 );
} }
// Make sure we got a closed file event: // Make sure we got a closed file event:
@ -213,15 +213,15 @@ namespace Svc {
Os::File::Status ret; Os::File::Status ret;
Os::File file; Os::File file;
ASSERT_TRUE(comLogger.fileMode == ComLogger::CLOSED); ASSERT_TRUE(comLogger.m_fileMode == ComLogger::CLOSED);
ASSERT_EVENTS_SIZE(0); ASSERT_EVENTS_SIZE(0);
U8 data[COM_BUFFER_LENGTH] = {0xde,0xad,0xbe,0xef}; U8 data[COM_BUFFER_LENGTH] = {0xde,0xad,0xbe,0xef};
Fw::ComBuffer buffer(&data[0], sizeof(data)); Fw::ComBuffer buffer(&data[0], sizeof(data));
// Make sure that noLengthMode is enabled: // Make sure that noLengthMode is enabled:
comLogger.storeBufferLength = false; comLogger.m_storeBufferLength = false;
comLogger.maxFileSize = MAX_BYTES_PER_FILE_NO_LENGTH; comLogger.m_maxFileSize = MAX_BYTES_PER_FILE_NO_LENGTH;
for(int j = 0; j < 3; j++) for(int j = 0; j < 3; j++)
{ {
@ -248,7 +248,7 @@ namespace Svc {
{ {
invoke_to_comIn(0, buffer, 0); invoke_to_comIn(0, buffer, 0);
dispatchAll(); dispatchAll();
ASSERT_TRUE(comLogger.fileMode == ComLogger::OPEN); ASSERT_TRUE(comLogger.m_fileMode == ComLogger::OPEN);
} }
// OK a new file should be opened after this final invoke, set a new test time so that a file // OK a new file should be opened after this final invoke, set a new test time so that a file
@ -256,12 +256,12 @@ namespace Svc {
setTestTime(testTimeNext); setTestTime(testTimeNext);
invoke_to_comIn(0, buffer, 0); invoke_to_comIn(0, buffer, 0);
dispatchAll(); dispatchAll();
ASSERT_TRUE(comLogger.fileMode == ComLogger::OPEN); ASSERT_TRUE(comLogger.m_fileMode == ComLogger::OPEN);
// A new file should have been opened from the previous loop iteration: // A new file should have been opened from the previous loop iteration:
if( j > 0 ) { if( j > 0 ) {
ASSERT_TRUE(comLogger.fileMode == ComLogger::OPEN); ASSERT_TRUE(comLogger.m_fileMode == ComLogger::OPEN);
ASSERT_TRUE(strcmp(static_cast<char*>(comLogger.fileName), fileName) == 0 ); ASSERT_TRUE(strcmp(static_cast<char*>(comLogger.m_fileName), fileName) == 0 );
} }
// Make sure we got a closed file event: // Make sure we got a closed file event:
@ -323,9 +323,9 @@ namespace Svc {
memset(filePrefix, 0, sizeof(filePrefix)); memset(filePrefix, 0, sizeof(filePrefix));
snprintf(filePrefix, sizeof(filePrefix), "illegal/fname?;\\*"); snprintf(filePrefix, sizeof(filePrefix), "illegal/fname?;\\*");
strncpy(static_cast<char*>(comLogger.filePrefix), filePrefix, sizeof(comLogger.filePrefix)); strncpy(static_cast<char*>(comLogger.m_filePrefix), filePrefix, sizeof(comLogger.m_filePrefix));
ASSERT_TRUE(comLogger.fileMode == ComLogger::CLOSED); ASSERT_TRUE(comLogger.m_fileMode == ComLogger::CLOSED);
ASSERT_EVENTS_SIZE(0); ASSERT_EVENTS_SIZE(0);
const U8 data[COM_BUFFER_LENGTH] = {0xde,0xad,0xbe,0xef}; const U8 data[COM_BUFFER_LENGTH] = {0xde,0xad,0xbe,0xef};
@ -340,7 +340,7 @@ namespace Svc {
{ {
invoke_to_comIn(0, buffer, 0); invoke_to_comIn(0, buffer, 0);
dispatchAll(); dispatchAll();
ASSERT_TRUE(comLogger.fileMode == ComLogger::CLOSED); ASSERT_TRUE(comLogger.m_fileMode == ComLogger::CLOSED);
} }
// Check generated events: // Check generated events:
@ -358,9 +358,9 @@ namespace Svc {
memset(filePrefix, 0, sizeof(filePrefix)); memset(filePrefix, 0, sizeof(filePrefix));
snprintf(filePrefix, sizeof(filePrefix), "good_"); snprintf(filePrefix, sizeof(filePrefix), "good_");
strncpy(comLogger.filePrefix, filePrefix, sizeof(comLogger.filePrefix)); strncpy(comLogger.m_filePrefix, filePrefix, sizeof(comLogger.m_filePrefix));
ASSERT_TRUE(comLogger.fileMode == ComLogger::CLOSED); ASSERT_TRUE(comLogger.m_fileMode == ComLogger::CLOSED);
snprintf(fileName, sizeof(fileName), "%s_%d_%d_%06d.com", filePrefix, static_cast<U32>(testTime.getTimeBase()), testTime.getSeconds(), testTime.getUSeconds()); snprintf(fileName, sizeof(fileName), "%s_%d_%d_%06d.com", filePrefix, static_cast<U32>(testTime.getTimeBase()), testTime.getSeconds(), testTime.getUSeconds());
@ -368,7 +368,7 @@ namespace Svc {
{ {
invoke_to_comIn(0, buffer, 0); invoke_to_comIn(0, buffer, 0);
dispatchAll(); dispatchAll();
ASSERT_TRUE(comLogger.fileMode == ComLogger::OPEN); ASSERT_TRUE(comLogger.m_fileMode == ComLogger::OPEN);
} }
// Check generated events: // Check generated events:
@ -382,9 +382,9 @@ namespace Svc {
memset(filePrefix, 0, sizeof(filePrefix)); memset(filePrefix, 0, sizeof(filePrefix));
snprintf(filePrefix, sizeof(filePrefix), "illegal/fname?;\\*"); snprintf(filePrefix, sizeof(filePrefix), "illegal/fname?;\\*");
strncpy(static_cast<char*>(comLogger.filePrefix), filePrefix, sizeof(comLogger.filePrefix)); strncpy(static_cast<char*>(comLogger.m_filePrefix), filePrefix, sizeof(comLogger.m_filePrefix));
ASSERT_TRUE(comLogger.fileMode == ComLogger::CLOSED); ASSERT_TRUE(comLogger.m_fileMode == ComLogger::CLOSED);
snprintf(fileName, sizeof(fileName), "%s_%d_%d_%06d.com", filePrefix, static_cast<U32>(testTime.getTimeBase()), testTime.getSeconds(), testTime.getUSeconds()); snprintf(fileName, sizeof(fileName), "%s_%d_%d_%06d.com", filePrefix, static_cast<U32>(testTime.getTimeBase()), testTime.getSeconds(), testTime.getUSeconds());
@ -392,7 +392,7 @@ namespace Svc {
{ {
invoke_to_comIn(0, buffer, 0); invoke_to_comIn(0, buffer, 0);
dispatchAll(); dispatchAll();
ASSERT_TRUE(comLogger.fileMode == ComLogger::CLOSED); ASSERT_TRUE(comLogger.m_fileMode == ComLogger::CLOSED);
} }
// Check generated events: // Check generated events:
@ -404,7 +404,7 @@ namespace Svc {
void ComLoggerTester :: void ComLoggerTester ::
writeError() writeError()
{ {
ASSERT_TRUE(comLogger.fileMode == ComLogger::CLOSED); ASSERT_TRUE(comLogger.m_fileMode == ComLogger::CLOSED);
ASSERT_EVENTS_SIZE(0); ASSERT_EVENTS_SIZE(0);
const U8 data[4] = {0xde,0xad,0xbe,0xef}; const U8 data[4] = {0xde,0xad,0xbe,0xef};
@ -417,17 +417,17 @@ namespace Svc {
{ {
invoke_to_comIn(0, buffer, 0); invoke_to_comIn(0, buffer, 0);
dispatchAll(); dispatchAll();
ASSERT_TRUE(comLogger.fileMode == ComLogger::OPEN); ASSERT_TRUE(comLogger.m_fileMode == ComLogger::OPEN);
} }
// Force close the file from underneath the component: // Force close the file from underneath the component:
comLogger.file.close(); comLogger.m_file.close();
// Send 2 packets: // Send 2 packets:
for(int i = 0; i < 3; i++) { for(int i = 0; i < 3; i++) {
invoke_to_comIn(0, buffer, 0); invoke_to_comIn(0, buffer, 0);
dispatchAll(); dispatchAll();
ASSERT_TRUE(comLogger.fileMode == ComLogger::OPEN); ASSERT_TRUE(comLogger.m_fileMode == ComLogger::OPEN);
} }
// Construct filename: // Construct filename:
@ -449,7 +449,7 @@ namespace Svc {
); );
// Make comlogger open a new file: // Make comlogger open a new file:
comLogger.fileMode = ComLogger::CLOSED; comLogger.m_fileMode = ComLogger::CLOSED;
comLogger.openFile(); comLogger.openFile();
// Try to write and make sure it succeeds: // Try to write and make sure it succeeds:
@ -457,7 +457,7 @@ namespace Svc {
for(int i = 0; i < 3; i++) { for(int i = 0; i < 3; i++) {
invoke_to_comIn(0, buffer, 0); invoke_to_comIn(0, buffer, 0);
dispatchAll(); dispatchAll();
ASSERT_TRUE(comLogger.fileMode == ComLogger::OPEN); ASSERT_TRUE(comLogger.m_fileMode == ComLogger::OPEN);
} }
// Expect no new errors: // Expect no new errors:
@ -465,13 +465,13 @@ namespace Svc {
ASSERT_EVENTS_FileWriteError_SIZE(1); ASSERT_EVENTS_FileWriteError_SIZE(1);
// Force close the file from underneath the component: // Force close the file from underneath the component:
comLogger.file.close(); comLogger.m_file.close();
// Send 2 packets: // Send 2 packets:
for(int i = 0; i < 3; i++) { for(int i = 0; i < 3; i++) {
invoke_to_comIn(0, buffer, 0); invoke_to_comIn(0, buffer, 0);
dispatchAll(); dispatchAll();
ASSERT_TRUE(comLogger.fileMode == ComLogger::OPEN); ASSERT_TRUE(comLogger.m_fileMode == ComLogger::OPEN);
} }
// Check generated events: // Check generated events:
@ -504,14 +504,14 @@ namespace Svc {
memset(hashFileName, 0, sizeof(hashFileName)); memset(hashFileName, 0, sizeof(hashFileName));
snprintf(hashFileName, sizeof(hashFileName), "%s_%d_%d_%06d.com%s", FILE_STR, testTime.getTimeBase(), testTime.getSeconds(), testTime.getUSeconds(), Utils::Hash::getFileExtensionString()); snprintf(hashFileName, sizeof(hashFileName), "%s_%d_%d_%06d.com%s", FILE_STR, testTime.getTimeBase(), testTime.getSeconds(), testTime.getUSeconds(), Utils::Hash::getFileExtensionString());
ASSERT_TRUE(comLogger.fileMode == ComLogger::CLOSED); ASSERT_TRUE(comLogger.m_fileMode == ComLogger::CLOSED);
ASSERT_EVENTS_SIZE(0); ASSERT_EVENTS_SIZE(0);
// Send close file commands: // Send close file commands:
for(int i = 0; i < 3; i++) { for(int i = 0; i < 3; i++) {
sendCmd_CloseFile(0, i+1); sendCmd_CloseFile(0, i+1);
dispatchAll(); dispatchAll();
ASSERT_TRUE(comLogger.fileMode == ComLogger::CLOSED); ASSERT_TRUE(comLogger.m_fileMode == ComLogger::CLOSED);
} }
ASSERT_CMD_RESPONSE_SIZE(3); ASSERT_CMD_RESPONSE_SIZE(3);
@ -532,14 +532,14 @@ namespace Svc {
{ {
invoke_to_comIn(0, buffer, 0); invoke_to_comIn(0, buffer, 0);
dispatchAll(); dispatchAll();
ASSERT_TRUE(comLogger.fileMode == ComLogger::OPEN); ASSERT_TRUE(comLogger.m_fileMode == ComLogger::OPEN);
} }
// Send close file commands: // Send close file commands:
for(int i = 0; i < 3; i++) { for(int i = 0; i < 3; i++) {
sendCmd_CloseFile(0, i+1); sendCmd_CloseFile(0, i+1);
dispatchAll(); dispatchAll();
ASSERT_TRUE(comLogger.fileMode == ComLogger::CLOSED); ASSERT_TRUE(comLogger.m_fileMode == ComLogger::CLOSED);
} }
ASSERT_CMD_RESPONSE_SIZE(6); ASSERT_CMD_RESPONSE_SIZE(6);
@ -582,7 +582,7 @@ namespace Svc {
this->comLogger.init_log_file(FILE_STR, MAX_BYTES_PER_FILE); this->comLogger.init_log_file(FILE_STR, MAX_BYTES_PER_FILE);
ASSERT_TRUE(comLogger.fileMode == ComLogger::CLOSED); ASSERT_TRUE(comLogger.m_fileMode == ComLogger::CLOSED);
ASSERT_EVENTS_SIZE(0); ASSERT_EVENTS_SIZE(0);
U8 data[COM_BUFFER_LENGTH] = {0xde,0xad,0xbe,0xef}; U8 data[COM_BUFFER_LENGTH] = {0xde,0xad,0xbe,0xef};
@ -615,7 +615,7 @@ namespace Svc {
{ {
invoke_to_comIn(0, buffer, 0); invoke_to_comIn(0, buffer, 0);
dispatchAll(); dispatchAll();
ASSERT_TRUE(comLogger.fileMode == ComLogger::OPEN); ASSERT_TRUE(comLogger.m_fileMode == ComLogger::OPEN);
} }
// OK a new file should be opened after this final invoke, set a new test time so that a file // OK a new file should be opened after this final invoke, set a new test time so that a file
@ -623,12 +623,12 @@ namespace Svc {
setTestTime(testTimeNext); setTestTime(testTimeNext);
invoke_to_comIn(0, buffer, 0); invoke_to_comIn(0, buffer, 0);
dispatchAll(); dispatchAll();
ASSERT_TRUE(comLogger.fileMode == ComLogger::OPEN); ASSERT_TRUE(comLogger.m_fileMode == ComLogger::OPEN);
// A new file should have been opened from the previous loop iteration: // A new file should have been opened from the previous loop iteration:
if( j > 0 ) { if( j > 0 ) {
ASSERT_TRUE(comLogger.fileMode == ComLogger::OPEN); ASSERT_TRUE(comLogger.m_fileMode == ComLogger::OPEN);
ASSERT_TRUE(strcmp(static_cast<char*>(comLogger.fileName), fileName) == 0 ); ASSERT_TRUE(strcmp(static_cast<char*>(comLogger.m_fileName), fileName) == 0 );
} }
// Make sure we got a closed file event: // Make sure we got a closed file event:
@ -695,7 +695,7 @@ namespace Svc {
this->invoke_to_comIn(0, buffer, 0); this->invoke_to_comIn(0, buffer, 0);
dispatchAll(); dispatchAll();
ASSERT_TRUE(comLogger.fileMode == ComLogger::CLOSED); ASSERT_TRUE(comLogger.m_fileMode == ComLogger::CLOSED);
ASSERT_EVENTS_FileNotInitialized_SIZE(1); ASSERT_EVENTS_FileNotInitialized_SIZE(1);
this->comLogger.init_log_file(FILE_STR, MAX_BYTES_PER_FILE); this->comLogger.init_log_file(FILE_STR, MAX_BYTES_PER_FILE);
@ -703,7 +703,7 @@ namespace Svc {
this->clearHistory(); this->clearHistory();
this->invoke_to_comIn(0, buffer, 0); this->invoke_to_comIn(0, buffer, 0);
dispatchAll(); dispatchAll();
ASSERT_TRUE(comLogger.fileMode == ComLogger::OPEN); ASSERT_TRUE(comLogger.m_fileMode == ComLogger::OPEN);
ASSERT_EVENTS_FileNotInitialized_SIZE(0); ASSERT_EVENTS_FileNotInitialized_SIZE(0);
} }

View File

@ -1,4 +1,4 @@
// ====================================================================== // ======================================================================
// \title File.cpp // \title File.cpp
// \author bocchino // \author bocchino
// \brief cpp file for FileDownlink::File // \brief cpp file for FileDownlink::File
@ -7,8 +7,8 @@
// Copyright 2009-2015, by the California Institute of Technology. // Copyright 2009-2015, by the California Institute of Technology.
// ALL RIGHTS RESERVED. United States Government Sponsorship // ALL RIGHTS RESERVED. United States Government Sponsorship
// acknowledged. // acknowledged.
// //
// ====================================================================== // ======================================================================
#include <Svc/FileDownlink/FileDownlink.hpp> #include <Svc/FileDownlink/FileDownlink.hpp>
#include <Fw/Types/Assert.hpp> #include <Fw/Types/Assert.hpp>
@ -33,20 +33,20 @@ namespace Svc {
this->destName = destLogStringArg; this->destName = destLogStringArg;
// Set size // Set size
FwSizeType size; FwSizeType file_size;
const Os::FileSystem::Status status = const Os::FileSystem::Status status =
Os::FileSystem::getFileSize(sourceFileName, size); Os::FileSystem::getFileSize(sourceFileName, file_size);
if (status != Os::FileSystem::OP_OK) if (status != Os::FileSystem::OP_OK)
return Os::File::BAD_SIZE; return Os::File::BAD_SIZE;
// If the size does not cast cleanly to the desired U32 type, return size error // If the size does not cast cleanly to the desired U32 type, return size error
if (static_cast<FwSizeType>(static_cast<U32>(size)) != size) { if (static_cast<FwSizeType>(static_cast<U32>(file_size)) != file_size) {
return Os::File::BAD_SIZE; return Os::File::BAD_SIZE;
} }
this->size = static_cast<U32>(size); this->size = static_cast<U32>(file_size);
// Initialize checksum // Initialize checksum
CFDP::Checksum checksum; CFDP::Checksum checksum;
this->checksum = checksum; this->m_checksum = checksum;
// Open osFile for reading // Open osFile for reading
return this->osFile.open(sourceFileName, Os::File::OPEN_READ); return this->osFile.open(sourceFileName, Os::File::OPEN_READ);
@ -57,7 +57,7 @@ namespace Svc {
read( read(
U8 *const data, U8 *const data,
const U32 byteOffset, const U32 byteOffset,
const U32 size const U32 a_size
) )
{ {
@ -66,15 +66,15 @@ namespace Svc {
if (status != Os::File::OP_OK) if (status != Os::File::OP_OK)
return status; return status;
NATIVE_INT_TYPE intSize = size; NATIVE_INT_TYPE intSize = a_size;
status = this->osFile.read(data, intSize); status = this->osFile.read(data, intSize);
if (status != Os::File::OP_OK) if (status != Os::File::OP_OK)
return status; return status;
// Force a bad size error when the U32 carrying size is bad // Force a bad size error when the U32 carrying size is bad
if (static_cast<U32>(intSize) != size) { if (static_cast<U32>(intSize) != a_size) {
return Os::File::BAD_SIZE; return Os::File::BAD_SIZE;
} }
this->checksum.update(data, byteOffset, size); this->m_checksum.update(data, byteOffset, a_size);
return Os::File::OP_OK; return Os::File::OP_OK;

View File

@ -27,19 +27,19 @@ namespace Svc {
const char *const name const char *const name
) : ) :
FileDownlinkComponentBase(name), FileDownlinkComponentBase(name),
configured(false), m_configured(false),
filesSent(this), m_filesSent(this),
packetsSent(this), m_packetsSent(this),
warnings(this), m_warnings(this),
sequenceIndex(0), m_sequenceIndex(0),
curTimer(0), m_curTimer(0),
bufferSize(0), m_bufferSize(0),
byteOffset(0), m_byteOffset(0),
endOffset(0), m_endOffset(0),
lastCompletedType(Fw::FilePacket::T_NONE), m_lastCompletedType(Fw::FilePacket::T_NONE),
lastBufferId(0), m_lastBufferId(0),
curEntry(), m_curEntry(),
cntxId(0) m_cntxId(0)
{ {
} }
@ -60,12 +60,12 @@ namespace Svc {
U32 fileQueueDepth U32 fileQueueDepth
) )
{ {
this->timeout = timeout; this->m_timeout = timeout;
this->cooldown = cooldown; this->m_cooldown = cooldown;
this->cycleTime = cycleTime; this->m_cycleTime = cycleTime;
this->configured = true; this->m_configured = true;
Os::Queue::QueueStatus stat = fileQueue.create( Os::Queue::QueueStatus stat = m_fileQueue.create(
Os::QueueString("fileDownlinkQueue"), Os::QueueString("fileDownlinkQueue"),
fileQueueDepth, fileQueueDepth,
sizeof(struct FileEntry) sizeof(struct FileEntry)
@ -76,7 +76,7 @@ namespace Svc {
void FileDownlink :: void FileDownlink ::
preamble() preamble()
{ {
FW_ASSERT(this->configured == true); FW_ASSERT(this->m_configured == true);
} }
FileDownlink :: FileDownlink ::
@ -95,49 +95,49 @@ namespace Svc {
NATIVE_UINT_TYPE context NATIVE_UINT_TYPE context
) )
{ {
switch(this->mode.get()) switch(this->m_mode.get())
{ {
case Mode::IDLE: { case Mode::IDLE: {
NATIVE_INT_TYPE real_size = 0; NATIVE_INT_TYPE real_size = 0;
NATIVE_INT_TYPE prio = 0; NATIVE_INT_TYPE prio = 0;
Os::Queue::QueueStatus stat = fileQueue.receive( Os::Queue::QueueStatus stat = m_fileQueue.receive(
reinterpret_cast<U8*>(&this->curEntry), reinterpret_cast<U8*>(&this->m_curEntry),
sizeof(this->curEntry), sizeof(this->m_curEntry),
real_size, real_size,
prio, prio,
Os::Queue::QUEUE_NONBLOCKING Os::Queue::QUEUE_NONBLOCKING
); );
if(stat != Os::Queue::QUEUE_OK || sizeof(this->curEntry) != real_size) { if(stat != Os::Queue::QUEUE_OK || sizeof(this->m_curEntry) != real_size) {
return; return;
} }
sendFile( sendFile(
this->curEntry.srcFilename, this->m_curEntry.srcFilename,
this->curEntry.destFilename, this->m_curEntry.destFilename,
this->curEntry.offset, this->m_curEntry.offset,
this->curEntry.length this->m_curEntry.length
); );
break; break;
} }
case Mode::COOLDOWN: { case Mode::COOLDOWN: {
if (this->curTimer >= this->cooldown) { if (this->m_curTimer >= this->m_cooldown) {
this->curTimer = 0; this->m_curTimer = 0;
this->mode.set(Mode::IDLE); this->m_mode.set(Mode::IDLE);
} else { } else {
this->curTimer += cycleTime; this->m_curTimer += m_cycleTime;
} }
break; break;
} }
case Mode::WAIT: { case Mode::WAIT: {
//If current timeout is too-high and we are waiting for a packet, issue a timeout //If current timeout is too-high and we are waiting for a packet, issue a timeout
if (this->curTimer >= this->timeout) { if (this->m_curTimer >= this->m_timeout) {
this->curTimer = 0; this->m_curTimer = 0;
this->log_WARNING_HI_DownlinkTimeout(this->file.sourceName, this->file.destName); this->log_WARNING_HI_DownlinkTimeout(this->m_file.sourceName, this->m_file.destName);
this->enterCooldown(); this->enterCooldown();
this->sendResponse(FILEDOWNLINK_COMMAND_FAILURES_DISABLED ? SendFileStatus::STATUS_OK : SendFileStatus::STATUS_ERROR); this->sendResponse(FILEDOWNLINK_COMMAND_FAILURES_DISABLED ? SendFileStatus::STATUS_OK : SendFileStatus::STATUS_ERROR);
} else { //Otherwise update the current counter } else { //Otherwise update the current counter
this->curTimer += cycleTime; this->m_curTimer += m_cycleTime;
} }
break; break;
} }
@ -163,14 +163,14 @@ namespace Svc {
entry.source = FileDownlink::PORT; entry.source = FileDownlink::PORT;
entry.opCode = 0; entry.opCode = 0;
entry.cmdSeq = 0; entry.cmdSeq = 0;
entry.context = cntxId++; entry.context = m_cntxId++;
FW_ASSERT(sourceFilename.length() < sizeof(entry.srcFilename)); FW_ASSERT(sourceFilename.length() < sizeof(entry.srcFilename));
FW_ASSERT(destFilename.length() < sizeof(entry.destFilename)); FW_ASSERT(destFilename.length() < sizeof(entry.destFilename));
Fw::StringUtils::string_copy(entry.srcFilename, sourceFilename.toChar(), sizeof(entry.srcFilename)); Fw::StringUtils::string_copy(entry.srcFilename, sourceFilename.toChar(), sizeof(entry.srcFilename));
Fw::StringUtils::string_copy(entry.destFilename, destFilename.toChar(), sizeof(entry.destFilename)); Fw::StringUtils::string_copy(entry.destFilename, destFilename.toChar(), sizeof(entry.destFilename));
Os::Queue::QueueStatus status = fileQueue.send(reinterpret_cast<U8*>(&entry), sizeof(entry), 0, Os::Queue::QUEUE_NONBLOCKING); Os::Queue::QueueStatus status = m_fileQueue.send(reinterpret_cast<U8*>(&entry), sizeof(entry), 0, Os::Queue::QUEUE_NONBLOCKING);
if(status != Os::Queue::QUEUE_OK) { if(status != Os::Queue::QUEUE_OK) {
return SendFileResponse(SendFileStatus::STATUS_ERROR, std::numeric_limits<U32>::max()); return SendFileResponse(SendFileStatus::STATUS_ERROR, std::numeric_limits<U32>::max());
@ -195,21 +195,21 @@ namespace Svc {
{ {
//If this is a stale buffer (old, timed-out, or both), then ignore its return. //If this is a stale buffer (old, timed-out, or both), then ignore its return.
//File downlink actions only respond to the return of the most-recently-sent buffer. //File downlink actions only respond to the return of the most-recently-sent buffer.
if (this->lastBufferId != fwBuffer.getContext() + 1 || if (this->m_lastBufferId != fwBuffer.getContext() + 1 ||
this->mode.get() == Mode::IDLE) { this->m_mode.get() == Mode::IDLE) {
return; return;
} }
//Non-ignored buffers cannot be returned in "DOWNLINK" and "IDLE" state. Only in "WAIT", "CANCEL" state. //Non-ignored buffers cannot be returned in "DOWNLINK" and "IDLE" state. Only in "WAIT", "CANCEL" state.
FW_ASSERT(this->mode.get() == Mode::WAIT || this->mode.get() == Mode::CANCEL, this->mode.get()); FW_ASSERT(this->m_mode.get() == Mode::WAIT || this->m_mode.get() == Mode::CANCEL, this->m_mode.get());
//If the last packet has been sent (and is returning now) then finish the file //If the last packet has been sent (and is returning now) then finish the file
if (this->lastCompletedType == Fw::FilePacket::T_END || if (this->m_lastCompletedType == Fw::FilePacket::T_END ||
this->lastCompletedType == Fw::FilePacket::T_CANCEL) { this->m_lastCompletedType == Fw::FilePacket::T_CANCEL) {
finishHelper(this->lastCompletedType == Fw::FilePacket::T_CANCEL); finishHelper(this->m_lastCompletedType == Fw::FilePacket::T_CANCEL);
return; return;
} }
//If waiting and a buffer is in-bound, then switch to downlink mode //If waiting and a buffer is in-bound, then switch to downlink mode
else if (this->mode.get() == Mode::WAIT) { else if (this->m_mode.get() == Mode::WAIT) {
this->mode.set(Mode::DOWNLINK); this->m_mode.set(Mode::DOWNLINK);
} }
this->downlinkPacket(); this->downlinkPacket();
@ -243,7 +243,7 @@ namespace Svc {
Fw::StringUtils::string_copy(entry.srcFilename, sourceFilename.toChar(), sizeof(entry.srcFilename)); Fw::StringUtils::string_copy(entry.srcFilename, sourceFilename.toChar(), sizeof(entry.srcFilename));
Fw::StringUtils::string_copy(entry.destFilename, destFilename.toChar(), sizeof(entry.destFilename)); Fw::StringUtils::string_copy(entry.destFilename, destFilename.toChar(), sizeof(entry.destFilename));
Os::Queue::QueueStatus status = fileQueue.send(reinterpret_cast<U8*>(&entry), sizeof(entry), 0, Os::Queue::QUEUE_NONBLOCKING); Os::Queue::QueueStatus status = m_fileQueue.send(reinterpret_cast<U8*>(&entry), sizeof(entry), 0, Os::Queue::QUEUE_NONBLOCKING);
if(status != Os::Queue::QUEUE_OK) { if(status != Os::Queue::QUEUE_OK) {
this->cmdResponse_out(opCode, cmdSeq, Fw::CmdResponse::EXECUTION_ERROR); this->cmdResponse_out(opCode, cmdSeq, Fw::CmdResponse::EXECUTION_ERROR);
@ -276,7 +276,7 @@ namespace Svc {
Fw::StringUtils::string_copy(entry.srcFilename, sourceFilename.toChar(), sizeof(entry.srcFilename)); Fw::StringUtils::string_copy(entry.srcFilename, sourceFilename.toChar(), sizeof(entry.srcFilename));
Fw::StringUtils::string_copy(entry.destFilename, destFilename.toChar(), sizeof(entry.destFilename)); Fw::StringUtils::string_copy(entry.destFilename, destFilename.toChar(), sizeof(entry.destFilename));
Os::Queue::QueueStatus status = fileQueue.send(reinterpret_cast<U8*>(&entry), sizeof(entry), 0, Os::Queue::QUEUE_NONBLOCKING); Os::Queue::QueueStatus status = m_fileQueue.send(reinterpret_cast<U8*>(&entry), sizeof(entry), 0, Os::Queue::QUEUE_NONBLOCKING);
if(status != Os::Queue::QUEUE_OK) { if(status != Os::Queue::QUEUE_OK) {
this->cmdResponse_out(opCode, cmdSeq, Fw::CmdResponse::EXECUTION_ERROR); this->cmdResponse_out(opCode, cmdSeq, Fw::CmdResponse::EXECUTION_ERROR);
@ -290,8 +290,8 @@ namespace Svc {
) )
{ {
//Must be able to cancel in both downlink and waiting states //Must be able to cancel in both downlink and waiting states
if (this->mode.get() == Mode::DOWNLINK || this->mode.get() == Mode::WAIT) { if (this->m_mode.get() == Mode::DOWNLINK || this->m_mode.get() == Mode::WAIT) {
this->mode.set(Mode::CANCEL); this->m_mode.set(Mode::CANCEL);
} }
this->cmdResponse_out(opCode, cmdSeq, Fw::CmdResponse::OK); this->cmdResponse_out(opCode, cmdSeq, Fw::CmdResponse::OK);
} }
@ -324,12 +324,12 @@ namespace Svc {
void FileDownlink :: void FileDownlink ::
sendResponse(SendFileStatus resp) sendResponse(SendFileStatus resp)
{ {
if(this->curEntry.source == FileDownlink::COMMAND) { if(this->m_curEntry.source == FileDownlink::COMMAND) {
this->cmdResponse_out(this->curEntry.opCode, this->curEntry.cmdSeq, statusToCmdResp(resp)); this->cmdResponse_out(this->m_curEntry.opCode, this->m_curEntry.cmdSeq, statusToCmdResp(resp));
} else { } else {
for(NATIVE_INT_TYPE i = 0; i < this->getNum_FileComplete_OutputPorts(); i++) { for(NATIVE_INT_TYPE i = 0; i < this->getNum_FileComplete_OutputPorts(); i++) {
if(this->isConnected_FileComplete_OutputPort(i)) { if(this->isConnected_FileComplete_OutputPort(i)) {
this->FileComplete_out(i, Svc::SendFileResponse(resp, this->curEntry.context)); this->FileComplete_out(i, Svc::SendFileResponse(resp, this->m_curEntry.context));
} }
} }
} }
@ -344,78 +344,78 @@ namespace Svc {
) )
{ {
// Open file for downlink // Open file for downlink
Os::File::Status status = this->file.open( Os::File::Status status = this->m_file.open(
sourceFilename, sourceFilename,
destFilename destFilename
); );
// Reject command if error when opening file // Reject command if error when opening file
if (status != Os::File::OP_OK) { if (status != Os::File::OP_OK) {
this->mode.set(Mode::IDLE); this->m_mode.set(Mode::IDLE);
this->warnings.fileOpenError(); this->m_warnings.fileOpenError();
sendResponse(FILEDOWNLINK_COMMAND_FAILURES_DISABLED ? SendFileStatus::STATUS_OK : SendFileStatus::STATUS_ERROR); sendResponse(FILEDOWNLINK_COMMAND_FAILURES_DISABLED ? SendFileStatus::STATUS_OK : SendFileStatus::STATUS_ERROR);
return; return;
} }
if (startOffset >= this->file.size) { if (startOffset >= this->m_file.size) {
this->enterCooldown(); this->enterCooldown();
this->log_WARNING_HI_DownlinkPartialFail(this->file.sourceName, this->file.destName, startOffset, this->file.size); this->log_WARNING_HI_DownlinkPartialFail(this->m_file.sourceName, this->m_file.destName, startOffset, this->m_file.size);
sendResponse(FILEDOWNLINK_COMMAND_FAILURES_DISABLED ? SendFileStatus::STATUS_OK : SendFileStatus::STATUS_INVALID); sendResponse(FILEDOWNLINK_COMMAND_FAILURES_DISABLED ? SendFileStatus::STATUS_OK : SendFileStatus::STATUS_INVALID);
return; return;
} else if (startOffset + length > this->file.size) { } else if (startOffset + length > this->m_file.size) {
// If the amount to downlink is greater than the file size, emit a Warning and then allow // If the amount to downlink is greater than the file size, emit a Warning and then allow
// the file to be downlinked anyway // the file to be downlinked anyway
this->log_WARNING_LO_DownlinkPartialWarning(startOffset, length, this->file.size, this->file.sourceName, this->file.destName); this->log_WARNING_LO_DownlinkPartialWarning(startOffset, length, this->m_file.size, this->m_file.sourceName, this->m_file.destName);
length = this->file.size - startOffset; length = this->m_file.size - startOffset;
} }
// Send file and switch to WAIT mode // Send file and switch to WAIT mode
this->getBuffer(this->buffer, FILE_PACKET); this->getBuffer(this->m_buffer, FILE_PACKET);
this->sendStartPacket(); this->sendStartPacket();
this->mode.set(Mode::WAIT); this->m_mode.set(Mode::WAIT);
this->sequenceIndex = 1; this->m_sequenceIndex = 1;
this->curTimer = 0; this->m_curTimer = 0;
this->byteOffset = startOffset; this->m_byteOffset = startOffset;
this->lastCompletedType = Fw::FilePacket::T_START; this->m_lastCompletedType = Fw::FilePacket::T_START;
// zero length means read until end of file // zero length means read until end of file
if (length > 0) { if (length > 0) {
this->log_ACTIVITY_HI_SendStarted(length, this->file.sourceName, this->file.destName); this->log_ACTIVITY_HI_SendStarted(length, this->m_file.sourceName, this->m_file.destName);
this->endOffset = startOffset + length; this->m_endOffset = startOffset + length;
} }
else { else {
this->log_ACTIVITY_HI_SendStarted(this->file.size - startOffset, this->file.sourceName, this->file.destName); this->log_ACTIVITY_HI_SendStarted(this->m_file.size - startOffset, this->m_file.sourceName, this->m_file.destName);
this->endOffset = this->file.size; this->m_endOffset = this->m_file.size;
} }
} }
Os::File::Status FileDownlink :: Os::File::Status FileDownlink ::
sendDataPacket(U32 &byteOffset) sendDataPacket(U32 &byteOffset)
{ {
FW_ASSERT(byteOffset < this->endOffset); FW_ASSERT(byteOffset < this->m_endOffset);
const U32 maxDataSize = FILEDOWNLINK_INTERNAL_BUFFER_SIZE - Fw::FilePacket::DataPacket::HEADERSIZE; const U32 maxDataSize = FILEDOWNLINK_INTERNAL_BUFFER_SIZE - Fw::FilePacket::DataPacket::HEADERSIZE;
const U32 dataSize = (byteOffset + maxDataSize > this->endOffset) ? (this->endOffset - byteOffset) : maxDataSize; const U32 dataSize = (byteOffset + maxDataSize > this->m_endOffset) ? (this->m_endOffset - byteOffset) : maxDataSize;
U8 buffer[FILEDOWNLINK_INTERNAL_BUFFER_SIZE - Fw::FilePacket::DataPacket::HEADERSIZE]; U8 buffer[FILEDOWNLINK_INTERNAL_BUFFER_SIZE - Fw::FilePacket::DataPacket::HEADERSIZE];
//This will be last data packet sent //This will be last data packet sent
if (dataSize + byteOffset == this->endOffset) { if (dataSize + byteOffset == this->m_endOffset) {
this->lastCompletedType = Fw::FilePacket::T_DATA; this->m_lastCompletedType = Fw::FilePacket::T_DATA;
} }
const Os::File::Status status = const Os::File::Status status =
this->file.read(buffer, byteOffset, dataSize); this->m_file.read(buffer, byteOffset, dataSize);
if (status != Os::File::OP_OK) { if (status != Os::File::OP_OK) {
this->warnings.fileRead(status); this->m_warnings.fileRead(status);
return status; return status;
} }
const Fw::FilePacket::DataPacket dataPacket = { const Fw::FilePacket::DataPacket dataPacket = {
{ Fw::FilePacket::T_DATA, this->sequenceIndex }, { Fw::FilePacket::T_DATA, this->m_sequenceIndex },
byteOffset, byteOffset,
static_cast<U16>(dataSize), static_cast<U16>(dataSize),
buffer buffer
}; };
++this->sequenceIndex; ++this->m_sequenceIndex;
Fw::FilePacket filePacket; Fw::FilePacket filePacket;
filePacket.fromDataPacket(dataPacket); filePacket.fromDataPacket(dataPacket);
this->sendFilePacket(filePacket); this->sendFilePacket(filePacket);
@ -431,7 +431,7 @@ namespace Svc {
{ {
Fw::Buffer buffer; Fw::Buffer buffer;
const Fw::FilePacket::CancelPacket cancelPacket = { const Fw::FilePacket::CancelPacket cancelPacket = {
{ Fw::FilePacket::T_CANCEL, this->sequenceIndex } { Fw::FilePacket::T_CANCEL, this->m_sequenceIndex }
}; };
Fw::FilePacket filePacket; Fw::FilePacket filePacket;
@ -441,7 +441,7 @@ namespace Svc {
const Fw::SerializeStatus status = filePacket.toBuffer(buffer); const Fw::SerializeStatus status = filePacket.toBuffer(buffer);
FW_ASSERT(status == Fw::FW_SERIALIZE_OK); FW_ASSERT(status == Fw::FW_SERIALIZE_OK);
this->bufferSendOut_out(0, buffer); this->bufferSendOut_out(0, buffer);
this->packetsSent.packetSent(); this->m_packetsSent.packetSent();
} }
void FileDownlink :: void FileDownlink ::
@ -449,13 +449,13 @@ namespace Svc {
{ {
const Fw::FilePacket::Header header = { const Fw::FilePacket::Header header = {
Fw::FilePacket::T_END, Fw::FilePacket::T_END,
this->sequenceIndex this->m_sequenceIndex
}; };
Fw::FilePacket::EndPacket endPacket; Fw::FilePacket::EndPacket endPacket;
endPacket.header = header; endPacket.header = header;
CFDP::Checksum checksum; CFDP::Checksum checksum;
this->file.getChecksum(checksum); this->m_file.getChecksum(checksum);
endPacket.setChecksum(checksum); endPacket.setChecksum(checksum);
Fw::FilePacket filePacket; Fw::FilePacket filePacket;
@ -469,9 +469,9 @@ namespace Svc {
{ {
Fw::FilePacket::StartPacket startPacket; Fw::FilePacket::StartPacket startPacket;
startPacket.initialize( startPacket.initialize(
this->file.size, this->m_file.size,
this->file.sourceName.toChar(), this->m_file.sourceName.toChar(),
this->file.destName.toChar() this->m_file.destName.toChar()
); );
Fw::FilePacket filePacket; Fw::FilePacket filePacket;
filePacket.fromStartPacket(startPacket); filePacket.fromStartPacket(startPacket);
@ -482,43 +482,43 @@ namespace Svc {
sendFilePacket(const Fw::FilePacket& filePacket) sendFilePacket(const Fw::FilePacket& filePacket)
{ {
const U32 bufferSize = filePacket.bufferSize(); const U32 bufferSize = filePacket.bufferSize();
FW_ASSERT(this->buffer.getData() != nullptr); FW_ASSERT(this->m_buffer.getData() != nullptr);
FW_ASSERT(this->buffer.getSize() >= bufferSize, bufferSize, this->buffer.getSize()); FW_ASSERT(this->m_buffer.getSize() >= bufferSize, bufferSize, this->m_buffer.getSize());
const Fw::SerializeStatus status = filePacket.toBuffer(this->buffer); const Fw::SerializeStatus status = filePacket.toBuffer(this->m_buffer);
FW_ASSERT(status == Fw::FW_SERIALIZE_OK); FW_ASSERT(status == Fw::FW_SERIALIZE_OK);
// set the buffer size to the packet size // set the buffer size to the packet size
this->buffer.setSize(bufferSize); this->m_buffer.setSize(bufferSize);
this->bufferSendOut_out(0, this->buffer); this->bufferSendOut_out(0, this->m_buffer);
// restore buffer size to max // restore buffer size to max
this->buffer.setSize(FILEDOWNLINK_INTERNAL_BUFFER_SIZE); this->m_buffer.setSize(FILEDOWNLINK_INTERNAL_BUFFER_SIZE);
this->packetsSent.packetSent(); this->m_packetsSent.packetSent();
} }
void FileDownlink :: void FileDownlink ::
enterCooldown() enterCooldown()
{ {
this->file.osFile.close(); this->m_file.osFile.close();
this->mode.set(Mode::COOLDOWN); this->m_mode.set(Mode::COOLDOWN);
this->lastCompletedType = Fw::FilePacket::T_NONE; this->m_lastCompletedType = Fw::FilePacket::T_NONE;
this->curTimer = 0; this->m_curTimer = 0;
} }
void FileDownlink :: void FileDownlink ::
downlinkPacket() downlinkPacket()
{ {
FW_ASSERT(this->lastCompletedType != Fw::FilePacket::T_NONE, this->lastCompletedType); FW_ASSERT(this->m_lastCompletedType != Fw::FilePacket::T_NONE, this->m_lastCompletedType);
FW_ASSERT(this->mode.get() == Mode::CANCEL || this->mode.get() == Mode::DOWNLINK, this->mode.get()); FW_ASSERT(this->m_mode.get() == Mode::CANCEL || this->m_mode.get() == Mode::DOWNLINK, this->m_mode.get());
//If canceled mode and currently downlinking data then send a cancel packet //If canceled mode and currently downlinking data then send a cancel packet
if (this->mode.get() == Mode::CANCEL && this->lastCompletedType == Fw::FilePacket::T_START) { if (this->m_mode.get() == Mode::CANCEL && this->m_lastCompletedType == Fw::FilePacket::T_START) {
this->sendCancelPacket(); this->sendCancelPacket();
this->lastCompletedType = Fw::FilePacket::T_CANCEL; this->m_lastCompletedType = Fw::FilePacket::T_CANCEL;
} }
//If in downlink mode and currently downlinking data then continue with the next packer //If in downlink mode and currently downlinking data then continue with the next packer
else if (this->mode.get() == Mode::DOWNLINK && this->lastCompletedType == Fw::FilePacket::T_START) { else if (this->m_mode.get() == Mode::DOWNLINK && this->m_lastCompletedType == Fw::FilePacket::T_START) {
//Send the next packet, or fail doing so //Send the next packet, or fail doing so
const Os::File::Status status = this->sendDataPacket(this->byteOffset); const Os::File::Status status = this->sendDataPacket(this->m_byteOffset);
if (status != Os::File::OP_OK) { if (status != Os::File::OP_OK) {
this->log_WARNING_HI_SendDataFail(this->file.sourceName, this->byteOffset); this->log_WARNING_HI_SendDataFail(this->m_file.sourceName, this->m_byteOffset);
this->enterCooldown(); this->enterCooldown();
this->sendResponse(FILEDOWNLINK_COMMAND_FAILURES_DISABLED ? SendFileStatus::STATUS_OK : SendFileStatus::STATUS_ERROR); this->sendResponse(FILEDOWNLINK_COMMAND_FAILURES_DISABLED ? SendFileStatus::STATUS_OK : SendFileStatus::STATUS_ERROR);
//Don't go to wait state //Don't go to wait state
@ -526,12 +526,12 @@ namespace Svc {
} }
} }
//If in downlink mode or cancel and finished downlinking data then send the last packet //If in downlink mode or cancel and finished downlinking data then send the last packet
else if (this->lastCompletedType == Fw::FilePacket::T_DATA) { else if (this->m_lastCompletedType == Fw::FilePacket::T_DATA) {
this->sendEndPacket(); this->sendEndPacket();
this->lastCompletedType = Fw::FilePacket::T_END; this->m_lastCompletedType = Fw::FilePacket::T_END;
} }
this->mode.set(Mode::WAIT); this->m_mode.set(Mode::WAIT);
this->curTimer = 0; this->m_curTimer = 0;
} }
void FileDownlink :: void FileDownlink ::
@ -539,10 +539,10 @@ namespace Svc {
{ {
//Complete command and switch to IDLE //Complete command and switch to IDLE
if (not cancel) { if (not cancel) {
this->filesSent.fileSent(); this->m_filesSent.fileSent();
this->log_ACTIVITY_HI_FileSent(this->file.sourceName, this->file.destName); this->log_ACTIVITY_HI_FileSent(this->m_file.sourceName, this->m_file.destName);
} else { } else {
this->log_ACTIVITY_HI_DownlinkCanceled(this->file.sourceName, this->file.destName); this->log_ACTIVITY_HI_DownlinkCanceled(this->m_file.sourceName, this->m_file.destName);
} }
this->enterCooldown(); this->enterCooldown();
sendResponse(SendFileStatus::STATUS_OK); sendResponse(SendFileStatus::STATUS_OK);
@ -554,10 +554,10 @@ namespace Svc {
//Check type is correct //Check type is correct
FW_ASSERT(type < COUNT_PACKET_TYPE && type >= 0, type); FW_ASSERT(type < COUNT_PACKET_TYPE && type >= 0, type);
// Wrap the buffer around our indexed memory. // Wrap the buffer around our indexed memory.
buffer.setData(this->memoryStore[type]); buffer.setData(this->m_memoryStore[type]);
buffer.setSize(FILEDOWNLINK_INTERNAL_BUFFER_SIZE); buffer.setSize(FILEDOWNLINK_INTERNAL_BUFFER_SIZE);
//Set a known ID to look for later //Set a known ID to look for later
buffer.setContext(lastBufferId); buffer.setContext(m_lastBufferId);
lastBufferId++; m_lastBufferId++;
} }
} // end namespace Svc } // end namespace Svc

View File

@ -43,32 +43,32 @@ namespace Svc {
public: public:
//! Constructor //! Constructor
Mode() : value(IDLE) { } Mode() : m_value(IDLE) { }
public: public:
//! Set the Mode value //! Set the Mode value
void set(const Type value) { void set(const Type value) {
this->mutex.lock(); this->m_mutex.lock();
this->value = value; this->m_value = value;
this->mutex.unLock(); this->m_mutex.unLock();
} }
//! Get the Mode value //! Get the Mode value
Type get() { Type get() {
this->mutex.lock(); this->m_mutex.lock();
const Type value = this->value; const Type value = this->m_value;
this->mutex.unLock(); this->m_mutex.unLock();
return value; return value;
} }
private: private:
//! The Mode value //! The Mode value
Type value; Type m_value;
//! The Mode mutex //! The Mode mutex
Os::Mutex mutex; Os::Mutex m_mutex;
}; };
//! Class representing an outgoing file //! Class representing an outgoing file
@ -96,7 +96,7 @@ namespace Svc {
PRIVATE: PRIVATE:
//! The checksum for the file //! The checksum for the file
CFDP::Checksum checksum; CFDP::Checksum m_checksum;
public: public:
@ -110,12 +110,12 @@ namespace Svc {
Os::File::Status read( Os::File::Status read(
U8 *const data, U8 *const data,
const U32 byteOffset, const U32 byteOffset,
const U32 size const U32 a_size
); );
//! Get the checksum //! Get the checksum
void getChecksum(CFDP::Checksum& checksum) { void getChecksum(CFDP::Checksum& checksum) {
checksum = this->checksum; checksum = this->m_checksum;
} }
}; };
@ -126,24 +126,25 @@ namespace Svc {
//! Construct a FilesSent object //! Construct a FilesSent object
FilesSent(FileDownlink *const fileDownlink) : FilesSent(FileDownlink *const fileDownlink) :
n(0), fileDownlink(fileDownlink) m_sent_file_count(0),
m_fileDownlink(fileDownlink)
{ } { }
public: public:
//! Record a file sent //! Record a file sent
void fileSent() { void fileSent() {
++this->n; ++this->m_sent_file_count;
this->fileDownlink->tlmWrite_FilesSent(n); this->m_fileDownlink->tlmWrite_FilesSent(m_sent_file_count);
} }
PRIVATE: PRIVATE:
//! The total number of downlinks canceled //! The total number of file sent
U32 n; U32 m_sent_file_count;
//! The enclosing FileDownlink object //! The enclosing FileDownlink object
FileDownlink *const fileDownlink; FileDownlink *const m_fileDownlink;
}; };
@ -154,24 +155,25 @@ namespace Svc {
//! Construct a PacketsSent object //! Construct a PacketsSent object
PacketsSent(FileDownlink *const fileDownlink) : PacketsSent(FileDownlink *const fileDownlink) :
n(0), fileDownlink(fileDownlink) m_sent_packet_count(0),
m_fileDownlink(fileDownlink)
{ } { }
public: public:
//! Record a packet sent //! Record a packet sent
void packetSent() { void packetSent() {
++this->n; ++this->m_sent_packet_count;
this->fileDownlink->tlmWrite_PacketsSent(n); this->m_fileDownlink->tlmWrite_PacketsSent(m_sent_packet_count);
} }
PRIVATE: PRIVATE:
//! The total number of downlinks canceled //! The total number of downlinked packets
U32 n; U32 m_sent_packet_count;
//! The enclosing FileDownlink object //! The enclosing FileDownlink object
FileDownlink *const fileDownlink; FileDownlink *const m_fileDownlink;
}; };
@ -182,7 +184,8 @@ namespace Svc {
//! Construct a Warnings object //! Construct a Warnings object
Warnings(FileDownlink *const fileDownlink) : Warnings(FileDownlink *const fileDownlink) :
n(0), fileDownlink(fileDownlink) m_warning_count(0),
m_fileDownlink(fileDownlink)
{ } { }
public: public:
@ -197,17 +200,17 @@ namespace Svc {
//! Record a warning //! Record a warning
void warning() { void warning() {
++this->n; ++this->m_warning_count;
this->fileDownlink->tlmWrite_Warnings(n); this->m_fileDownlink->tlmWrite_Warnings(m_warning_count);
} }
PRIVATE: PRIVATE:
//! The total number of warnings //! The total number of warnings
U32 n; U32 m_warning_count;
//! The enclosing FileDownlink object //! The enclosing FileDownlink object
FileDownlink *const fileDownlink; FileDownlink *const m_fileDownlink;
}; };
@ -390,67 +393,67 @@ namespace Svc {
// ---------------------------------------------------------------------- // ----------------------------------------------------------------------
//! Whether the configuration function has been called. //! Whether the configuration function has been called.
bool configured; bool m_configured;
//! File downlink queue //! File downlink queue
Os::Queue fileQueue; Os::Queue m_fileQueue;
//!Buffer's memory backing //!Buffer's memory backing
U8 memoryStore[COUNT_PACKET_TYPE][FILEDOWNLINK_INTERNAL_BUFFER_SIZE]; U8 m_memoryStore[COUNT_PACKET_TYPE][FILEDOWNLINK_INTERNAL_BUFFER_SIZE];
//! The mode //! The mode
Mode mode; Mode m_mode;
//! The file //! The file
File file; File m_file;
//! Files sent //! Files sent
FilesSent filesSent; FilesSent m_filesSent;
//! Packets sent //! Packets sent
PacketsSent packetsSent; PacketsSent m_packetsSent;
//! Warnings //! Warnings
Warnings warnings; Warnings m_warnings;
//! The current sequence index //! The current sequence index
U32 sequenceIndex; U32 m_sequenceIndex;
//! Timeout threshold (milliseconds) while in WAIT state //! Timeout threshold (milliseconds) while in WAIT state
U32 timeout; U32 m_timeout;
//! Cooldown (in ms) between finishing a downlink and starting the next file. //! Cooldown (in ms) between finishing a downlink and starting the next file.
U32 cooldown; U32 m_cooldown;
//! current time residing in WAIT state //! current time residing in WAIT state
U32 curTimer; U32 m_curTimer;
//! rate (milliseconds) at which we are running //! rate (milliseconds) at which we are running
U32 cycleTime; U32 m_cycleTime;
////! Buffer for sending file data ////! Buffer for sending file data
Fw::Buffer buffer; Fw::Buffer m_buffer;
//! Buffer size for file data //! Buffer size for file data
U32 bufferSize; U32 m_bufferSize;
//! Current byte offset in file //! Current byte offset in file
U32 byteOffset; U32 m_byteOffset;
//! Amount of bytes left to read //! Amount of bytes left to read
U32 endOffset; U32 m_endOffset;
//! Set to true when all data packets have been sent //! Set to true when all data packets have been sent
Fw::FilePacket::Type lastCompletedType; Fw::FilePacket::Type m_lastCompletedType;
//! Last buffer used //! Last buffer used
U32 lastBufferId; U32 m_lastBufferId;
//! Current in progress file entry from queue //! Current in progress file entry from queue
struct FileEntry curEntry; struct FileEntry m_curEntry;
//! Incrementing context id used to unique identify a specific downlink request //! Incrementing context id used to unique identify a specific downlink request
U32 cntxId; U32 m_cntxId;
}; };
} // end namespace Svc } // end namespace Svc

View File

@ -15,8 +15,8 @@ namespace Svc {
void FileDownlink::Warnings :: void FileDownlink::Warnings ::
fileOpenError() fileOpenError()
{ {
this->fileDownlink->log_WARNING_HI_FileOpenError( this->m_fileDownlink->log_WARNING_HI_FileOpenError(
this->fileDownlink->file.sourceName this->m_fileDownlink->m_file.sourceName
); );
this->warning(); this->warning();
} }
@ -24,8 +24,8 @@ namespace Svc {
void FileDownlink::Warnings :: void FileDownlink::Warnings ::
fileRead(const Os::File::Status status) fileRead(const Os::File::Status status)
{ {
this->fileDownlink->log_WARNING_HI_FileReadError( this->m_fileDownlink->log_WARNING_HI_FileReadError(
this->fileDownlink->file.sourceName, this->m_fileDownlink->m_file.sourceName,
status status
); );
this->warning(); this->warning();

View File

@ -55,7 +55,7 @@ namespace Svc {
downlink() downlink()
{ {
// Assert idle mode // Assert idle mode
ASSERT_EQ(FileDownlink::Mode::IDLE, this->component.mode.get()); ASSERT_EQ(FileDownlink::Mode::IDLE, this->component.m_mode.get());
// Create a file // Create a file
const char *const sourceFileName = "source.bin"; const char *const sourceFileName = "source.bin";
@ -102,7 +102,7 @@ namespace Svc {
ASSERT_EQ(true, FileBuffer::compare(fileBufferIn, fileBufferOut)); ASSERT_EQ(true, FileBuffer::compare(fileBufferIn, fileBufferOut));
// Assert idle mode // Assert idle mode
ASSERT_EQ(FileDownlink::Mode::IDLE, this->component.mode.get()); ASSERT_EQ(FileDownlink::Mode::IDLE, this->component.m_mode.get());
// Remove the outgoing file // Remove the outgoing file
this->removeFile(sourceFileName); this->removeFile(sourceFileName);
@ -160,7 +160,7 @@ namespace Svc {
ASSERT_CMD_RESPONSE_SIZE(1); ASSERT_CMD_RESPONSE_SIZE(1);
ASSERT_CMD_RESPONSE(0, FileDownlink::OPCODE_CANCEL, CMD_SEQ, Fw::CmdResponse::OK); ASSERT_CMD_RESPONSE(0, FileDownlink::OPCODE_CANCEL, CMD_SEQ, Fw::CmdResponse::OK);
this->cmdResponseHistory->clear(); this->cmdResponseHistory->clear();
ASSERT_EQ(FileDownlink::Mode::CANCEL, this->component.mode.get()); ASSERT_EQ(FileDownlink::Mode::CANCEL, this->component.m_mode.get());
this->component.doDispatch(); // Process return of original buffer and send cancel packet this->component.doDispatch(); // Process return of original buffer and send cancel packet
this->component.doDispatch(); // Process return of cancel packet this->component.doDispatch(); // Process return of cancel packet
@ -177,7 +177,7 @@ namespace Svc {
ASSERT_EVENTS_SIZE(2); // Started and cancel ASSERT_EVENTS_SIZE(2); // Started and cancel
ASSERT_EVENTS_DownlinkCanceled_SIZE(1); ASSERT_EVENTS_DownlinkCanceled_SIZE(1);
ASSERT_EQ(FileDownlink::Mode::COOLDOWN, this->component.mode.get()); ASSERT_EQ(FileDownlink::Mode::COOLDOWN, this->component.m_mode.get());
this->removeFile(sourceFileName); this->removeFile(sourceFileName);
} }
@ -186,14 +186,14 @@ namespace Svc {
cancelInIdleMode() cancelInIdleMode()
{ {
// Assert idle mode // Assert idle mode
ASSERT_EQ(FileDownlink::Mode::IDLE, this->component.mode.get()); ASSERT_EQ(FileDownlink::Mode::IDLE, this->component.m_mode.get());
// Send a cancel command // Send a cancel command
this->cancel(Fw::CmdResponse::OK); this->cancel(Fw::CmdResponse::OK);
this->component.Run_handler(0,0); this->component.Run_handler(0,0);
// Assert idle mode // Assert idle mode
ASSERT_EQ(FileDownlink::Mode::IDLE, this->component.mode.get()); ASSERT_EQ(FileDownlink::Mode::IDLE, this->component.m_mode.get());
} }
@ -201,7 +201,7 @@ namespace Svc {
downlinkPartial() downlinkPartial()
{ {
// Assert idle mode // Assert idle mode
ASSERT_EQ(FileDownlink::Mode::IDLE, this->component.mode.get()); ASSERT_EQ(FileDownlink::Mode::IDLE, this->component.m_mode.get());
// Create a file // Create a file
const char *const sourceFileName = "source.bin"; const char *const sourceFileName = "source.bin";
@ -263,7 +263,7 @@ namespace Svc {
ASSERT_EQ(true, FileBuffer::compare(fileBufferIn, fileBufferOutSubset)); ASSERT_EQ(true, FileBuffer::compare(fileBufferIn, fileBufferOutSubset));
// Assert idle mode // Assert idle mode
ASSERT_EQ(FileDownlink::Mode::IDLE, this->component.mode.get()); ASSERT_EQ(FileDownlink::Mode::IDLE, this->component.m_mode.get());
// Remove the outgoing file // Remove the outgoing file
this->removeFile(sourceFileName); this->removeFile(sourceFileName);
@ -274,7 +274,7 @@ namespace Svc {
timeout() timeout()
{ {
// Assert idle mode // Assert idle mode
ASSERT_EQ(FileDownlink::Mode::IDLE, this->component.mode.get()); ASSERT_EQ(FileDownlink::Mode::IDLE, this->component.m_mode.get());
// Create a file // Create a file
const char *const sourceFileName = "source.bin"; const char *const sourceFileName = "source.bin";
@ -318,7 +318,7 @@ namespace Svc {
ASSERT_EVENTS_DownlinkTimeout(0, sourceFileName, destFileName); ASSERT_EVENTS_DownlinkTimeout(0, sourceFileName, destFileName);
// Assert idle mode // Assert idle mode
ASSERT_EQ(FileDownlink::Mode::COOLDOWN, this->component.mode.get()); ASSERT_EQ(FileDownlink::Mode::COOLDOWN, this->component.m_mode.get());
// Remove the outgoing file // Remove the outgoing file
this->removeFile(sourceFileName); this->removeFile(sourceFileName);
@ -342,8 +342,8 @@ namespace Svc {
ASSERT_EQ(resp.getcontext(), 0); ASSERT_EQ(resp.getcontext(), 0);
this->component.Run_handler(0,0); // Dequeue file downlink request this->component.Run_handler(0,0); // Dequeue file downlink request
while (this->component.mode.get() != FileDownlink::Mode::IDLE) { while (this->component.m_mode.get() != FileDownlink::Mode::IDLE) {
if(this->component.mode.get() != FileDownlink::Mode::COOLDOWN) { if(this->component.m_mode.get() != FileDownlink::Mode::COOLDOWN) {
this->component.doDispatch(); this->component.doDispatch();
} }
this->component.Run_handler(0,0); this->component.Run_handler(0,0);
@ -538,8 +538,8 @@ namespace Svc {
this->component.doDispatch(); this->component.doDispatch();
this->component.Run_handler(0,0); this->component.Run_handler(0,0);
while (this->component.mode.get() != FileDownlink::Mode::IDLE) { while (this->component.m_mode.get() != FileDownlink::Mode::IDLE) {
if(this->component.mode.get() != FileDownlink::Mode::COOLDOWN) { if(this->component.m_mode.get() != FileDownlink::Mode::COOLDOWN) {
this->component.doDispatch(); this->component.doDispatch();
} }
this->component.Run_handler(0,0); this->component.Run_handler(0,0);
@ -572,8 +572,8 @@ namespace Svc {
this->component.doDispatch(); this->component.doDispatch();
this->component.Run_handler(0,0); this->component.Run_handler(0,0);
while (this->component.mode.get() != FileDownlink::Mode::IDLE) { while (this->component.m_mode.get() != FileDownlink::Mode::IDLE) {
if(this->component.mode.get() != FileDownlink::Mode::COOLDOWN) { if(this->component.m_mode.get() != FileDownlink::Mode::COOLDOWN) {
this->component.doDispatch(); this->component.doDispatch();
} }
this->component.Run_handler(0,0); this->component.Run_handler(0,0);

View File

@ -27,7 +27,7 @@ namespace Svc {
this->name = logStringArg; this->name = logStringArg;
this->size = startPacket.fileSize; this->size = startPacket.fileSize;
CFDP::Checksum checksum; CFDP::Checksum checksum;
this->checksum = checksum; this->m_checksum = checksum;
return this->osFile.open(path, Os::File::OPEN_WRITE); return this->osFile.open(path, Os::File::OPEN_WRITE);
} }
@ -53,7 +53,7 @@ namespace Svc {
} }
FW_ASSERT(static_cast<U32>(intLength) == length, intLength); FW_ASSERT(static_cast<U32>(intLength) == length, intLength);
this->checksum.update(data, byteOffset, length); this->m_checksum.update(data, byteOffset, length);
return Os::File::OP_OK; return Os::File::OP_OK;
} }

View File

@ -49,7 +49,7 @@ namespace Svc {
PRIVATE: PRIVATE:
//! The checksum for the file //! The checksum for the file
::CFDP::Checksum checksum; ::CFDP::Checksum m_checksum;
public: public:
@ -67,7 +67,7 @@ namespace Svc {
//! Get the checksum //! Get the checksum
void getChecksum(::CFDP::Checksum& checksum) { void getChecksum(::CFDP::Checksum& checksum) {
checksum = this->checksum; checksum = this->m_checksum;
} }
}; };
@ -79,24 +79,25 @@ namespace Svc {
//! Construct a FilesReceived object //! Construct a FilesReceived object
FilesReceived(FileUplink *const fileUplink) : FilesReceived(FileUplink *const fileUplink) :
n(0), fileUplink(fileUplink) m_received_files_counter(0),
m_fileUplink(fileUplink)
{ } { }
public: public:
//! Record a received file //! Record a received file
void fileReceived() { void fileReceived() {
++this->n; ++this->m_received_files_counter;
this->fileUplink->tlmWrite_FilesReceived(n); this->m_fileUplink->tlmWrite_FilesReceived(m_received_files_counter);
} }
PRIVATE: PRIVATE:
//! The total number of files received //! The total number of files received
U32 n; U32 m_received_files_counter;
//! The enclosing FileUplink object //! The enclosing FileUplink object
FileUplink *const fileUplink; FileUplink *const m_fileUplink;
}; };
@ -107,24 +108,25 @@ namespace Svc {
//! Construct a PacketsReceived object //! Construct a PacketsReceived object
PacketsReceived(FileUplink *const fileUplink) : PacketsReceived(FileUplink *const fileUplink) :
n(0), fileUplink(fileUplink) m_received_packet_count(0),
m_fileUplink(fileUplink)
{ } { }
public: public:
//! Record a packet received //! Record a packet received
void packetReceived() { void packetReceived() {
++this->n; ++this->m_received_packet_count;
this->fileUplink->tlmWrite_PacketsReceived(n); this->m_fileUplink->tlmWrite_PacketsReceived(m_received_packet_count);
} }
PRIVATE: PRIVATE:
//! The total number of cancel packets //! The total number of received packets
U32 n; U32 m_received_packet_count;
//! The enclosing FileUplink object //! The enclosing FileUplink object
FileUplink *const fileUplink; FileUplink *const m_fileUplink;
}; };
@ -135,7 +137,8 @@ namespace Svc {
//! Construct a Warnings object //! Construct a Warnings object
Warnings(FileUplink *const fileUplink) : Warnings(FileUplink *const fileUplink) :
n(0), fileUplink(fileUplink) m_warning_count(0),
m_fileUplink(fileUplink)
{ } { }
public: public:
@ -171,17 +174,17 @@ namespace Svc {
//! Record a warning //! Record a warning
void warning() { void warning() {
++this->n; ++this->m_warning_count;
this->fileUplink->tlmWrite_Warnings(n); this->m_fileUplink->tlmWrite_Warnings(m_warning_count);
} }
PRIVATE: PRIVATE:
//! The total number of warnings //! The total number of warnings
U32 n; U32 m_warning_count;
//! The enclosing FileUplink object //! The enclosing FileUplink object
FileUplink *const fileUplink; FileUplink *const m_fileUplink;
}; };

View File

@ -1,4 +1,4 @@
// ====================================================================== // ======================================================================
// \title Warnings.cpp // \title Warnings.cpp
// \author bocchino // \author bocchino
// \brief cpp file for FileUplink::Warnings // \brief cpp file for FileUplink::Warnings
@ -7,8 +7,8 @@
// Copyright 2009-2016, by the California Institute of Technology. // Copyright 2009-2016, by the California Institute of Technology.
// ALL RIGHTS RESERVED. United States Government Sponsorship // ALL RIGHTS RESERVED. United States Government Sponsorship
// acknowledged. // acknowledged.
// //
// ====================================================================== // ======================================================================
#include <Svc/FileUplink/FileUplink.hpp> #include <Svc/FileUplink/FileUplink.hpp>
@ -17,9 +17,9 @@ namespace Svc {
void FileUplink::Warnings :: void FileUplink::Warnings ::
invalidReceiveMode(const Fw::FilePacket::Type packetType) invalidReceiveMode(const Fw::FilePacket::Type packetType)
{ {
this->fileUplink->log_WARNING_HI_InvalidReceiveMode( this->m_fileUplink->log_WARNING_HI_InvalidReceiveMode(
static_cast<U32>(packetType), static_cast<U32>(packetType),
static_cast<U32>(fileUplink->receiveMode) static_cast<U32>(m_fileUplink->receiveMode)
); );
this->warning(); this->warning();
} }
@ -27,7 +27,7 @@ namespace Svc {
void FileUplink::Warnings :: void FileUplink::Warnings ::
fileOpen(Fw::LogStringArg& fileName) fileOpen(Fw::LogStringArg& fileName)
{ {
this->fileUplink->log_WARNING_HI_FileOpenError(fileName); this->m_fileUplink->log_WARNING_HI_FileOpenError(fileName);
this->warning(); this->warning();
} }
@ -37,7 +37,7 @@ namespace Svc {
Fw::LogStringArg& fileName Fw::LogStringArg& fileName
) )
{ {
this->fileUplink->log_WARNING_HI_PacketOutOfBounds( this->m_fileUplink->log_WARNING_HI_PacketOutOfBounds(
sequenceIndex, sequenceIndex,
fileName fileName
); );
@ -50,7 +50,7 @@ namespace Svc {
const U32 lastSequenceIndex const U32 lastSequenceIndex
) )
{ {
this->fileUplink->log_WARNING_HI_PacketOutOfOrder( this->m_fileUplink->log_WARNING_HI_PacketOutOfOrder(
sequenceIndex, sequenceIndex,
lastSequenceIndex lastSequenceIndex
); );
@ -60,7 +60,7 @@ namespace Svc {
void FileUplink::Warnings :: void FileUplink::Warnings ::
fileWrite(Fw::LogStringArg& fileName) fileWrite(Fw::LogStringArg& fileName)
{ {
this->fileUplink->log_WARNING_HI_FileWriteError(fileName); this->m_fileUplink->log_WARNING_HI_FileWriteError(fileName);
this->warning(); this->warning();
} }
@ -70,8 +70,8 @@ namespace Svc {
const U32 read const U32 read
) )
{ {
this->fileUplink->log_WARNING_HI_BadChecksum( this->m_fileUplink->log_WARNING_HI_BadChecksum(
this->fileUplink->file.name, this->m_fileUplink->file.name,
computed, computed,
read read
); );

View File

@ -165,7 +165,7 @@ void TlmChan::Run_handler(NATIVE_INT_TYPE portNum, NATIVE_UINT_TYPE context) {
// reset packet for more entries // reset packet for more entries
pkt.resetPktSer(); pkt.resetPktSer();
// add entry to new packet // add entry to new packet
Fw::SerializeStatus stat = pkt.addValue(p_entry->id, p_entry->lastUpdate, p_entry->buffer); stat = pkt.addValue(p_entry->id, p_entry->lastUpdate, p_entry->buffer);
// if this doesn't work, that means packet isn't big enough for // if this doesn't work, that means packet isn't big enough for
// even one channel, so assert // even one channel, so assert
FW_ASSERT(Fw::FW_SERIALIZE_OK == stat, static_cast<NATIVE_INT_TYPE>(stat)); FW_ASSERT(Fw::FW_SERIALIZE_OK == stat, static_cast<NATIVE_INT_TYPE>(stat));