add first fault handler base class

This commit is contained in:
Robin Müller 2022-08-09 14:05:43 +02:00
parent 0d26a0f54b
commit 7fb906a0ac
No known key found for this signature in database
GPG Key ID: 71B58F8A3CDFA9AC
9 changed files with 86 additions and 31 deletions

View File

@ -1,6 +1,7 @@
target_sources(
${LIB_FSFW_NAME} PRIVATE CfdpMessage.cpp CfdpDistributor.cpp
CfdpSourceHandler.cpp CfdpDestHandler.cpp)
${LIB_FSFW_NAME}
PRIVATE CfdpMessage.cpp CfdpDistributor.cpp CfdpSourceHandler.cpp
CfdpDestHandler.cpp FaultHandlerBase.cpp)
# CfdpDistributor.cpp CfdpHandler.cpp
add_subdirectory(pdu)

View File

@ -1,6 +1,15 @@
#ifndef FSFW_CFDP_CFDPDESTHANDLER_H
#define FSFW_CFDP_CFDPDESTHANDLER_H
class CfdpDestHandler {};
#include <etl/flat_map.h>
#include "fsfw/cfdp/pdu/PduConfig.h"
class CfdpDestHandler {
public:
CfdpDestHandler();
private:
};
#endif // FSFW_CFDP_CFDPDESTHANDLER_H

View File

@ -0,0 +1,5 @@
#include "FaultHandlerBase.h"
CfdpFaultHandlerBase::CfdpFaultHandlerBase() {}
CfdpFaultHandlerBase::~CfdpFaultHandlerBase() = default;

View File

@ -0,0 +1,29 @@
#ifndef FSFW_CFDP_FAULTHANDLERBASE_H
#define FSFW_CFDP_FAULTHANDLERBASE_H
#include <etl/flat_map.h>
#include "definitions.h"
class CfdpFaultHandlerBase {
public:
virtual ~CfdpFaultHandlerBase();
CfdpFaultHandlerBase();
private:
etl::flat_map<cfdp::ConditionCode, cfdp::FaultHandlerCodes, 9> handleMap = {
etl::pair{cfdp::ConditionCode::POSITIVE_ACK_LIMIT_REACHED,
cfdp::FaultHandlerCodes::IGNORE_ERROR},
etl::pair{cfdp::ConditionCode::KEEP_ALIVE_LIMIT_REACHED,
cfdp::FaultHandlerCodes::IGNORE_ERROR},
etl::pair{cfdp::ConditionCode::INVALID_TRANSMISSION_MODE,
cfdp::FaultHandlerCodes::IGNORE_ERROR},
etl::pair{cfdp::ConditionCode::FILE_CHECKSUM_FAILURE, cfdp::FaultHandlerCodes::IGNORE_ERROR},
etl::pair{cfdp::ConditionCode::FILE_SIZE_ERROR, cfdp::FaultHandlerCodes::IGNORE_ERROR},
etl::pair{cfdp::ConditionCode::NAK_LIMIT_REACHED, cfdp::FaultHandlerCodes::IGNORE_ERROR},
etl::pair{cfdp::ConditionCode::INACTIVITY_DETECTED, cfdp::FaultHandlerCodes::IGNORE_ERROR},
etl::pair{cfdp::ConditionCode::UNSUPPORTED_CHECKSUM_TYPE,
cfdp::FaultHandlerCodes::IGNORE_ERROR}};
};
#endif // FSFW_CFDP_FAULTHANDLERBASE_H

View File

@ -6,6 +6,7 @@
#include <cstddef>
#include <cstdint>
#include "fsfw/cfdp/pdu/PduHeaderIF.h"
#include "fsfw/returnvalues/FwClassIds.h"
#include "fsfw/returnvalues/HasReturnvaluesIF.h"
@ -90,6 +91,14 @@ enum ConditionCode : uint8_t {
CANCEL_REQUEST_RECEIVED = 0b1111
};
enum FaultHandlerCodes {
RESERVED = 0b0000,
NOTICE_OF_CANCELLATION = 0b0001,
NOTICE_OF_SUSPENSION = 0b0010,
IGNORE_ERROR = 0b0011,
ABANDON_TRANSACTION = 0b0100
};
enum AckTransactionStatus {
UNDEFINED = 0b00,
ACTIVE = 0b01,
@ -125,6 +134,20 @@ enum RecordContinuationState {
CONTAINS_START_AND_END = 0b11
};
struct IndicationCfg {
bool eofSentIndicRequired = true;
bool eofRecvIndicRequired = true;
bool fileSegmentRecvIndicRequired = true;
bool transactionFinishedIndicRequired = true;
bool suspendedIndicRequired = true;
bool resumedIndicRequired = true;
};
struct LocalEntityCfg {
EntityId localId;
IndicationCfg indicCfg;
};
} // namespace cfdp
#endif /* FSFW_SRC_FSFW_CFDP_PDU_DEFINITIONS_H_ */

View File

