From ea6fd8c952efe9f24ce2f700d6ba80e6e99f2b82 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Wed, 9 Nov 2022 13:07:20 +0100 Subject: [PATCH 1/2] smaller fixes and improvements --- bsp_q7s/core/CoreController.cpp | 22 ++++++++++------------ bsp_q7s/core/CoreController.h | 6 +++++- fsfw | 2 +- linux/devices/ScexUartReader.cpp | 6 +++++- mission/devices/ScexDeviceHandler.cpp | 13 ++++++++++--- mission/devices/ScexDeviceHandler.h | 1 + tmtc | 2 +- 7 files changed, 33 insertions(+), 19 deletions(-) diff --git a/bsp_q7s/core/CoreController.cpp b/bsp_q7s/core/CoreController.cpp index 5a807b64..05660705 100644 --- a/bsp_q7s/core/CoreController.cpp +++ b/bsp_q7s/core/CoreController.cpp @@ -47,10 +47,7 @@ CoreController::CoreController(object_id_t objectId) sdcMan->setBlocking(false); } - result = initBootCopy(); - if (result != returnvalue::OK) { - sif::warning << "CoreController::CoreController: Boot copy init" << std::endl; - } + getCurrentBootCopy(CURRENT_CHIP, CURRENT_COPY); } catch (const std::filesystem::filesystem_error &e) { sif::error << "CoreController::CoreController: Failed with exception " << e.what() << std::endl; } @@ -95,9 +92,9 @@ void CoreController::performControlOperation() { ReturnValue_t CoreController::initializeLocalDataPool(localpool::DataPool &localDataPoolMap, LocalDataPoolManager &poolManager) { - localDataPoolMap.emplace(core::TEMPERATURE, new PoolEntry({0})); - localDataPoolMap.emplace(core::PS_VOLTAGE, new PoolEntry({0})); - localDataPoolMap.emplace(core::PL_VOLTAGE, new PoolEntry({0})); + localDataPoolMap.emplace(core::TEMPERATURE, &tempPoolEntry); + localDataPoolMap.emplace(core::PS_VOLTAGE, &psVoltageEntry); + localDataPoolMap.emplace(core::PL_VOLTAGE, &plVoltageEntry); poolManager.subscribeForRegularPeriodicPacket({hkSet.getSid(), false, 10.0}); return returnvalue::OK; } @@ -175,8 +172,7 @@ ReturnValue_t CoreController::initializeAfterTaskCreation() { setenv("PATH", updatedEnvPath.c_str(), true); updateProtInfo(); initPrint(); - ExtendedControllerBase::initializeAfterTaskCreation(); - return result; + return ExtendedControllerBase::initializeAfterTaskCreation(); } ReturnValue_t CoreController::executeAction(ActionId_t actionId, MessageQueueId_t commandedBy, @@ -797,7 +793,7 @@ ReturnValue_t CoreController::actionListDirectoryIntoFile(ActionId_t actionId, return returnvalue::OK; } -ReturnValue_t CoreController::initBootCopy() { +ReturnValue_t CoreController::initBootCopyFile() { if (not std::filesystem::exists(CURR_COPY_FILE)) { // This file is created by the systemd service eive-early-config so this should // not happen normally @@ -807,8 +803,6 @@ ReturnValue_t CoreController::initBootCopy() { utility::handleSystemError(result, "CoreController::initBootCopy"); } } - - getCurrentBootCopy(CURRENT_CHIP, CURRENT_COPY); return returnvalue::OK; } @@ -1244,6 +1238,10 @@ void CoreController::performMountedSdCardOperations() { std::filesystem::create_directory(path.str()); } initVersionFile(); + ReturnValue_t result = initBootCopyFile(); + if (result != returnvalue::OK) { + sif::warning << "CoreController::CoreController: Boot copy init" << std::endl; + } initClockFromTimeFile(); performRebootFileHandling(false); } diff --git a/bsp_q7s/core/CoreController.h b/bsp_q7s/core/CoreController.h index c3c830cc..4d9d5ee8 100644 --- a/bsp_q7s/core/CoreController.h +++ b/bsp_q7s/core/CoreController.h @@ -226,6 +226,10 @@ class CoreController : public ExtendedControllerBase { PeriodicOperationDivider opDivider5; PeriodicOperationDivider opDivider10; + PoolEntry tempPoolEntry = PoolEntry(0.0); + PoolEntry psVoltageEntry = PoolEntry(0.0); + PoolEntry plVoltageEntry = PoolEntry(0.0); + core::HkSet hkSet; #if OBSW_SD_CARD_MUST_BE_ON == 1 @@ -243,7 +247,7 @@ class CoreController : public ExtendedControllerBase { ReturnValue_t initClockFromTimeFile(); ReturnValue_t performSdCardCheck(); ReturnValue_t timeFileHandler(); - ReturnValue_t initBootCopy(); + ReturnValue_t initBootCopyFile(); ReturnValue_t initWatchdogFifo(); ReturnValue_t initSdCardBlocking(); bool startSdStateMachine(sd::SdCard targetActiveSd, SdCfgMode mode, MessageQueueId_t commander, diff --git a/fsfw b/fsfw index 84b9d1ce..0e8f5ddd 160000 --- a/fsfw +++ b/fsfw @@ -1 +1 @@ -Subproject commit 84b9d1ce216c076bdfeeaf1663aa873c7f1c9cff +Subproject commit 0e8f5ddd26d586dd40e69f52aef1a63c0d5a9da6 diff --git a/linux/devices/ScexUartReader.cpp b/linux/devices/ScexUartReader.cpp index d128fa63..38a4025f 100644 --- a/linux/devices/ScexUartReader.cpp +++ b/linux/devices/ScexUartReader.cpp @@ -58,7 +58,7 @@ ReturnValue_t ScexUartReader::performOperation(uint8_t operationCode) { result = tryDleParsing(); } - TaskFactory::delayTask(400); + TaskFactory::delayTask(150); } else if (bytesRead < 0) { sif::warning << "ScexUartReader::performOperation: read call failed with error [" << errno << ", " << strerror(errno) << "]" << std::endl; @@ -213,6 +213,10 @@ ReturnValue_t ScexUartReader::tryDleParsing() { void ScexUartReader::reset() { lock->lockMutex(); state = States::FINISH; + ipcRingBuf.clear(); + while (not ipcQueue.empty()) { + ipcQueue.pop(); + } lock->unlockMutex(); } diff --git a/mission/devices/ScexDeviceHandler.cpp b/mission/devices/ScexDeviceHandler.cpp index 8819cd95..8da6d229 100644 --- a/mission/devices/ScexDeviceHandler.cpp +++ b/mission/devices/ScexDeviceHandler.cpp @@ -28,6 +28,7 @@ void ScexDeviceHandler::doStartUp() { setMode(MODE_ON); } void ScexDeviceHandler::doShutDown() { reader.reset(); commandActive = false; + multiFileFinishOutstanding = false; setMode(_MODE_POWER_DOWN); } @@ -96,6 +97,7 @@ ReturnValue_t ScexDeviceHandler::buildCommandFromCommand(DeviceCommandId_t devic << remainingMillis << std::endl; } + multiFileFinishOutstanding = true; prepareScexCmd(cmdTyped, {cmdBuf.data(), cmdBuf.size()}, rawPacketLen, {commandData + 1, commandDataLen - 1}, tempCheck); updatePeriodicReply(true, deviceCommand); @@ -105,6 +107,7 @@ ReturnValue_t ScexDeviceHandler::buildCommandFromCommand(DeviceCommandId_t devic finishCountdown.setTimeout(LONG_CD); // countdown starts finishCountdown.resetTimer(); + multiFileFinishOutstanding = true; prepareScexCmd(cmdTyped, {cmdBuf.data(), cmdBuf.size()}, rawPacketLen, {commandData + 1, commandDataLen - 1}, tempCheck); updatePeriodicReply(true, deviceCommand); @@ -114,6 +117,7 @@ ReturnValue_t ScexDeviceHandler::buildCommandFromCommand(DeviceCommandId_t devic finishCountdown.setTimeout(LONG_CD); // countdown starts finishCountdown.resetTimer(); + multiFileFinishOutstanding = true; prepareScexCmd(cmdTyped, {cmdBuf.data(), cmdBuf.size()}, rawPacketLen, {commandData + 1, commandDataLen - 1}, tempCheck); updatePeriodicReply(true, deviceCommand); @@ -173,17 +177,14 @@ ReturnValue_t ScexDeviceHandler::handleValidReply(size_t remSize, DeviceCommandI sif::info << "ScexDeviceHandler::handleValidReply: RemMillis: " << remainingMillis << std::endl; } - finishAction(true, helper.getCmd(), OK); result = APERIODIC_REPLY; break; } case (ONE_CELL): { - finishAction(true, helper.getCmd(), OK); result = APERIODIC_REPLY; break; } case (ALL_CELLS_CMD): { - finishAction(true, helper.getCmd(), OK); result = APERIODIC_REPLY; break; } @@ -191,6 +192,11 @@ ReturnValue_t ScexDeviceHandler::handleValidReply(size_t remSize, DeviceCommandI break; } } + if (result == APERIODIC_REPLY and multiFileFinishOutstanding) { + finishAction(true, helper.getCmd(), OK); + multiFileFinishOutstanding = false; + } + *foundId = helper.getCmd(); *foundLen = remSize; return result; @@ -250,6 +256,7 @@ ReturnValue_t ScexDeviceHandler::interpretDeviceReply(DeviceCommandId_t id, cons } return OK; }; + id = helper.getCmd(); switch (id) { case (PING): { status = oneFileHandler("ping_"); diff --git a/mission/devices/ScexDeviceHandler.h b/mission/devices/ScexDeviceHandler.h index 1c96618e..a164c5e2 100644 --- a/mission/devices/ScexDeviceHandler.h +++ b/mission/devices/ScexDeviceHandler.h @@ -28,6 +28,7 @@ class ScexDeviceHandler : public DeviceHandlerBase { std::string fileName = ""; bool fileNameSet = false; bool commandActive = false; + bool multiFileFinishOutstanding = false; bool debugMode = false; scex::Cmds currCmd = scex::Cmds::PING; diff --git a/tmtc b/tmtc index f62c67a1..f6fab2d4 160000 --- a/tmtc +++ b/tmtc @@ -1 +1 @@ -Subproject commit f62c67a11e54b99fdb60dab13e55456f16450951 +Subproject commit f6fab2d44aff98174835c8446fd69c1ff589521b From 4a070f2b7f1c79bfcf515249201e76259c0c52b5 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Wed, 9 Nov 2022 14:53:08 +0100 Subject: [PATCH 2/2] bump tmtc --- tmtc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tmtc b/tmtc index f6fab2d4..b6490a05 160000 --- a/tmtc +++ b/tmtc @@ -1 +1 @@ -Subproject commit f6fab2d44aff98174835c8446fd69c1ff589521b +Subproject commit b6490a05ec3ed8fca30719bc657ed9e13d5a32ad