CFDP FSFW Integration #111
@ -1,5 +1,41 @@
|
|||||||
#include "FaultHandlerBase.h"
|
#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;
|
CfdpFaultHandlerBase::~CfdpFaultHandlerBase() = default;
|
||||||
|
@ -10,8 +10,28 @@ class CfdpFaultHandlerBase {
|
|||||||
virtual ~CfdpFaultHandlerBase();
|
virtual ~CfdpFaultHandlerBase();
|
||||||
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:
|
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,
|
etl::pair{cfdp::ConditionCode::POSITIVE_ACK_LIMIT_REACHED,
|
||||||
cfdp::FaultHandlerCodes::IGNORE_ERROR},
|
cfdp::FaultHandlerCodes::IGNORE_ERROR},
|
||||||
etl::pair{cfdp::ConditionCode::KEEP_ALIVE_LIMIT_REACHED,
|
etl::pair{cfdp::ConditionCode::KEEP_ALIVE_LIMIT_REACHED,
|
||||||
|
@ -6,7 +6,6 @@
|
|||||||
#include <cstddef>
|
#include <cstddef>
|
||||||
#include <cstdint>
|
#include <cstdint>
|
||||||
|
|
||||||
#include "fsfw/cfdp/pdu/PduHeaderIF.h"
|
|
||||||
#include "fsfw/returnvalues/FwClassIds.h"
|
#include "fsfw/returnvalues/FwClassIds.h"
|
||||||
#include "fsfw/returnvalues/HasReturnvaluesIF.h"
|
#include "fsfw/returnvalues/HasReturnvaluesIF.h"
|
||||||
|
|
||||||
@ -134,20 +133,6 @@ enum RecordContinuationState {
|
|||||||
CONTAINS_START_AND_END = 0b11
|
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
|
} // namespace cfdp
|
||||||
|
|
||||||
#endif /* FSFW_SRC_FSFW_CFDP_PDU_DEFINITIONS_H_ */
|
#endif /* FSFW_SRC_FSFW_CFDP_PDU_DEFINITIONS_H_ */
|
||||||
|
19
src/fsfw/cfdp/mib.h
Normal file
19
src/fsfw/cfdp/mib.h
Normal 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
|
@ -1,7 +1,5 @@
|
|||||||
#include "HeaderCreator.h"
|
#include "HeaderCreator.h"
|
||||||
|
|
||||||
#include "HeaderReader.h"
|
|
||||||
|
|
||||||
HeaderCreator::HeaderCreator(PduConfig &pduConf, cfdp::PduType pduType, size_t initPduDataFieldLen,
|
HeaderCreator::HeaderCreator(PduConfig &pduConf, cfdp::PduType pduType, size_t initPduDataFieldLen,
|
||||||
cfdp::SegmentMetadataFlag segmentMetadataFlag,
|
cfdp::SegmentMetadataFlag segmentMetadataFlag,
|
||||||
cfdp::SegmentationControl segCtrl)
|
cfdp::SegmentationControl segCtrl)
|
||||||
|
@ -1,9 +1,9 @@
|
|||||||
#ifndef FSFW_SRC_FSFW_CFDP_PDU_HEADERSERIALIZER_H_
|
#ifndef FSFW_SRC_FSFW_CFDP_PDU_HEADERSERIALIZER_H_
|
||||||
#define FSFW_SRC_FSFW_CFDP_PDU_HEADERSERIALIZER_H_
|
#define FSFW_SRC_FSFW_CFDP_PDU_HEADERSERIALIZER_H_
|
||||||
|
|
||||||
#include "../definitions.h"
|
|
||||||
#include "PduConfig.h"
|
#include "PduConfig.h"
|
||||||
#include "PduHeaderIF.h"
|
#include "PduHeaderIF.h"
|
||||||
|
#include "fsfw/cfdp/definitions.h"
|
||||||
#include "fsfw/serialize/SerializeIF.h"
|
#include "fsfw/serialize/SerializeIF.h"
|
||||||
|
|
||||||
class HeaderCreator : public SerializeIF, public PduHeaderIF {
|
class HeaderCreator : public SerializeIF, public PduHeaderIF {
|
||||||
@ -23,7 +23,7 @@ class HeaderCreator : public SerializeIF, public PduHeaderIF {
|
|||||||
* data field length was not properly.
|
* data field length was not properly.
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
size_t getSerializedSize() const override;
|
[[nodiscard]] size_t getSerializedSize() const override;
|
||||||
|
|
||||||
ReturnValue_t deSerialize(const uint8_t** buffer, size_t* size,
|
ReturnValue_t deSerialize(const uint8_t** buffer, size_t* size,
|
||||||
Endianness streamEndianness) override;
|
Endianness streamEndianness) override;
|
||||||
@ -32,19 +32,19 @@ class HeaderCreator : public SerializeIF, public PduHeaderIF {
|
|||||||
void setPduType(cfdp::PduType pduType);
|
void setPduType(cfdp::PduType pduType);
|
||||||
void setSegmentMetadataFlag(cfdp::SegmentMetadataFlag);
|
void setSegmentMetadataFlag(cfdp::SegmentMetadataFlag);
|
||||||
|
|
||||||
size_t getPduDataFieldLen() const override;
|
[[nodiscard]] size_t getPduDataFieldLen() const override;
|
||||||
size_t getWholePduSize() const override;
|
[[nodiscard]] size_t getWholePduSize() const override;
|
||||||
|
|
||||||
cfdp::PduType getPduType() const override;
|
[[nodiscard]] cfdp::PduType getPduType() const override;
|
||||||
cfdp::Direction getDirection() const override;
|
[[nodiscard]] cfdp::Direction getDirection() const override;
|
||||||
cfdp::TransmissionModes getTransmissionMode() const override;
|
[[nodiscard]] cfdp::TransmissionModes getTransmissionMode() const override;
|
||||||
bool getCrcFlag() const override;
|
[[nodiscard]] bool getCrcFlag() const override;
|
||||||
bool getLargeFileFlag() const override;
|
[[nodiscard]] bool getLargeFileFlag() const override;
|
||||||
cfdp::SegmentationControl getSegmentationControl() const override;
|
[[nodiscard]] cfdp::SegmentationControl getSegmentationControl() const override;
|
||||||
cfdp::WidthInBytes getLenEntityIds() const override;
|
[[nodiscard]] cfdp::WidthInBytes getLenEntityIds() const override;
|
||||||
cfdp::WidthInBytes getLenSeqNum() const override;
|
[[nodiscard]] cfdp::WidthInBytes getLenSeqNum() const override;
|
||||||
cfdp::SegmentMetadataFlag getSegmentMetadataFlag() const override;
|
[[nodiscard]] cfdp::SegmentMetadataFlag getSegmentMetadataFlag() const override;
|
||||||
bool hasSegmentMetadataFlag() const override;
|
[[nodiscard]] bool hasSegmentMetadataFlag() const override;
|
||||||
void setSegmentationControl(cfdp::SegmentationControl);
|
void setSegmentationControl(cfdp::SegmentationControl);
|
||||||
|
|
||||||
void getSourceId(cfdp::EntityId& sourceId) const override;
|
void getSourceId(cfdp::EntityId& sourceId) const override;
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
#ifndef FSFW_SRC_FSFW_CFDP_PDU_PDUCONFIG_H_
|
#ifndef FSFW_SRC_FSFW_CFDP_PDU_PDUCONFIG_H_
|
||||||
#define FSFW_SRC_FSFW_CFDP_PDU_PDUCONFIG_H_
|
#define FSFW_SRC_FSFW_CFDP_PDU_PDUCONFIG_H_
|
||||||
|
|
||||||
|
#include "fsfw/cfdp/definitions.h"
|
||||||
#include "VarLenField.h"
|
#include "VarLenField.h"
|
||||||
|
|
||||||
namespace cfdp {
|
namespace cfdp {
|
||||||
@ -21,7 +22,7 @@ struct TransactionSeqNum : public VarLenField {
|
|||||||
TransactionSeqNum(cfdp::WidthInBytes width, size_t seqNum) : VarLenField(width, seqNum) {}
|
TransactionSeqNum(cfdp::WidthInBytes width, size_t seqNum) : VarLenField(width, seqNum) {}
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace cfdp
|
}
|
||||||
|
|
||||||
class PduConfig {
|
class PduConfig {
|
||||||
public:
|
public:
|
||||||
|
@ -3,8 +3,8 @@
|
|||||||
|
|
||||||
#include <cstddef>
|
#include <cstddef>
|
||||||
|
|
||||||
#include "../definitions.h"
|
|
||||||
#include "PduConfig.h"
|
#include "PduConfig.h"
|
||||||
|
#include "fsfw/cfdp/definitions.h"
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Generic interface to access all fields of a PDU header
|
* @brief Generic interface to access all fields of a PDU header
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
#include "VarLenField.h"
|
#include "VarLenField.h"
|
||||||
|
|
||||||
#include "fsfw/FSFW.h"
|
|
||||||
#include "fsfw/serialize/SerializeAdapter.h"
|
#include "fsfw/serialize/SerializeAdapter.h"
|
||||||
#include "fsfw/serviceinterface.h"
|
#include "fsfw/serviceinterface.h"
|
||||||
|
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
#ifndef FSFW_SRC_FSFW_CFDP_PDU_VARLENFIELD_H_
|
#ifndef FSFW_CFDP_PDU_VARLENFIELD_H_
|
||||||
#define FSFW_SRC_FSFW_CFDP_PDU_VARLENFIELD_H_
|
#define FSFW_CFDP_PDU_VARLENFIELD_H_
|
||||||
|
|
||||||
#include <cstddef>
|
#include <cstddef>
|
||||||
#include <cstdint>
|
#include <cstdint>
|
||||||
@ -7,6 +7,7 @@
|
|||||||
#include "fsfw/cfdp/definitions.h"
|
#include "fsfw/cfdp/definitions.h"
|
||||||
#include "fsfw/serialize/SerializeIF.h"
|
#include "fsfw/serialize/SerializeIF.h"
|
||||||
#include "fsfw/util/UnsignedByteField.h"
|
#include "fsfw/util/UnsignedByteField.h"
|
||||||
|
|
||||||
namespace cfdp {
|
namespace cfdp {
|
||||||
|
|
||||||
class VarLenField : public SerializeIF {
|
class VarLenField : public SerializeIF {
|
||||||
@ -21,6 +22,7 @@ class VarLenField : public SerializeIF {
|
|||||||
VarLenField();
|
VarLenField();
|
||||||
template <typename T>
|
template <typename T>
|
||||||
explicit VarLenField(UnsignedByteField<T> byteField);
|
explicit VarLenField(UnsignedByteField<T> byteField);
|
||||||
|
|
||||||
VarLenField(cfdp::WidthInBytes width, size_t value);
|
VarLenField(cfdp::WidthInBytes width, size_t value);
|
||||||
|
|
||||||
bool operator==(const VarLenField &other) const;
|
bool operator==(const VarLenField &other) const;
|
||||||
@ -49,11 +51,11 @@ class VarLenField : public SerializeIF {
|
|||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
cfdp::VarLenField::VarLenField(UnsignedByteField<T> byteField)
|
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);
|
static_assert((sizeof(T) % 2) == 0);
|
||||||
setValue(width, byteField.getValue());
|
setValue(width, byteField.getValue());
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace cfdp
|
} // namespace cfdp
|
||||||
|
|
||||||
#endif /* FSFW_SRC_FSFW_CFDP_PDU_VARLENFIELD_H_ */
|
#endif /* FSFW_CFDP_PDU_VARLENFIELD_H_ */
|
||||||
|
Loading…
x
Reference in New Issue
Block a user