fnished fault handler base

This commit is contained in:
Robin Müller 2022-08-09 14:39:03 +02:00
parent 7fb906a0ac
commit eccb629ba8
No known key found for this signature in database
GPG Key ID: 71B58F8A3CDFA9AC
10 changed files with 100 additions and 40 deletions

View File

@ -1,5 +1,41 @@
#include "FaultHandlerBase.h"
CfdpFaultHandlerBase::CfdpFaultHandlerBase() {}
CfdpFaultHandlerBase::CfdpFaultHandlerBase() = default;
bool CfdpFaultHandlerBase::getFaultHandler(
cfdp::ConditionCode code, cfdp::FaultHandlerCodes& handler) const {
auto iter = faultHandlerMap.find(code);
if(iter == faultHandlerMap.end()) {
return false;
}
handler = iter->second;
return true;
}
bool CfdpFaultHandlerBase::setFaultHandler(cfdp::ConditionCode code,
cfdp::FaultHandlerCodes handler) {
if (not faultHandlerMap.contains(code)) {
return false;
}
faultHandlerMap[code] = handler;
return true;
}
bool CfdpFaultHandlerBase::faultCallback(cfdp::ConditionCode code) {
if (not faultHandlerMap.contains(code)) {
return false;
}
cfdp::FaultHandlerCodes fh = faultHandlerMap[code];
if (fh == cfdp::FaultHandlerCodes::IGNORE_ERROR) {
ignoreCb(code);
} else if(fh == cfdp::FaultHandlerCodes::ABANDON_TRANSACTION) {
abandonCb(code);
} else if(fh == cfdp::FaultHandlerCodes::NOTICE_OF_CANCELLATION) {
noticeOfCancellationCb(code);
} else {
noticeOfSuspensionCb(code);
}
return true;
}
CfdpFaultHandlerBase::~CfdpFaultHandlerBase() = default;

View File

