Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
fb6b177
Implement file packet headers
chownw Jun 18, 2024
d091a1e
Implement LV and TLV object formats
chownw Jun 20, 2024
a0a4b2a
Rename header test file
chownw Jun 20, 2024
d774bed
Refactor serialize and deserialize functions to include an offset par…
chownw Jun 24, 2024
92ba380
Move PDU header definitions to PDU header hpp file
chownw Jun 24, 2024
23872ae
Add function to get length of serialized header
chownw Jun 24, 2024
4ada7ca
Add functions to get length of serialized LV and TLV objects
chownw Jun 24, 2024
9817088
Remove support for TLV objects
chownw Jun 25, 2024
c0ba04b
Remove TLV tests and reorganize FilePacket
chownw Jun 25, 2024
4f11331
Save metadata progress
chownw Jun 26, 2024
ba9e741
Finish metadata implementation
chownw Jun 26, 2024
a10a336
Refactor unit tests
chownw Jun 27, 2024
2e42d83
Fix deserializeValue
chownw Jun 27, 2024
3511d49
Fix metadata serialization offsets
chownw Jun 27, 2024
002de78
Add function to get packet types, add directive code to metadata
chownw Jul 1, 2024
2ce3939
Redo file packet types
chownw Jul 1, 2024
f5d8b69
Make header and metadata const correct
chownw Jul 1, 2024
d3399e8
Implement End-of-file packets
chownw Jul 2, 2024
eb7059f
Replace some magic numbers for calculating offsets
chownw Jul 2, 2024
db45212
Implement Finished packets
chownw Jul 2, 2024
acc6347
Implement Ack packet
chownw Jul 2, 2024
8f07b63
Remove Ack packet which is not needed for class 1
chownw Jul 3, 2024
88513b8
Implement file data packets
chownw Jul 10, 2024
0fd4fcc
Cosmetic updates
chownw Jul 23, 2024
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
3 changes: 3 additions & 0 deletions Fw/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@ add_fprime_subdirectory("${CMAKE_CURRENT_LIST_DIR}/SerializableFile/")
add_fprime_subdirectory("${CMAKE_CURRENT_LIST_DIR}/Test/")
add_fprime_subdirectory("${CMAKE_CURRENT_LIST_DIR}/Types/")

# CCSDS subdirectories
add_fprime_subdirectory("${CMAKE_CURRENT_LIST_DIR}/Ccsds/Cfdp/")

# Setup an interface target for Fw for efficiency
add_library(Fw INTERFACE)
add_dependencies(Fw ${FPRIME_FRAMEWORK_MODULES})
31 changes: 31 additions & 0 deletions Fw/Ccsds/Cfdp/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
####

Check warning on line 1 in Fw/Ccsds/Cfdp/CMakeLists.txt

View workflow job for this annotation

GitHub Actions / Check Spelling

`Cfdp` is not a recognized word. (check-file-path)
# CMakeLists.txt:
#
# Sets up the fprime module build within CMake.
####
set(SOURCE_FILES
"${CMAKE_CURRENT_LIST_DIR}/EndOfFile.cpp"
"${CMAKE_CURRENT_LIST_DIR}/FileData.cpp"
"${CMAKE_CURRENT_LIST_DIR}/FilePacket.cpp"
"${CMAKE_CURRENT_LIST_DIR}/Finished.cpp"
"${CMAKE_CURRENT_LIST_DIR}/Header.cpp"
"${CMAKE_CURRENT_LIST_DIR}/Metadata.cpp"
)

set(MOD_DEPS
Fw/Types
Fw/Buffer
)

register_fprime_module()

