some API improvements

This commit is contained in:
Robin Müller 2022-09-08 11:26:17 +02:00
parent 683cf8a047
commit c87667c03f
No known key found for this signature in database
GPG Key ID: 71B58F8A3CDFA9AC
13 changed files with 42 additions and 29 deletions

View File

@ -49,7 +49,7 @@ enum ChecksumTypes {
NULL_CHECKSUM = 15
};
enum PduType : uint8_t { FILE_DIRECTIVE = 0, FILE_DATA = 1 };
enum PduTypes : uint8_t { FILE_DIRECTIVE = 0, FILE_DATA = 1 };
enum TransmissionModes : uint8_t { ACKNOWLEDGED = 0, UNACKNOWLEDGED = 1 };

View File

@ -29,7 +29,7 @@ const cfdp::DestHandler::FsmResult& cfdp::DestHandler::performStateMachine() {
fsmRes.resetOfIteration();
if (fsmRes.step == TransactionStep::IDLE) {
for (auto infoIter = dp.packetListRef.begin(); infoIter != dp.packetListRef.end();) {
if (infoIter->pduType == PduType::FILE_DIRECTIVE and
if (infoIter->pduType == PduTypes::FILE_DIRECTIVE and
infoIter->directiveType == FileDirectives::METADATA) {
result = handleMetadataPdu(*infoIter);
checkAndHandleError(result, errorIdx);
@ -57,12 +57,12 @@ const cfdp::DestHandler::FsmResult& cfdp::DestHandler::performStateMachine() {
if (fsmRes.state == CfdpStates::BUSY_CLASS_1_NACKED) {
if (fsmRes.step == TransactionStep::RECEIVING_FILE_DATA_PDUS) {
for (auto infoIter = dp.packetListRef.begin(); infoIter != dp.packetListRef.end();) {
if (infoIter->pduType == PduType::FILE_DATA) {
if (infoIter->pduType == PduTypes::FILE_DATA) {
result = handleFileDataPdu(*infoIter);
checkAndHandleError(result, errorIdx);
// Store data was deleted in PDU handler because a store guard is used
dp.packetListRef.erase(infoIter++);
} else if (infoIter->pduType == PduType::FILE_DIRECTIVE and
} else if (infoIter->pduType == PduTypes::FILE_DIRECTIVE and
infoIter->directiveType == FileDirectives::EOF_DIRECTIVE) {
// TODO: Support for check timer missing
result = handleEofPdu(*infoIter);
@ -463,3 +463,6 @@ void cfdp::DestHandler::setEventReporter(EventReportingProxyIF& reporter) {
}
const cfdp::DestHandlerParams& cfdp::DestHandler::getDestHandlerParams() const { return dp; }
StorageManagerIF* cfdp::DestHandler::getTmStore() const { return fp.tcStore; }
StorageManagerIF* cfdp::DestHandler::getTcStore() const { return fp.tmStore; }

View File

@ -21,11 +21,11 @@
namespace cfdp {
struct PacketInfo {
PacketInfo(PduType type, store_address_t storeId,
PacketInfo(PduTypes type, store_address_t storeId,
std::optional<FileDirectives> directive = std::nullopt)
: pduType(type), directiveType(directive), storeId(storeId) {}
PduType pduType = PduType::FILE_DATA;
PduTypes pduType = PduTypes::FILE_DATA;
std::optional<FileDirectives> directiveType = FileDirectives::INVALID_DIRECTIVE;
store_address_t storeId = store_address_t::invalid();
PacketInfo() = default;
@ -62,6 +62,14 @@ struct DestHandlerParams {
};
struct FsfwParams {
FsfwParams(AcceptsTelemetryIF& packetDest, MessageQueueIF* msgQueue,
EventReportingProxyIF* eventReporter, StorageManagerIF& tcStore, StorageManagerIF& tmStore)
: FsfwParams(packetDest, msgQueue, eventReporter) {
this->tcStore = &tcStore;
this->tmStore = &tmStore;
}
FsfwParams(AcceptsTelemetryIF& packetDest, MessageQueueIF* msgQueue,
EventReportingProxyIF* eventReporter)
: packetDest(packetDest), msgQueue(msgQueue), eventReporter(eventReporter) {}
@ -127,6 +135,8 @@ class DestHandler {
[[nodiscard]] TransactionStep getTransactionStep() const;
[[nodiscard]] const TransactionId& getTransactionId() const;
[[nodiscard]] const DestHandlerParams& getDestHandlerParams() const;
[[nodiscard]] StorageManagerIF* getTcStore() const;
[[nodiscard]] StorageManagerIF* getTmStore() const;
private:
struct TransactionParams {

View File

@ -3,7 +3,7 @@
#include <cstring>
FileDataCreator::FileDataCreator(PduConfig& conf, FileDataInfo& info)
: HeaderCreator(conf, cfdp::PduType::FILE_DATA, 0, info.getSegmentMetadataFlag()), info(info) {
: HeaderCreator(conf, cfdp::PduTypes::FILE_DATA, 0, info.getSegmentMetadataFlag()), info(info) {
update();
}

View File

@ -2,7 +2,7 @@
FileDirectiveCreator::FileDirectiveCreator(PduConfig &pduConf, cfdp::FileDirectives directiveCode,
size_t directiveParamFieldLen)
: HeaderCreator(pduConf, cfdp::PduType::FILE_DIRECTIVE, directiveParamFieldLen + 1),
: HeaderCreator(pduConf, cfdp::PduTypes::FILE_DIRECTIVE, directiveParamFieldLen + 1),
directiveCode(directiveCode) {}
size_t FileDirectiveCreator::getSerializedSize() const {

View File

@ -1,6 +1,6 @@
#include "HeaderCreator.h"
HeaderCreator::HeaderCreator(PduConfig &pduConf, cfdp::PduType pduType, size_t initPduDataFieldLen,
HeaderCreator::HeaderCreator(PduConfig &pduConf, cfdp::PduTypes pduType, size_t initPduDataFieldLen,
cfdp::SegmentMetadataFlag segmentMetadataFlag,
cfdp::SegmentationControl segCtrl)
: pduType(pduType),
@ -65,13 +65,13 @@ void HeaderCreator::setPduDataFieldLen(size_t pduDataFieldLen_) {
pduDataFieldLen = pduDataFieldLen_;
}
void HeaderCreator::setPduType(cfdp::PduType pduType_) { pduType = pduType_; }
void HeaderCreator::setPduType(cfdp::PduTypes pduType_) { pduType = pduType_; }
void HeaderCreator::setSegmentMetadataFlag(cfdp::SegmentMetadataFlag segmentMetadataFlag_) {
segmentMetadataFlag = segmentMetadataFlag_;
}
cfdp::PduType HeaderCreator::getPduType() const { return pduType; }
cfdp::PduTypes HeaderCreator::getPduType() const { return pduType; }
cfdp::Direction HeaderCreator::getDirection() const { return pduConf.direction; }

View File

@ -9,7 +9,7 @@
class HeaderCreator : public SerializeIF, public PduHeaderIF {
public:
HeaderCreator(
PduConfig& pduConf, cfdp::PduType pduType, size_t initPduDataFieldLen,
PduConfig& pduConf, cfdp::PduTypes pduType, size_t initPduDataFieldLen,
cfdp::SegmentMetadataFlag segmentMetadataFlag = cfdp::SegmentMetadataFlag::NOT_PRESENT,
cfdp::SegmentationControl segCtrl =
cfdp::SegmentationControl::NO_RECORD_BOUNDARIES_PRESERVATION);
@ -29,13 +29,13 @@ class HeaderCreator : public SerializeIF, public PduHeaderIF {
Endianness streamEndianness) override;
void setPduDataFieldLen(size_t pduDataFieldLen);
void setPduType(cfdp::PduType pduType);
void setPduType(cfdp::PduTypes pduType);
void setSegmentMetadataFlag(cfdp::SegmentMetadataFlag);
[[nodiscard]] size_t getPduDataFieldLen() const override;
[[nodiscard]] size_t getWholePduSize() const override;
[[nodiscard]] cfdp::PduType getPduType() const override;
[[nodiscard]] cfdp::PduTypes getPduType() const override;
[[nodiscard]] cfdp::Direction getDirection() const override;
[[nodiscard]] cfdp::TransmissionModes getTransmissionMode() const override;
[[nodiscard]] bool getCrcFlag() const override;
@ -52,7 +52,7 @@ class HeaderCreator : public SerializeIF, public PduHeaderIF {
void getTransactionSeqNum(cfdp::TransactionSeqNum& seqNum) const override;
private:
cfdp::PduType pduType;
cfdp::PduTypes pduType;
cfdp::SegmentMetadataFlag segmentMetadataFlag;
cfdp::SegmentationControl segmentationCtrl;
size_t pduDataFieldLen;

View File

@ -57,8 +57,8 @@ size_t PduHeaderReader::getWholePduSize() const {
return getPduDataFieldLen() + PduHeaderReader::getHeaderSize();
}
cfdp::PduType PduHeaderReader::getPduType() const {
return static_cast<cfdp::PduType>((pointers.fixedHeader->firstByte >> 4) & 0x01);
cfdp::PduTypes PduHeaderReader::getPduType() const {
return static_cast<cfdp::PduTypes>((pointers.fixedHeader->firstByte >> 4) & 0x01);
}
cfdp::Direction PduHeaderReader::getDirection() const {

View File

@ -17,7 +17,7 @@ class PduHeaderIF {
[[nodiscard]] virtual size_t getWholePduSize() const = 0;
[[nodiscard]] virtual size_t getPduDataFieldLen() const = 0;
[[nodiscard]] virtual cfdp::PduType getPduType() const = 0;
[[nodiscard]] virtual cfdp::PduTypes getPduType() const = 0;
[[nodiscard]] virtual cfdp::Direction getDirection() const = 0;
[[nodiscard]] virtual cfdp::TransmissionModes getTransmissionMode() const = 0;
[[nodiscard]] virtual bool getCrcFlag() const = 0;

View File

@ -56,7 +56,7 @@ class PduHeaderReader : public RedirectableDataPointerIF, public PduHeaderIF {
[[nodiscard]] size_t getPduDataFieldLen() const override;
[[nodiscard]] size_t getWholePduSize() const override;
[[nodiscard]] cfdp::PduType getPduType() const override;
[[nodiscard]] cfdp::PduTypes getPduType() const override;
[[nodiscard]] cfdp::Direction getDirection() const override;
[[nodiscard]] cfdp::TransmissionModes getTransmissionMode() const override;
[[nodiscard]] bool getCrcFlag() const override;

View File

@ -21,7 +21,7 @@ TEST_CASE("CFDP Header", "[cfdp]") {
uint8_t* serTarget = serBuf.data();
const uint8_t* deserTarget = serTarget;
size_t serSize = 0;
auto creator = HeaderCreator(pduConf, cfdp::PduType::FILE_DIRECTIVE, 0);
auto creator = HeaderCreator(pduConf, cfdp::PduTypes::FILE_DIRECTIVE, 0);
SECTION("Header State") {
REQUIRE(seqNum.getSerializedSize() == 1);
@ -33,7 +33,7 @@ TEST_CASE("CFDP Header", "[cfdp]") {
REQUIRE(creator.getLargeFileFlag() == false);
REQUIRE(creator.getLenEntityIds() == 1);
REQUIRE(creator.getLenSeqNum() == 1);
REQUIRE(creator.getPduType() == cfdp::PduType::FILE_DIRECTIVE);
REQUIRE(creator.getPduType() == cfdp::PduTypes::FILE_DIRECTIVE);
REQUIRE(creator.getSegmentMetadataFlag() == cfdp::SegmentMetadataFlag::NOT_PRESENT);
REQUIRE(creator.getSegmentationControl() == false);
REQUIRE(creator.getTransmissionMode() == cfdp::TransmissionModes::ACKNOWLEDGED);
@ -87,7 +87,7 @@ TEST_CASE("CFDP Header", "[cfdp]") {
pduConf.direction = cfdp::Direction::TOWARDS_SENDER;
pduConf.mode = cfdp::TransmissionModes::UNACKNOWLEDGED;
creator.setSegmentationControl(cfdp::SegmentationControl::RECORD_BOUNDARIES_PRESERVATION);
creator.setPduType(cfdp::PduType::FILE_DATA);
creator.setPduType(cfdp::PduTypes::FILE_DATA);
creator.setSegmentMetadataFlag(cfdp::SegmentMetadataFlag::PRESENT);
serTarget = serBuf.data();
serSize = 0;
@ -103,7 +103,7 @@ TEST_CASE("CFDP Header", "[cfdp]") {
REQUIRE(creator.getLargeFileFlag() == true);
REQUIRE(creator.getLenEntityIds() == 1);
REQUIRE(creator.getLenSeqNum() == 1);
REQUIRE(creator.getPduType() == cfdp::PduType::FILE_DATA);
REQUIRE(creator.getPduType() == cfdp::PduTypes::FILE_DATA);
REQUIRE(creator.getSegmentMetadataFlag() == cfdp::SegmentMetadataFlag::PRESENT);
REQUIRE(creator.getTransmissionMode() == cfdp::TransmissionModes::UNACKNOWLEDGED);
REQUIRE(creator.getSegmentationControl() == true);
@ -122,7 +122,7 @@ TEST_CASE("CFDP Header", "[cfdp]") {
REQUIRE(creator.getLargeFileFlag() == true);
REQUIRE(creator.getLenEntityIds() == 4);
REQUIRE(creator.getLenSeqNum() == 2);
REQUIRE(creator.getPduType() == cfdp::PduType::FILE_DATA);
REQUIRE(creator.getPduType() == cfdp::PduTypes::FILE_DATA);
REQUIRE(creator.getSegmentMetadataFlag() == cfdp::SegmentMetadataFlag::PRESENT);
REQUIRE(creator.getTransmissionMode() == cfdp::TransmissionModes::UNACKNOWLEDGED);
REQUIRE(creator.getSegmentationControl() == true);
@ -235,7 +235,7 @@ TEST_CASE("CFDP Header", "[cfdp]") {
REQUIRE(reader.getLargeFileFlag() == false);
REQUIRE(reader.getLenEntityIds() == 1);
REQUIRE(reader.getLenSeqNum() == 1);
REQUIRE(reader.getPduType() == cfdp::PduType::FILE_DIRECTIVE);
REQUIRE(reader.getPduType() == cfdp::PduTypes::FILE_DIRECTIVE);
REQUIRE(reader.getSegmentMetadataFlag() == cfdp::SegmentMetadataFlag::NOT_PRESENT);
REQUIRE(reader.getSegmentationControl() == false);
REQUIRE(reader.getTransmissionMode() == cfdp::TransmissionModes::ACKNOWLEDGED);
@ -255,7 +255,7 @@ TEST_CASE("CFDP Header", "[cfdp]") {
pduConf.direction = cfdp::Direction::TOWARDS_SENDER;
pduConf.mode = cfdp::TransmissionModes::UNACKNOWLEDGED;
creator.setSegmentationControl(cfdp::SegmentationControl::RECORD_BOUNDARIES_PRESERVATION);
creator.setPduType(cfdp::PduType::FILE_DATA);
creator.setPduType(cfdp::PduTypes::FILE_DATA);
creator.setSegmentMetadataFlag(cfdp::SegmentMetadataFlag::PRESENT);
result = pduConf.seqNum.setValue(cfdp::WidthInBytes::TWO_BYTES, 0x0fff);
REQUIRE(result == returnvalue::OK);
@ -278,7 +278,7 @@ TEST_CASE("CFDP Header", "[cfdp]") {
REQUIRE(reader.getLargeFileFlag() == true);
REQUIRE(reader.getLenEntityIds() == 4);
REQUIRE(reader.getLenSeqNum() == 2);
REQUIRE(reader.getPduType() == cfdp::PduType::FILE_DATA);
REQUIRE(reader.getPduType() == cfdp::PduTypes::FILE_DATA);
REQUIRE(reader.getSegmentMetadataFlag() == cfdp::SegmentMetadataFlag::PRESENT);
REQUIRE(reader.getSegmentationControl() == true);
REQUIRE(reader.getTransmissionMode() == cfdp::TransmissionModes::UNACKNOWLEDGED);

View File

@ -76,7 +76,7 @@ TEST_CASE("CFDP File Directive", "[cfdp][pdu]") {
REQUIRE(fdDeser.getFileDirective() == FileDirectives::ACK);
REQUIRE(fdDeser.getPduDataFieldLen() == 5);
REQUIRE(fdDeser.getHeaderSize() == 8);
REQUIRE(fdDeser.getPduType() == cfdp::PduType::FILE_DIRECTIVE);
REQUIRE(fdDeser.getPduType() == cfdp::PduTypes::FILE_DIRECTIVE);
serBuf[7] = 0xff;
// Invalid file directive

View File

@ -68,7 +68,7 @@ TEST_CASE("CFDP Base", "[cfdp]") {
REQUIRE(fdDeser.getFileDirective() == FileDirectives::ACK);
REQUIRE(fdDeser.getPduDataFieldLen() == 5);
REQUIRE(fdDeser.getHeaderSize() == 8);
REQUIRE(fdDeser.getPduType() == cfdp::PduType::FILE_DIRECTIVE);
REQUIRE(fdDeser.getPduType() == cfdp::PduTypes::FILE_DIRECTIVE);
serBuf[7] = 0xff;
// Invalid file directive