diff --git a/CHANGELOG.md b/CHANGELOG.md index 3d982765..dd4976a7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -19,6 +19,10 @@ will consitute of a breaking change warranting a new major release: ## Changed - SCEX filename updates. Also use T as the file ID / date separator between date and time. +- COM TM store and dump handling: Introduce modes for all 4 TM VC/store tasks. The OFF mode can be + used to disable ongoing dumps or to prevent writes to the PTME VC. This allows cleaner reset + handling of the PTME. All 4 VC/store tasks were attached to the COM mode tree and are commanded + as part of the COM sequence as well to ensure consistent state with the CCSDS IP core handler. ## Fixed diff --git a/bsp_q7s/core/ObjectFactory.cpp b/bsp_q7s/core/ObjectFactory.cpp index 76bb39f3..26d19dcd 100644 --- a/bsp_q7s/core/ObjectFactory.cpp +++ b/bsp_q7s/core/ObjectFactory.cpp @@ -20,15 +20,15 @@ #include #include #include +#include +#include +#include #include #include #include #include #include #include -#include -#include -#include #include "OBSWConfig.h" #include "bsp_q7s/boardtest/Q7STestTask.h" @@ -81,6 +81,7 @@ using gpio::Levels; #include #include #include +#include #include #include #include @@ -96,7 +97,6 @@ using gpio::Levels; #include #include #include -#include #include diff --git a/bsp_q7s/core/ObjectFactory.h b/bsp_q7s/core/ObjectFactory.h index dc65e1f4..1d971a5e 100644 --- a/bsp_q7s/core/ObjectFactory.h +++ b/bsp_q7s/core/ObjectFactory.h @@ -4,11 +4,11 @@ #include #include #include +#include #include #include #include #include -#include #include #include diff --git a/linux/ipcore/PapbVcInterface.cpp b/linux/ipcore/PapbVcInterface.cpp index e2c0805c..446e3afd 100644 --- a/linux/ipcore/PapbVcInterface.cpp +++ b/linux/ipcore/PapbVcInterface.cpp @@ -19,7 +19,7 @@ PapbVcInterface::~PapbVcInterface() {} ReturnValue_t PapbVcInterface::initialize() { UioMapper uioMapper(uioFile, mapNum); ReturnValue_t result = uioMapper.getMappedAdress(const_cast(&vcBaseReg), - UioMapper::Permissions::WRITE_ONLY); + UioMapper::Permissions::WRITE_ONLY); if (result != returnvalue::OK) { return result; } @@ -38,7 +38,7 @@ ReturnValue_t PapbVcInterface::write(const uint8_t* data, size_t size) { // TODO: Maybe this should not be done like this. It would be better if there was a custom // FPGA module which can accept packets and then takes care of dumping that packet into // the PTME. DMA would be an ideal solution for this. - nanosleep(&BETWEEN_POLL_DELAY, &remDelay); + // nanosleep(&BETWEEN_POLL_DELAY, &remDelay); if (pollPapbBusySignal(2) == returnvalue::OK) { *(vcBaseReg + DATA_REG_OFFSET) = static_cast(data[idx]); } else { @@ -46,7 +46,7 @@ ReturnValue_t PapbVcInterface::write(const uint8_t* data, size_t size) { return returnvalue::FAILED; } } - nanosleep(&BETWEEN_POLL_DELAY, &remDelay); + // nanosleep(&BETWEEN_POLL_DELAY, &remDelay); if (pollPapbBusySignal(2) == returnvalue::OK) { completePacketTransfer(); } else { diff --git a/linux/ipcore/PapbVcInterface.h b/linux/ipcore/PapbVcInterface.h index b4454dae..22b8ee5f 100644 --- a/linux/ipcore/PapbVcInterface.h +++ b/linux/ipcore/PapbVcInterface.h @@ -5,6 +5,8 @@ #include #include +#include + #include "OBSWConfig.h" #include "fsfw/returnvalues/returnvalue.h" diff --git a/mission/com/CMakeLists.txt b/mission/com/CMakeLists.txt index 94d3e7f0..90e90c88 100644 --- a/mission/com/CMakeLists.txt +++ b/mission/com/CMakeLists.txt @@ -1,2 +1,11 @@ -target_sources(${LIB_EIVE_MISSION} PRIVATE SyrlinksHandler.cpp - CcsdsIpCoreHandler.cpp) +target_sources( + ${LIB_EIVE_MISSION} + PRIVATE SyrlinksHandler.cpp + CcsdsIpCoreHandler.cpp + LiveTmTask.cpp + PersistentLogTmStoreTask.cpp + TmStoreTaskBase.cpp + VirtualChannel.cpp + VirtualChannelWithQueue.cpp + PersistentSingleTmStoreTask.cpp + LiveTmTask.cpp) diff --git a/mission/com/CcsdsIpCoreHandler.h b/mission/com/CcsdsIpCoreHandler.h index 0fad0aae..fc686230 100644 --- a/mission/com/CcsdsIpCoreHandler.h +++ b/mission/com/CcsdsIpCoreHandler.h @@ -2,7 +2,7 @@ #define CCSDSHANDLER_H_ #include -#include +#include #include #include diff --git a/mission/com/LiveTmTask.cpp b/mission/com/LiveTmTask.cpp new file mode 100644 index 00000000..70e8303f --- /dev/null +++ b/mission/com/LiveTmTask.cpp @@ -0,0 +1,101 @@ +#include "LiveTmTask.h" + +#include +#include +#include +#include + +LiveTmTask::LiveTmTask(object_id_t objectId, PusTmFunnel& pusFunnel, CfdpTmFunnel& cfdpFunnel, + VirtualChannelWithQueue& channel) + : SystemObject(objectId), + modeHelper(this), + pusFunnel(pusFunnel), + cfdpFunnel(cfdpFunnel), + channel(channel) { + requestQueue = QueueFactory::instance()->createMessageQueue(); +} + +ReturnValue_t LiveTmTask::performOperation(uint8_t opCode) { + readCommandQueue(); + while (true) { + bool performWriteOp = true; + if (mode == MODE_OFF) { + performWriteOp = false; + } + + // The funnel tasks are scheduled here directly as well. + ReturnValue_t result = channel.handleNextTm(performWriteOp); + if (result == DirectTmSinkIF::IS_BUSY) { + sif::error << "Lost live TM, PAPB busy" << std::endl; + } + if (result == MessageQueueIF::EMPTY) { + if (tmFunnelCd.hasTimedOut()) { + pusFunnel.performOperation(0); + cfdpFunnel.performOperation(0); + tmFunnelCd.resetTimer(); + } + // Read command queue during idle times. + readCommandQueue(); + // 40 ms IDLE delay. Might tweak this in the future. + TaskFactory::delayTask(40); + } else { + packetCounter++; + } + } +} + +MessageQueueId_t LiveTmTask::getCommandQueue() const { return requestQueue->getId(); } + +void LiveTmTask::getMode(Mode_t* mode, Submode_t* submode) { + if (mode != nullptr) { + *mode = this->mode; + } + if (submode != nullptr) { + *submode = SUBMODE_NONE; + } +} + +ReturnValue_t LiveTmTask::checkModeCommand(Mode_t mode, Submode_t submode, + uint32_t* msToReachTheMode) { + if (mode == MODE_ON or mode == MODE_OFF) { + return returnvalue::OK; + } + return returnvalue::FAILED; +} + +void LiveTmTask::startTransition(Mode_t mode, Submode_t submode) { + this->mode = mode; + modeHelper.modeChanged(mode, submode); + announceMode(false); +} + +void LiveTmTask::announceMode(bool recursive) { triggerEvent(MODE_INFO, mode, SUBMODE_NONE); } + +object_id_t LiveTmTask::getObjectId() const { return SystemObject::getObjectId(); } + +const HasHealthIF* LiveTmTask::getOptHealthIF() const { return nullptr; } + +const HasModesIF& LiveTmTask::getModeIF() const { return *this; } + +ReturnValue_t LiveTmTask::connectModeTreeParent(HasModeTreeChildrenIF& parent) { + return modetree::connectModeTreeParent(parent, *this, nullptr, modeHelper); +} + +void LiveTmTask::readCommandQueue(void) { + CommandMessage commandMessage; + ReturnValue_t result = returnvalue::FAILED; + + result = requestQueue->receiveMessage(&commandMessage); + if (result == returnvalue::OK) { + result = modeHelper.handleModeCommand(&commandMessage); + if (result == returnvalue::OK) { + return; + } + CommandMessage reply; + reply.setReplyRejected(CommandMessage::UNKNOWN_COMMAND, commandMessage.getCommand()); + requestQueue->reply(&reply); + return; + } +} + +ModeTreeChildIF& LiveTmTask::getModeTreeChildIF() { return *this; } diff --git a/mission/com/LiveTmTask.h b/mission/com/LiveTmTask.h new file mode 100644 index 00000000..e8eb7fc0 --- /dev/null +++ b/mission/com/LiveTmTask.h @@ -0,0 +1,55 @@ +#ifndef MISSION_TMTC_LIVETMTASK_H_ +#define MISSION_TMTC_LIVETMTASK_H_ + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +class LiveTmTask : public SystemObject, + public HasModesIF, + public ExecutableObjectIF, + public ModeTreeChildIF, + public ModeTreeConnectionIF { + public: + LiveTmTask(object_id_t objectId, PusTmFunnel& pusFunnel, CfdpTmFunnel& cfdpFunnel, + VirtualChannelWithQueue& channel); + + ReturnValue_t performOperation(uint8_t opCode) override; + + private: + MessageQueueIF* requestQueue; + ModeHelper modeHelper; + Mode_t mode = HasModesIF::MODE_OFF; + Countdown tmFunnelCd = Countdown(100); + PusTmFunnel& pusFunnel; + CfdpTmFunnel& cfdpFunnel; + VirtualChannelWithQueue& channel; + uint32_t packetCounter = 0; + + void readCommandQueue(void); + + MessageQueueId_t getCommandQueue() const override; + + void getMode(Mode_t* mode, Submode_t* submode) override; + + ReturnValue_t checkModeCommand(Mode_t mode, Submode_t submode, + uint32_t* msToReachTheMode) override; + + void startTransition(Mode_t mode, Submode_t submode) override; + + void announceMode(bool recursive) override; + + object_id_t getObjectId() const override; + const HasHealthIF* getOptHealthIF() const override; + const HasModesIF& getModeIF() const override; + ReturnValue_t connectModeTreeParent(HasModeTreeChildrenIF& parent) override; + ModeTreeChildIF& getModeTreeChildIF() override; +}; + +#endif /* MISSION_TMTC_LIVETMTASK_H_ */ diff --git a/mission/tmtc/PersistentLogTmStoreTask.cpp b/mission/com/PersistentLogTmStoreTask.cpp similarity index 79% rename from mission/tmtc/PersistentLogTmStoreTask.cpp rename to mission/com/PersistentLogTmStoreTask.cpp index dcd78b54..07fe5ad6 100644 --- a/mission/tmtc/PersistentLogTmStoreTask.cpp +++ b/mission/com/PersistentLogTmStoreTask.cpp @@ -27,6 +27,8 @@ ReturnValue_t PersistentLogTmStoreTask::performOperation(uint8_t opCode) { } }; while (true) { + readCommandQueue(); + if (not cyclicStoreCheck()) { continue; } @@ -54,3 +56,17 @@ bool PersistentLogTmStoreTask::initStoresIfPossible() { } return false; } + +void PersistentLogTmStoreTask::startTransition(Mode_t mode, Submode_t submode) { + if (mode == MODE_OFF) { + bool channelIsOn = channel.isTxOn(); + cancelDump(okStoreContext, stores.okStore, channelIsOn); + cancelDump(notOkStoreContext, stores.notOkStore, channelIsOn); + cancelDump(miscStoreContext, stores.miscStore, channelIsOn); + this->mode = MODE_OFF; + } else if (mode == MODE_ON) { + this->mode = MODE_ON; + } + modeHelper.modeChanged(mode, submode); + announceMode(false); +} diff --git a/mission/tmtc/PersistentLogTmStoreTask.h b/mission/com/PersistentLogTmStoreTask.h similarity index 90% rename from mission/tmtc/PersistentLogTmStoreTask.h rename to mission/com/PersistentLogTmStoreTask.h index 116b369e..51431e2f 100644 --- a/mission/tmtc/PersistentLogTmStoreTask.h +++ b/mission/com/PersistentLogTmStoreTask.h @@ -5,11 +5,11 @@ #include #include #include +#include +#include #include #include #include -#include -#include struct LogStores { LogStores(PersistentTmStores& stores) @@ -36,6 +36,7 @@ class PersistentLogTmStoreTask : public TmStoreTaskBase, public ExecutableObject bool someFileWasSwapped = false; bool initStoresIfPossible() override; + void startTransition(Mode_t mode, Submode_t submode) override; }; #endif /* MISSION_TMTC_PERSISTENTLOGTMSTORETASK_H_ */ diff --git a/mission/tmtc/PersistentSingleTmStoreTask.cpp b/mission/com/PersistentSingleTmStoreTask.cpp similarity index 72% rename from mission/tmtc/PersistentSingleTmStoreTask.cpp rename to mission/com/PersistentSingleTmStoreTask.cpp index a2d57208..f84738ad 100644 --- a/mission/tmtc/PersistentSingleTmStoreTask.cpp +++ b/mission/com/PersistentSingleTmStoreTask.cpp @@ -1,17 +1,21 @@ +#include "PersistentSingleTmStoreTask.h" + #include #include -#include #include PersistentSingleTmStoreTask::PersistentSingleTmStoreTask( object_id_t objectId, StorageManagerIF& ipcStore, PersistentTmStoreWithTmQueue& tmStore, VirtualChannel& channel, Event eventIfDumpDone, Event eventIfCancelled, SdCardMountedIF& sdcMan) : TmStoreTaskBase(objectId, ipcStore, channel, sdcMan), + modeHelper(this), storeWithQueue(tmStore), dumpContext(eventIfDumpDone, eventIfCancelled) {} ReturnValue_t PersistentSingleTmStoreTask::performOperation(uint8_t opCode) { while (true) { + readCommandQueue(); + // Delay done by the check if (not cyclicStoreCheck()) { continue; @@ -33,3 +37,14 @@ bool PersistentSingleTmStoreTask::initStoresIfPossible() { } return false; } + +void PersistentSingleTmStoreTask::startTransition(Mode_t mode, Submode_t submode) { + if (mode == MODE_OFF) { + cancelDump(dumpContext, storeWithQueue, channel.isTxOn()); + this->mode = MODE_OFF; + } else if (mode == MODE_ON) { + this->mode = MODE_ON; + } + modeHelper.modeChanged(mode, submode); + announceMode(false); +} diff --git a/mission/tmtc/PersistentSingleTmStoreTask.h b/mission/com/PersistentSingleTmStoreTask.h similarity index 85% rename from mission/tmtc/PersistentSingleTmStoreTask.h rename to mission/com/PersistentSingleTmStoreTask.h index 1529928f..d8a1979b 100644 --- a/mission/tmtc/PersistentSingleTmStoreTask.h +++ b/mission/com/PersistentSingleTmStoreTask.h @@ -3,9 +3,9 @@ #include #include +#include +#include #include -#include -#include class PersistentSingleTmStoreTask : public TmStoreTaskBase, public ExecutableObjectIF { public: @@ -17,12 +17,15 @@ class PersistentSingleTmStoreTask : public TmStoreTaskBase, public ExecutableObj ReturnValue_t performOperation(uint8_t opCode) override; private: + ModeHelper modeHelper; PersistentTmStoreWithTmQueue& storeWithQueue; DumpContext dumpContext; Countdown tcHandlingCd = Countdown(400); Countdown graceDelayDuringDumping = Countdown(100); bool initStoresIfPossible() override; + + void startTransition(Mode_t mode, Submode_t submode) override; }; #endif /* MISSION_TMTC_PERSISTENTSINGLETMSTORETASK_H_ */ diff --git a/mission/tmtc/TmStoreTaskBase.cpp b/mission/com/TmStoreTaskBase.cpp similarity index 67% rename from mission/tmtc/TmStoreTaskBase.cpp rename to mission/com/TmStoreTaskBase.cpp index 7ca03488..b2f21a83 100644 --- a/mission/tmtc/TmStoreTaskBase.cpp +++ b/mission/com/TmStoreTaskBase.cpp @@ -1,6 +1,8 @@ #include "TmStoreTaskBase.h" #include +#include +#include #include #include #include @@ -9,7 +11,13 @@ TmStoreTaskBase::TmStoreTaskBase(object_id_t objectId, StorageManagerIF& ipcStore, VirtualChannel& channel, SdCardMountedIF& sdcMan) - : SystemObject(objectId), ipcStore(ipcStore), channel(channel), sdcMan(sdcMan) {} + : SystemObject(objectId), + modeHelper(this), + ipcStore(ipcStore), + channel(channel), + sdcMan(sdcMan) { + requestQueue = QueueFactory::instance()->createMessageQueue(10); +} bool TmStoreTaskBase::handleOneStore(PersistentTmStoreWithTmQueue& store, DumpContext& dumpContext) { @@ -26,8 +34,8 @@ bool TmStoreTaskBase::handleOneStore(PersistentTmStoreWithTmQueue& store, if (result == returnvalue::OK) { tmToStoreReceived = true; } - // Dump TMs when applicable - if (store.getState() == PersistentTmStore::State::DUMPING) { + // Dump TMs when applicable and allowed (mode is on) + if (mode == MODE_ON and store.getState() == PersistentTmStore::State::DUMPING) { if (handleOneDump(store, dumpContext, dumpPerformed) != returnvalue::OK) { return result; } @@ -129,3 +137,57 @@ ReturnValue_t TmStoreTaskBase::handleOneDump(PersistentTmStoreWithTmQueue& store } return result; } + +ReturnValue_t TmStoreTaskBase::initialize() { + modeHelper.initialize(); + return returnvalue::OK; +} + +void TmStoreTaskBase::getMode(Mode_t* mode, Submode_t* submode) { + if (mode != nullptr) { + *mode = this->mode; + } + if (submode != nullptr) { + *submode = SUBMODE_NONE; + } +} + +ReturnValue_t TmStoreTaskBase::checkModeCommand(Mode_t mode, Submode_t submode, + uint32_t* msToReachTheMode) { + if (mode == MODE_ON or mode == MODE_OFF) { + return returnvalue::OK; + } + return returnvalue::FAILED; +} + +MessageQueueId_t TmStoreTaskBase::getCommandQueue() const { return requestQueue->getId(); } + +void TmStoreTaskBase::announceMode(bool recursive) { triggerEvent(MODE_INFO, mode, SUBMODE_NONE); } + +object_id_t TmStoreTaskBase::getObjectId() const { return SystemObject::getObjectId(); } + +const HasHealthIF* TmStoreTaskBase::getOptHealthIF() const { return nullptr; } + +const HasModesIF& TmStoreTaskBase::getModeIF() const { return *this; } + +ReturnValue_t TmStoreTaskBase::connectModeTreeParent(HasModeTreeChildrenIF& parent) { + return modetree::connectModeTreeParent(parent, *this, nullptr, modeHelper); +} + +ModeTreeChildIF& TmStoreTaskBase::getModeTreeChildIF() { return *this; } +void TmStoreTaskBase::readCommandQueue(void) { + CommandMessage commandMessage; + ReturnValue_t result = returnvalue::FAILED; + + result = requestQueue->receiveMessage(&commandMessage); + if (result == returnvalue::OK) { + result = modeHelper.handleModeCommand(&commandMessage); + if (result == returnvalue::OK) { + return; + } + CommandMessage reply; + reply.setReplyRejected(CommandMessage::UNKNOWN_COMMAND, commandMessage.getCommand()); + requestQueue->reply(&reply); + return; + } +} diff --git a/mission/tmtc/TmStoreTaskBase.h b/mission/com/TmStoreTaskBase.h similarity index 66% rename from mission/tmtc/TmStoreTaskBase.h rename to mission/com/TmStoreTaskBase.h index 5fef74ff..c9f0b9a3 100644 --- a/mission/tmtc/TmStoreTaskBase.h +++ b/mission/com/TmStoreTaskBase.h @@ -1,15 +1,21 @@ #ifndef MISSION_TMTC_TMSTORETASKBASE_H_ #define MISSION_TMTC_TMSTORETASKBASE_H_ +#include +#include +#include #include +#include #include -#include /** * Generic class which composes a Virtual Channel and a persistent TM stores. This allows dumping * the TM store into the virtual channel directly. */ -class TmStoreTaskBase : public SystemObject { +class TmStoreTaskBase : public SystemObject, + public HasModesIF, + public ModeTreeChildIF, + public ModeTreeConnectionIF { public: struct DumpContext { DumpContext(Event eventIfDone, Event eventIfCancelled) @@ -35,8 +41,13 @@ class TmStoreTaskBase : public SystemObject { TmStoreTaskBase(object_id_t objectId, StorageManagerIF& ipcStore, VirtualChannel& channel, SdCardMountedIF& sdcMan); + ReturnValue_t initialize() override; + protected: + MessageQueueIF* requestQueue; + ModeHelper modeHelper; StorageManagerIF& ipcStore; + Mode_t mode = HasModesIF::MODE_OFF; Countdown sdCardCheckCd = Countdown(800); // 20 minutes are allowed as maximum dump time. Countdown cancelDumpCd = Countdown(60 * 20 * 1000); @@ -47,6 +58,11 @@ class TmStoreTaskBase : public SystemObject { bool fileHasSwapped = false; SdCardMountedIF& sdcMan; + void readCommandQueue(void); + + virtual bool initStoresIfPossible() = 0; + virtual void startTransition(Mode_t mode, Submode_t submode) = 0; + void cancelDump(DumpContext& ctx, PersistentTmStore& store, bool isTxOn); /** * @@ -65,7 +81,18 @@ class TmStoreTaskBase : public SystemObject { */ bool cyclicStoreCheck(); - virtual bool initStoresIfPossible() = 0; + MessageQueueId_t getCommandQueue() const override; + + void getMode(Mode_t* mode, Submode_t* submode) override; + + ReturnValue_t checkModeCommand(Mode_t mode, Submode_t submode, + uint32_t* msToReachTheMode) override; + void announceMode(bool recursive) override; + object_id_t getObjectId() const override; + const HasHealthIF* getOptHealthIF() const override; + const HasModesIF& getModeIF() const override; + ReturnValue_t connectModeTreeParent(HasModeTreeChildrenIF& parent) override; + ModeTreeChildIF& getModeTreeChildIF() override; }; #endif /* MISSION_TMTC_TMSTORETASKBASE_H_ */ diff --git a/mission/tmtc/VirtualChannel.cpp b/mission/com/VirtualChannel.cpp similarity index 100% rename from mission/tmtc/VirtualChannel.cpp rename to mission/com/VirtualChannel.cpp diff --git a/mission/tmtc/VirtualChannel.h b/mission/com/VirtualChannel.h similarity index 100% rename from mission/tmtc/VirtualChannel.h rename to mission/com/VirtualChannel.h diff --git a/mission/tmtc/VirtualChannelWithQueue.cpp b/mission/com/VirtualChannelWithQueue.cpp similarity index 91% rename from mission/tmtc/VirtualChannelWithQueue.cpp rename to mission/com/VirtualChannelWithQueue.cpp index 44a20031..a90829ab 100644 --- a/mission/tmtc/VirtualChannelWithQueue.cpp +++ b/mission/com/VirtualChannelWithQueue.cpp @@ -1,4 +1,4 @@ -#include +#include "VirtualChannelWithQueue.h" #include "OBSWConfig.h" #include "fsfw/ipc/QueueFactory.h" @@ -19,7 +19,7 @@ VirtualChannelWithQueue::VirtualChannelWithQueue(object_id_t objectId, uint8_t v const char* VirtualChannelWithQueue::getName() const { return VirtualChannel::getName(); } -ReturnValue_t VirtualChannelWithQueue::sendNextTm() { +ReturnValue_t VirtualChannelWithQueue::handleNextTm(bool performWriteOp) { TmTcMessage message; ReturnValue_t result = tmQueue->receiveMessage(&message); if (result == MessageQueueIF::EMPTY) { @@ -36,7 +36,9 @@ ReturnValue_t VirtualChannelWithQueue::sendNextTm() { return result; } - result = write(data, size); + if (performWriteOp) { + result = write(data, size); + } // Try delete in any case, ignore failures (which should not happen), it is more important to // propagate write errors. tmStore.deleteData(storeId); diff --git a/mission/tmtc/VirtualChannelWithQueue.h b/mission/com/VirtualChannelWithQueue.h similarity index 93% rename from mission/tmtc/VirtualChannelWithQueue.h rename to mission/com/VirtualChannelWithQueue.h index 0c060a06..04c7f965 100644 --- a/mission/tmtc/VirtualChannelWithQueue.h +++ b/mission/com/VirtualChannelWithQueue.h @@ -4,7 +4,7 @@ #include #include #include -#include +#include #include @@ -34,7 +34,7 @@ class VirtualChannelWithQueue : public VirtualChannel, public AcceptsTelemetryIF MessageQueueId_t getReportReceptionQueue(uint8_t virtualChannel = 0) const override; [[nodiscard]] const char* getName() const override; - ReturnValue_t sendNextTm(); + ReturnValue_t handleNextTm(bool performWriteOp); private: MessageQueueIF* tmQueue = nullptr; diff --git a/mission/config/comCfg.cpp b/mission/config/comCfg.cpp index 8387214d..664a2e55 100644 --- a/mission/config/comCfg.cpp +++ b/mission/config/comCfg.cpp @@ -3,6 +3,8 @@ #include #include +#include + com::Datarate DATARATE_CFG_RAW = com::Datarate::LOW_RATE_MODULATION_BPSK; MutexIF* DATARATE_LOCK = nullptr; diff --git a/mission/system/com/comModeTree.cpp b/mission/system/com/comModeTree.cpp index 9501262d..bb9a8d10 100644 --- a/mission/system/com/comModeTree.cpp +++ b/mission/system/com/comModeTree.cpp @@ -22,7 +22,7 @@ auto COM_SEQUENCE_RX_ONLY = auto COM_TABLE_RX_ONLY_TGT = std::make_pair( static_cast(::com::Submode::RX_ONLY << 24) | 1, FixedArrayList()); auto COM_TABLE_RX_ONLY_TRANS_0 = std::make_pair( - static_cast(::com::Submode::RX_ONLY << 24) | 2, FixedArrayList()); + static_cast(::com::Submode::RX_ONLY << 24) | 2, FixedArrayList()); auto COM_TABLE_RX_ONLY_TRANS_1 = std::make_pair( static_cast(::com::Submode::RX_ONLY << 24) | 3, FixedArrayList()); @@ -36,7 +36,7 @@ auto COM_TABLE_RX_AND_TX_LOW_RATE_TRANS_0 = FixedArrayList()); auto COM_TABLE_RX_AND_TX_LOW_RATE_TRANS_1 = std::make_pair(static_cast(::com::Submode::RX_AND_TX_LOW_DATARATE << 24) | 3, - FixedArrayList()); + FixedArrayList()); auto COM_SEQUENCE_RX_AND_TX_HIGH_RATE = std::make_pair(::com::Submode::RX_AND_TX_HIGH_DATARATE, FixedArrayList()); @@ -48,7 +48,7 @@ auto COM_TABLE_RX_AND_TX_HIGH_RATE_TRANS_0 = FixedArrayList()); auto COM_TABLE_RX_AND_TX_HIGH_RATE_TRANS_1 = std::make_pair(static_cast(::com::Submode::RX_AND_TX_HIGH_DATARATE << 24) | 3, - FixedArrayList()); + FixedArrayList()); auto COM_SEQUENCE_RX_AND_TX_DEFAULT_RATE = std::make_pair(::com::Submode::RX_AND_TX_DEFAULT_DATARATE, FixedArrayList()); @@ -60,7 +60,7 @@ auto COM_TABLE_RX_AND_TX_DEFAULT_RATE_TRANS_0 = FixedArrayList()); auto COM_TABLE_RX_AND_TX_DEFAULT_RATE_TRANS_1 = std::make_pair(static_cast(::com::Submode::RX_AND_TX_DEFAULT_DATARATE << 24) | 3, - FixedArrayList()); + FixedArrayList()); namespace { @@ -110,6 +110,10 @@ void buildRxOnlySequence(Subsystem& ss, ModeListEntry& eh) { // Build RX Only transition 0 iht(objects::SYRLINKS_ASSY, NML, ::com::Submode::RX_ONLY, COM_TABLE_RX_ONLY_TRANS_0.second); + iht(objects::LOG_STORE_AND_TM_TASK, OFF, 0, COM_TABLE_RX_ONLY_TRANS_0.second); + iht(objects::HK_STORE_AND_TM_TASK, OFF, 0, COM_TABLE_RX_ONLY_TRANS_0.second); + iht(objects::CFDP_STORE_AND_TM_TASK, OFF, 0, COM_TABLE_RX_ONLY_TRANS_0.second); + iht(objects::LIVE_TM_TASK, OFF, 0, COM_TABLE_RX_ONLY_TRANS_0.second); check(ss.addTable(TableEntry(COM_TABLE_RX_ONLY_TRANS_0.first, &COM_TABLE_RX_ONLY_TRANS_0.second)), ctxc); @@ -165,6 +169,10 @@ void buildTxAndRxLowRateSequence(Subsystem& ss, ModeListEntry& eh) { // Build TX and RX low transition 1 iht(objects::SYRLINKS_ASSY, NML, ::com::Submode::RX_AND_TX_LOW_DATARATE, COM_TABLE_RX_AND_TX_LOW_RATE_TRANS_1.second); + iht(objects::LOG_STORE_AND_TM_TASK, ON, 0, COM_TABLE_RX_AND_TX_LOW_RATE_TRANS_1.second); + iht(objects::HK_STORE_AND_TM_TASK, ON, 0, COM_TABLE_RX_AND_TX_LOW_RATE_TRANS_1.second); + iht(objects::CFDP_STORE_AND_TM_TASK, ON, 0, COM_TABLE_RX_AND_TX_LOW_RATE_TRANS_1.second); + iht(objects::LIVE_TM_TASK, ON, 0, COM_TABLE_RX_AND_TX_LOW_RATE_TRANS_1.second); check(ss.addTable(TableEntry(COM_TABLE_RX_AND_TX_LOW_RATE_TRANS_1.first, &COM_TABLE_RX_AND_TX_LOW_RATE_TRANS_1.second)), ctxc); @@ -217,6 +225,10 @@ void buildTxAndRxHighRateSequence(Subsystem& ss, ModeListEntry& eh) { // Build TX and RX high transition 1 iht(objects::SYRLINKS_ASSY, NML, ::com::Submode::RX_AND_TX_HIGH_DATARATE, COM_TABLE_RX_AND_TX_HIGH_RATE_TRANS_1.second); + iht(objects::LOG_STORE_AND_TM_TASK, ON, 0, COM_TABLE_RX_AND_TX_HIGH_RATE_TRANS_1.second); + iht(objects::HK_STORE_AND_TM_TASK, ON, 0, COM_TABLE_RX_AND_TX_HIGH_RATE_TRANS_1.second); + iht(objects::CFDP_STORE_AND_TM_TASK, ON, 0, COM_TABLE_RX_AND_TX_HIGH_RATE_TRANS_1.second); + iht(objects::LIVE_TM_TASK, ON, 0, COM_TABLE_RX_AND_TX_HIGH_RATE_TRANS_1.second); check(ss.addTable(TableEntry(COM_TABLE_RX_AND_TX_HIGH_RATE_TRANS_1.first, &COM_TABLE_RX_AND_TX_HIGH_RATE_TRANS_1.second)), ctxc); @@ -271,6 +283,10 @@ void buildTxAndRxDefaultRateSequence(Subsystem& ss, ModeListEntry& eh) { // Build TX and RX default transition 1 iht(objects::SYRLINKS_ASSY, NML, ::com::Submode::RX_AND_TX_DEFAULT_DATARATE, COM_TABLE_RX_AND_TX_DEFAULT_RATE_TRANS_1.second); + iht(objects::LOG_STORE_AND_TM_TASK, ON, 0, COM_TABLE_RX_AND_TX_DEFAULT_RATE_TRANS_1.second); + iht(objects::HK_STORE_AND_TM_TASK, ON, 0, COM_TABLE_RX_AND_TX_DEFAULT_RATE_TRANS_1.second); + iht(objects::CFDP_STORE_AND_TM_TASK, ON, 0, COM_TABLE_RX_AND_TX_DEFAULT_RATE_TRANS_1.second); + iht(objects::LIVE_TM_TASK, ON, 0, COM_TABLE_RX_AND_TX_DEFAULT_RATE_TRANS_1.second); check(ss.addTable(TableEntry(COM_TABLE_RX_AND_TX_DEFAULT_RATE_TRANS_1.first, &COM_TABLE_RX_AND_TX_DEFAULT_RATE_TRANS_1.second)), ctxc); diff --git a/mission/tmtc/CMakeLists.txt b/mission/tmtc/CMakeLists.txt index c797e315..a8388d83 100644 --- a/mission/tmtc/CMakeLists.txt +++ b/mission/tmtc/CMakeLists.txt @@ -1,17 +1,11 @@ target_sources( ${LIB_EIVE_MISSION} - PRIVATE VirtualChannelWithQueue.cpp - PersistentTmStoreWithTmQueue.cpp - LiveTmTask.cpp - VirtualChannel.cpp + PRIVATE PersistentTmStoreWithTmQueue.cpp TmFunnelHandler.cpp TmFunnelBase.cpp CfdpTmFunnel.cpp tmFilters.cpp PusLiveDemux.cpp - PersistentSingleTmStoreTask.cpp - PersistentLogTmStoreTask.cpp - TmStoreTaskBase.cpp PusPacketFilter.cpp PusTmRouteByFilterHelper.cpp Service15TmStorage.cpp diff --git a/mission/tmtc/LiveTmTask.cpp b/mission/tmtc/LiveTmTask.cpp deleted file mode 100644 index 7e6d3de6..00000000 --- a/mission/tmtc/LiveTmTask.cpp +++ /dev/null @@ -1,27 +0,0 @@ -#include "LiveTmTask.h" - -#include -#include - -LiveTmTask::LiveTmTask(object_id_t objectId, PusTmFunnel& pusFunnel, CfdpTmFunnel& cfdpFunnel, - VirtualChannelWithQueue& channel) - : SystemObject(objectId), pusFunnel(pusFunnel), cfdpFunnel(cfdpFunnel), channel(channel) {} - -ReturnValue_t LiveTmTask::performOperation(uint8_t opCode) { - while (true) { - // The funnel tasks are scheduled here directly as well. - ReturnValue_t result = channel.sendNextTm(); - if (result == DirectTmSinkIF::IS_BUSY) { - sif::error << "Lost live TM, PAPB busy" << std::endl; - } - if (result == MessageQueueIF::EMPTY) { - if (tmFunnelCd.hasTimedOut()) { - pusFunnel.performOperation(0); - cfdpFunnel.performOperation(0); - tmFunnelCd.resetTimer(); - } - // 40 ms IDLE delay. Might tweak this in the future. - TaskFactory::delayTask(40); - } - } -} diff --git a/mission/tmtc/LiveTmTask.h b/mission/tmtc/LiveTmTask.h deleted file mode 100644 index a0ca6b83..00000000 --- a/mission/tmtc/LiveTmTask.h +++ /dev/null @@ -1,25 +0,0 @@ -#ifndef MISSION_TMTC_LIVETMTASK_H_ -#define MISSION_TMTC_LIVETMTASK_H_ - -#include -#include -#include -#include -#include -#include - -class LiveTmTask : public SystemObject, public ExecutableObjectIF { - public: - LiveTmTask(object_id_t objectId, PusTmFunnel& pusFunnel, CfdpTmFunnel& cfdpFunnel, - VirtualChannelWithQueue& channel); - - ReturnValue_t performOperation(uint8_t opCode) override; - - private: - Countdown tmFunnelCd = Countdown(100); - PusTmFunnel& pusFunnel; - CfdpTmFunnel& cfdpFunnel; - VirtualChannelWithQueue& channel; -}; - -#endif /* MISSION_TMTC_LIVETMTASK_H_ */