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_ */