From 55d31d0dc259df379aa53738bb82f017ee48082b Mon Sep 17 00:00:00 2001 From: Jakob Meier Date: Wed, 29 Sep 2021 14:47:20 +0200 Subject: [PATCH] ccsds handler --- bsp_q7s/core/InitMission.cpp | 8 ++++++++ bsp_q7s/core/ObjectFactory.cpp | 4 ++-- linux/fsfwconfig/OBSWConfig.h.in | 1 + linux/obc/PapbVcInterface.cpp | 2 +- linux/obc/Ptme.h | 6 +++++- mission/tmtc/CCSDSHandler.cpp | 10 ++++++++++ mission/tmtc/VirtualChannel.cpp | 7 ++++--- mission/tmtc/VirtualChannel.h | 11 +++++++++-- tmtc | 2 +- 9 files changed, 41 insertions(+), 10 deletions(-) diff --git a/bsp_q7s/core/InitMission.cpp b/bsp_q7s/core/InitMission.cpp index e7d8779b..06cf5ca9 100644 --- a/bsp_q7s/core/InitMission.cpp +++ b/bsp_q7s/core/InitMission.cpp @@ -96,6 +96,13 @@ void initmission::initTasks() { initmission::printAddObjectError("UDP_POLLING", objects::TMTC_POLLING_TASK); } + PeriodicTaskIF* ccsdsHandlerTask = factory->createPeriodicTask( + "UDP_POLLING", 50, PeriodicTaskIF::MINIMUM_STACK_SIZE, 2.0, missedDeadlineFunc); + result = ccsdsHandlerTask->addComponent(objects::CCSDS_HANDLER); + if(result != HasReturnvaluesIF::RETURN_OK) { + initmission::printAddObjectError("CCSDS Handler", objects::CCSDS_HANDLER); + } + # if BOARD_TE0720 == 0 // FS task, task interval does not matter because it runs in permanent loop, priority low // because it is a non-essential background task @@ -141,6 +148,7 @@ void initmission::initTasks() { tmTcDistributor->startTask(); tmtcBridgeTask->startTask(); tmtcPollingTask->startTask(); + ccsdsHandlerTask->startTask(); #if BOARD_TE0720 == 0 coreController->startTask(); #endif diff --git a/bsp_q7s/core/ObjectFactory.cpp b/bsp_q7s/core/ObjectFactory.cpp index 86709292..c36d05e1 100644 --- a/bsp_q7s/core/ObjectFactory.cpp +++ b/bsp_q7s/core/ObjectFactory.cpp @@ -948,9 +948,9 @@ void ObjectFactory::createCcsdsComponents(LinuxLibgpioIF *gpioComIF) { ccsdsHandler->addVirtualChannel(ccsds::VC0, vc); vc = new VirtualChannel(ccsds::VC1, config::VC1_QUEUE_SIZE); ccsdsHandler->addVirtualChannel(ccsds::VC1, vc); - vc = new VirtualChannel(2, config::VC2_QUEUE_SIZE); + vc = new VirtualChannel(ccsds::VC2, config::VC2_QUEUE_SIZE); ccsdsHandler->addVirtualChannel(ccsds::VC2, vc); - vc = new VirtualChannel(3, config::VC3_QUEUE_SIZE); + vc = new VirtualChannel(ccsds::VC3, config::VC3_QUEUE_SIZE); ccsdsHandler->addVirtualChannel(ccsds::VC3, vc); } diff --git a/linux/fsfwconfig/OBSWConfig.h.in b/linux/fsfwconfig/OBSWConfig.h.in index afaed4a5..d54ab39a 100644 --- a/linux/fsfwconfig/OBSWConfig.h.in +++ b/linux/fsfwconfig/OBSWConfig.h.in @@ -86,6 +86,7 @@ debugging. */ #define OBSW_TEST_TE7020_HEATER 0 #define OBSW_TEST_GPIO_OPEN_BY_LABEL 0 #define OBSW_TEST_GPIO_OPEN_BY_LINE_NAME 0 +#define OBSW_LINK_IS_UP 0 #define OBSW_DEBUG_P60DOCK 0 #define OBSW_DEBUG_PDU1 0 diff --git a/linux/obc/PapbVcInterface.cpp b/linux/obc/PapbVcInterface.cpp index 6cbd81a3..5bb72066 100644 --- a/linux/obc/PapbVcInterface.cpp +++ b/linux/obc/PapbVcInterface.cpp @@ -26,7 +26,7 @@ ReturnValue_t PapbVcInterface::write(const uint8_t * data, size_t size) { *(vcBaseReg + DATA_REG_OFFSET) = static_cast(*(data + idx)); } else { - sif::warning << "PapbVcInterface::sendTm: Only written " << idx - 1 << " of " + sif::warning << "PapbVcInterface::write: Only written " << idx << " of " << size << " data" << std::endl; return RETURN_FAILED; } diff --git a/linux/obc/Ptme.h b/linux/obc/Ptme.h index aa131d9e..753cc08f 100644 --- a/linux/obc/Ptme.h +++ b/linux/obc/Ptme.h @@ -48,9 +48,13 @@ private: static const ReturnValue_t UNKNOWN_VC_ID = MAKE_RETURN_CODE(0xA0); - +#if BOARD_TE0720 == 1 + /** Size of mapped address space */ + static const int MAP_SIZE = 0x1000; +#else /** Size of mapped address space */ static const int MAP_SIZE = 0x40000; +#endif /* BOARD_TE0720 == 1 */ /** * Configuration bits: diff --git a/mission/tmtc/CCSDSHandler.cpp b/mission/tmtc/CCSDSHandler.cpp index 2a337d68..95d557ee 100644 --- a/mission/tmtc/CCSDSHandler.cpp +++ b/mission/tmtc/CCSDSHandler.cpp @@ -43,6 +43,16 @@ ReturnValue_t CCSDSHandler::initialize() { if (result != HasReturnvaluesIF::RETURN_OK) { return result; } + + VirtualChannelMapIter iter; + for (iter = virtualChannelMap.begin(); iter != virtualChannelMap.end(); iter++) { + result = iter->second->initialize(); + if (result != RETURN_OK) { + return result; + } + iter->second->setPtmeObject(ptme); + } + return result; } diff --git a/mission/tmtc/VirtualChannel.cpp b/mission/tmtc/VirtualChannel.cpp index 1f8f5ffb..3423692b 100644 --- a/mission/tmtc/VirtualChannel.cpp +++ b/mission/tmtc/VirtualChannel.cpp @@ -56,11 +56,12 @@ MessageQueueId_t VirtualChannel::getReportReceptionQueue(uint8_t virtualChannel) return tmQueue->getId(); } -void VirtualChannel::setPtmeObject(PtmeIF* ptme) { - if (ptme == nullptr) { +void VirtualChannel::setPtmeObject(PtmeIF* ptme_) { + if (ptme_ == nullptr) { sif::warning << "VirtualChannel::setPtmeObject: Invalid ptme object" << std::endl; + return; } - ptme = ptme; + ptme = ptme_; } void VirtualChannel::setLinkState(bool linkIsUp) { diff --git a/mission/tmtc/VirtualChannel.h b/mission/tmtc/VirtualChannel.h index d897e2d6..d7d95cb7 100644 --- a/mission/tmtc/VirtualChannel.h +++ b/mission/tmtc/VirtualChannel.h @@ -1,6 +1,7 @@ #ifndef VIRTUALCHANNEL_H_ #define VIRTUALCHANNEL_H_ +#include "OBSWConfig.h" #include "fsfw/tmtcservices/AcceptsTelemetryIF.h" #include "fsfw/returnvalues/HasReturnvaluesIF.h" #include @@ -31,7 +32,7 @@ class VirtualChannel: public AcceptsTelemetryIF, public HasReturnvaluesIF { * * @param ptme Pointer to ptme object */ - void setPtmeObject(PtmeIF* ptme); + void setPtmeObject(PtmeIF* ptme_); /** * @brief Can be used by the owner to set the link state. Packets will be discarded if link @@ -44,7 +45,13 @@ private: PtmeIF* ptme = nullptr; MessageQueueIF* tmQueue = nullptr; uint8_t vcId; - bool linkIsUp; + +#if OBSW_LINK_IS_UP == 1 + bool linkIsUp = true; +#else + bool linkIsUp = false; +#endif /* OBSW_LINK_IS_UP == 1 */ + StorageManagerIF* tmStore = nullptr; }; diff --git a/tmtc b/tmtc index 53bf6508..bad6a42a 160000 --- a/tmtc +++ b/tmtc @@ -1 +1 @@ -Subproject commit 53bf65083889af10f77c3899972b1153ea835f3c +Subproject commit bad6a42af715f62ddc2a593a5f1ce344fde96da7