From 66d20dc11873acca86b5c004b04703ccc8c52c0b Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Tue, 14 Feb 2023 10:59:35 +0100 Subject: [PATCH 01/10] add tracing for first tasks --- bsp_q7s/OBSWConfig.h.in | 1 + bsp_q7s/core/CoreController.cpp | 4 ++++ bsp_q7s/core/CoreController.h | 3 +++ bsp_q7s/core/scheduling.cpp | 8 ++++---- mission/CMakeLists.txt | 2 +- mission/controller/AcsController.cpp | 4 ++++ mission/controller/AcsController.h | 5 +++++ mission/devices/BpxBatteryHandler.cpp | 8 +++++++- mission/devices/BpxBatteryHandler.h | 6 ++++++ mission/devices/SolarArrayDeploymentHandler.cpp | 6 ++++++ mission/devices/SolarArrayDeploymentHandler.h | 3 +++ mission/trace.cpp | 10 ++++++++++ mission/trace.h | 12 ++++++++++++ 13 files changed, 66 insertions(+), 6 deletions(-) create mode 100644 mission/trace.cpp create mode 100644 mission/trace.h diff --git a/bsp_q7s/OBSWConfig.h.in b/bsp_q7s/OBSWConfig.h.in index 687d9363..a86dd8c7 100644 --- a/bsp_q7s/OBSWConfig.h.in +++ b/bsp_q7s/OBSWConfig.h.in @@ -77,6 +77,7 @@ // If this is enabled, all other I2C code should be disabled #define OBSW_ADD_I2C_TEST_CODE 0 #define OBSW_ADD_UART_TEST_CODE 0 +#define OBSW_THREAD_TRACING 1 #define OBSW_TEST_ACS 0 #define OBSW_DEBUG_ACS 0 diff --git a/bsp_q7s/core/CoreController.cpp b/bsp_q7s/core/CoreController.cpp index 116b4fc9..79dc68f5 100644 --- a/bsp_q7s/core/CoreController.cpp +++ b/bsp_q7s/core/CoreController.cpp @@ -9,6 +9,7 @@ #include "fsfw/serviceinterface/ServiceInterface.h" #include "fsfw/timemanager/Stopwatch.h" #include "fsfw/version.h" +#include "mission/trace.h" #include "watchdog/definitions.h" #if OBSW_ADD_TMTC_UDP_SERVER == 1 #include "fsfw/osal/common/UdpTmTcBridge.h" @@ -63,6 +64,9 @@ ReturnValue_t CoreController::handleCommandMessage(CommandMessage *message) { } void CoreController::performControlOperation() { +#if OBSW_THREAD_TRACING == 1 + trace::threadTrace(opCounter, "CORE CTRL"); +#endif EventMessage event; for (ReturnValue_t result = eventQueue->receiveMessage(&event); result == returnvalue::OK; result = eventQueue->receiveMessage(&event)) { diff --git a/bsp_q7s/core/CoreController.h b/bsp_q7s/core/CoreController.h index 9cbc6340..36cf5d27 100644 --- a/bsp_q7s/core/CoreController.h +++ b/bsp_q7s/core/CoreController.h @@ -222,6 +222,9 @@ class CoreController : public ExtendedControllerBase { std::string currMntPrefix; bool performOneShotSdCardOpsSwitch = false; uint8_t shortSdCardCdCounter = 0; +#if OBSW_THREAD_TRACING == 1 + uint32_t opCounter; +#endif Countdown sdCardCheckCd = Countdown(INIT_SD_CARD_CHECK_TIMEOUT); /** diff --git a/bsp_q7s/core/scheduling.cpp b/bsp_q7s/core/scheduling.cpp index ad76d308..5abe3fd5 100644 --- a/bsp_q7s/core/scheduling.cpp +++ b/bsp_q7s/core/scheduling.cpp @@ -374,9 +374,9 @@ void scheduling::createPstTasks(TaskFactory& factory, TaskDeadlineMissedFunction #else static constexpr float acsPstPeriod = 0.8; #endif - FixedTimeslotTaskIF* acsPst = factory.createFixedTimeslotTask( - "ACS_PST", 85, PeriodicTaskIF::MINIMUM_STACK_SIZE * 2, acsPstPeriod, missedDeadlineFunc); - result = pst::pstTcsAndAcs(acsPst, cfg); + FixedTimeslotTaskIF* acsTcsPst = factory.createFixedTimeslotTask( + "ACS_TCS_PST", 85, PeriodicTaskIF::MINIMUM_STACK_SIZE * 2, acsPstPeriod, missedDeadlineFunc); + result = pst::pstTcsAndAcs(acsTcsPst, cfg); if (result != returnvalue::OK) { if (result == FixedTimeslotTaskIF::SLOT_LIST_EMPTY) { sif::warning << "scheduling::initTasks: ACS PST is empty" << std::endl; @@ -384,7 +384,7 @@ void scheduling::createPstTasks(TaskFactory& factory, TaskDeadlineMissedFunction sif::error << "scheduling::initTasks: Creating ACS PST failed!" << std::endl; } } else { - taskVec.push_back(acsPst); + taskVec.push_back(acsTcsPst); } /* Polling Sequence Table Default */ diff --git a/mission/CMakeLists.txt b/mission/CMakeLists.txt index f284a675..37c4a2e2 100644 --- a/mission/CMakeLists.txt +++ b/mission/CMakeLists.txt @@ -9,4 +9,4 @@ add_subdirectory(csp) add_subdirectory(cfdp) add_subdirectory(config) -target_sources(${LIB_EIVE_MISSION} PRIVATE acsDefs.cpp) +target_sources(${LIB_EIVE_MISSION} PRIVATE acsDefs.cpp trace.cpp) diff --git a/mission/controller/AcsController.cpp b/mission/controller/AcsController.cpp index ef590b8c..72589fcc 100644 --- a/mission/controller/AcsController.cpp +++ b/mission/controller/AcsController.cpp @@ -4,6 +4,7 @@ #include "mission/acsDefs.h" #include "mission/config/torquer.h" +#include "mission/trace.h" AcsController::AcsController(object_id_t objectId) : ExtendedControllerBase(objectId), @@ -50,6 +51,9 @@ ReturnValue_t AcsController::getParameter(uint8_t domainId, uint8_t parameterId, } void AcsController::performControlOperation() { +#if OBSW_THREAD_TRACING == 1 + trace::threadTrace(opCounter, "ACS & TCS PST"); +#endif switch (internalState) { case InternalState::STARTUP: { initialCountdown.resetTimer(); diff --git a/mission/controller/AcsController.h b/mission/controller/AcsController.h index 1e017099..14972b3e 100644 --- a/mission/controller/AcsController.h +++ b/mission/controller/AcsController.h @@ -6,6 +6,7 @@ #include #include +#include "OBSWConfig.h" #include "acs/ActuatorCmd.h" #include "acs/Guidance.h" #include "acs/Navigation.h" @@ -51,6 +52,10 @@ class AcsController : public ExtendedControllerBase, public ReceivesParameterMes ParameterHelper parameterHelper; +#if OBSW_THREAD_TRACING == 1 + uint32_t opCounter = 0; +#endif + enum class InternalState { STARTUP, INITIAL_DELAY, READY }; InternalState internalState = InternalState::STARTUP; diff --git a/mission/devices/BpxBatteryHandler.cpp b/mission/devices/BpxBatteryHandler.cpp index 4e49bebe..efda26f8 100644 --- a/mission/devices/BpxBatteryHandler.cpp +++ b/mission/devices/BpxBatteryHandler.cpp @@ -2,7 +2,7 @@ #include -#include "OBSWConfig.h" +#include "mission/trace.h" BpxBatteryHandler::BpxBatteryHandler(object_id_t objectId, object_id_t comIF, CookieIF* comCookie) : DeviceHandlerBase(objectId, comIF, comCookie), hkSet(this), cfgSet(this) {} @@ -280,3 +280,9 @@ void BpxBatteryHandler::setToGoToNormalMode(bool enable) { } void BpxBatteryHandler::setDebugMode(bool enable) { this->debugMode = enable; } + +void BpxBatteryHandler::performOperationHook() { +#if OBSW_THREAD_TRACING == 1 + trace::threadTrace(opCounter, "BPX BATT"); +#endif +} diff --git a/mission/devices/BpxBatteryHandler.h b/mission/devices/BpxBatteryHandler.h index ceb0ff8d..31448799 100644 --- a/mission/devices/BpxBatteryHandler.h +++ b/mission/devices/BpxBatteryHandler.h @@ -3,6 +3,7 @@ #include +#include "OBSWConfig.h" #include "devicedefinitions/BpxBatteryDefinitions.h" class BpxBatteryHandler : public DeviceHandlerBase { @@ -24,6 +25,10 @@ class BpxBatteryHandler : public DeviceHandlerBase { bool debugMode = false; bool goToNormalModeImmediately = false; uint8_t sentPingByte = BpxBattery::DEFAULT_PING_SENT_BYTE; +#if OBSW_THREAD_TRACING == 1 + uint32_t opCounter = 0; +#endif + BpxBatteryHk hkSet; DeviceCommandId_t lastCmd = DeviceHandlerIF::NO_COMMAND_ID; BpxBatteryCfg cfgSet; @@ -47,6 +52,7 @@ class BpxBatteryHandler : public DeviceHandlerBase { ReturnValue_t buildNormalDeviceCommand(DeviceCommandId_t* id) override; ReturnValue_t buildTransitionDeviceCommand(DeviceCommandId_t* id) override; void fillCommandAndReplyMap() override; + void performOperationHook() override; ReturnValue_t buildCommandFromCommand(DeviceCommandId_t deviceCommand, const uint8_t* commandData, size_t commandDataLen) override; ReturnValue_t scanForReply(const uint8_t* start, size_t remainingSize, DeviceCommandId_t* foundId, diff --git a/mission/devices/SolarArrayDeploymentHandler.cpp b/mission/devices/SolarArrayDeploymentHandler.cpp index 2b4e22ac..2eacdea4 100644 --- a/mission/devices/SolarArrayDeploymentHandler.cpp +++ b/mission/devices/SolarArrayDeploymentHandler.cpp @@ -37,6 +37,12 @@ SolarArrayDeploymentHandler::~SolarArrayDeploymentHandler() = default; ReturnValue_t SolarArrayDeploymentHandler::performOperation(uint8_t operationCode) { using namespace std::filesystem; +#if OBSW_THREAD_TRACING == 1 + opCounter++; + if (opCounter % 5 == 0) { + sif::debug << "SA DEPL task running" << std::endl; + } +#endif if (opDivider.checkAndIncrement()) { auto activeSdc = sdcMan.getActiveSdCard(); if (activeSdc and activeSdc.value() == sd::SdCard::SLOT_0 and diff --git a/mission/devices/SolarArrayDeploymentHandler.h b/mission/devices/SolarArrayDeploymentHandler.h index 63f1d3de..27c466f1 100644 --- a/mission/devices/SolarArrayDeploymentHandler.h +++ b/mission/devices/SolarArrayDeploymentHandler.h @@ -172,6 +172,9 @@ class SolarArrayDeploymentHandler : public ExecutableObjectIF, bool firstAutonomousCycle = true; ActionId_t activeCmd = HasActionsIF::INVALID_ACTION_ID; std::optional initUptime; +#if OBSW_THREAD_TRACING == 1 + uint32_t opCounter; +#endif PeriodicOperationDivider opDivider = PeriodicOperationDivider(5); uint8_t retryCounter = 3; diff --git a/mission/trace.cpp b/mission/trace.cpp new file mode 100644 index 00000000..f12e5902 --- /dev/null +++ b/mission/trace.cpp @@ -0,0 +1,10 @@ +#include "trace.h" + +#include "fsfw/serviceinterface.h" + +void trace::threadTrace(uint32_t& counter, const char* name) { + counter++; + if (counter % 5 == 0) { + sif::debug << name << " running" << std::endl; + } +} diff --git a/mission/trace.h b/mission/trace.h new file mode 100644 index 00000000..a3fabbd9 --- /dev/null +++ b/mission/trace.h @@ -0,0 +1,12 @@ +#ifndef MISSION_TRACE_H_ +#define MISSION_TRACE_H_ + +#include + +namespace trace { + +void threadTrace(uint32_t& counter, const char* name); + +} + +#endif /* MISSION_TRACE_H_ */ -- 2.43.0 From 2aac3c67ee7402a8a004f5231df830ccd52b3404 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Tue, 14 Feb 2023 11:10:18 +0100 Subject: [PATCH 02/10] instrumented some more tasks --- bsp_q7s/OBSWConfig.h.in | 1 - bsp_q7s/core/CoreController.cpp | 1 - bsp_q7s/core/CoreController.h | 1 + linux/devices/ploc/PlocMPSoCHelper.cpp | 4 +++- linux/devices/ploc/PlocMPSoCHelper.h | 5 +++++ linux/devices/ploc/PlocSupvUartMan.cpp | 3 +++ linux/devices/ploc/PlocSupvUartMan.h | 5 +++++ mission/controller/AcsController.cpp | 1 - mission/controller/AcsController.h | 2 +- mission/devices/BpxBatteryHandler.cpp | 2 -- mission/devices/BpxBatteryHandler.h | 2 +- mission/devices/SolarArrayDeploymentHandler.cpp | 1 + mission/devices/SolarArrayDeploymentHandler.h | 3 ++- mission/trace.h | 2 ++ 14 files changed, 24 insertions(+), 9 deletions(-) diff --git a/bsp_q7s/OBSWConfig.h.in b/bsp_q7s/OBSWConfig.h.in index a86dd8c7..687d9363 100644 --- a/bsp_q7s/OBSWConfig.h.in +++ b/bsp_q7s/OBSWConfig.h.in @@ -77,7 +77,6 @@ // If this is enabled, all other I2C code should be disabled #define OBSW_ADD_I2C_TEST_CODE 0 #define OBSW_ADD_UART_TEST_CODE 0 -#define OBSW_THREAD_TRACING 1 #define OBSW_TEST_ACS 0 #define OBSW_DEBUG_ACS 0 diff --git a/bsp_q7s/core/CoreController.cpp b/bsp_q7s/core/CoreController.cpp index 79dc68f5..4ff4965f 100644 --- a/bsp_q7s/core/CoreController.cpp +++ b/bsp_q7s/core/CoreController.cpp @@ -9,7 +9,6 @@ #include "fsfw/serviceinterface/ServiceInterface.h" #include "fsfw/timemanager/Stopwatch.h" #include "fsfw/version.h" -#include "mission/trace.h" #include "watchdog/definitions.h" #if OBSW_ADD_TMTC_UDP_SERVER == 1 #include "fsfw/osal/common/UdpTmTcBridge.h" diff --git a/bsp_q7s/core/CoreController.h b/bsp_q7s/core/CoreController.h index 36cf5d27..65ee20ef 100644 --- a/bsp_q7s/core/CoreController.h +++ b/bsp_q7s/core/CoreController.h @@ -12,6 +12,7 @@ #include "events/subsystemIdRanges.h" #include "fsfw/controller/ExtendedControllerBase.h" #include "mission/devices/devicedefinitions/GPSDefinitions.h" +#include "mission/trace.h" class Timer; class SdCardManager; diff --git a/linux/devices/ploc/PlocMPSoCHelper.cpp b/linux/devices/ploc/PlocMPSoCHelper.cpp index fcd5178b..fca2e51c 100644 --- a/linux/devices/ploc/PlocMPSoCHelper.cpp +++ b/linux/devices/ploc/PlocMPSoCHelper.cpp @@ -3,7 +3,6 @@ #include #include -#include "OBSWConfig.h" #ifdef XIPHOS_Q7S #include "bsp_q7s/fs/FilesystemHelper.h" #endif @@ -34,6 +33,9 @@ ReturnValue_t PlocMPSoCHelper::performOperation(uint8_t operationCode) { ReturnValue_t result = returnvalue::OK; semaphore.acquire(); while (true) { +#if OBSW_THREAD_TRACING == 1 + trace::threadTrace(opCounter, "PLOC MPSOC Helper"); +#endif switch (internalState) { case InternalState::IDLE: { semaphore.acquire(); diff --git a/linux/devices/ploc/PlocMPSoCHelper.h b/linux/devices/ploc/PlocMPSoCHelper.h index c39cc758..dea35a82 100644 --- a/linux/devices/ploc/PlocMPSoCHelper.h +++ b/linux/devices/ploc/PlocMPSoCHelper.h @@ -11,6 +11,7 @@ #include "fsfw/tmtcservices/SourceSequenceCounter.h" #include "fsfw_hal/linux/serial/SerialComIF.h" #include "linux/devices/devicedefinitions/PlocMPSoCDefinitions.h" +#include "mission/trace.h" #ifdef XIPHOS_Q7S #include "bsp_q7s/fs/SdCardManager.h" #endif @@ -116,6 +117,10 @@ class PlocMPSoCHelper : public SystemObject, public ExecutableObjectIF { struct FlashWrite flashWrite; +#if OBSW_THREAD_TRACING == 1 + uint32_t opCounter = 0; +#endif + enum class InternalState { IDLE, FLASH_WRITE, FLASH_READ }; InternalState internalState = InternalState::IDLE; diff --git a/linux/devices/ploc/PlocSupvUartMan.cpp b/linux/devices/ploc/PlocSupvUartMan.cpp index 1fd2b841..5113de40 100644 --- a/linux/devices/ploc/PlocSupvUartMan.cpp +++ b/linux/devices/ploc/PlocSupvUartMan.cpp @@ -101,6 +101,9 @@ ReturnValue_t PlocSupvUartManager::performOperation(uint8_t operationCode) { lock->unlockMutex(); semaphore->acquire(); putTaskToSleep = false; +#if OBSW_THREAD_TRACING == 1 + trace::threadTrace(opCounter, "PLOC SUPV Helper PST"); +#endif while (true) { if (putTaskToSleep) { performUartShutdown(); diff --git a/linux/devices/ploc/PlocSupvUartMan.h b/linux/devices/ploc/PlocSupvUartMan.h index e1539c97..b787815f 100644 --- a/linux/devices/ploc/PlocSupvUartMan.h +++ b/linux/devices/ploc/PlocSupvUartMan.h @@ -7,6 +7,7 @@ #include #include "OBSWConfig.h" +#include "mission/trace.h" #include "fsfw/container/FIFO.h" #include "fsfw/devicehandlers/CookieIF.h" #include "fsfw/objectmanager/SystemObject.h" @@ -15,6 +16,7 @@ #include "fsfw/tasks/ExecutableObjectIF.h" #include "fsfw_hal/linux/serial/SerialComIF.h" #include "linux/devices/devicedefinitions/PlocSupervisorDefinitions.h" +#include "mission/trace.h" #include "tas/crc.h" #ifdef XIPHOS_Q7S @@ -211,6 +213,9 @@ class PlocSupvUartManager : public DeviceCommunicationIF, supv::TmBase tmReader; int serialPort = 0; struct termios tty = {}; +#if OBSW_THREAD_TRACING == 1 + uint32_t opCounter = 0; +#endif struct EventBufferRequest { std::string path = ""; diff --git a/mission/controller/AcsController.cpp b/mission/controller/AcsController.cpp index 72589fcc..051fa8f0 100644 --- a/mission/controller/AcsController.cpp +++ b/mission/controller/AcsController.cpp @@ -4,7 +4,6 @@ #include "mission/acsDefs.h" #include "mission/config/torquer.h" -#include "mission/trace.h" AcsController::AcsController(object_id_t objectId) : ExtendedControllerBase(objectId), diff --git a/mission/controller/AcsController.h b/mission/controller/AcsController.h index 14972b3e..f5240b74 100644 --- a/mission/controller/AcsController.h +++ b/mission/controller/AcsController.h @@ -6,7 +6,6 @@ #include #include -#include "OBSWConfig.h" #include "acs/ActuatorCmd.h" #include "acs/Guidance.h" #include "acs/Navigation.h" @@ -20,6 +19,7 @@ #include "fsfw_hal/devicehandlers/MgmRM3100Handler.h" #include "mission/devices/devicedefinitions/SusDefinitions.h" #include "mission/devices/devicedefinitions/imtqHandlerDefinitions.h" +#include "mission/trace.h" class AcsController : public ExtendedControllerBase, public ReceivesParameterMessagesIF { public: diff --git a/mission/devices/BpxBatteryHandler.cpp b/mission/devices/BpxBatteryHandler.cpp index efda26f8..922bcd3b 100644 --- a/mission/devices/BpxBatteryHandler.cpp +++ b/mission/devices/BpxBatteryHandler.cpp @@ -2,8 +2,6 @@ #include -#include "mission/trace.h" - BpxBatteryHandler::BpxBatteryHandler(object_id_t objectId, object_id_t comIF, CookieIF* comCookie) : DeviceHandlerBase(objectId, comIF, comCookie), hkSet(this), cfgSet(this) {} diff --git a/mission/devices/BpxBatteryHandler.h b/mission/devices/BpxBatteryHandler.h index 31448799..c42ed7fd 100644 --- a/mission/devices/BpxBatteryHandler.h +++ b/mission/devices/BpxBatteryHandler.h @@ -3,8 +3,8 @@ #include -#include "OBSWConfig.h" #include "devicedefinitions/BpxBatteryDefinitions.h" +#include "mission/trace.h" class BpxBatteryHandler : public DeviceHandlerBase { public: diff --git a/mission/devices/SolarArrayDeploymentHandler.cpp b/mission/devices/SolarArrayDeploymentHandler.cpp index 2eacdea4..cb8658bc 100644 --- a/mission/devices/SolarArrayDeploymentHandler.cpp +++ b/mission/devices/SolarArrayDeploymentHandler.cpp @@ -11,6 +11,7 @@ #include "fsfw/ipc/QueueFactory.h" #include "fsfw/objectmanager/ObjectManager.h" #include "fsfw_hal/common/gpio/GpioCookie.h" +#include "mission/trace.h" static constexpr bool DEBUG_MODE = true; diff --git a/mission/devices/SolarArrayDeploymentHandler.h b/mission/devices/SolarArrayDeploymentHandler.h index 27c466f1..61211ca3 100644 --- a/mission/devices/SolarArrayDeploymentHandler.h +++ b/mission/devices/SolarArrayDeploymentHandler.h @@ -19,6 +19,7 @@ #include "fsfw/timemanager/Countdown.h" #include "fsfw_hal/common/gpio/GpioIF.h" #include "mission/memory/SdCardMountedIF.h" +#include "mission/trace.h" #include "returnvalues/classIds.h" enum DeploymentChannels : uint8_t { SA_1 = 1, SA_2 = 2 }; @@ -173,7 +174,7 @@ class SolarArrayDeploymentHandler : public ExecutableObjectIF, ActionId_t activeCmd = HasActionsIF::INVALID_ACTION_ID; std::optional initUptime; #if OBSW_THREAD_TRACING == 1 - uint32_t opCounter; + uint32_t opCounter = 0; #endif PeriodicOperationDivider opDivider = PeriodicOperationDivider(5); uint8_t retryCounter = 3; diff --git a/mission/trace.h b/mission/trace.h index a3fabbd9..6f20a698 100644 --- a/mission/trace.h +++ b/mission/trace.h @@ -3,6 +3,8 @@ #include +#define OBSW_THREAD_TRACING 1 + namespace trace { void threadTrace(uint32_t& counter, const char* name); -- 2.43.0 From a57384f6c43a20281884cde5cd984af71ed89b0f Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Tue, 14 Feb 2023 11:11:06 +0100 Subject: [PATCH 03/10] trace has settable div --- mission/trace.cpp | 4 ++-- mission/trace.h | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/mission/trace.cpp b/mission/trace.cpp index f12e5902..6c9af0af 100644 --- a/mission/trace.cpp +++ b/mission/trace.cpp @@ -2,9 +2,9 @@ #include "fsfw/serviceinterface.h" -void trace::threadTrace(uint32_t& counter, const char* name) { +void trace::threadTrace(uint32_t& counter, const char* name, unsigned div) { counter++; - if (counter % 5 == 0) { + if (counter % div == 0) { sif::debug << name << " running" << std::endl; } } diff --git a/mission/trace.h b/mission/trace.h index 6f20a698..59fdd99e 100644 --- a/mission/trace.h +++ b/mission/trace.h @@ -7,7 +7,7 @@ namespace trace { -void threadTrace(uint32_t& counter, const char* name); +void threadTrace(uint32_t& counter, const char* name, unsigned div = 5); } -- 2.43.0 From 9b2398888dfd11a8e4e5093492067b7bbca81d5b Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Tue, 14 Feb 2023 11:18:51 +0100 Subject: [PATCH 04/10] add some more traces --- linux/devices/GpsHyperionLinuxController.cpp | 3 +++ linux/devices/GpsHyperionLinuxController.h | 4 ++++ linux/devices/ploc/PlocSupvUartMan.h | 1 - mission/controller/ThermalController.cpp | 3 +++ mission/controller/ThermalController.h | 7 ++++++- 5 files changed, 16 insertions(+), 2 deletions(-) diff --git a/linux/devices/GpsHyperionLinuxController.cpp b/linux/devices/GpsHyperionLinuxController.cpp index afc76fcf..a6e0a1a3 100644 --- a/linux/devices/GpsHyperionLinuxController.cpp +++ b/linux/devices/GpsHyperionLinuxController.cpp @@ -102,6 +102,9 @@ ReturnValue_t GpsHyperionLinuxController::performOperation(uint8_t opCode) { handleQueue(); poolManager.performHkOperation(); while (true) { +#if OBSW_THREAD_TRACING == 1 + trace::threadTrace(opCounter, "GPS CTRL"); +#endif bool callAgainImmediately = readGpsDataFromGpsd(); if (not callAgainImmediately) { handleQueue(); diff --git a/linux/devices/GpsHyperionLinuxController.h b/linux/devices/GpsHyperionLinuxController.h index 5d4a35ff..1e97bc29 100644 --- a/linux/devices/GpsHyperionLinuxController.h +++ b/linux/devices/GpsHyperionLinuxController.h @@ -6,6 +6,7 @@ #include "fsfw/controller/ExtendedControllerBase.h" #include "fsfw/devicehandlers/DeviceHandlerBase.h" #include "mission/devices/devicedefinitions/GPSDefinitions.h" +#include "mission/trace.h" #ifdef FSFW_OSAL_LINUX #include @@ -60,6 +61,9 @@ class GpsHyperionLinuxController : public ExtendedControllerBase { Countdown maxTimeToReachFix = Countdown(MAX_SECONDS_TO_REACH_FIX * 1000); bool modeCommanded = false; bool timeInit = false; +#if OBSW_THREAD_TRACING == 1 + uint32_t opCounter = 0; +#endif struct OneShotSwitches { void reset() { diff --git a/linux/devices/ploc/PlocSupvUartMan.h b/linux/devices/ploc/PlocSupvUartMan.h index b787815f..02bfb6c7 100644 --- a/linux/devices/ploc/PlocSupvUartMan.h +++ b/linux/devices/ploc/PlocSupvUartMan.h @@ -7,7 +7,6 @@ #include #include "OBSWConfig.h" -#include "mission/trace.h" #include "fsfw/container/FIFO.h" #include "fsfw/devicehandlers/CookieIF.h" #include "fsfw/objectmanager/SystemObject.h" diff --git a/mission/controller/ThermalController.cpp b/mission/controller/ThermalController.cpp index 0521d9aa..53b7f13d 100644 --- a/mission/controller/ThermalController.cpp +++ b/mission/controller/ThermalController.cpp @@ -72,6 +72,9 @@ ReturnValue_t ThermalController::handleCommandMessage(CommandMessage* message) { } void ThermalController::performControlOperation() { +#if OBSW_THREAD_TRACING == 1 + trace::threadTrace(opCounter, "TCS Task"); +#endif switch (internalState) { case InternalState::STARTUP: { initialCountdown.resetTimer(); diff --git a/mission/controller/ThermalController.h b/mission/controller/ThermalController.h index 03c7954c..6297b175 100644 --- a/mission/controller/ThermalController.h +++ b/mission/controller/ThermalController.h @@ -11,7 +11,8 @@ #include -#include "../devices/HeaterHandler.h" +#include "mission/devices/HeaterHandler.h" +#include "mission/trace.h" /** * NOP Limit: Hard limit for device, usually from datasheet. Device damage is possible lif NOP limit @@ -152,6 +153,10 @@ class ThermalController : public ExtendedControllerBase { // Initial delay to make sure all pool variables have been initialized their owners Countdown initialCountdown = Countdown(DELAY); +#if OBSW_THREAD_TRACING == 1 + uint32_t opCounter = 0; +#endif + std::array, 5> sensors; uint8_t numSensors = 0; -- 2.43.0 From ecb22bdd85655d93e673646fe108a666daaee690 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Tue, 14 Feb 2023 11:32:03 +0100 Subject: [PATCH 05/10] further cut down the number of threads --- bsp_q7s/core/scheduling.cpp | 56 ++++++++++++------------------- linux/scheduling.cpp | 66 ++++++++++++++++++------------------- linux/scheduling.h | 4 +-- 3 files changed, 56 insertions(+), 70 deletions(-) diff --git a/bsp_q7s/core/scheduling.cpp b/bsp_q7s/core/scheduling.cpp index 5abe3fd5..2fa8f015 100644 --- a/bsp_q7s/core/scheduling.cpp +++ b/bsp_q7s/core/scheduling.cpp @@ -154,6 +154,14 @@ void scheduling::initTasks() { if (result != returnvalue::OK) { scheduling::printAddObjectError("PL_SUBSYSTEM", objects::PL_SUBSYSTEM); } + result = genericSysTask->addComponent(objects::INTERNAL_ERROR_REPORTER); + if (result != returnvalue::OK) { + scheduling::printAddObjectError("ERROR_REPORTER", objects::INTERNAL_ERROR_REPORTER); + } + result = genericSysTask->addComponent(objects::PUS_SERVICE_17_TEST); + if (result != returnvalue::OK) { + scheduling::printAddObjectError("PUS_17", objects::PUS_SERVICE_17_TEST); + } #if OBSW_ADD_CCSDS_IP_CORES == 1 result = genericSysTask->addComponent(objects::CCSDS_HANDLER); @@ -266,14 +274,16 @@ void scheduling::initTasks() { #endif /* OBSW_ADD_PLOC_SUPERVISOR */ PeriodicTaskIF* plTask = factory->createPeriodicTask( - "PL_TASK", 25, PeriodicTaskIF::MINIMUM_STACK_SIZE, 1.0, missedDeadlineFunc); - scheduling::addMpsocSupvHandlers(plTask); + "PL_TASK", 30, PeriodicTaskIF::MINIMUM_STACK_SIZE, 0.8, missedDeadlineFunc); plTask->addComponent(objects::CAM_SWITCHER); + scheduling::addMpsocSupvHandlers(plTask); +#if OBSW_ADD_SCEX_DEVICE == 1 + scheduling::scheduleScexDev(plTask); +#endif #if OBSW_ADD_SCEX_DEVICE == 1 - PeriodicTaskIF* scexDevHandler; PeriodicTaskIF* scexReaderTask; - scheduling::schedulingScex(*factory, scexDevHandler, scexReaderTask); + scheduling::scheduleScexReader(*factory, scexReaderTask); #endif std::vector pusTasks; @@ -330,7 +340,6 @@ void scheduling::initTasks() { taskStarter(pstTasks, "PST task vector"); taskStarter(pusTasks, "PUS task vector"); #if OBSW_ADD_SCEX_DEVICE == 1 - scexDevHandler->startTask(); scexReaderTask->startTask(); #endif @@ -435,42 +444,28 @@ void scheduling::createPusTasks(TaskFactory& factory, TaskDeadlineMissedFunction std::vector& taskVec) { ReturnValue_t result = returnvalue::OK; /* PUS Services */ - PeriodicTaskIF* pusVerification = factory.createPeriodicTask( - "PUS_VERIF", 40, PeriodicTaskIF::MINIMUM_STACK_SIZE, 0.200, missedDeadlineFunc); - result = pusVerification->addComponent(objects::PUS_SERVICE_1_VERIFICATION); + PeriodicTaskIF* pusHighPrio = factory.createPeriodicTask( + "PUS_HIGH_PRIO", 60, PeriodicTaskIF::MINIMUM_STACK_SIZE, 0.2, missedDeadlineFunc); + result = pusHighPrio->addComponent(objects::PUS_SERVICE_1_VERIFICATION); if (result != returnvalue::OK) { scheduling::printAddObjectError("PUS_VERIF", objects::PUS_SERVICE_1_VERIFICATION); } - taskVec.push_back(pusVerification); - - PeriodicTaskIF* pusEvents = factory.createPeriodicTask( - "PUS_EVENTS", 60, PeriodicTaskIF::MINIMUM_STACK_SIZE, 0.200, missedDeadlineFunc); - result = pusEvents->addComponent(objects::PUS_SERVICE_5_EVENT_REPORTING); + result = pusHighPrio->addComponent(objects::PUS_SERVICE_5_EVENT_REPORTING); if (result != returnvalue::OK) { scheduling::printAddObjectError("PUS_EVENTS", objects::PUS_SERVICE_5_EVENT_REPORTING); } - result = pusEvents->addComponent(objects::EVENT_MANAGER); + result = pusHighPrio->addComponent(objects::EVENT_MANAGER); if (result != returnvalue::OK) { scheduling::printAddObjectError("PUS_MGMT", objects::EVENT_MANAGER); } - taskVec.push_back(pusEvents); - - PeriodicTaskIF* pusHighPrio = factory.createPeriodicTask( - "PUS_HIGH_PRIO", 50, PeriodicTaskIF::MINIMUM_STACK_SIZE, 0.2, missedDeadlineFunc); - result = pusHighPrio->addComponent(objects::PUS_SERVICE_2_DEVICE_ACCESS); - if (result != returnvalue::OK) { - scheduling::printAddObjectError("PUS_2", objects::PUS_SERVICE_2_DEVICE_ACCESS); - } result = pusHighPrio->addComponent(objects::PUS_SERVICE_9_TIME_MGMT); if (result != returnvalue::OK) { scheduling::printAddObjectError("PUS_9", objects::PUS_SERVICE_9_TIME_MGMT); } - taskVec.push_back(pusHighPrio); PeriodicTaskIF* pusMedPrio = factory.createPeriodicTask( "PUS_MED_PRIO", 40, PeriodicTaskIF::MINIMUM_STACK_SIZE, 0.8, missedDeadlineFunc); - result = pusMedPrio->addComponent(objects::PUS_SERVICE_3_HOUSEKEEPING); if (result != returnvalue::OK) { scheduling::printAddObjectError("PUS_3", objects::PUS_SERVICE_3_HOUSEKEEPING); @@ -495,20 +490,11 @@ void scheduling::createPusTasks(TaskFactory& factory, TaskDeadlineMissedFunction if (result != returnvalue::OK) { scheduling::printAddObjectError("PUS_201", objects::PUS_SERVICE_201_HEALTH); } - // Used for connection tests, therefore use higher priority - result = pusMedPrio->addComponent(objects::PUS_SERVICE_17_TEST); + result = pusMedPrio->addComponent(objects::PUS_SERVICE_2_DEVICE_ACCESS); if (result != returnvalue::OK) { - scheduling::printAddObjectError("PUS_17", objects::PUS_SERVICE_17_TEST); + scheduling::printAddObjectError("PUS_2", objects::PUS_SERVICE_2_DEVICE_ACCESS); } taskVec.push_back(pusMedPrio); - - PeriodicTaskIF* pusLowPrio = factory.createPeriodicTask( - "PUS_LOW_PRIO", 30, PeriodicTaskIF::MINIMUM_STACK_SIZE, 1.6, missedDeadlineFunc); - result = pusLowPrio->addComponent(objects::INTERNAL_ERROR_REPORTER); - if (result != returnvalue::OK) { - scheduling::printAddObjectError("ERROR_REPORTER", objects::INTERNAL_ERROR_REPORTER); - } - taskVec.push_back(pusLowPrio); } void scheduling::createTestTasks(TaskFactory& factory, diff --git a/linux/scheduling.cpp b/linux/scheduling.cpp index f2e6ddec..85394dea 100644 --- a/linux/scheduling.cpp +++ b/linux/scheduling.cpp @@ -8,8 +8,7 @@ #include "ObjectFactory.h" #include "eive/objects.h" -void scheduling::schedulingScex(TaskFactory& factory, PeriodicTaskIF*& scexDevHandler, - PeriodicTaskIF*& scexReaderTask) { +void scheduling::scheduleScexReader(TaskFactory& factory, PeriodicTaskIF*& scexReaderTask) { using namespace scheduling; ReturnValue_t result = returnvalue::OK; #if OBSW_PRINT_MISSED_DEADLINES == 1 @@ -17,37 +16,6 @@ void scheduling::schedulingScex(TaskFactory& factory, PeriodicTaskIF*& scexDevHa #else void (*missedDeadlineFunc)(void) = nullptr; #endif - scexDevHandler = factory.createPeriodicTask( - "SCEX_DEV", 35, PeriodicTaskIF::MINIMUM_STACK_SIZE * 2, 0.5, missedDeadlineFunc); - - result = scexDevHandler->addComponent(objects::SCEX, DeviceHandlerIF::PERFORM_OPERATION); - if (result != returnvalue::OK) { - printAddObjectError("SCEX_DEV", objects::SCEX); - } - result = scexDevHandler->addComponent(objects::SCEX, DeviceHandlerIF::SEND_WRITE); - if (result != returnvalue::OK) { - printAddObjectError("SCEX_DEV", objects::SCEX); - } - result = scexDevHandler->addComponent(objects::SCEX, DeviceHandlerIF::GET_WRITE); - if (result != returnvalue::OK) { - printAddObjectError("SCEX_DEV", objects::SCEX); - } - result = scexDevHandler->addComponent(objects::SCEX, DeviceHandlerIF::SEND_READ); - if (result != returnvalue::OK) { - printAddObjectError("SCEX_DEV", objects::SCEX); - } - result = scexDevHandler->addComponent(objects::SCEX, DeviceHandlerIF::GET_READ); - if (result != returnvalue::OK) { - printAddObjectError("SCEX_DEV", objects::SCEX); - } - result = scexDevHandler->addComponent(objects::SCEX, DeviceHandlerIF::SEND_READ); - if (result != returnvalue::OK) { - printAddObjectError("SCEX_DEV", objects::SCEX); - } - result = scexDevHandler->addComponent(objects::SCEX, DeviceHandlerIF::GET_READ); - if (result != returnvalue::OK) { - printAddObjectError("SCEX_DEV", objects::SCEX); - } result = returnvalue::OK; scexReaderTask = factory.createPeriodicTask( @@ -79,3 +47,35 @@ void scheduling::addMpsocSupvHandlers(PeriodicTaskIF* plTask) { plTask->addComponent(objects::PLOC_MPSOC_HANDLER, DeviceHandlerIF::GET_READ); #endif } + +void scheduling::scheduleScexDev(PeriodicTaskIF*& scexDevHandler) { + ReturnValue_t result = + scexDevHandler->addComponent(objects::SCEX, DeviceHandlerIF::PERFORM_OPERATION); + if (result != returnvalue::OK) { + printAddObjectError("SCEX_DEV", objects::SCEX); + } + result = scexDevHandler->addComponent(objects::SCEX, DeviceHandlerIF::SEND_WRITE); + if (result != returnvalue::OK) { + printAddObjectError("SCEX_DEV", objects::SCEX); + } + result = scexDevHandler->addComponent(objects::SCEX, DeviceHandlerIF::GET_WRITE); + if (result != returnvalue::OK) { + printAddObjectError("SCEX_DEV", objects::SCEX); + } + result = scexDevHandler->addComponent(objects::SCEX, DeviceHandlerIF::SEND_READ); + if (result != returnvalue::OK) { + printAddObjectError("SCEX_DEV", objects::SCEX); + } + result = scexDevHandler->addComponent(objects::SCEX, DeviceHandlerIF::GET_READ); + if (result != returnvalue::OK) { + printAddObjectError("SCEX_DEV", objects::SCEX); + } + result = scexDevHandler->addComponent(objects::SCEX, DeviceHandlerIF::SEND_READ); + if (result != returnvalue::OK) { + printAddObjectError("SCEX_DEV", objects::SCEX); + } + result = scexDevHandler->addComponent(objects::SCEX, DeviceHandlerIF::GET_READ); + if (result != returnvalue::OK) { + printAddObjectError("SCEX_DEV", objects::SCEX); + } +} diff --git a/linux/scheduling.h b/linux/scheduling.h index d33e9d1f..b5ec8ef2 100644 --- a/linux/scheduling.h +++ b/linux/scheduling.h @@ -3,7 +3,7 @@ #include namespace scheduling { -void schedulingScex(TaskFactory& factory, PeriodicTaskIF*& scexDevHandler, - PeriodicTaskIF*& scexReaderTask); +void scheduleScexDev(PeriodicTaskIF*& scexDevHandler); +void scheduleScexReader(TaskFactory& factory, PeriodicTaskIF*& scexReaderTask); void addMpsocSupvHandlers(PeriodicTaskIF* task); } // namespace scheduling -- 2.43.0 From 2d4c881d3ab84914603494f6ad4d6df71e7713b9 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Tue, 14 Feb 2023 11:56:40 +0100 Subject: [PATCH 06/10] add missing include --- linux/fsfwconfig/pollingsequence/pollingSequenceFactory.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/linux/fsfwconfig/pollingsequence/pollingSequenceFactory.cpp b/linux/fsfwconfig/pollingsequence/pollingSequenceFactory.cpp index 63b40df2..062bf7e7 100644 --- a/linux/fsfwconfig/pollingsequence/pollingSequenceFactory.cpp +++ b/linux/fsfwconfig/pollingsequence/pollingSequenceFactory.cpp @@ -1,5 +1,7 @@ #include "pollingSequenceFactory.h" +#include "OBSWConfig.h" + #include #include #include -- 2.43.0 From 35b9c7a4df590f28e8ed05c18378c74dd120c475 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Tue, 14 Feb 2023 14:27:25 +0100 Subject: [PATCH 07/10] bump changelog --- CHANGELOG.md | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index f49f4ed4..d01f4290 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -19,8 +19,17 @@ change warranting a new major release: ## Changed -- Remove 2 TCS threads. -- Move low level polling into ACS PST, move high level device handlers into TCS system task. +- Remove 2 TCS threads. Move low level polling into ACS PST, move high level device handlers into + TCS system task. +- Further reduce number of threads: + 1. Remove PUS low priority task, move assigned threads to the generic system task + 2. Group events and verification tasks into PUS high priority task + 3. Group all other components into PUS medium priority task + 4. Add SCEX device handler to PL task, remove dedicated thread + +## Added + +- Tracing supports which allows checking whether threads are running as usual. ## Removed -- 2.43.0 From 024e06a3d33cf85303a62083fb027effef155ff7 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Tue, 14 Feb 2023 14:28:26 +0100 Subject: [PATCH 08/10] set define to 0 for PR --- mission/trace.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mission/trace.h b/mission/trace.h index 59fdd99e..fbc99d37 100644 --- a/mission/trace.h +++ b/mission/trace.h @@ -3,7 +3,7 @@ #include -#define OBSW_THREAD_TRACING 1 +#define OBSW_THREAD_TRACING 0 namespace trace { -- 2.43.0 From 6f84099c5e5e537a312d6221101f892fc8ef83aa Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Tue, 14 Feb 2023 14:29:47 +0100 Subject: [PATCH 09/10] small update and afmt --- CMakeLists.txt | 4 ++-- linux/boardtest/UartTestClass.h | 2 +- linux/fsfwconfig/pollingsequence/pollingSequenceFactory.cpp | 3 +-- mission/devices/SolarArrayDeploymentHandler.cpp | 5 +---- test/TestTask.cpp | 3 --- 5 files changed, 5 insertions(+), 12 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 5ce19479..8a8055bd 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -490,8 +490,8 @@ endif() # ############################################################################## # Add libraries -target_link_libraries(${LIB_EIVE_MISSION} - PUBLIC ${LIB_FSFW_NAME} ${LIB_OS_NAME}) +target_link_libraries(${LIB_EIVE_MISSION} PUBLIC ${LIB_FSFW_NAME} + ${LIB_OS_NAME}) target_link_libraries(${LIB_DUMMIES} PUBLIC ${LIB_FSFW_NAME} ${LIB_JSON_NAME}) diff --git a/linux/boardtest/UartTestClass.h b/linux/boardtest/UartTestClass.h index 6cb0d31c..fd20e621 100644 --- a/linux/boardtest/UartTestClass.h +++ b/linux/boardtest/UartTestClass.h @@ -59,7 +59,7 @@ class UartTestClass : public TestTask { DleEncoder dleEncoder = DleEncoder(); SerialCookie* uartCookie = nullptr; size_t encodedLen = 0; - //lwgps_t gpsData = {}; + // lwgps_t gpsData = {}; struct termios tty = {}; int serialPort = 0; bool startFound = false; diff --git a/linux/fsfwconfig/pollingsequence/pollingSequenceFactory.cpp b/linux/fsfwconfig/pollingsequence/pollingSequenceFactory.cpp index 062bf7e7..d8df8e9a 100644 --- a/linux/fsfwconfig/pollingsequence/pollingSequenceFactory.cpp +++ b/linux/fsfwconfig/pollingsequence/pollingSequenceFactory.cpp @@ -1,12 +1,11 @@ #include "pollingSequenceFactory.h" -#include "OBSWConfig.h" - #include #include #include #include +#include "OBSWConfig.h" #include "eive/definitions.h" #include "mission/devices/devicedefinitions/Max31865Definitions.h" diff --git a/mission/devices/SolarArrayDeploymentHandler.cpp b/mission/devices/SolarArrayDeploymentHandler.cpp index cb8658bc..77c826fd 100644 --- a/mission/devices/SolarArrayDeploymentHandler.cpp +++ b/mission/devices/SolarArrayDeploymentHandler.cpp @@ -39,10 +39,7 @@ SolarArrayDeploymentHandler::~SolarArrayDeploymentHandler() = default; ReturnValue_t SolarArrayDeploymentHandler::performOperation(uint8_t operationCode) { using namespace std::filesystem; #if OBSW_THREAD_TRACING == 1 - opCounter++; - if (opCounter % 5 == 0) { - sif::debug << "SA DEPL task running" << std::endl; - } + trace::threadTrace(opCounter, "SA DEPL"); #endif if (opDivider.checkAndIncrement()) { auto activeSdc = sdcMan.getActiveSdCard(); diff --git a/test/TestTask.cpp b/test/TestTask.cpp index 33af5494..2c6cb015 100644 --- a/test/TestTask.cpp +++ b/test/TestTask.cpp @@ -42,10 +42,8 @@ ReturnValue_t EiveTestTask::performOperation(uint8_t operationCode) { #include - // #include - /** * @brief Dummy data from GPS receiver. Will be replaced witgh hyperion data later. */ @@ -76,7 +74,6 @@ const char hyperion_gps_data[] = "$GNVTG,040.7,T,,M,000.0,N,000.0,K,A*10\r\n" "$GNZDA,173225.998892,27,02,2021,00,00*75\r\n"; - ReturnValue_t EiveTestTask::performOneShotAction() { #if OBSW_ADD_TEST_CODE == 1 // performLwgpsTest(); -- 2.43.0 From d506b515fc63476304e2d7934096549ecce2fa13 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Tue, 14 Feb 2023 14:33:12 +0100 Subject: [PATCH 10/10] bump fsfw --- fsfw | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fsfw b/fsfw index d256ede8..9de6c4b3 160000 --- a/fsfw +++ b/fsfw @@ -1 +1 @@ -Subproject commit d256ede8c1d8e7a746d3a56d45313d2b863e0b28 +Subproject commit 9de6c4b3aa20ee63c28051d486be8a12df147f22 -- 2.43.0