some internal state handling

This commit is contained in:
Robin Müller 2023-07-17 15:03:08 +02:00
parent 972dc7e19e
commit 8fcc4eab60
Signed by: muellerr
GPG Key ID: 407F9B00F858F270
2 changed files with 20 additions and 6 deletions

View File

@ -26,6 +26,7 @@ void cfdp::SourceHandler::fsmNacked() {
if (result != OK) { if (result != OK) {
// TODO: Some error handling // TODO: Some error handling
} }
step = TransactionStep::SENDING_METADATA;
} }
if (step == TransactionStep::SENDING_METADATA) { if (step == TransactionStep::SENDING_METADATA) {
// TODO: Prepare and send metadata PDU // TODO: Prepare and send metadata PDU
@ -83,9 +84,18 @@ ReturnValue_t cfdp::SourceHandler::checksumGeneration() {
} }
ReturnValue_t cfdp::SourceHandler::putRequest(PutRequestFull& putRequest, RemoteEntityCfg& cfg) { ReturnValue_t cfdp::SourceHandler::putRequest(PutRequestFull& putRequest, RemoteEntityCfg& cfg) {
if (state != CfdpState::IDLE) {
return SOURCE_TRANSACTION_PENDING;
}
transactionParams.closureRequested = putRequest.closureRequested; transactionParams.closureRequested = putRequest.closureRequested;
transactionParams.destId = putRequest.destId; transactionParams.destId = putRequest.destId;
transactionParams.transmissionMode = putRequest.transmissionMode; transactionParams.transmissionMode = putRequest.transmissionMode;
if (transactionParams.transmissionMode == TransmissionMode::ACKNOWLEDGED) {
state = cfdp::CfdpState::BUSY_CLASS_2_ACKED;
} else if (transactionParams.transmissionMode == TransmissionMode::UNACKNOWLEDGED) {
state = cfdp::CfdpState::BUSY_CLASS_1_NACKED;
}
step = TransactionStep::IDLE;
if (transactionParams.transmissionMode == TransmissionMode::ACKNOWLEDGED) { if (transactionParams.transmissionMode == TransmissionMode::ACKNOWLEDGED) {
} }
if (putRequest.sourceNameSize > transactionParams.sourceName.size()) { if (putRequest.sourceNameSize > transactionParams.sourceName.size()) {

View File

@ -12,6 +12,7 @@ namespace cfdp {
enum class CfdpState { IDLE, BUSY_CLASS_1_NACKED, BUSY_CLASS_2_ACKED, SUSPENDED }; enum class CfdpState { IDLE, BUSY_CLASS_1_NACKED, BUSY_CLASS_2_ACKED, SUSPENDED };
static constexpr uint8_t SSID = SUBSYSTEM_ID::CFDP; static constexpr uint8_t SSID = SUBSYSTEM_ID::CFDP;
static constexpr uint8_t CID = CLASS_ID::CFDP;
struct PacketInfo { struct PacketInfo {
PacketInfo(PduType type, store_address_t storeId, PacketInfo(PduType type, store_address_t storeId,
@ -48,13 +49,14 @@ using PacketInfoList = etl::list<PacketInfo, SIZE>;
using PacketInfoListBase = etl::ilist<PacketInfo>; using PacketInfoListBase = etl::ilist<PacketInfo>;
struct PutRequestFull { struct PutRequestFull {
public:
EntityId destId; EntityId destId;
TransmissionMode transmissionMode; TransmissionMode transmissionMode = TransmissionMode::UNACKNOWLEDGED;
char destName[524]; char destName[524]{};
size_t destNameSize; size_t destNameSize = 0;
char sourceName[524]; char sourceName[524]{};
size_t sourceNameSize; size_t sourceNameSize = 0;
bool closureRequested; bool closureRequested = true;
}; };
namespace events { namespace events {
@ -68,5 +70,7 @@ static constexpr Event FILENAME_TOO_LARGE_ERROR = event::makeEvent(SSID, 4, seve
} // namespace events } // namespace events
static constexpr ReturnValue_t SOURCE_TRANSACTION_PENDING = returnvalue::makeCode(CID, 0);
} // namespace cfdp } // namespace cfdp
#endif // FSFW_CFDP_HANDLER_DEFS_H #endif // FSFW_CFDP_HANDLER_DEFS_H