a list should do the job
fsfw/fsfw/pipeline/pr-development This commit looks good Details

This commit is contained in:
Robin Müller 2022-08-17 18:49:51 +02:00
parent 6930656d4e
commit 11a699c3ce
No known key found for this signature in database
GPG Key ID: 11D4952C8CCEF814
5 changed files with 109 additions and 11 deletions

View File

@ -2,6 +2,51 @@
#include <utility>
cfdp::DestHandler::DestHandler(LocalEntityCfg cfg, UserBase& user,
RemoteConfigTableIF& remoteCfgTable)
: cfg(std::move(cfg)), user(user), remoteCfgTable(remoteCfgTable) {}
#include "fsfw/objectmanager.h"
cfdp::DestHandler::DestHandler(DestHandlerParams params) : p(std::move(params)) {}
ReturnValue_t cfdp::DestHandler::performStateMachine() {
switch (step) {
case TransactionStep::IDLE: {
for (const auto& info : p.packetListRef) {
}
}
case TransactionStep::TRANSACTION_START:
break;
case TransactionStep::RECEIVING_FILE_DATA_PDUS:
break;
case TransactionStep::SENDING_ACK_PDU:
break;
case TransactionStep::TRANSFER_COMPLETION:
break;
case TransactionStep::SENDING_FINISHED_PDU:
break;
}
return HasReturnvaluesIF::RETURN_OK;
}
ReturnValue_t cfdp::DestHandler::passPacket(PacketInfo packet) {
if (p.packetListRef.full()) {
return HasReturnvaluesIF::RETURN_FAILED;
}
p.packetListRef.push_back(packet);
return HasReturnvaluesIF::RETURN_OK;
}
ReturnValue_t cfdp::DestHandler::initialize() {
if (p.tmStore == nullptr) {
p.tmStore = ObjectManager::instance()->get<StorageManagerIF>(objects::TM_STORE);
if (p.tmStore == nullptr) {
return HasReturnvaluesIF::RETURN_FAILED;
}
}
if (p.tcStore == nullptr) {
p.tcStore = ObjectManager::instance()->get<StorageManagerIF>(objects::TC_STORE);
if (p.tcStore == nullptr) {
return HasReturnvaluesIF::RETURN_FAILED;
}
}
return HasReturnvaluesIF::RETURN_OK;
}

View File

@ -1,21 +1,73 @@
#ifndef FSFW_CFDP_CFDPDESTHANDLER_H
#define FSFW_CFDP_CFDPDESTHANDLER_H
#include <etl/list.h>
#include <utility>
#include "RemoteConfigTableIF.h"
#include "UserBase.h"
#include "fsfw/cfdp/handler/mib.h"
#include "fsfw/cfdp/pdu/PduConfig.h"
#include "fsfw/container/DynamicFIFO.h"
#include "fsfw/storagemanager/StorageManagerIF.h"
#include "fsfw/storagemanager/storeAddress.h"
#include "fsfw/tmtcservices/AcceptsTelemetryIF.h"
namespace cfdp {
class DestHandler {
public:
DestHandler(LocalEntityCfg cfg, UserBase& user, RemoteConfigTableIF& remoteCfgTable);
struct PacketInfo {
PacketInfo(PduType type, FileDirectives directive, store_address_t storeId)
: pduType(type), directiveType(directive), storeId(storeId) {}
PduType pduType = PduType::FILE_DATA;
FileDirectives directiveType = FileDirectives::INVALID_DIRECTIVE;
store_address_t storeId = store_address_t::invalid();
PacketInfo() = default;
};
struct DestHandlerParams {
DestHandlerParams(LocalEntityCfg cfg, UserBase& user, RemoteConfigTableIF& remoteCfgTable,
AcceptsTelemetryIF& packetDest, MessageQueueIF& msgQueue,
etl::ilist<PacketInfo>& packetList)
: cfg(std::move(cfg)),
user(user),
remoteCfgTable(remoteCfgTable),
packetDest(packetDest),
msgQueue(msgQueue),
packetListRef(packetList) {}
private:
LocalEntityCfg cfg;
UserBase& user;
RemoteConfigTableIF& remoteCfgTable;
AcceptsTelemetryIF& packetDest;
MessageQueueIF& msgQueue;
StorageManagerIF* tcStore = nullptr;
StorageManagerIF* tmStore = nullptr;
etl::ilist<PacketInfo>& packetListRef;
};
class DestHandler {
public:
explicit DestHandler(DestHandlerParams params);
ReturnValue_t performStateMachine();
ReturnValue_t passPacket(PacketInfo packet);
ReturnValue_t initialize();
private:
DestHandlerParams p;
enum class TransactionStep {
IDLE = 0,
TRANSACTION_START = 1,
RECEIVING_FILE_DATA_PDUS = 2,
SENDING_ACK_PDU = 3,
TRANSFER_COMPLETION = 4,
SENDING_FINISHED_PDU = 5
};
TransactionStep step = TransactionStep::IDLE;
};
} // namespace cfdp

View File

@ -18,7 +18,8 @@
template <typename T>
class DynamicFIFO : public FIFOBase<T> {
public:
DynamicFIFO(size_t maxCapacity) : FIFOBase<T>(nullptr, maxCapacity), fifoVector(maxCapacity) {
explicit DynamicFIFO(size_t maxCapacity)
: FIFOBase<T>(nullptr, maxCapacity), fifoVector(maxCapacity) {
// trying to pass the pointer of the uninitialized vector
// to the FIFOBase constructor directly lead to a super evil bug.
// So we do it like this now.

View File

@ -15,7 +15,7 @@ class FIFOBase {
/** Default ctor, takes pointer to first entry of underlying container
* and maximum capacity */
FIFOBase(T* values, const size_t maxCapacity);
FIFOBase(T* values, size_t maxCapacity);
/**
* Insert value into FIFO
@ -60,7 +60,7 @@ class FIFOBase {
* Get maximal capacity of fifo
* @return size_t with max capacity of this fifo
*/
size_t getMaxCapacity() const;
[[nodiscard]] size_t getMaxCapacity() const;
protected:
void setContainer(T* data);

View File

@ -14,7 +14,7 @@ TEST_CASE("CFDP Dest Handler", "[cfdp]") {
auto fsMock = FilesystemMock();
auto userMock = UserMock(fsMock);
auto remoteCfgTableMock = RemoteConfigTableMock();
auto destHandler = DestHandler(localEntityCfg, userMock, remoteCfgTableMock);
// auto destHandler = DestHandler(localEntityCfg, userMock, remoteCfgTableMock);
SECTION("State") {}
}