From 6fe4c71cee6aceddb75355ac41a7352789d5e5d6 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Mon, 11 Sep 2023 19:23:48 +0200 Subject: [PATCH] this is useable --- bsp_q7s/objectFactory.cpp | 4 ++-- mission/sysDefs.h | 5 +++++ mission/system/systemTree.cpp | 4 +++- mission/tmtc/CfdpTmFunnel.cpp | 6 ++++++ mission/tmtc/CfdpTmFunnel.h | 2 ++ mission/tmtc/PusLiveDemux.cpp | 20 ++++++++++++++++++-- mission/tmtc/PusLiveDemux.h | 5 ++++- mission/tmtc/TmFunnelBase.cpp | 7 ++++--- mission/tmtc/TmFunnelBase.h | 5 +++-- 9 files changed, 47 insertions(+), 11 deletions(-) diff --git a/bsp_q7s/objectFactory.cpp b/bsp_q7s/objectFactory.cpp index 39271628..d1eadb57 100644 --- a/bsp_q7s/objectFactory.cpp +++ b/bsp_q7s/objectFactory.cpp @@ -134,7 +134,7 @@ using gpio::Levels; ResetArgs RESET_ARGS_GNSS; std::atomic_bool LINK_STATE = CcsdsIpCoreHandler::LINK_DOWN; std::atomic_bool PTME_LOCKED = false; -std::atomic_uint16_t I2C_FATAL_ERRORS = 0; +std::atomic_uint16_t signals::I2C_FATAL_ERRORS = 0; uint8_t core::FW_VERSION_MAJOR = 0; uint8_t core::FW_VERSION_MINOR = 0; uint8_t core::FW_VERSION_REVISION = 0; @@ -953,7 +953,7 @@ void ObjectFactory::createImtqComponents(PowerSwitchIF* pwrSwitcher, bool enable auto* imtqAssy = new ImtqAssembly(objects::IMTQ_ASSY); imtqAssy->connectModeTreeParent(satsystem::acs::ACS_SUBSYSTEM); - new ImtqPollingTask(objects::IMTQ_POLLING, I2C_FATAL_ERRORS); + new ImtqPollingTask(objects::IMTQ_POLLING, signals::I2C_FATAL_ERRORS); I2cCookie* imtqI2cCookie = new I2cCookie(addresses::IMTQ, imtq::MAX_REPLY_SIZE, i2cDev); auto imtqHandler = new ImtqHandler(objects::IMTQ_HANDLER, objects::IMTQ_POLLING, imtqI2cCookie, power::Switches::PDU1_CH3_MGT_5V, enableHkSets); diff --git a/mission/sysDefs.h b/mission/sysDefs.h index 4a53a76d..00a5635f 100644 --- a/mission/sysDefs.h +++ b/mission/sysDefs.h @@ -9,8 +9,13 @@ #include #include +namespace signals { + +extern std::atomic_bool CFDP_CHANNEL_THROTTLE_SIGNAL; extern std::atomic_uint16_t I2C_FATAL_ERRORS; +} // namespace signals + namespace satsystem { enum Mode : Mode_t { diff --git a/mission/system/systemTree.cpp b/mission/system/systemTree.cpp index 10c40617..8eb693ef 100644 --- a/mission/system/systemTree.cpp +++ b/mission/system/systemTree.cpp @@ -10,6 +10,7 @@ #include "eive/objects.h" #include "mission/com/defs.h" +#include "mission/sysDefs.h" #include "mission/system/acs/acsModeTree.h" #include "mission/system/tcs/tcsModeTree.h" #include "mission/system/tree/payloadModeTree.h" @@ -51,7 +52,8 @@ void satsystem::init(bool commandPlPcdu1) { EIVE_SYSTEM.setInitialMode(satsystem::Mode::BOOT, 0); } -EiveSystem satsystem::EIVE_SYSTEM = EiveSystem(objects::EIVE_SYSTEM, 12, 24, I2C_FATAL_ERRORS); +EiveSystem satsystem::EIVE_SYSTEM = + EiveSystem(objects::EIVE_SYSTEM, 12, 24, signals::I2C_FATAL_ERRORS); auto EIVE_SEQUENCE_BOOT = std::make_pair(satsystem::Mode::BOOT, FixedArrayList()); auto EIVE_TABLE_BOOT_TGT = diff --git a/mission/tmtc/CfdpTmFunnel.cpp b/mission/tmtc/CfdpTmFunnel.cpp index d4ea76ba..e50250e8 100644 --- a/mission/tmtc/CfdpTmFunnel.cpp +++ b/mission/tmtc/CfdpTmFunnel.cpp @@ -3,6 +3,7 @@ #include "fsfw/ipc/QueueFactory.h" #include "fsfw/tmtcpacket/ccsds/SpacePacketCreator.h" #include "fsfw/tmtcservices/TmTcMessage.h" +#include "mission/sysDefs.h" CfdpTmFunnel::CfdpTmFunnel(TmFunnelBase::FunnelCfg cfg, std::optional fileStoreDest, @@ -109,3 +110,8 @@ ReturnValue_t CfdpTmFunnel::handlePacket(TmTcMessage& msg) { } return demultiplexLivePackets(origStoreId, newPacketData, packetLen); } + +void CfdpTmFunnel::addLiveDestination(const char* name, + const AcceptsTelemetryIF& downlinkDestination, uint8_t vcid) { + uint32_t listIndex = TmFunnelBase::addLiveDestination(name, downlinkDestination, vcid); +} diff --git a/mission/tmtc/CfdpTmFunnel.h b/mission/tmtc/CfdpTmFunnel.h index 5bb5d95b..45642c4a 100644 --- a/mission/tmtc/CfdpTmFunnel.h +++ b/mission/tmtc/CfdpTmFunnel.h @@ -16,6 +16,8 @@ class CfdpTmFunnel : public TmFunnelBase { CfdpTmFunnel(TmFunnelBase::FunnelCfg cfg, std::optional fileStoreDest, StorageManagerIF& ramToFileStore, uint16_t cfdpInCcsdsApid); [[nodiscard]] const char* getName() const override; + void addLiveDestination(const char* name, const AcceptsTelemetryIF& downlinkDestination, + uint8_t vcid = 0) override; ReturnValue_t performOperation(uint8_t opCode); ReturnValue_t initialize() override; diff --git a/mission/tmtc/PusLiveDemux.cpp b/mission/tmtc/PusLiveDemux.cpp index 4d78a188..12c8ccb3 100644 --- a/mission/tmtc/PusLiveDemux.cpp +++ b/mission/tmtc/PusLiveDemux.cpp @@ -13,6 +13,9 @@ ReturnValue_t PusLiveDemux::demultiplexPackets(StorageManagerIF& tmStore, // std::endl; for (unsigned int idx = 0; idx < destinations.size(); idx++) { const auto& dest = destinations[idx]; + if (dest.isFull) { + continue; + } if ((destinations.size() > 1) and (idx < (destinations.size() - 1))) { // Create copy of data to ensure each TM recipient has its own copy. That way, we don't need // to bother with send order and where the data is deleted. @@ -52,8 +55,21 @@ ReturnValue_t PusLiveDemux::demultiplexPackets(StorageManagerIF& tmStore, return result; } -void PusLiveDemux::addDestination(const char* name, const AcceptsTelemetryIF& downlinkDestination, - uint8_t vcid) { +uint32_t PusLiveDemux::addDestination(const char* name, + const AcceptsTelemetryIF& downlinkDestination, uint8_t vcid) { auto queueId = downlinkDestination.getReportReceptionQueue(vcid); destinations.emplace_back(name, queueId, vcid); + return destinations.size() - 1; +} + +void PusLiveDemux::setDestFull(uint32_t listIndex) { + if (destinations.size() > 0 and listIndex <= destinations.size() - 1) { + destinations[listIndex].isFull = true; + } +} + +void PusLiveDemux::setDestAvailable(uint32_t listIndex) { + if (destinations.size() > 0 and listIndex <= destinations.size() - 1) { + destinations[listIndex].isFull = false; + } } diff --git a/mission/tmtc/PusLiveDemux.h b/mission/tmtc/PusLiveDemux.h index b9af04ff..f4f83958 100644 --- a/mission/tmtc/PusLiveDemux.h +++ b/mission/tmtc/PusLiveDemux.h @@ -14,8 +14,10 @@ class PusLiveDemux { ReturnValue_t demultiplexPackets(StorageManagerIF& tmStore, store_address_t origStoreId, const uint8_t* tmData, size_t tmSize); - void addDestination(const char* name, const AcceptsTelemetryIF& downlinkDestination, + uint32_t addDestination(const char* name, const AcceptsTelemetryIF& downlinkDestination, uint8_t vcid = 0); + void setDestFull(uint32_t listIndex); + void setDestAvailable(uint32_t listIndex); private: struct Destination { @@ -24,6 +26,7 @@ class PusLiveDemux { const char* name; MessageQueueId_t queueId; + bool isFull = false; uint8_t virtualChannel = 0; }; diff --git a/mission/tmtc/TmFunnelBase.cpp b/mission/tmtc/TmFunnelBase.cpp index fc2e4b76..4a17984a 100644 --- a/mission/tmtc/TmFunnelBase.cpp +++ b/mission/tmtc/TmFunnelBase.cpp @@ -30,9 +30,10 @@ MessageQueueId_t TmFunnelBase::getReportReceptionQueue(uint8_t virtualChannel) c return tmQueue->getId(); } -void TmFunnelBase::addLiveDestination(const char *name, - const AcceptsTelemetryIF &downlinkDestination, uint8_t vcid) { - liveDemux.addDestination(name, downlinkDestination, vcid); +uint32_t TmFunnelBase::addLiveDestination(const char *name, + const AcceptsTelemetryIF &downlinkDestination, + uint8_t vcid) { + return liveDemux.addDestination(name, downlinkDestination, vcid); } ReturnValue_t TmFunnelBase::initialize() { diff --git a/mission/tmtc/TmFunnelBase.h b/mission/tmtc/TmFunnelBase.h index 72d91103..7495af4a 100644 --- a/mission/tmtc/TmFunnelBase.h +++ b/mission/tmtc/TmFunnelBase.h @@ -37,8 +37,9 @@ class TmFunnelBase : public AcceptsTelemetryIF, public SystemObject { }; explicit TmFunnelBase(FunnelCfg cfg); [[nodiscard]] MessageQueueId_t getReportReceptionQueue(uint8_t virtualChannel) const override; - void addLiveDestination(const char* name, const AcceptsTelemetryIF& downlinkDestination, - uint8_t vcid = 0); + virtual uint32_t addLiveDestination(const char* name, + const AcceptsTelemetryIF& downlinkDestination, + uint8_t vcid = 0); ReturnValue_t demultiplexLivePackets(store_address_t origStoreId, const uint8_t* tmData, size_t tmSize); ReturnValue_t initialize() override;