set(UT_SOURCE_FILES
"${CMAKE_CURRENT_LIST_DIR}/test/ut/TestEndOfFile.cpp"
"${CMAKE_CURRENT_LIST_DIR}/test/ut/TestFileData.cpp"
"${CMAKE_CURRENT_LIST_DIR}/test/ut/TestFilePacketMain.cpp"
"${CMAKE_CURRENT_LIST_DIR}/test/ut/TestFilePacket.cpp"
"${CMAKE_CURRENT_LIST_DIR}/test/ut/TestFinished.cpp"
"${CMAKE_CURRENT_LIST_DIR}/test/ut/TestHeader.cpp"
"${CMAKE_CURRENT_LIST_DIR}/test/ut/TestMetadata.cpp"
)
register_fprime_ut()
111 changes: 111 additions & 0 deletions Fw/Ccsds/Cfdp/EndOfFile.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
//! ============================================================================

Check warning on line 1 in Fw/Ccsds/Cfdp/EndOfFile.cpp

View workflow job for this annotation

GitHub Actions / Check Spelling

`Cfdp` is not a recognized word. (check-file-path)
//! @file EndOfFile.cpp
//! @brief cpp file for a CFDP file packet End-of-file data field.
//! @author chownw

Check warning on line 4 in Fw/Ccsds/Cfdp/EndOfFile.cpp

View workflow job for this annotation

GitHub Actions / Check Spelling

`chownw` is not a recognized word. (unrecognized-spelling)
//! ============================================================================

#include <string.h>

#include <FpConfig.hpp>
#include <Fw/Buffer/Buffer.hpp>
#include <Fw/Ccsds/Cfdp/EndOfFile.hpp>
#include <Fw/Ccsds/Cfdp/FilePacket.hpp>
#include <Fw/Ccsds/Cfdp/Header.hpp>

namespace Fw
{

namespace Cfdp
{

FilePacket::DirectiveType FilePacket::EndOfFile::directiveCode =
FilePacket::DirectiveType::END_OF_FILE;

FilePacket::EndOfFile::
EndOfFile()
{
}

FilePacket::EndOfFile::
EndOfFile(ConditionCode conditionCode, U32 fileChecksum, U64 fileSize)
{
this->conditionCode = conditionCode;
this->spare = 0;
this->fileChecksum = fileChecksum;
this->fileSize = FileSizeSensitive(fileSize);
}

FilePacket::ConditionCode FilePacket::EndOfFile::
getConditionCode() const
{
return this->conditionCode;
}

U32 FilePacket::EndOfFile::
getFileChecksum() const
{
return this->fileChecksum;
}

U64 FilePacket::EndOfFile::
getFileSize() const
{
return this->fileSize.getValue();
}

void FilePacket::EndOfFile::
serialize(const Fw::Buffer& buf, U32 offset, const Header& header) const
{
U8* data = buf.getData() + offset;

// Serialize octet 0
data[0] = static_cast<U8>(this->directiveCode);

// Serialize octet 1
data[1] = (static_cast<U8>(this->conditionCode) & 15) << 4;

// Push file checksum in big-endian format
FilePacket::serializeValue(
&data[2],
this->fileChecksum,
FieldLength::FILE_CHECKSUM / 8
);

// Serialize the FSS field file size
U32 fileSizeOffset = offset + FixedSize::BYTES;
this->fileSize.serialize(buf, fileSizeOffset, header);
}

void FilePacket::EndOfFile::
deserialize(const Fw::Buffer& buf, U32 offset, const Header& header)
{
U8* data = buf.getData() + offset;

// Deserialize octet 1
this->conditionCode =
static_cast<FilePacket::ConditionCode>((data[1] >> 4) & 15);
this->spare = data[1] & 15;

// Deserialize file checksum bytes
this->fileChecksum = FilePacket::deserializeValue(
&data[2],
FieldLength::FILE_CHECKSUM / 8
);

// Deserialize the FSS field file size
U32 fileSizeOffset = offset + FixedSize::BYTES;
this->fileSize.deserialize(buf, fileSizeOffset, header);
}

U32 FilePacket::EndOfFile::
getSerializedLength(const Header& header) const
{
return (
FixedSize::BYTES
+ this->fileSize.getSerializedLength(header)
);
}

} // Cfdp

} // Fw
141 changes: 141 additions & 0 deletions Fw/Ccsds/Cfdp/EndOfFile.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,141 @@
//! ============================================================================

