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/linux/devices/ScexUartReader.cpp b/linux/devices/ScexUartReader.cpp index 7d632b06..ca797e74 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; @@ -206,6 +206,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 f6fab2d4..b6490a05 160000 --- a/tmtc +++ b/tmtc @@ -1 +1 @@ -Subproject commit f6fab2d44aff98174835c8446fd69c1ff589521b +Subproject commit b6490a05ec3ed8fca30719bc657ed9e13d5a32ad