@ -11,10 +11,10 @@ class FinishedInfo {
FinishedInfo(cfdp::ConditionCode conditionCode, cfdp::FinishedDeliveryCode deliveryCode,
cfdp::FinishedFileStatus fileStatus);
size_t getSerializedSize() const;
[[nodiscard]] size_t getSerializedSize() const;
bool hasFsResponses() const;
bool canHoldFsResponses() const;
[[nodiscard]] bool hasFsResponses() const;
[[nodiscard]] bool canHoldFsResponses() const;
ReturnValue_t setFilestoreResponsesArray(FilestoreResponseTlv** fsResponses,
size_t* fsResponsesLen, const size_t* maxFsResponseLen);
@ -22,14 +22,14 @@ class FinishedInfo {
ReturnValue_t getFilestoreResonses(FilestoreResponseTlv*** fsResponses, size_t* fsResponsesLen,
size_t* fsResponsesMaxLen);
size_t getFsResponsesLen() const;
[[nodiscard]] size_t getFsResponsesLen() const;
void setFilestoreResponsesArrayLen(size_t fsResponsesLen);
ReturnValue_t getFaultLocation(EntityIdTlv** entityId);
cfdp::ConditionCode getConditionCode() const;
[[nodiscard]] cfdp::ConditionCode getConditionCode() const;
void setConditionCode(cfdp::ConditionCode conditionCode);
cfdp::FinishedDeliveryCode getDeliveryCode() const;
[[nodiscard]] cfdp::FinishedDeliveryCode getDeliveryCode() const;
void setDeliveryCode(cfdp::FinishedDeliveryCode deliveryCode);
cfdp::FinishedFileStatus getFileStatus() const;
[[nodiscard]] cfdp::FinishedFileStatus getFileStatus() const;
void setFileStatus(cfdp::FinishedFileStatus fileStatus);
private:

View File

@ -1,10 +1,10 @@
#include "FaultHandlerOverrideTlv.h"
FaultHandlerOverrideTlv::FaultHandlerOverrideTlv(cfdp::ConditionCode conditionCode,
cfdp::FaultHandlerCode handlerCode)
cfdp::FaultHandlerCodes handlerCode)
: conditionCode(conditionCode), handlerCode(handlerCode) {}
FaultHandlerOverrideTlv::FaultHandlerOverrideTlv() {}
FaultHandlerOverrideTlv::FaultHandlerOverrideTlv() = default;
uint8_t FaultHandlerOverrideTlv::getLengthField() const { return 1; }
@ -45,7 +45,7 @@ ReturnValue_t FaultHandlerOverrideTlv::deSerialize(const uint8_t **buffer, size_
*buffer += 1;
*size += 1;
this->conditionCode = static_cast<cfdp::ConditionCode>((**buffer >> 4) & 0x0f);
this->handlerCode = static_cast<cfdp::FaultHandlerCode>(**buffer & 0x0f);
this->handlerCode = static_cast<cfdp::FaultHandlerCodes>(**buffer & 0x0f);
*buffer += 1;
*size += 1;
return HasReturnvaluesIF::RETURN_OK;

View File

@ -3,36 +3,24 @@
#include "TlvIF.h"
namespace cfdp {
enum FaultHandlerCode {
RESERVED = 0b0000,
NOTICE_OF_CANCELLATION = 0b0001,
NOTICE_OF_SUSPENSION = 0b0010,
IGNORE_ERROR = 0b0011,
ABANDON_TRANSACTION = 0b0100
};
}
class FaultHandlerOverrideTlv : public TlvIF {
public:
FaultHandlerOverrideTlv();
FaultHandlerOverrideTlv(cfdp::ConditionCode conditionCode, cfdp::FaultHandlerCode handlerCode);
FaultHandlerOverrideTlv(cfdp::ConditionCode conditionCode, cfdp::FaultHandlerCodes handlerCode);
ReturnValue_t serialize(uint8_t **buffer, size_t *size, size_t maxSize,
Endianness streamEndianness) const override;
size_t getSerializedSize() const override;
[[nodiscard]] size_t getSerializedSize() const override;
ReturnValue_t deSerialize(const uint8_t **buffer, size_t *size,
Endianness streamEndianness) override;
uint8_t getLengthField() const override;
cfdp::TlvTypes getType() const override;
[[nodiscard]] uint8_t getLengthField() const override;
[[nodiscard]] cfdp::TlvTypes getType() const override;
private:
cfdp::ConditionCode conditionCode = cfdp::ConditionCode::NO_CONDITION_FIELD;
cfdp::FaultHandlerCode handlerCode = cfdp::FaultHandlerCode::RESERVED;
cfdp::FaultHandlerCodes handlerCode = cfdp::FaultHandlerCodes::RESERVED;
};
#endif /* FSFW_SRC_FSFW_CFDP_TLV_FAULTHANDLEROVERRIDETLV_H_ */

View File

@ -304,7 +304,7 @@ TEST_CASE("CFDP TLV LV", "[cfdp]") {
FlowLabelTlv flowLabelTlv(&flowLabel, 1);
FaultHandlerOverrideTlv faultOverrideTlv(cfdp::ConditionCode::FILESTORE_REJECTION,
cfdp::FaultHandlerCode::NOTICE_OF_CANCELLATION);
cfdp::FaultHandlerCodes::NOTICE_OF_CANCELLATION);
size_t sz = 0;
result =
faultOverrideTlv.serialize(&serPtr, &sz, rawBuf.size(), SerializeIF::Endianness::NETWORK);