From 6a38950e35b95fc39f4328ac14b42f47a1a9439b Mon Sep 17 00:00:00 2001 From: Johan Bertrand Date: Thu, 1 Feb 2024 23:37:31 +0100 Subject: [PATCH 1/3] Removed a_ prefix on arguments --- Fw/FilePacket/CancelPacket.cpp | 8 +- Fw/FilePacket/DataPacket.cpp | 48 +++---- Fw/FilePacket/EndPacket.cpp | 10 +- Fw/FilePacket/FilePacket.cpp | 22 +-- Fw/FilePacket/FilePacket.hpp | 129 +++++++++++++----- Fw/FilePacket/GTest/CancelPacket.cpp | 10 +- Fw/FilePacket/GTest/DataPacket.cpp | 16 +-- Fw/FilePacket/GTest/EndPacket.cpp | 10 +- Fw/FilePacket/GTest/Header.cpp | 12 +- Fw/FilePacket/GTest/PathName.cpp | 18 +-- Fw/FilePacket/GTest/StartPacket.cpp | 16 +-- Fw/FilePacket/Header.cpp | 18 +-- Fw/FilePacket/PathName.cpp | 22 +-- Fw/FilePacket/StartPacket.cpp | 41 +++--- STest/STest/Rule/Rule.hpp | 19 ++- STest/STest/Scenario/RepeatedRuleScenario.hpp | 2 +- STest/STest/Scenario/Scenario.hpp | 2 +- Svc/FileDownlink/File.cpp | 20 +-- Svc/FileDownlink/FileDownlink.cpp | 56 ++++---- Svc/FileDownlink/FileDownlink.hpp | 36 +++-- Svc/FileDownlink/Warnings.cpp | 6 +- Svc/FileDownlink/test/ut/FileBuffer.cpp | 18 +-- .../test/ut/FileDownlinkTester.cpp | 20 +-- Svc/FileUplink/File.cpp | 6 +- Svc/FileUplink/FileUplink.cpp | 14 +- Svc/FileUplink/test/ut/FileUplinkTester.cpp | 2 +- 26 files changed, 333 insertions(+), 248 deletions(-) diff --git a/Fw/FilePacket/CancelPacket.cpp b/Fw/FilePacket/CancelPacket.cpp index 990b47cf43..80725bf050 100644 --- a/Fw/FilePacket/CancelPacket.cpp +++ b/Fw/FilePacket/CancelPacket.cpp @@ -18,13 +18,13 @@ namespace Fw { void FilePacket::CancelPacket :: initialize(const U32 sequenceIndex) { - this->header.initialize(FilePacket::T_CANCEL, sequenceIndex); + this->m_header.initialize(FilePacket::T_CANCEL, sequenceIndex); } U32 FilePacket::CancelPacket :: bufferSize() const { - return this->header.bufferSize(); + return this->m_header.bufferSize(); } SerializeStatus FilePacket::CancelPacket :: @@ -34,14 +34,14 @@ namespace Fw { buffer.getData(), buffer.getSize() ); - return this->header.toSerialBuffer(serialBuffer); + return this->m_header.toSerialBuffer(serialBuffer); } SerializeStatus FilePacket::CancelPacket :: fromSerialBuffer(SerialBuffer& serialBuffer) { - FW_ASSERT(this->header.type == T_CANCEL); + FW_ASSERT(this->m_header.m_type == T_CANCEL); if (serialBuffer.getBuffLeft() != 0) return FW_DESERIALIZE_SIZE_MISMATCH; diff --git a/Fw/FilePacket/DataPacket.cpp b/Fw/FilePacket/DataPacket.cpp index ce9d2b7818..e08c957448 100644 --- a/Fw/FilePacket/DataPacket.cpp +++ b/Fw/FilePacket/DataPacket.cpp @@ -18,25 +18,25 @@ namespace Fw { void FilePacket::DataPacket :: initialize( const U32 sequenceIndex, - const U32 a_byteOffset, - const U16 a_dataSize, - const U8 *const a_data + const U32 byteOffset, + const U16 dataSize, + const U8 *const data ) { - this->header.initialize(FilePacket::T_DATA, sequenceIndex); - this->byteOffset = a_byteOffset; - this->dataSize = a_dataSize; - this->data = a_data; + this->m_header.initialize(FilePacket::T_DATA, sequenceIndex); + this->m_byteOffset = byteOffset; + this->m_dataSize = dataSize; + this->m_data = data; } U32 FilePacket::DataPacket :: bufferSize() const { return - this->header.bufferSize() + - sizeof(this->byteOffset) + - sizeof(this->dataSize) + - this->dataSize; + this->m_header.bufferSize() + + sizeof(this->m_byteOffset) + + sizeof(this->m_dataSize) + + this->m_dataSize; } SerializeStatus FilePacket::DataPacket :: @@ -53,21 +53,21 @@ namespace Fw { fromSerialBuffer(SerialBuffer& serialBuffer) { - FW_ASSERT(this->header.type == T_DATA); + FW_ASSERT(this->m_header.m_type == T_DATA); - SerializeStatus status = serialBuffer.deserialize(this->byteOffset); + SerializeStatus status = serialBuffer.deserialize(this->m_byteOffset); if (status != FW_SERIALIZE_OK) return status; - status = serialBuffer.deserialize(this->dataSize); + status = serialBuffer.deserialize(this->m_dataSize); if (status != FW_SERIALIZE_OK) return status; - if (serialBuffer.getBuffLeft() != this->dataSize) + if (serialBuffer.getBuffLeft() != this->m_dataSize) return FW_DESERIALIZE_SIZE_MISMATCH; U8 *const addr = serialBuffer.getBuffAddr(); - this->data = &addr[this->fixedLengthSize()]; + this->m_data = &addr[this->fixedLengthSize()]; return FW_SERIALIZE_OK; @@ -77,32 +77,32 @@ namespace Fw { fixedLengthSize() const { return - this->header.bufferSize() + - sizeof(this->byteOffset) + - sizeof(this->dataSize); + this->m_header.bufferSize() + + sizeof(this->m_byteOffset) + + sizeof(this->m_dataSize); } SerializeStatus FilePacket::DataPacket :: toSerialBuffer(SerialBuffer& serialBuffer) const { - FW_ASSERT(this->header.type == T_DATA); + FW_ASSERT(this->m_header.m_type == T_DATA); SerializeStatus status; - status = this->header.toSerialBuffer(serialBuffer); + status = this->m_header.toSerialBuffer(serialBuffer); if (status != FW_SERIALIZE_OK) return status; - status = serialBuffer.serialize(this->byteOffset); + status = serialBuffer.serialize(this->m_byteOffset); if (status != FW_SERIALIZE_OK) return status; - status = serialBuffer.serialize(this->dataSize); + status = serialBuffer.serialize(this->m_dataSize); if (status != FW_SERIALIZE_OK) return status; - status = serialBuffer.pushBytes(this->data, dataSize); + status = serialBuffer.pushBytes(this->m_data, this->m_dataSize); return status; diff --git a/Fw/FilePacket/EndPacket.cpp b/Fw/FilePacket/EndPacket.cpp index 13deafa6b1..c0a1aa0abd 100644 --- a/Fw/FilePacket/EndPacket.cpp +++ b/Fw/FilePacket/EndPacket.cpp @@ -23,14 +23,14 @@ namespace Fw { const CFDP::Checksum& checksum ) { - this->header.initialize(FilePacket::T_END, sequenceIndex); + this->m_header.initialize(FilePacket::T_END, sequenceIndex); this->setChecksum(checksum); } U32 FilePacket::EndPacket :: bufferSize() const { - return this->header.bufferSize() + sizeof(this->m_checksumValue); + return this->m_header.bufferSize() + sizeof(this->m_checksumValue); } SerializeStatus FilePacket::EndPacket :: @@ -61,7 +61,7 @@ namespace Fw { fromSerialBuffer(SerialBuffer& serialBuffer) { - FW_ASSERT(this->header.type == T_END); + FW_ASSERT(this->m_header.m_type == T_END); const SerializeStatus status = serialBuffer.deserialize(this->m_checksumValue); @@ -74,11 +74,11 @@ namespace Fw { toSerialBuffer(SerialBuffer& serialBuffer) const { - FW_ASSERT(this->header.type == T_END); + FW_ASSERT(this->m_header.m_type == T_END); SerializeStatus status; - status = this->header.toSerialBuffer(serialBuffer); + status = this->m_header.toSerialBuffer(serialBuffer); if (status != FW_SERIALIZE_OK) return status; diff --git a/Fw/FilePacket/FilePacket.cpp b/Fw/FilePacket/FilePacket.cpp index d27c8711fa..be7b7850d8 100644 --- a/Fw/FilePacket/FilePacket.cpp +++ b/Fw/FilePacket/FilePacket.cpp @@ -40,28 +40,28 @@ namespace Fw { const FilePacket::StartPacket& FilePacket :: asStartPacket() const { - FW_ASSERT(this->m_header.type == T_START); + FW_ASSERT(this->m_header.m_type == T_START); return this->m_startPacket; } const FilePacket::DataPacket& FilePacket :: asDataPacket() const { - FW_ASSERT(this->m_header.type == T_DATA); + FW_ASSERT(this->m_header.m_type == T_DATA); return this->m_dataPacket; } const FilePacket::EndPacket& FilePacket :: asEndPacket() const { - FW_ASSERT(this->m_header.type == T_END); + FW_ASSERT(this->m_header.m_type == T_END); return this->m_endPacket; } const FilePacket::CancelPacket& FilePacket :: asCancelPacket() const { - FW_ASSERT(this->m_header.type == T_CANCEL); + FW_ASSERT(this->m_header.m_type == T_CANCEL); return this->m_cancelPacket; } @@ -69,34 +69,34 @@ namespace Fw { fromStartPacket(const StartPacket& startPacket) { this->m_startPacket = startPacket; - this->m_header.type = T_START; + this->m_header.m_type = T_START; } void FilePacket :: fromDataPacket(const DataPacket& dataPacket) { this->m_dataPacket = dataPacket; - this->m_header.type = T_DATA; + this->m_header.m_type = T_DATA; } void FilePacket :: fromEndPacket(const EndPacket& endPacket) { this->m_endPacket = endPacket; - this->m_header.type = T_END; + this->m_header.m_type = T_END; } void FilePacket :: fromCancelPacket(const CancelPacket& cancelPacket) { this->m_cancelPacket = cancelPacket; - this->m_header.type = T_CANCEL; + this->m_header.m_type = T_CANCEL; } U32 FilePacket :: bufferSize() const { - switch (this->m_header.type) { + switch (this->m_header.m_type) { case T_START: return this->m_startPacket.bufferSize(); case T_DATA: @@ -116,7 +116,7 @@ namespace Fw { SerializeStatus FilePacket :: toBuffer(Buffer& buffer) const { - switch (this->m_header.type) { + switch (this->m_header.m_type) { case T_START: return this->m_startPacket.toBuffer(buffer); case T_DATA: @@ -142,7 +142,7 @@ namespace Fw { status = this->m_header.fromSerialBuffer(serialBuffer); if (status != FW_SERIALIZE_OK) return status; - switch (this->m_header.type) { + switch (this->m_header.m_type) { case T_START: status = this->m_startPacket.fromSerialBuffer(serialBuffer); break; diff --git a/Fw/FilePacket/FilePacket.hpp b/Fw/FilePacket/FilePacket.hpp index 12c311b30a..b73f37d449 100644 --- a/Fw/FilePacket/FilePacket.hpp +++ b/Fw/FilePacket/FilePacket.hpp @@ -51,24 +51,34 @@ namespace Fw { //! The maximum length of a path name enum { MAX_LENGTH = 255 }; - public: + PRIVATE: //! The length - U8 length; + U8 m_length; //! Pointer to the path value - const char *value; + const char *m_value; public: //! Initialize a PathName void initialize( - const char *const a_value //! The path value + const char *const value //! The path value ); //! Compute the buffer size needed to hold this PathName U32 bufferSize() const; + //! Get the length of the path name value + U32 getLength(void) const { + return this->m_length; + }; + + //! Get the path name value pointer + const char* getValuePointer(void) const { + return this->m_value; + }; + PRIVATE: //! Initialize this PathName from a SerialBuffer @@ -84,13 +94,15 @@ namespace Fw { friend union FilePacket; - public: + PRIVATE: //! The packet type - Type type; + Type m_type; //! The sequence index - U32 sequenceIndex; + U32 m_sequenceIndex; + + public: //! Header size enum { HEADERSIZE = sizeof(U8) + sizeof(U32) }; @@ -99,8 +111,8 @@ namespace Fw { //! Initialize a file packet header void initialize( - const Type a_type, //!< The packet type - const U32 a_sequenceIndex //!< The sequence index + const Type type, //!< The packet type + const U32 sequenceIndex //!< The sequence index ); //! Compute the buffer size needed to hold this Header @@ -112,6 +124,15 @@ namespace Fw { //! Write this Header to a SerialBuffer SerializeStatus toSerialBuffer(SerialBuffer& serialBuffer) const; + public: + Type getType(void) const { + return this->m_type; + }; + + U32 getSequenceIndex(void) const { + return this->m_sequenceIndex; + }; + }; //! The type of a start packet @@ -119,27 +140,27 @@ namespace Fw { friend union FilePacket; - public: + PRIVATE: //! The packet header - Header header; + Header m_header; //! The file size - U32 fileSize; + U32 m_fileSize; //! The source path - PathName sourcePath; + PathName m_sourcePath; //! The destination path - PathName destinationPath; + PathName m_destinationPath; public: //! Initialize a StartPacket with sequence number 0 void initialize( - const U32 a_fileSize, //!< The file size - const char *const a_sourcePath, //!< The source path - const char *const a_destinationPath //!< The destination path + const U32 fileSize, //!< The file size + const char *const sourcePath, //!< The source path + const char *const destinationPath //!< The destination path ); //! Compute the buffer size needed to hold this StartPacket @@ -148,6 +169,20 @@ namespace Fw { //! Convert this StartPacket to a Buffer SerializeStatus toBuffer(Buffer& buffer) const; + //! Get the destination path + const PathName& getDestinationPath() const { + return this->m_destinationPath; + }; + + //! Get the source path + const PathName& getSourcePath() const { + return this->m_sourcePath; + }; + + //! Get the file size + U32 getFileSize() const { + return this->m_fileSize; + }; PRIVATE: //! Initialize this StartPacket from a SerialBuffer @@ -163,34 +198,33 @@ namespace Fw { friend union FilePacket; - public: + PRIVATE: //! The packet header - Header header; + Header m_header; //! The byte offset of the packet data into the destination file - U32 byteOffset; + U32 m_byteOffset; //! The size of the file data in the packet - U16 dataSize; + U16 m_dataSize; //! Pointer to the file data - const U8 *data; + const U8 *m_data; + + public: //! header size enum { HEADERSIZE = Header::HEADERSIZE + sizeof(U32) + sizeof(U16) }; - - public: - //! Initialize a data packet void initialize( const U32 sequenceIndex, //!< The sequence index - const U32 a_byteOffset, //!< The byte offset - const U16 a_dataSize, //!< The data size - const U8 *const a_data //!< The file data + const U32 byteOffset, //!< The byte offset + const U16 dataSize, //!< The data size + const U8 *const data //!< The file data ); //! Compute the buffer size needed to hold this DataPacket @@ -199,6 +233,25 @@ namespace Fw { //! Convert this DataPacket to a Buffer SerializeStatus toBuffer(Buffer& buffer) const; + //! Get this as a Header + const FilePacket::Header& asHeader() const { + return this->m_header; + }; + + //! Get the byte offset + U32 getByteOffset() const { + return this->m_byteOffset; + }; + + //! Get the data size + U32 getDataSize() const { + return this->m_dataSize; + }; + + //! Get the data pointer + const U8* getDataPointer() const { + return this->m_data; + }; PRIVATE: //! Initialize this DataPacket from a SerialBuffer @@ -217,10 +270,12 @@ namespace Fw { friend union FilePacket; - public: + PRIVATE: //! The packet header - Header header; + Header m_header; + + public: //! Set the checksum void setChecksum(const CFDP::Checksum& checksum); @@ -234,6 +289,10 @@ namespace Fw { //! Convert this EndPacket to a Buffer SerializeStatus toBuffer(Buffer& buffer) const; + //! Get this as a Header + const FilePacket::Header& asHeader() const { + return this->m_header; + }; public: //! Initialize an end packet @@ -260,10 +319,10 @@ namespace Fw { friend union FilePacket; - public: + PRIVATE: //! The packet header - Header header; + Header m_header; public: @@ -278,6 +337,10 @@ namespace Fw { //! Convert this CancelPacket to a Buffer SerializeStatus toBuffer(Buffer& buffer) const; + //! Get this as a Header + const FilePacket::Header& asHeader() const { + return this->m_header; + }; PRIVATE: //! Initialize this CancelPacket from a SerialBuffer @@ -291,7 +354,7 @@ namespace Fw { // Constructor // ---------------------------------------------------------------------- - FilePacket() { this->m_header.type = T_NONE; } + FilePacket() { this->m_header.m_type = T_NONE; } public: diff --git a/Fw/FilePacket/GTest/CancelPacket.cpp b/Fw/FilePacket/GTest/CancelPacket.cpp index 3ce2e89e7e..b9a900a06b 100644 --- a/Fw/FilePacket/GTest/CancelPacket.cpp +++ b/Fw/FilePacket/GTest/CancelPacket.cpp @@ -1,4 +1,4 @@ -// ====================================================================== +// ====================================================================== // \title Fw/FilePacket/GTest/CancelPacket.cpp // \author bocchino // \brief Test utilities for data file packets @@ -7,8 +7,8 @@ // Copyright (C) 2016, California Institute of Technology. // ALL RIGHTS RESERVED. United States Government Sponsorship // acknowledged. -// -// ====================================================================== +// +// ====================================================================== #include @@ -20,9 +20,9 @@ namespace Fw { compare( const FilePacket::CancelPacket& expected, const FilePacket::CancelPacket& actual - ) + ) { - FilePackets::Header::compare(expected.header, actual.header); + FilePackets::Header::compare(expected.m_header, actual.m_header); } } diff --git a/Fw/FilePacket/GTest/DataPacket.cpp b/Fw/FilePacket/GTest/DataPacket.cpp index 892a0e93dd..4939a4b0ec 100644 --- a/Fw/FilePacket/GTest/DataPacket.cpp +++ b/Fw/FilePacket/GTest/DataPacket.cpp @@ -1,4 +1,4 @@ -// ====================================================================== +// ====================================================================== // \title Fw/FilePacket/GTest/DataPacket.cpp // \author bocchino // \brief Test utilities for data file packets @@ -7,8 +7,8 @@ // Copyright (C) 2016, California Institute of Technology. // ALL RIGHTS RESERVED. United States Government Sponsorship // acknowledged. -// -// ====================================================================== +// +// ====================================================================== #include #include @@ -21,12 +21,12 @@ namespace Fw { compare( const FilePacket::DataPacket& expected, const FilePacket::DataPacket& actual - ) + ) { - FilePackets::Header::compare(expected.header, actual.header); - ASSERT_EQ(expected.byteOffset, actual.byteOffset); - Bytes expectedData(expected.data, expected.dataSize); - Bytes actualData(actual.data, actual.dataSize); + FilePackets::Header::compare(expected.m_header, actual.m_header); + ASSERT_EQ(expected.m_byteOffset, actual.m_byteOffset); + Bytes expectedData(expected.m_data, expected.m_dataSize); + Bytes actualData(actual.m_data, actual.m_dataSize); Bytes::compare(expectedData, actualData); } diff --git a/Fw/FilePacket/GTest/EndPacket.cpp b/Fw/FilePacket/GTest/EndPacket.cpp index d590ad28c3..f2b37b817e 100644 --- a/Fw/FilePacket/GTest/EndPacket.cpp +++ b/Fw/FilePacket/GTest/EndPacket.cpp @@ -1,4 +1,4 @@ -// ====================================================================== +// ====================================================================== // \title Fw/FilePacket/GTest/EndPacket.cpp // \author bocchino // \brief Test utilities for data file packets @@ -7,8 +7,8 @@ // Copyright (C) 2016, California Institute of Technology. // ALL RIGHTS RESERVED. United States Government Sponsorship // acknowledged. -// -// ====================================================================== +// +// ====================================================================== #include #include @@ -22,9 +22,9 @@ namespace Fw { compare( const FilePacket::EndPacket& expected, const FilePacket::EndPacket& actual - ) + ) { - FilePackets::Header::compare(expected.header, actual.header); + FilePackets::Header::compare(expected.m_header, actual.m_header); CFDP::Checksum expectedChecksum; CFDP::Checksum actualChecksum; expected.getChecksum(expectedChecksum); diff --git a/Fw/FilePacket/GTest/Header.cpp b/Fw/FilePacket/GTest/Header.cpp index db971ddbd2..b20f231d60 100644 --- a/Fw/FilePacket/GTest/Header.cpp +++ b/Fw/FilePacket/GTest/Header.cpp @@ -1,4 +1,4 @@ -// ====================================================================== +// ====================================================================== // \title Fw/FilePacket/GTest/Header.cpp // \author bocchino // \brief Test utilities for file packet headers @@ -7,8 +7,8 @@ // Copyright (C) 2016, California Institute of Technology. // ALL RIGHTS RESERVED. United States Government Sponsorship // acknowledged. -// -// ====================================================================== +// +// ====================================================================== #include @@ -20,10 +20,10 @@ namespace Fw { compare( const FilePacket::Header& expected, const FilePacket::Header& actual - ) + ) { - ASSERT_EQ(expected.type, actual.type); - ASSERT_EQ(expected.sequenceIndex, actual.sequenceIndex); + ASSERT_EQ(expected.m_type, actual.m_type); + ASSERT_EQ(expected.m_sequenceIndex, actual.m_sequenceIndex); } } diff --git a/Fw/FilePacket/GTest/PathName.cpp b/Fw/FilePacket/GTest/PathName.cpp index ae09eee89b..c25037b1be 100644 --- a/Fw/FilePacket/GTest/PathName.cpp +++ b/Fw/FilePacket/GTest/PathName.cpp @@ -1,4 +1,4 @@ -// ====================================================================== +// ====================================================================== // \title Fw/FilePacket/GTest/PathName.cpp // \author bocchino // \brief Test utilities for start file packets @@ -7,8 +7,8 @@ // Copyright (C) 2016, California Institute of Technology. // ALL RIGHTS RESERVED. United States Government Sponsorship // acknowledged. -// -// ====================================================================== +// +// ====================================================================== #include #include @@ -21,16 +21,16 @@ namespace Fw { compare( const FilePacket::PathName& expected, const FilePacket::PathName& actual - ) + ) { - ASSERT_EQ(expected.length, actual.length); + ASSERT_EQ(expected.m_length, actual.m_length); Bytes expectedPath( - reinterpret_cast(expected.value), - expected.length + reinterpret_cast(expected.m_value), + expected.m_length ); Bytes actualPath( - reinterpret_cast(actual.value), - actual.length + reinterpret_cast(actual.m_value), + actual.m_length ); Bytes::compare(expectedPath, actualPath); } diff --git a/Fw/FilePacket/GTest/StartPacket.cpp b/Fw/FilePacket/GTest/StartPacket.cpp index 53b489a807..6c2bb1210f 100644 --- a/Fw/FilePacket/GTest/StartPacket.cpp +++ b/Fw/FilePacket/GTest/StartPacket.cpp @@ -1,4 +1,4 @@ -// ====================================================================== +// ====================================================================== // \title Fw/FilePacket/GTest/StartPacket.cpp // \author bocchino // \brief Test utilities for start file packets @@ -7,8 +7,8 @@ // Copyright (C) 2016, California Institute of Technology. // ALL RIGHTS RESERVED. United States Government Sponsorship // acknowledged. -// -// ====================================================================== +// +// ====================================================================== #include #include @@ -21,12 +21,12 @@ namespace Fw { compare( const FilePacket::StartPacket& expected, const FilePacket::StartPacket& actual - ) + ) { - FilePackets::Header::compare(expected.header, actual.header); - ASSERT_EQ(expected.fileSize, actual.fileSize); - PathName::compare(expected.sourcePath, actual.sourcePath); - PathName::compare(expected.destinationPath, actual.destinationPath); + FilePackets::Header::compare(expected.m_header, actual.m_header); + ASSERT_EQ(expected.m_fileSize, actual.m_fileSize); + PathName::compare(expected.m_sourcePath, actual.m_sourcePath); + PathName::compare(expected.m_destinationPath, actual.m_destinationPath); } } diff --git a/Fw/FilePacket/Header.cpp b/Fw/FilePacket/Header.cpp index 19ade5bc17..4d8f018743 100644 --- a/Fw/FilePacket/Header.cpp +++ b/Fw/FilePacket/Header.cpp @@ -17,18 +17,18 @@ namespace Fw { void FilePacket::Header :: initialize( - const Type a_type, - const U32 a_sequenceIndex + const Type type, + const U32 sequenceIndex ) { - this->type = a_type; - this->sequenceIndex = a_sequenceIndex; + this->m_type = type; + this->m_sequenceIndex = sequenceIndex; } U32 FilePacket::Header :: bufferSize() const { - return sizeof(U8) + sizeof(this->sequenceIndex); + return sizeof(U8) + sizeof(this->m_sequenceIndex); } SerializeStatus FilePacket::Header :: @@ -42,9 +42,9 @@ namespace Fw { if (status != FW_SERIALIZE_OK) { return status; } - this->type = static_cast(new_type); + this->m_type = static_cast(new_type); - status = serialBuffer.deserialize(this->sequenceIndex); + status = serialBuffer.deserialize(this->m_sequenceIndex); return status; @@ -54,14 +54,14 @@ namespace Fw { toSerialBuffer(SerialBuffer& serialBuffer) const { - const U8 type_casted = static_cast(this->type); + const U8 type_casted = static_cast(this->m_type); SerializeStatus status; status = serialBuffer.serialize(type_casted); if (status != FW_SERIALIZE_OK) return status; - status = serialBuffer.serialize(this->sequenceIndex); + status = serialBuffer.serialize(this->m_sequenceIndex); if (status != FW_SERIALIZE_OK) return status; diff --git a/Fw/FilePacket/PathName.cpp b/Fw/FilePacket/PathName.cpp index 7d57f42e02..1b29ef1383 100644 --- a/Fw/FilePacket/PathName.cpp +++ b/Fw/FilePacket/PathName.cpp @@ -19,17 +19,17 @@ namespace Fw { void FilePacket::PathName :: - initialize(const char *const a_value) + initialize(const char *const value) { - const U8 new_length = static_cast(StringUtils::string_length(a_value, MAX_LENGTH)); - this->length = new_length; - this->value = a_value; + const U8 length = static_cast(StringUtils::string_length(value, MAX_LENGTH)); + this->m_length = length; + this->m_value = value; } U32 FilePacket::PathName :: bufferSize() const { - return sizeof(this->length) + this->length; + return sizeof(this->m_length) + this->m_length; } SerializeStatus FilePacket::PathName :: @@ -38,7 +38,7 @@ namespace Fw { { const SerializeStatus status = - serialBuffer.deserialize(this->length); + serialBuffer.deserialize(this->m_length); if (status != FW_SERIALIZE_OK) return status; } @@ -47,10 +47,10 @@ namespace Fw { const U8* addrLeft = serialBuffer.getBuffAddrLeft(); U8 bytes[MAX_LENGTH]; const SerializeStatus status = - serialBuffer.popBytes(bytes, this->length); + serialBuffer.popBytes(bytes, this->m_length); if (status != FW_SERIALIZE_OK) return status; - this->value = reinterpret_cast(addrLeft); + this->m_value = reinterpret_cast(addrLeft); } return FW_SERIALIZE_OK; @@ -63,15 +63,15 @@ namespace Fw { { const SerializeStatus status = - serialBuffer.serialize(this->length); + serialBuffer.serialize(this->m_length); if (status != FW_SERIALIZE_OK) return status; } { const SerializeStatus status = serialBuffer.pushBytes( - reinterpret_cast(this->value), - this->length + reinterpret_cast(this->m_value), + this->m_length ); if (status != FW_SERIALIZE_OK) return status; diff --git a/Fw/FilePacket/StartPacket.cpp b/Fw/FilePacket/StartPacket.cpp index 4a3d97c5ab..c597948f1e 100644 --- a/Fw/FilePacket/StartPacket.cpp +++ b/Fw/FilePacket/StartPacket.cpp @@ -17,25 +17,24 @@ namespace Fw { void FilePacket::StartPacket :: initialize( - const U32 a_fileSize, - const char *const a_sourcePath, - const char *const a_destinationPath + const U32 fileSize, + const char *const sourcePath, + const char *const destinationPath ) { - const FilePacket::Header new_header = { FilePacket::T_START, 0 }; - this->header = new_header; - this->fileSize = a_fileSize; - this->sourcePath.initialize(a_sourcePath); - this->destinationPath.initialize(a_destinationPath); + this->m_header.initialize(FilePacket::T_START, 0); + this->m_fileSize = fileSize; + this->m_sourcePath.initialize(sourcePath); + this->m_destinationPath.initialize(destinationPath); } U32 FilePacket::StartPacket :: bufferSize() const { - return this->header.bufferSize() + - sizeof(this->fileSize) + - this->sourcePath.bufferSize() + - this->destinationPath.bufferSize(); + return this->m_header.bufferSize() + + sizeof(this->m_fileSize) + + this->m_sourcePath.bufferSize() + + this->m_destinationPath.bufferSize(); } SerializeStatus FilePacket::StartPacket :: @@ -52,25 +51,25 @@ namespace Fw { fromSerialBuffer(SerialBuffer& serialBuffer) { - FW_ASSERT(this->header.type == T_START); + FW_ASSERT(this->m_header.m_type == T_START); { const SerializeStatus status = - serialBuffer.deserialize(this->fileSize); + serialBuffer.deserialize(this->m_fileSize); if (status != FW_SERIALIZE_OK) return status; } { const SerializeStatus status = - this->sourcePath.fromSerialBuffer(serialBuffer); + this->m_sourcePath.fromSerialBuffer(serialBuffer); if (status != FW_SERIALIZE_OK) return status; } { const SerializeStatus status = - this->destinationPath.fromSerialBuffer(serialBuffer); + this->m_destinationPath.fromSerialBuffer(serialBuffer); if (status != FW_SERIALIZE_OK) return status; } @@ -83,32 +82,32 @@ namespace Fw { toSerialBuffer(SerialBuffer& serialBuffer) const { - FW_ASSERT(this->header.type == T_START); + FW_ASSERT(this->m_header.m_type == T_START); { const SerializeStatus status = - this->header.toSerialBuffer(serialBuffer); + this->m_header.toSerialBuffer(serialBuffer); if (status != FW_SERIALIZE_OK) return status; } { const SerializeStatus status = - serialBuffer.serialize(this->fileSize); + serialBuffer.serialize(this->m_fileSize); if (status != FW_SERIALIZE_OK) return status; } { const SerializeStatus status = - this->sourcePath.toSerialBuffer(serialBuffer); + this->m_sourcePath.toSerialBuffer(serialBuffer); if (status != FW_SERIALIZE_OK) return status; } { const SerializeStatus status = - this->destinationPath.toSerialBuffer(serialBuffer); + this->m_destinationPath.toSerialBuffer(serialBuffer); if (status != FW_SERIALIZE_OK) return status; } diff --git a/STest/STest/Rule/Rule.hpp b/STest/STest/Rule/Rule.hpp index c2988fe9f2..bec39da5f3 100644 --- a/STest/STest/Rule/Rule.hpp +++ b/STest/STest/Rule/Rule.hpp @@ -27,9 +27,9 @@ namespace STest { //! Construct object Rule Rule( - const char *const a_name //!< The name of the rule + const char *const name //!< The name of the rule ) : - name(a_name) + m_name(name) { } @@ -50,7 +50,7 @@ namespace STest { State& state //!< The system state ) { ASSERT_TRUE(this->precondition(state)) - << "precondition failed applying rule " << this->name; + << "precondition failed applying rule " << this->m_name; this->action(state); } @@ -60,6 +60,11 @@ namespace STest { const State& state //!< The system state ) = 0; + //! Get rule name + char const * getRuleNamePointer() const { + return this->m_name; + } + protected: // ---------------------------------------------------------------------- @@ -77,8 +82,14 @@ namespace STest { // Public member variables // ---------------------------------------------------------------------- + private: + + // ---------------------------------------------------------------------- + // Private member variables + // ---------------------------------------------------------------------- + //! The name of the rule - const char *const name; + const char *const m_name; }; diff --git a/STest/STest/Scenario/RepeatedRuleScenario.hpp b/STest/STest/Scenario/RepeatedRuleScenario.hpp index 7ebd3404ff..ff05469078 100644 --- a/STest/STest/Scenario/RepeatedRuleScenario.hpp +++ b/STest/STest/Scenario/RepeatedRuleScenario.hpp @@ -31,7 +31,7 @@ namespace STest { RepeatedRuleScenario( Rule& rule //!< The rule ) : - Scenario(rule.name), + Scenario(rule.getRuleNamePointer()), rule(rule) { diff --git a/STest/STest/Scenario/Scenario.hpp b/STest/STest/Scenario/Scenario.hpp index 73883237a7..c992826076 100644 --- a/STest/STest/Scenario/Scenario.hpp +++ b/STest/STest/Scenario/Scenario.hpp @@ -136,7 +136,7 @@ namespace STest { printf( "[Scenario %s] Applying rule %s\n", this->name, - rule.name + rule.getRuleNamePointer() ); } rule.apply(state); diff --git a/Svc/FileDownlink/File.cpp b/Svc/FileDownlink/File.cpp index 888894db95..830a390dd6 100644 --- a/Svc/FileDownlink/File.cpp +++ b/Svc/FileDownlink/File.cpp @@ -26,11 +26,11 @@ namespace Svc { // Set source name Fw::LogStringArg sourceLogStringArg(sourceFileName); - this->sourceName = sourceLogStringArg; + this->m_sourceName = sourceLogStringArg; // Set dest name Fw::LogStringArg destLogStringArg(destFileName); - this->destName = destLogStringArg; + this->m_destName = destLogStringArg; // Set size FwSizeType file_size; @@ -42,14 +42,14 @@ namespace Svc { if (static_cast(static_cast(file_size)) != file_size) { return Os::File::BAD_SIZE; } - this->size = static_cast(file_size); + this->m_size = static_cast(file_size); // Initialize checksum CFDP::Checksum checksum; this->m_checksum = checksum; // Open osFile for reading - return this->osFile.open(sourceFileName, Os::File::OPEN_READ); + return this->m_osFile.open(sourceFileName, Os::File::OPEN_READ); } @@ -57,24 +57,24 @@ namespace Svc { read( U8 *const data, const U32 byteOffset, - const U32 a_size + const U32 size ) { Os::File::Status status; - status = this->osFile.seek(byteOffset); + status = this->m_osFile.seek(byteOffset); if (status != Os::File::OP_OK) return status; - NATIVE_INT_TYPE intSize = a_size; - status = this->osFile.read(data, intSize); + NATIVE_INT_TYPE intSize = size; + status = this->m_osFile.read(data, intSize); if (status != Os::File::OP_OK) return status; // Force a bad size error when the U32 carrying size is bad - if (static_cast(intSize) != a_size) { + if (static_cast(intSize) != size) { return Os::File::BAD_SIZE; } - this->m_checksum.update(data, byteOffset, a_size); + this->m_checksum.update(data, byteOffset, size); return Os::File::OP_OK; diff --git a/Svc/FileDownlink/FileDownlink.cpp b/Svc/FileDownlink/FileDownlink.cpp index b27a428d4d..a68e59178a 100644 --- a/Svc/FileDownlink/FileDownlink.cpp +++ b/Svc/FileDownlink/FileDownlink.cpp @@ -133,7 +133,7 @@ namespace Svc { //If current timeout is too-high and we are waiting for a packet, issue a timeout if (this->m_curTimer >= this->m_timeout) { this->m_curTimer = 0; - this->log_WARNING_HI_DownlinkTimeout(this->m_file.sourceName, this->m_file.destName); + this->log_WARNING_HI_DownlinkTimeout(this->m_file.getSourceName(), this->m_file.getDestName()); this->enterCooldown(); this->sendResponse(FILEDOWNLINK_COMMAND_FAILURES_DISABLED ? SendFileStatus::STATUS_OK : SendFileStatus::STATUS_ERROR); } else { //Otherwise update the current counter @@ -358,16 +358,16 @@ namespace Svc { } - if (startOffset >= this->m_file.size) { + if (startOffset >= this->m_file.getSize()) { this->enterCooldown(); - this->log_WARNING_HI_DownlinkPartialFail(this->m_file.sourceName, this->m_file.destName, startOffset, this->m_file.size); + this->log_WARNING_HI_DownlinkPartialFail(this->m_file.getSourceName(), this->m_file.getDestName(), startOffset, this->m_file.getSize()); sendResponse(FILEDOWNLINK_COMMAND_FAILURES_DISABLED ? SendFileStatus::STATUS_OK : SendFileStatus::STATUS_INVALID); return; - } else if (startOffset + length > this->m_file.size) { + } else if (startOffset + length > this->m_file.getSize()) { // If the amount to downlink is greater than the file size, emit a Warning and then allow // the file to be downlinked anyway - this->log_WARNING_LO_DownlinkPartialWarning(startOffset, length, this->m_file.size, this->m_file.sourceName, this->m_file.destName); - length = this->m_file.size - startOffset; + this->log_WARNING_LO_DownlinkPartialWarning(startOffset, length, this->m_file.getSize(), this->m_file.getSourceName(), this->m_file.getDestName()); + length = this->m_file.getSize() - startOffset; } // Send file and switch to WAIT mode @@ -381,12 +381,12 @@ namespace Svc { // zero length means read until end of file if (length > 0) { - this->log_ACTIVITY_HI_SendStarted(length, this->m_file.sourceName, this->m_file.destName); + this->log_ACTIVITY_HI_SendStarted(length, this->m_file.getSourceName(), this->m_file.getDestName()); this->m_endOffset = startOffset + length; } else { - this->log_ACTIVITY_HI_SendStarted(this->m_file.size - startOffset, this->m_file.sourceName, this->m_file.destName); - this->m_endOffset = this->m_file.size; + this->log_ACTIVITY_HI_SendStarted(this->m_file.getSize() - startOffset, this->m_file.getSourceName(), this->m_file.getDestName()); + this->m_endOffset = this->m_file.getSize(); } } @@ -409,12 +409,12 @@ namespace Svc { return status; } - const Fw::FilePacket::DataPacket dataPacket = { - { Fw::FilePacket::T_DATA, this->m_sequenceIndex }, + Fw::FilePacket::DataPacket dataPacket; + dataPacket.initialize( + this->m_sequenceIndex, byteOffset, static_cast(dataSize), - buffer - }; + buffer); ++this->m_sequenceIndex; Fw::FilePacket filePacket; filePacket.fromDataPacket(dataPacket); @@ -430,9 +430,8 @@ namespace Svc { sendCancelPacket() { Fw::Buffer buffer; - const Fw::FilePacket::CancelPacket cancelPacket = { - { Fw::FilePacket::T_CANCEL, this->m_sequenceIndex } - }; + Fw::FilePacket::CancelPacket cancelPacket; + cancelPacket.initialize(this->m_sequenceIndex); Fw::FilePacket filePacket; filePacket.fromCancelPacket(cancelPacket); @@ -447,16 +446,11 @@ namespace Svc { void FileDownlink :: sendEndPacket() { - const Fw::FilePacket::Header header = { - Fw::FilePacket::T_END, - this->m_sequenceIndex - }; - Fw::FilePacket::EndPacket endPacket; - endPacket.header = header; - CFDP::Checksum checksum; this->m_file.getChecksum(checksum); - endPacket.setChecksum(checksum); + + Fw::FilePacket::EndPacket endPacket; + endPacket.initialize(this->m_sequenceIndex, checksum); Fw::FilePacket filePacket; filePacket.fromEndPacket(endPacket); @@ -469,9 +463,9 @@ namespace Svc { { Fw::FilePacket::StartPacket startPacket; startPacket.initialize( - this->m_file.size, - this->m_file.sourceName.toChar(), - this->m_file.destName.toChar() + this->m_file.getSize(), + this->m_file.getSourceName().toChar(), + this->m_file.getDestName().toChar() ); Fw::FilePacket filePacket; filePacket.fromStartPacket(startPacket); @@ -497,7 +491,7 @@ namespace Svc { void FileDownlink :: enterCooldown() { - this->m_file.osFile.close(); + this->m_file.getOsFile().close(); this->m_mode.set(Mode::COOLDOWN); this->m_lastCompletedType = Fw::FilePacket::T_NONE; this->m_curTimer = 0; @@ -518,7 +512,7 @@ namespace Svc { //Send the next packet, or fail doing so const Os::File::Status status = this->sendDataPacket(this->m_byteOffset); if (status != Os::File::OP_OK) { - this->log_WARNING_HI_SendDataFail(this->m_file.sourceName, this->m_byteOffset); + this->log_WARNING_HI_SendDataFail(this->m_file.getSourceName(), this->m_byteOffset); this->enterCooldown(); this->sendResponse(FILEDOWNLINK_COMMAND_FAILURES_DISABLED ? SendFileStatus::STATUS_OK : SendFileStatus::STATUS_ERROR); //Don't go to wait state @@ -540,9 +534,9 @@ namespace Svc { //Complete command and switch to IDLE if (not cancel) { this->m_filesSent.fileSent(); - this->log_ACTIVITY_HI_FileSent(this->m_file.sourceName, this->m_file.destName); + this->log_ACTIVITY_HI_FileSent(this->m_file.getSourceName(), this->m_file.getDestName()); } else { - this->log_ACTIVITY_HI_DownlinkCanceled(this->m_file.sourceName, this->m_file.destName); + this->log_ACTIVITY_HI_DownlinkCanceled(this->m_file.getSourceName(), this->m_file.getDestName()); } this->enterCooldown(); sendResponse(SendFileStatus::STATUS_OK); diff --git a/Svc/FileDownlink/FileDownlink.hpp b/Svc/FileDownlink/FileDownlink.hpp index 291af9e490..2bbca103ed 100644 --- a/Svc/FileDownlink/FileDownlink.hpp +++ b/Svc/FileDownlink/FileDownlink.hpp @@ -77,23 +77,21 @@ namespace Svc { public: //! Constructor - File() : size(0) { } + File() : m_size(0) { } - public: + PRIVATE: //! The source file name - Fw::LogStringArg sourceName; + Fw::LogStringArg m_sourceName; //! The destination file name - Fw::LogStringArg destName; + Fw::LogStringArg m_destName; //! The underlying OS file - Os::File osFile; + Os::File m_osFile; //! The file size - U32 size; - - PRIVATE: + U32 m_size; //! The checksum for the file CFDP::Checksum m_checksum; @@ -110,13 +108,33 @@ namespace Svc { Os::File::Status read( U8 *const data, const U32 byteOffset, - const U32 a_size + const U32 size ); //! Get the checksum void getChecksum(CFDP::Checksum& checksum) { checksum = this->m_checksum; } + + //! Get the source file name + Fw::LogStringArg& getSourceName(void) { + return this->m_sourceName; + } + + //! Get the destination file name + Fw::LogStringArg& getDestName(void) { + return this->m_destName; + } + + //! Get the underlying OS file + Os::File& getOsFile(void) { + return this->m_osFile; + } + + //! Get the file size + U32 getSize(void) { + return this->m_size; + } }; //! Class to record files sent diff --git a/Svc/FileDownlink/Warnings.cpp b/Svc/FileDownlink/Warnings.cpp index 4d1b13961c..680e577aa4 100644 --- a/Svc/FileDownlink/Warnings.cpp +++ b/Svc/FileDownlink/Warnings.cpp @@ -16,7 +16,7 @@ namespace Svc { fileOpenError() { this->m_fileDownlink->log_WARNING_HI_FileOpenError( - this->m_fileDownlink->m_file.sourceName + this->m_fileDownlink->m_file.getSourceName() ); this->warning(); } @@ -25,8 +25,8 @@ namespace Svc { fileRead(const Os::File::Status status) { this->m_fileDownlink->log_WARNING_HI_FileReadError( - this->m_fileDownlink->m_file.sourceName, - status + this->m_fileDownlink->m_file.getSourceName(), + status ); this->warning(); } diff --git a/Svc/FileDownlink/test/ut/FileBuffer.cpp b/Svc/FileDownlink/test/ut/FileBuffer.cpp index c187903d93..f3a8abb573 100644 --- a/Svc/FileDownlink/test/ut/FileBuffer.cpp +++ b/Svc/FileDownlink/test/ut/FileBuffer.cpp @@ -1,4 +1,4 @@ -// ====================================================================== +// ====================================================================== // \title FileBuffer.hpp // \author bocchino // \brief cpp file for FileDownlinkTester::FileBuffer @@ -7,7 +7,7 @@ // Copyright 2009-2015, by the California Institute of Technology. // ALL RIGHTS RESERVED. United States Government Sponsorship // acknowledged. -// ====================================================================== +// ====================================================================== #include @@ -19,7 +19,7 @@ namespace Svc { FileBuffer( const U8 *const data, const size_t size - ) : + ) : index(0) { this->push(data, size); @@ -29,17 +29,17 @@ namespace Svc { FileDownlinkTester::FileBuffer :: FileBuffer( const History& dataPackets - ) : + ) : index(0) { size_t numPackets = dataPackets.size(); for (size_t i = 0; i < numPackets; ++i) { const Fw::FilePacket::DataPacket& dataPacket = dataPackets.at(i); - this->push(dataPacket.data, dataPacket.dataSize); + this->push(dataPacket.m_data, dataPacket.m_dataSize); } } - void FileDownlinkTester::FileBuffer :: + void FileDownlinkTester::FileBuffer :: push( const U8 *const data, const size_t size @@ -69,7 +69,7 @@ namespace Svc { file.close(); } - + void FileDownlinkTester::FileBuffer :: getChecksum(CFDP::Checksum& checksum) { @@ -79,12 +79,12 @@ namespace Svc { } bool FileDownlinkTester::FileBuffer :: - compare(const FileBuffer& fb1, const FileBuffer& fb2) + compare(const FileBuffer& fb1, const FileBuffer& fb2) { if (fb1.index != fb2.index) { fprintf( - stderr, + stderr, "FileBuffer: sizes do not match (%lu vs %lu)\n", fb1.index, fb2.index diff --git a/Svc/FileDownlink/test/ut/FileDownlinkTester.cpp b/Svc/FileDownlink/test/ut/FileDownlinkTester.cpp index aa226371f8..7ecf3fd765 100644 --- a/Svc/FileDownlink/test/ut/FileDownlinkTester.cpp +++ b/Svc/FileDownlink/test/ut/FileDownlinkTester.cpp @@ -679,8 +679,8 @@ namespace Svc { Fw::FilePacket filePacket; validateFilePacket(buffer, filePacket); const Fw::FilePacket::Header& header = filePacket.asHeader(); - ASSERT_EQ(0U, header.sequenceIndex); - ASSERT_EQ(Fw::FilePacket::T_START, header.type); + ASSERT_EQ(0U, header.m_sequenceIndex); + ASSERT_EQ(Fw::FilePacket::T_START, header.m_type); } void FileDownlinkTester :: @@ -694,11 +694,11 @@ namespace Svc { Fw::FilePacket filePacket; validateFilePacket(buffer, filePacket); const Fw::FilePacket::Header& header = filePacket.asHeader(); - ASSERT_EQ(sequenceIndex, header.sequenceIndex); - ASSERT_EQ(Fw::FilePacket::T_DATA, header.type); + ASSERT_EQ(sequenceIndex, header.m_sequenceIndex); + ASSERT_EQ(Fw::FilePacket::T_DATA, header.m_type); dataPacket = filePacket.asDataPacket(); - ASSERT_EQ(byteOffset, dataPacket.byteOffset); - byteOffset += dataPacket.dataSize; + ASSERT_EQ(byteOffset, dataPacket.m_byteOffset); + byteOffset += dataPacket.m_dataSize; } void FileDownlinkTester :: @@ -711,8 +711,8 @@ namespace Svc { Fw::FilePacket filePacket; validateFilePacket(buffer, filePacket); const Fw::FilePacket::Header& header = filePacket.asHeader(); - ASSERT_EQ(sequenceIndex, header.sequenceIndex); - ASSERT_EQ(Fw::FilePacket::T_END, header.type); + ASSERT_EQ(sequenceIndex, header.m_sequenceIndex); + ASSERT_EQ(Fw::FilePacket::T_END, header.m_type); const Fw::FilePacket::EndPacket endPacket = filePacket.asEndPacket(); CFDP::Checksum computedChecksum; endPacket.getChecksum(computedChecksum); @@ -728,8 +728,8 @@ namespace Svc { Fw::FilePacket filePacket; validateFilePacket(buffer, filePacket); const Fw::FilePacket::Header& header = filePacket.asHeader(); - ASSERT_EQ(sequenceIndex, header.sequenceIndex); - ASSERT_EQ(Fw::FilePacket::T_CANCEL, header.type); + ASSERT_EQ(sequenceIndex, header.m_sequenceIndex); + ASSERT_EQ(Fw::FilePacket::T_CANCEL, header.m_type); } } diff --git a/Svc/FileUplink/File.cpp b/Svc/FileUplink/File.cpp index c4683daf5e..939714852c 100644 --- a/Svc/FileUplink/File.cpp +++ b/Svc/FileUplink/File.cpp @@ -19,13 +19,13 @@ namespace Svc { Os::File::Status FileUplink::File :: open(const Fw::FilePacket::StartPacket& startPacket) { - const U32 length = startPacket.destinationPath.length; + const U32 length = startPacket.getDestinationPath().getLength(); char path[Fw::FilePacket::PathName::MAX_LENGTH + 1]; - memcpy(path, startPacket.destinationPath.value, length); + memcpy(path, startPacket.getDestinationPath().getValuePointer(), length); path[length] = 0; Fw::LogStringArg logStringArg(path); this->name = logStringArg; - this->size = startPacket.fileSize; + this->size = startPacket.getFileSize(); CFDP::Checksum checksum; this->m_checksum = checksum; return this->osFile.open(path, Os::File::OPEN_WRITE); diff --git a/Svc/FileUplink/FileUplink.cpp b/Svc/FileUplink/FileUplink.cpp index bff997fc6d..4802e3fb82 100644 --- a/Svc/FileUplink/FileUplink.cpp +++ b/Svc/FileUplink/FileUplink.cpp @@ -62,8 +62,8 @@ namespace Svc { if (status != Fw::FW_SERIALIZE_OK) { this->log_WARNING_HI_DecodeError(status); } else { - const Fw::FilePacket::Header& header = filePacket.asHeader(); - switch (header.type) { + Fw::FilePacket::Type header_type = filePacket.asHeader().getType(); + switch (header_type) { case Fw::FilePacket::T_START: this->handleStartPacket(filePacket.asStartPacket()); break; @@ -129,16 +129,16 @@ namespace Svc { this->warnings.invalidReceiveMode(Fw::FilePacket::T_DATA); return; } - const U32 sequenceIndex = dataPacket.header.sequenceIndex; + const U32 sequenceIndex = dataPacket.asHeader().getSequenceIndex(); this->checkSequenceIndex(sequenceIndex); - const U32 byteOffset = dataPacket.byteOffset; - const U32 dataSize = dataPacket.dataSize; + const U32 byteOffset = dataPacket.getByteOffset(); + const U32 dataSize = dataPacket.getDataSize(); if (byteOffset + dataSize > this->file.size) { this->warnings.packetOutOfBounds(sequenceIndex, this->file.name); return; } const Os::File::Status status = this->file.write( - dataPacket.data, + dataPacket.getDataPointer(), byteOffset, dataSize ); @@ -153,7 +153,7 @@ namespace Svc { this->packetsReceived.packetReceived(); if (this->receiveMode == DATA) { this->filesReceived.fileReceived(); - this->checkSequenceIndex(endPacket.header.sequenceIndex); + this->checkSequenceIndex(endPacket.asHeader().getSequenceIndex()); this->compareChecksums(endPacket); this->log_ACTIVITY_HI_FileReceived(this->file.name); } diff --git a/Svc/FileUplink/test/ut/FileUplinkTester.cpp b/Svc/FileUplink/test/ut/FileUplinkTester.cpp index 59f6561858..0e923da8a8 100644 --- a/Svc/FileUplink/test/ut/FileUplinkTester.cpp +++ b/Svc/FileUplink/test/ut/FileUplinkTester.cpp @@ -608,7 +608,7 @@ namespace Svc { this->sequenceIndex++ }; Fw::FilePacket::EndPacket endPacket; - endPacket.header = header; + endPacket.m_header = header; endPacket.setChecksum(checksum); Fw::FilePacket filePacket; filePacket.fromEndPacket(endPacket); From d538efaebf4b2fe4790f4c64daabaded8170a132 Mon Sep 17 00:00:00 2001 From: Johan Bertrand Date: Sat, 3 Feb 2024 19:07:57 +0100 Subject: [PATCH 2/3] Removed pointer in the getter name --- Fw/FilePacket/FilePacket.hpp | 8 ++++---- STest/STest/Rule/Rule.hpp | 2 +- STest/STest/Scenario/RepeatedRuleScenario.hpp | 2 +- STest/STest/Scenario/Scenario.hpp | 2 +- Svc/FileUplink/File.cpp | 2 +- Svc/FileUplink/FileUplink.cpp | 2 +- 6 files changed, 9 insertions(+), 9 deletions(-) diff --git a/Fw/FilePacket/FilePacket.hpp b/Fw/FilePacket/FilePacket.hpp index b73f37d449..e920e7db17 100644 --- a/Fw/FilePacket/FilePacket.hpp +++ b/Fw/FilePacket/FilePacket.hpp @@ -74,8 +74,8 @@ namespace Fw { return this->m_length; }; - //! Get the path name value pointer - const char* getValuePointer(void) const { + //! Get the path name value + const char* getValue(void) const { return this->m_value; }; @@ -248,8 +248,8 @@ namespace Fw { return this->m_dataSize; }; - //! Get the data pointer - const U8* getDataPointer() const { + //! Get the data + const U8* getData() const { return this->m_data; }; PRIVATE: diff --git a/STest/STest/Rule/Rule.hpp b/STest/STest/Rule/Rule.hpp index bec39da5f3..12d64e5f63 100644 --- a/STest/STest/Rule/Rule.hpp +++ b/STest/STest/Rule/Rule.hpp @@ -61,7 +61,7 @@ namespace STest { ) = 0; //! Get rule name - char const * getRuleNamePointer() const { + char const * getRuleName() const { return this->m_name; } diff --git a/STest/STest/Scenario/RepeatedRuleScenario.hpp b/STest/STest/Scenario/RepeatedRuleScenario.hpp index ff05469078..15ac62fa4f 100644 --- a/STest/STest/Scenario/RepeatedRuleScenario.hpp +++ b/STest/STest/Scenario/RepeatedRuleScenario.hpp @@ -31,7 +31,7 @@ namespace STest { RepeatedRuleScenario( Rule& rule //!< The rule ) : - Scenario(rule.getRuleNamePointer()), + Scenario(rule.getRuleName()), rule(rule) { diff --git a/STest/STest/Scenario/Scenario.hpp b/STest/STest/Scenario/Scenario.hpp index c992826076..ce64f557c5 100644 --- a/STest/STest/Scenario/Scenario.hpp +++ b/STest/STest/Scenario/Scenario.hpp @@ -136,7 +136,7 @@ namespace STest { printf( "[Scenario %s] Applying rule %s\n", this->name, - rule.getRuleNamePointer() + rule.getRuleName() ); } rule.apply(state); diff --git a/Svc/FileUplink/File.cpp b/Svc/FileUplink/File.cpp index 939714852c..55a99682e3 100644 --- a/Svc/FileUplink/File.cpp +++ b/Svc/FileUplink/File.cpp @@ -21,7 +21,7 @@ namespace Svc { { const U32 length = startPacket.getDestinationPath().getLength(); char path[Fw::FilePacket::PathName::MAX_LENGTH + 1]; - memcpy(path, startPacket.getDestinationPath().getValuePointer(), length); + memcpy(path, startPacket.getDestinationPath().getValue(), length); path[length] = 0; Fw::LogStringArg logStringArg(path); this->name = logStringArg; diff --git a/Svc/FileUplink/FileUplink.cpp b/Svc/FileUplink/FileUplink.cpp index 4802e3fb82..0bd88f46ba 100644 --- a/Svc/FileUplink/FileUplink.cpp +++ b/Svc/FileUplink/FileUplink.cpp @@ -138,7 +138,7 @@ namespace Svc { return; } const Os::File::Status status = this->file.write( - dataPacket.getDataPointer(), + dataPacket.getData(), byteOffset, dataSize ); From 917090cb16d3fe1e38aef6e1341219373c7b07b7 Mon Sep 17 00:00:00 2001 From: Johan Bertrand Date: Sat, 3 Feb 2024 19:09:19 +0100 Subject: [PATCH 3/3] Renamed getter --- STest/STest/Rule/Rule.hpp | 2 +- STest/STest/Scenario/RepeatedRuleScenario.hpp | 2 +- STest/STest/Scenario/Scenario.hpp | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/STest/STest/Rule/Rule.hpp b/STest/STest/Rule/Rule.hpp index 12d64e5f63..04acc4c49d 100644 --- a/STest/STest/Rule/Rule.hpp +++ b/STest/STest/Rule/Rule.hpp @@ -61,7 +61,7 @@ namespace STest { ) = 0; //! Get rule name - char const * getRuleName() const { + char const * getName() const { return this->m_name; } diff --git a/STest/STest/Scenario/RepeatedRuleScenario.hpp b/STest/STest/Scenario/RepeatedRuleScenario.hpp index 15ac62fa4f..5db0bd8c02 100644 --- a/STest/STest/Scenario/RepeatedRuleScenario.hpp +++ b/STest/STest/Scenario/RepeatedRuleScenario.hpp @@ -31,7 +31,7 @@ namespace STest { RepeatedRuleScenario( Rule& rule //!< The rule ) : - Scenario(rule.getRuleName()), + Scenario(rule.getName()), rule(rule) { diff --git a/STest/STest/Scenario/Scenario.hpp b/STest/STest/Scenario/Scenario.hpp index ce64f557c5..6ba8914d93 100644 --- a/STest/STest/Scenario/Scenario.hpp +++ b/STest/STest/Scenario/Scenario.hpp @@ -136,7 +136,7 @@ namespace STest { printf( "[Scenario %s] Applying rule %s\n", this->name, - rule.getRuleName() + rule.getName() ); } rule.apply(state);