Update FSFW from upstream #71

Closed
muellerr wants to merge 1112 commits from development into eive/develop
16 changed files with 128 additions and 103 deletions
Showing only changes of commit 202d9341d8 - Show all commits

View File

@ -2,7 +2,7 @@
#include "fsfw/tcdistribution/definitions.h"
CfdpDistributor::CfdpDistributor(CfdpRouterCfg cfg)
CfdpDistributor::CfdpDistributor(CfdpDistribCfg cfg)
: TcDistributorBase(cfg.objectId, cfg.tcQueue), cfg(cfg) {}
ReturnValue_t CfdpDistributor::registerTcDestination(const cfdp::EntityId& address,
@ -47,7 +47,7 @@ ReturnValue_t CfdpDistributor::selectDestination(MessageQueueId_t& destId) {
return HasReturnvaluesIF::RETURN_OK;
}
const char* CfdpDistributor::getName() const { return "CFDP Router"; }
const char* CfdpDistributor::getName() const { return "CFDP Distributor"; }
uint32_t CfdpDistributor::getIdentifier() const { return 0; }

View File

@ -12,8 +12,8 @@
#include "fsfw/tmtcservices/AcceptsTelecommandsIF.h"
#include "fsfw/tmtcservices/VerificationReporter.h"
struct CfdpRouterCfg {
CfdpRouterCfg(object_id_t objectId, StorageManagerIF& tcStore, MessageQueueIF* tcQueue)
struct CfdpDistribCfg {
CfdpDistribCfg(object_id_t objectId, StorageManagerIF& tcStore, MessageQueueIF* tcQueue)
: objectId(objectId), tcStore(tcStore), tcQueue(tcQueue) {}
object_id_t objectId;
@ -37,7 +37,7 @@ class CfdpDistributor : public TcDistributorBase, public AcceptsTelecommandsIF {
* @param setPacketSource Object ID of the source of TC packets.
* Must implement CcsdsDistributorIF.
*/
explicit CfdpDistributor(CfdpRouterCfg cfg);
explicit CfdpDistributor(CfdpDistribCfg cfg);
[[nodiscard]] const char* getName() const override;
[[nodiscard]] uint32_t getIdentifier() const override;
@ -58,7 +58,7 @@ class CfdpDistributor : public TcDistributorBase, public AcceptsTelecommandsIF {
// I don't think a regular OBSW will have more than 1 or 2 of these destinations, so I think
// it is okay to accept the overhead here
std::vector<EntityInfo> tcDestinations;
CfdpRouterCfg cfg;
CfdpDistribCfg cfg;
ReturnValue_t selectDestination(MessageQueueId_t& destId) override;

View File

@ -19,8 +19,8 @@ target_sources(
FinishedPduSerializer.cpp
FinishedPduDeserializer.cpp
MetadataInfo.cpp
MetadataPduSerializer.cpp
MetadataPduDeserializer.cpp
MetadataPduCreator.cpp
MetadataPduReader.cpp
KeepAlivePduSerializer.cpp
KeepAlivePduDeserializer.cpp
PromptPduSerializer.cpp

View File

@ -9,41 +9,41 @@ MetadataInfo::MetadataInfo(bool closureRequested, cfdp::ChecksumType checksumTyp
sourceFileName(sourceFileName),
destFileName(destFileName) {}
void MetadataInfo::setOptionsArray(cfdp::Tlv** optionsArray, size_t* optionsLen,
size_t* maxOptionsLen) {
this->optionsArray = optionsArray;
if (maxOptionsLen != nullptr) {
this->maxOptionsLen = *maxOptionsLen;
void MetadataInfo::setOptionsArray(cfdp::Tlv** optionsArray_, const size_t* optionsLen_,
const size_t* maxOptionsLen_) {
this->optionsArray = optionsArray_;
if (maxOptionsLen_ != nullptr) {
this->maxOptionsLen = *maxOptionsLen_;
}
if (optionsLen != nullptr) {
this->optionsLen = *optionsLen;
if (optionsLen_ != nullptr) {
this->optionsLen = *optionsLen_;
}
}
cfdp::ChecksumType MetadataInfo::getChecksumType() const { return checksumType; }
void MetadataInfo::setChecksumType(cfdp::ChecksumType checksumType) {
this->checksumType = checksumType;
void MetadataInfo::setChecksumType(cfdp::ChecksumType checksumType_) {
checksumType = checksumType_;
}
bool MetadataInfo::isClosureRequested() const { return closureRequested; }
void MetadataInfo::setClosureRequested(bool closureRequested) {
this->closureRequested = closureRequested;
void MetadataInfo::setClosureRequested(bool closureRequested_) {
closureRequested = closureRequested_;
}
cfdp::Lv& MetadataInfo::getDestFileName() { return destFileName; }
cfdp::FileSize& MetadataInfo::getFileSize() { return fileSize; }
ReturnValue_t MetadataInfo::getOptions(cfdp::Tlv*** optionsArray, size_t* optionsLen,
ReturnValue_t MetadataInfo::getOptions(cfdp::Tlv*** optionsArray_, size_t* optionsLen_,
size_t* maxOptsLen) {
if (optionsArray == nullptr or this->optionsArray == nullptr) {
if (optionsArray_ == nullptr or optionsArray == nullptr) {
return HasReturnvaluesIF::RETURN_FAILED;
}
*optionsArray = this->optionsArray;
if (optionsLen != nullptr) {
*optionsLen = this->optionsLen;
*optionsArray_ = optionsArray;
if (optionsLen_ != nullptr) {
*optionsLen_ = this->optionsLen;
}
if (maxOptsLen != nullptr) {
*maxOptsLen = this->maxOptionsLen;
@ -81,18 +81,18 @@ size_t MetadataInfo::getSerializedSize(bool fssLarge) {
return size;
}
void MetadataInfo::setDestFileName(cfdp::Lv& destFileName) { this->destFileName = destFileName; }
void MetadataInfo::setDestFileName(cfdp::Lv& destFileName_) { this->destFileName = destFileName_; }
void MetadataInfo::setSourceFileName(cfdp::Lv& sourceFileName) {
this->sourceFileName = sourceFileName;
void MetadataInfo::setSourceFileName(cfdp::Lv& sourceFileName_) {
this->sourceFileName = sourceFileName_;
}
size_t MetadataInfo::getMaxOptionsLen() const { return maxOptionsLen; }
void MetadataInfo::setMaxOptionsLen(size_t maxOptionsLen) { this->maxOptionsLen = maxOptionsLen; }
void MetadataInfo::setMaxOptionsLen(size_t maxOptionsLen_) { this->maxOptionsLen = maxOptionsLen_; }
size_t MetadataInfo::getOptionsLen() const { return optionsLen; }
void MetadataInfo::setOptionsLen(size_t optionsLen) { this->optionsLen = optionsLen; }
void MetadataInfo::setOptionsLen(size_t optionsLen_) { this->optionsLen = optionsLen_; }
cfdp::Lv& MetadataInfo::getSourceFileName() { return sourceFileName; }

View File

@ -13,10 +13,11 @@ class MetadataInfo {
size_t getSerializedSize(bool fssLarge = false);
void setOptionsArray(cfdp::Tlv** optionsArray, size_t* optionsLen, size_t* maxOptionsLen);
cfdp::ChecksumType getChecksumType() const;
void setOptionsArray(cfdp::Tlv** optionsArray, const size_t* optionsLen,
const size_t* maxOptionsLen);
[[nodiscard]] cfdp::ChecksumType getChecksumType() const;
void setChecksumType(cfdp::ChecksumType checksumType);
bool isClosureRequested() const;
[[nodiscard]] bool isClosureRequested() const;
void setClosureRequested(bool closureRequested = false);
void setDestFileName(cfdp::Lv& destFileName);
@ -26,13 +27,13 @@ class MetadataInfo {
cfdp::Lv& getSourceFileName();
cfdp::FileSize& getFileSize();
bool hasOptions() const;
bool canHoldOptions() const;
[[nodiscard]] bool hasOptions() const;
[[nodiscard]] bool canHoldOptions() const;
ReturnValue_t getOptions(cfdp::Tlv*** optionsArray, size_t* optionsLen, size_t* maxOptsLen);
void setOptionsLen(size_t optionsLen);
size_t getOptionsLen() const;
[[nodiscard]] size_t getOptionsLen() const;
void setMaxOptionsLen(size_t maxOptionsLen);
size_t getMaxOptionsLen() const;
[[nodiscard]] size_t getMaxOptionsLen() const;
private:
bool closureRequested = false;

View File

@ -1,20 +1,20 @@
#include "MetadataPduSerializer.h"
#include "MetadataPduCreator.h"
MetadataPduSerializer::MetadataPduSerializer(PduConfig &conf, MetadataInfo &info)
MetadataPduCreator::MetadataPduCreator(PduConfig &conf, MetadataInfo &info)
: FileDirectiveCreator(conf, cfdp::FileDirectives::METADATA, 5), info(info) {
updateDirectiveFieldLen();
}
void MetadataPduSerializer::updateDirectiveFieldLen() {
void MetadataPduCreator::updateDirectiveFieldLen() {
setDirectiveDataFieldLen(info.getSerializedSize(getLargeFileFlag()));
}
size_t MetadataPduSerializer::getSerializedSize() const {
size_t MetadataPduCreator::getSerializedSize() const {
return FileDirectiveCreator::getWholePduSize();
}
ReturnValue_t MetadataPduSerializer::serialize(uint8_t **buffer, size_t *size, size_t maxSize,
Endianness streamEndianness) const {
ReturnValue_t MetadataPduCreator::serialize(uint8_t **buffer, size_t *size, size_t maxSize,
Endianness streamEndianness) const {
ReturnValue_t result = FileDirectiveCreator::serialize(buffer, size, maxSize, streamEndianness);
if (result != HasReturnvaluesIF::RETURN_OK) {
return result;

View File

@ -0,0 +1,22 @@
#ifndef FSFW_CFDP_PDU_METADATAPDUCREATOR_H_
#define FSFW_CFDP_PDU_METADATAPDUCREATOR_H_
#include "fsfw/cfdp/pdu/FileDirectiveCreator.h"
#include "fsfw/cfdp/pdu/MetadataInfo.h"
class MetadataPduCreator : public FileDirectiveCreator {
public:
MetadataPduCreator(PduConfig& conf, MetadataInfo& info);
void updateDirectiveFieldLen();
[[nodiscard]] size_t getSerializedSize() const override;
ReturnValue_t serialize(uint8_t** buffer, size_t* size, size_t maxSize,
Endianness streamEndianness) const override;
private:
MetadataInfo& info;
};
#endif /* FSFW_CFDP_PDU_METADATAPDUCREATOR_H_ */

View File

@ -1,17 +0,0 @@
#ifndef FSFW_SRC_FSFW_CFDP_PDU_METADATAPDUDESERIALIZER_H_
#define FSFW_SRC_FSFW_CFDP_PDU_METADATAPDUDESERIALIZER_H_
#include "fsfw/cfdp/pdu/FileDirectiveReader.h"
#include "fsfw/cfdp/pdu/MetadataInfo.h"
class MetadataPduDeserializer : public FileDirectiveReader {
public:
MetadataPduDeserializer(const uint8_t* pduBuf, size_t maxSize, MetadataInfo& info);
ReturnValue_t parseData() override;
private:
MetadataInfo& info;
};
#endif /* FSFW_SRC_FSFW_CFDP_PDU_METADATAPDUDESERIALIZER_H_ */

View File

@ -1,10 +1,9 @@
#include "MetadataPduDeserializer.h"
#include "MetadataPduReader.h"
MetadataPduDeserializer::MetadataPduDeserializer(const uint8_t* pduBuf, size_t maxSize,
MetadataInfo& info)
MetadataPduReader::MetadataPduReader(const uint8_t* pduBuf, size_t maxSize, MetadataInfo& info)
: FileDirectiveReader(pduBuf, maxSize), info(info) {}
ReturnValue_t MetadataPduDeserializer::parseData() {
ReturnValue_t MetadataPduReader::parseData() {
ReturnValue_t result = FileDirectiveReader::parseData();
if (result != HasReturnvaluesIF::RETURN_OK) {
return result;

View File

@ -0,0 +1,17 @@
#ifndef FSFW_CFDP_PDU_METADATAPDUREADER_H_
#define FSFW_CFDP_PDU_METADATAPDUREADER_H_
#include "fsfw/cfdp/pdu/FileDirectiveReader.h"
#include "fsfw/cfdp/pdu/MetadataInfo.h"
class MetadataPduReader : public FileDirectiveReader {
public:
MetadataPduReader(const uint8_t* pduBuf, size_t maxSize, MetadataInfo& info);
ReturnValue_t parseData() override;
private:
MetadataInfo& info;
};
#endif /* FSFW_CFDP_PDU_METADATAPDUREADER_H_ */

View File

@ -1,22 +0,0 @@
#ifndef FSFW_SRC_FSFW_CFDP_PDU_METADATAPDUSERIALIZER_H_
#define FSFW_SRC_FSFW_CFDP_PDU_METADATAPDUSERIALIZER_H_
#include "fsfw/cfdp/pdu/FileDirectiveCreator.h"
#include "fsfw/cfdp/pdu/MetadataInfo.h"
class MetadataPduSerializer : public FileDirectiveCreator {
public:
MetadataPduSerializer(PduConfig& conf, MetadataInfo& info);
void updateDirectiveFieldLen();
size_t getSerializedSize() const override;
ReturnValue_t serialize(uint8_t** buffer, size_t* size, size_t maxSize,
Endianness streamEndianness) const override;
private:
MetadataInfo& info;
};
#endif /* FSFW_SRC_FSFW_CFDP_PDU_METADATAPDUSERIALIZER_H_ */

View File

@ -8,12 +8,16 @@ namespace cfdp {
struct EntityId : public VarLenField {
public:
EntityId() : VarLenField() {}
template <typename T>
explicit EntityId(UnsignedByteField<T> byteField) : VarLenField(byteField) {}
EntityId(cfdp::WidthInBytes width, size_t entityId) : VarLenField(width, entityId) {}
};
struct TransactionSeqNum : public VarLenField {
public:
TransactionSeqNum() : VarLenField() {}
template <typename T>
explicit TransactionSeqNum(UnsignedByteField<T> byteField) : VarLenField(byteField) {}
TransactionSeqNum(cfdp::WidthInBytes width, size_t seqNum) : VarLenField(width, seqNum) {}
};

View File

@ -1,5 +1,3 @@
#include <catch2/catch_test_macros.hpp>
TEST_CASE("CFDP Dest Handler", "[cfdp]") {
}
TEST_CASE("CFDP Dest Handler", "[cfdp]") {}

View File

@ -1,5 +1,30 @@
#include <catch2/catch_test_macros.hpp>
TEST_CASE("CFDP Distributor", "[cfdp][distributor]") {
#include "fsfw/cfdp/CfdpDistributor.h"
#include "fsfw/cfdp/pdu/MetadataPduCreator.h"
#include "fsfw/storagemanager/LocalPool.h"
#include "mocks/AcceptsTcMock.h"
#include "mocks/MessageQueueMock.h"
TEST_CASE("CFDP Distributor", "[cfdp][distributor]") {
LocalPool::LocalPoolConfig cfg = {{5, 32}, {2, 64}};
LocalPool pool(objects::NO_OBJECT, cfg);
auto queue = MessageQueueMock(1);
CfdpDistribCfg distribCfg(1, pool, &queue);
auto distributor = CfdpDistributor(distribCfg);
auto entityId = cfdp::EntityId(UnsignedByteField<uint16_t>(2));
MessageQueueId_t acceptorQueueId = 3;
auto tcAcceptor = AcceptsTcMock("TC Acceptor", 0, acceptorQueueId);
SECTION("State") {
CHECK(distributor.initialize() == result::OK);
CHECK(std::strcmp(distributor.getName(), "CFDP Distributor") == 0);
CHECK(distributor.getIdentifier() == 0);
CHECK(distributor.getRequestQueue() == queue.getId());
}
SECTION("Register Listener") {
CHECK(distributor.initialize() == result::OK);
CHECK(distributor.registerTcDestination(entityId, tcAcceptor));
// queue.addReceivedMessage()
}
}

View File

@ -3,8 +3,8 @@
#include <array>
#include <catch2/catch_test_macros.hpp>
#include "fsfw/cfdp/pdu/MetadataPduDeserializer.h"
#include "fsfw/cfdp/pdu/MetadataPduSerializer.h"
#include "fsfw/cfdp/pdu/MetadataPduCreator.h"
#include "fsfw/cfdp/pdu/MetadataPduReader.h"
#include "fsfw/cfdp/tlv/FilestoreResponseTlv.h"
#include "fsfw/globalfunctions/arrayprinter.h"
@ -39,7 +39,7 @@ TEST_CASE("Metadata PDU", "[cfdp][pdu]") {
REQUIRE(options[1]->getSerializedSize() == 5);
SECTION("Serialize") {
MetadataPduSerializer serializer(pduConf, info);
MetadataPduCreator serializer(pduConf, info);
result = serializer.serialize(&buffer, &sz, mdBuffer.size(), SerializeIF::Endianness::NETWORK);
REQUIRE(result == HasReturnvaluesIF::RETURN_OK);
REQUIRE(serializer.getWholePduSize() == 27);
@ -72,7 +72,7 @@ TEST_CASE("Metadata PDU", "[cfdp][pdu]") {
otherFileName.size());
info.setSourceFileName(otherFileNameLv);
size_t sizeOfOptions = options.size();
info.setOptionsArray(options.data(), &sizeOfOptions, &sizeOfOptions);
info.setOptionsArray(*options.data(), &sizeOfOptions, &sizeOfOptions);
REQUIRE(info.getMaxOptionsLen() == 2);
info.setMaxOptionsLen(3);
REQUIRE(info.getMaxOptionsLen() == 3);
@ -115,22 +115,22 @@ TEST_CASE("Metadata PDU", "[cfdp][pdu]") {
}
SECTION("Deserialize") {
MetadataPduSerializer serializer(pduConf, info);
MetadataPduCreator serializer(pduConf, info);
result = serializer.serialize(&buffer, &sz, mdBuffer.size(), SerializeIF::Endianness::NETWORK);
REQUIRE(result == HasReturnvaluesIF::RETURN_OK);
MetadataPduDeserializer deserializer(mdBuffer.data(), mdBuffer.size(), info);
MetadataPduReader deserializer(mdBuffer.data(), mdBuffer.size(), info);
result = deserializer.parseData();
REQUIRE(result == HasReturnvaluesIF::RETURN_OK);
size_t fullSize = deserializer.getWholePduSize();
for (size_t maxSz = 0; maxSz < fullSize; maxSz++) {
MetadataPduDeserializer invalidSzDeser(mdBuffer.data(), maxSz, info);
MetadataPduReader invalidSzDeser(mdBuffer.data(), maxSz, info);
result = invalidSzDeser.parseData();
REQUIRE(result != HasReturnvaluesIF::RETURN_OK);
}
size_t sizeOfOptions = options.size();
size_t maxSize = 4;
info.setOptionsArray(options.data(), &sizeOfOptions, &maxSize);
info.setOptionsArray(reinterpret_cast<Tlv*>(options.data()), &sizeOfOptions, &maxSize);
REQUIRE(info.getOptionsLen() == 2);
info.setChecksumType(cfdp::ChecksumType::CRC_32C);
info.setClosureRequested(true);
@ -142,7 +142,7 @@ TEST_CASE("Metadata PDU", "[cfdp][pdu]") {
result = serializer.serialize(&buffer, &sz, mdBuffer.size(), SerializeIF::Endianness::NETWORK);
REQUIRE(result == HasReturnvaluesIF::RETURN_OK);
MetadataPduDeserializer deserializer2(mdBuffer.data(), mdBuffer.size(), info);
MetadataPduReader deserializer2(mdBuffer.data(), mdBuffer.size(), info);
result = deserializer2.parseData();
REQUIRE(result == HasReturnvaluesIF::RETURN_OK);
REQUIRE(options[0]->getType() == cfdp::TlvTypes::FILESTORE_RESPONSE);
@ -169,9 +169,9 @@ TEST_CASE("Metadata PDU", "[cfdp][pdu]") {
mdBuffer[2] = 36 & 0xff;
info.setOptionsArray(nullptr, nullptr, nullptr);
REQUIRE(deserializer2.parseData() == cfdp::METADATA_CANT_PARSE_OPTIONS);
info.setOptionsArray(options.data(), &sizeOfOptions, nullptr);
info.setOptionsArray(reinterpret_cast<Tlv*>(options.data()), &sizeOfOptions, nullptr);
for (size_t maxSz = 0; maxSz < 46; maxSz++) {
MetadataPduDeserializer invalidSzDeser(mdBuffer.data(), maxSz, info);
MetadataPduReader invalidSzDeser(mdBuffer.data(), maxSz, info);
result = invalidSzDeser.parseData();
REQUIRE(result == SerializeIF::STREAM_TOO_SHORT);
}

View File

@ -1,5 +1,3 @@
#include <catch2/catch_test_macros.hpp>
TEST_CASE("CFDP Source Handler", "[cfdp]") {
}
TEST_CASE("CFDP Source Handler", "[cfdp]") {}