@ -10,8 +10,28 @@ class CfdpFaultHandlerBase {
virtual ~CfdpFaultHandlerBase();
CfdpFaultHandlerBase();
/**
* Get the fault handler code for the given condition code
* @param code
* @param handler [out] Will be set to the approrpiate handler for the condition code if
* it is valid
* @return
* - true if the condition code is valid
* - false otherwise
*/
bool getFaultHandler(cfdp::ConditionCode code, cfdp::FaultHandlerCodes& handler) const;
bool setFaultHandler(cfdp::ConditionCode code, cfdp::FaultHandlerCodes handler);
bool faultCallback(cfdp::ConditionCode code);
virtual void noticeOfSuspensionCb(cfdp::ConditionCode code) = 0;
virtual void noticeOfCancellationCb(cfdp::ConditionCode code) = 0;
virtual void abandonCb(cfdp::ConditionCode code) = 0;
virtual void ignoreCb(cfdp::ConditionCode code) = 0;
private:
etl::flat_map<cfdp::ConditionCode, cfdp::FaultHandlerCodes, 9> handleMap = {
etl::flat_map<cfdp::ConditionCode, cfdp::FaultHandlerCodes, 9> faultHandlerMap = {
etl::pair{cfdp::ConditionCode::POSITIVE_ACK_LIMIT_REACHED,
cfdp::FaultHandlerCodes::IGNORE_ERROR},
etl::pair{cfdp::ConditionCode::KEEP_ALIVE_LIMIT_REACHED,

View File

@ -6,7 +6,6 @@
#include <cstddef>
#include <cstdint>
#include "fsfw/cfdp/pdu/PduHeaderIF.h"
#include "fsfw/returnvalues/FwClassIds.h"
#include "fsfw/returnvalues/HasReturnvaluesIF.h"
@ -134,20 +133,6 @@ 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_ */

19
src/fsfw/cfdp/mib.h Normal file
View File

@ -0,0 +1,19 @@
#ifndef FSFW_CFDP_MIB_H
#define FSFW_CFDP_MIB_H
struct IndicationCfg {
bool eofSentIndicRequired = true;
bool eofRecvIndicRequired = true;
bool fileSegmentRecvIndicRequired = true;
bool transactionFinishedIndicRequired = true;
bool suspendedIndicRequired = true;
bool resumedIndicRequired = true;
};
struct LocalEntityCfg {
cfdp::EntityId localId;
IndicationCfg indicCfg;
};
#endif // FSFW_CFDP_MIB_H

View File

@ -1,7 +1,5 @@
#include "HeaderCreator.h"
#include "HeaderReader.h"
HeaderCreator::HeaderCreator(PduConfig &pduConf, cfdp::PduType pduType, size_t initPduDataFieldLen,
cfdp::SegmentMetadataFlag segmentMetadataFlag,
cfdp::SegmentationControl segCtrl)

View File

@ -1,9 +1,9 @@
#ifndef FSFW_SRC_FSFW_CFDP_PDU_HEADERSERIALIZER_H_
#define FSFW_SRC_FSFW_CFDP_PDU_HEADERSERIALIZER_H_
#include "../definitions.h"
#include "PduConfig.h"
#include "PduHeaderIF.h"
#include "fsfw/cfdp/definitions.h"
#include "fsfw/serialize/SerializeIF.h"
class HeaderCreator : public SerializeIF, public PduHeaderIF {
@ -23,7 +23,7 @@ class HeaderCreator : public SerializeIF, public PduHeaderIF {
* data field length was not properly.
* @return
*/
size_t getSerializedSize() const override;
[[nodiscard]] size_t getSerializedSize() const override;
ReturnValue_t deSerialize(const uint8_t** buffer, size_t* size,
Endianness streamEndianness) override;
@ -32,19 +32,19 @@ class HeaderCreator : public SerializeIF, public PduHeaderIF {
void setPduType(cfdp::PduType pduType);
void setSegmentMetadataFlag(cfdp::SegmentMetadataFlag);
size_t getPduDataFieldLen() const override;
size_t getWholePduSize() const override;
[[nodiscard]] size_t getPduDataFieldLen() const override;
[[nodiscard]] size_t getWholePduSize() const override;
cfdp::PduType getPduType() const override;
cfdp::Direction getDirection() const override;
cfdp::TransmissionModes getTransmissionMode() const override;
bool getCrcFlag() const override;
bool getLargeFileFlag() const override;
cfdp::SegmentationControl getSegmentationControl() const override;
cfdp::WidthInBytes getLenEntityIds() const override;
cfdp::WidthInBytes getLenSeqNum() const override;
cfdp::SegmentMetadataFlag getSegmentMetadataFlag() const override;
bool hasSegmentMetadataFlag() const override;
[[nodiscard]] cfdp::PduType getPduType() const override;
[[nodiscard]] cfdp::Direction getDirection() const override;
[[nodiscard]] cfdp::TransmissionModes getTransmissionMode() const override;
[[nodiscard]] bool getCrcFlag() const override;
[[nodiscard]] bool getLargeFileFlag() const override;
[[nodiscard]] cfdp::SegmentationControl getSegmentationControl() const override;
[[nodiscard]] cfdp::WidthInBytes getLenEntityIds() const override;
[[nodiscard]] cfdp::WidthInBytes getLenSeqNum() const override;
[[nodiscard]] cfdp::SegmentMetadataFlag getSegmentMetadataFlag() const override;
[[nodiscard]] bool hasSegmentMetadataFlag() const override;
void setSegmentationControl(cfdp::SegmentationControl);
void getSourceId(cfdp::EntityId& sourceId) const override;

View File

@ -1,6 +1,7 @@
#ifndef FSFW_SRC_FSFW_CFDP_PDU_PDUCONFIG_H_
#define FSFW_SRC_FSFW_CFDP_PDU_PDUCONFIG_H_
#include "fsfw/cfdp/definitions.h"
#include "VarLenField.h"
namespace cfdp {
@ -21,7 +22,7 @@ struct TransactionSeqNum : public VarLenField {
TransactionSeqNum(cfdp::WidthInBytes width, size_t seqNum) : VarLenField(width, seqNum) {}
};
} // namespace cfdp
}
class PduConfig {
public:

View File

@ -3,8 +3,8 @@
#include <cstddef>
#include "../definitions.h"
#include "PduConfig.h"
#include "fsfw/cfdp/definitions.h"
/**
* @brief Generic interface to access all fields of a PDU header

View File

@ -1,6 +1,5 @@
#include "VarLenField.h"
#include "fsfw/FSFW.h"
#include "fsfw/serialize/SerializeAdapter.h"
#include "fsfw/serviceinterface.h"

View File

@ -1,5 +1,5 @@
#ifndef FSFW_SRC_FSFW_CFDP_PDU_VARLENFIELD_H_
#define FSFW_SRC_FSFW_CFDP_PDU_VARLENFIELD_H_
#ifndef FSFW_CFDP_PDU_VARLENFIELD_H_
#define FSFW_CFDP_PDU_VARLENFIELD_H_
#include <cstddef>
#include <cstdint>
@ -7,6 +7,7 @@
#include "fsfw/cfdp/definitions.h"
#include "fsfw/serialize/SerializeIF.h"
#include "fsfw/util/UnsignedByteField.h"
namespace cfdp {
class VarLenField : public SerializeIF {
@ -21,6 +22,7 @@ class VarLenField : public SerializeIF {
VarLenField();
template <typename T>
explicit VarLenField(UnsignedByteField<T> byteField);
VarLenField(cfdp::WidthInBytes width, size_t value);
bool operator==(const VarLenField &other) const;
@ -49,11 +51,11 @@ class VarLenField : public SerializeIF {
template <typename T>
cfdp::VarLenField::VarLenField(UnsignedByteField<T> byteField)
: width(static_cast<WidthInBytes>(sizeof(T))) {
: width(static_cast<cfdp::WidthInBytes>(sizeof(T))) {
static_assert((sizeof(T) % 2) == 0);
setValue(width, byteField.getValue());
}
} // namespace cfdp
#endif /* FSFW_SRC_FSFW_CFDP_PDU_VARLENFIELD_H_ */
#endif /* FSFW_CFDP_PDU_VARLENFIELD_H_ */