Check warning on line 1 in Fw/Ccsds/Cfdp/EndOfFile.hpp

View workflow job for this annotation

GitHub Actions / Check Spelling

`Cfdp` is not a recognized word. (check-file-path)
//! @file EndOfFile.hpp
//! @brief hpp file for a CFDP file packet End-of-file data field.
//! @author chownw
//! ============================================================================

#ifndef FW_CFDP_ENDOFFILE_HPP
#define FW_CFDP_ENDOFFILE_HPP

#include <FpConfig.hpp>
#include <Fw/Buffer/Buffer.hpp>
#include <Fw/Ccsds/Cfdp/FilePacket.hpp>

namespace Fw
{

namespace Cfdp
{

//! @brief A CFDP file packet End-of-file data field.
//!
class FilePacket::EndOfFile : public DataField
{
friend FilePacket;

public:
//! @brief Construct an empty CFDP End-of-file PDU.
//!
//! This can be used to construct an End-of-file PDU to hold deserialized
//! data.
//!
EndOfFile();

//! @brief Construct a filled CFDP End-of-file PDU.
//!
//! This can be used to construct an End-of-file PDU for serialization.
//!
//! @param conditionCode The condition code.
//! @param fileChecksum The file checksum.
//! @param fileSize The number of file data octets transmitted by sender.
//!
EndOfFile(
ConditionCode conditionCode,
U32 fileChecksum,
U64 fileSize
);

//! @brief Get the condition code.
//!
ConditionCode getConditionCode() const;

//! @brief Get the file checksum.
//!
U32 getFileChecksum() const;

//! @brief Get the file size.
//!
U64 getFileSize() const;

PRIVATE:
//! @brief Serialize this End-of-file PDU into a buffer.
//!
//! @param buf The buffer to hold the serialized data.
//! @param offset The byte offset to start serialization from.
//! @param header The header attached to this PDU.
//!
void serialize(
const Fw::Buffer& buf,
U32 offset,
const Header& header
) const;

//! @brief Deserialize a buffer containing serialized End-of-file PDU data.
//!
//! @param buf The buffer containing serialized data.
//! @param offset The byte offset to start deserialization from.
//! @param header The header attached to this PDU.
//!
void deserialize(
const Fw::Buffer& buf,
U32 offset,
const Header& header
);

//! @brief Get the length in octets of this End-of-file PDU when serialized.
//!
//! @param header The header attached to this PDU.
//!
U32 getSerializedLength(const Header& header) const;

PRIVATE:
//! @brief Length in bits of fixed-size End-of-file PDU fields.
//!
enum FieldLength : U32
{
DIRECTIVE_CODE = 8,
CONDITION_CODE = 4,
SPARE = 4,
FILE_CHECKSUM = 32,
};

//! @brief Total length of fixed-size End-of-file PDU fields.
//!
enum FixedSize : U32
{
BITS =
FieldLength::DIRECTIVE_CODE
+ FieldLength::CONDITION_CODE
+ FieldLength::SPARE
+ FieldLength::FILE_CHECKSUM,
BYTES = BITS / 8,
};

//! @brief Indicates that the data field contains an End-of-file PDU.
//!
static DirectiveType directiveCode;

//! @brief Condition code.
//!
ConditionCode conditionCode;

//! @brief Spare bits, set to all zeroes.
//!
U8 spare;

//! @brief File checksum.
//!
U32 fileChecksum;

//! @brief Number of file data octets transmitted by sender.
//!
FileSizeSensitive fileSize;

// NOTE: Fault location field not supported.
};

} // Cfdp

} // Fw

#endif // FW_CFDP_ENDOFFILE_HPP
Loading
Loading