Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
52 changes: 37 additions & 15 deletions Fw/FilePacket/FilePacket.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,12 @@
#include <Fw/Types/SerialBuffer.hpp>
#include <Fw/Types/Serializable.hpp>

// Forward declaration for UTs
namespace Svc {
class FileUplinkTester;
class FileDownlinkTester;
}

namespace Fw {

//! \class FilePacket
Expand All @@ -44,14 +50,16 @@ namespace Fw {
//! The type of a path name
class PathName {

friend union FilePacket;
friend union FilePacket;
friend class Svc::FileDownlinkTester;
friend class Svc::FileUplinkTester;

public:

//! The maximum length of a path name
enum { MAX_LENGTH = 255 };

PRIVATE:
private:

//! The length
U8 m_length;
Expand Down Expand Up @@ -79,7 +87,7 @@ namespace Fw {
return this->m_value;
};

PRIVATE:
private:

//! Initialize this PathName from a SerialBuffer
SerializeStatus fromSerialBuffer(SerialBuffer& serialBuffer);
Expand All @@ -93,8 +101,11 @@ namespace Fw {
class Header {

friend union FilePacket;
friend class FilePacketTester;
friend class Svc::FileDownlinkTester;
friend class Svc::FileUplinkTester;

PRIVATE:
private:

//! The packet type
Type m_type;
Expand All @@ -107,7 +118,7 @@ namespace Fw {
//! Header size
enum { HEADERSIZE = sizeof(U8) + sizeof(U32) };

PRIVATE:
private:

//! Initialize a file packet header
void initialize(
Expand Down Expand Up @@ -140,7 +151,7 @@ namespace Fw {

friend union FilePacket;

PRIVATE:
private:

//! The packet header
Header m_header;
Expand Down Expand Up @@ -169,6 +180,11 @@ namespace Fw {
//! Convert this StartPacket to a Buffer
SerializeStatus toBuffer(Buffer& buffer) const;

//! Get this as a Header
const FilePacket::Header& asHeader() const {
return this->m_header;
};

//! Get the destination path
const PathName& getDestinationPath() const {
return this->m_destinationPath;
Expand All @@ -183,7 +199,7 @@ namespace Fw {
U32 getFileSize() const {
return this->m_fileSize;
};
PRIVATE:
private:

//! Initialize this StartPacket from a SerialBuffer
SerializeStatus fromSerialBuffer(SerialBuffer& serialBuffer);
Expand All @@ -197,8 +213,10 @@ namespace Fw {
class DataPacket {

friend union FilePacket;
friend class Svc::FileDownlinkTester;
friend class Svc::FileUplinkTester;

PRIVATE:
private:

//! The packet header
Header m_header;
Expand Down Expand Up @@ -252,7 +270,7 @@ namespace Fw {
const U8* getData() const {
return this->m_data;
};
PRIVATE:
private:

//! Initialize this DataPacket from a SerialBuffer
SerializeStatus fromSerialBuffer(SerialBuffer& serialBuffer);
Expand All @@ -269,8 +287,10 @@ namespace Fw {
class EndPacket {

friend union FilePacket;
friend class Svc::FileDownlinkTester;
friend class Svc::FileUplinkTester;

PRIVATE:
private:

//! The packet header
Header m_header;
Expand Down Expand Up @@ -301,7 +321,7 @@ namespace Fw {
const CFDP::Checksum& checksum //!< The checksum
);

PRIVATE:
private:

//! The checksum
U32 m_checksumValue;
Expand All @@ -318,8 +338,10 @@ namespace Fw {
class CancelPacket {

friend union FilePacket;
friend class Svc::FileDownlinkTester;
friend class Svc::FileUplinkTester;

PRIVATE:
private:

//! The packet header
Header m_header;
Expand All @@ -341,7 +363,7 @@ namespace Fw {
const FilePacket::Header& asHeader() const {
return this->m_header;
};
PRIVATE:
private:

//! Initialize this CancelPacket from a SerialBuffer
SerializeStatus fromSerialBuffer(SerialBuffer& serialBuffer);
Expand Down Expand Up @@ -410,7 +432,7 @@ namespace Fw {
//!
SerializeStatus toBuffer(Buffer& buffer) const;

PRIVATE:
private:

// ----------------------------------------------------------------------
// Private methods
Expand All @@ -420,7 +442,7 @@ namespace Fw {
//!
SerializeStatus fromSerialBuffer(SerialBuffer& serialBuffer);

PRIVATE:
private:

// ----------------------------------------------------------------------
// Private data
Expand Down
2 changes: 1 addition & 1 deletion Fw/FilePacket/GTest/CancelPacket.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ namespace Fw {
const FilePacket::CancelPacket& actual
)
{
FilePackets::Header::compare(expected.m_header, actual.m_header);
FilePackets::Header::compare(expected.asHeader(), actual.asHeader());
}

}
Expand Down
8 changes: 4 additions & 4 deletions Fw/FilePacket/GTest/DataPacket.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,10 @@ namespace Fw {
const FilePacket::DataPacket& actual
)
{
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);
FilePackets::Header::compare(expected.asHeader(), actual.asHeader());
ASSERT_EQ(expected.getByteOffset(), actual.getByteOffset());
Bytes expectedData(expected.getData(), expected.getDataSize());
Bytes actualData(actual.getData(), actual.getDataSize());
Bytes::compare(expectedData, actualData);
}

Expand Down
2 changes: 1 addition & 1 deletion Fw/FilePacket/GTest/EndPacket.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ namespace Fw {
const FilePacket::EndPacket& actual
)
{
FilePackets::Header::compare(expected.m_header, actual.m_header);
FilePackets::Header::compare(expected.asHeader(), actual.asHeader());
CFDP::Checksum expectedChecksum;
CFDP::Checksum actualChecksum;
expected.getChecksum(expectedChecksum);
Expand Down
4 changes: 2 additions & 2 deletions Fw/FilePacket/GTest/Header.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ namespace Fw {
const FilePacket::Header& actual
)
{
ASSERT_EQ(expected.m_type, actual.m_type);
ASSERT_EQ(expected.m_sequenceIndex, actual.m_sequenceIndex);
ASSERT_EQ(expected.getType(), actual.getType());
ASSERT_EQ(expected.getSequenceIndex(), actual.getSequenceIndex());
}

}
Expand Down
10 changes: 5 additions & 5 deletions Fw/FilePacket/GTest/PathName.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,14 @@ namespace Fw {
const FilePacket::PathName& actual
)
{
ASSERT_EQ(expected.m_length, actual.m_length);
ASSERT_EQ(expected.getLength(), actual.getLength());
Bytes expectedPath(
reinterpret_cast<const U8*>(expected.m_value),
expected.m_length
reinterpret_cast<const U8*>(expected.getValue()),
expected.getLength()
);
Bytes actualPath(
reinterpret_cast<const U8*>(actual.m_value),
actual.m_length
reinterpret_cast<const U8*>(actual.getValue()),
actual.getLength()
);
Bytes::compare(expectedPath, actualPath);
}
Expand Down
8 changes: 4 additions & 4 deletions Fw/FilePacket/GTest/StartPacket.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,10 @@ namespace Fw {
const FilePacket::StartPacket& actual
)
{
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);
FilePackets::Header::compare(expected.asHeader(), actual.asHeader());
ASSERT_EQ(expected.getFileSize(), actual.getFileSize());
PathName::compare(expected.getSourcePath(), actual.getSourcePath());
PathName::compare(expected.getDestinationPath(), actual.getDestinationPath());
}

}
Expand Down
Loading
Loading