From b3275d015fcd1488a26d9f96393770eb65bb53ab Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Mon, 26 Sep 2022 11:50:35 +0200 Subject: [PATCH] start update handler impl --- bsp_q7s/core/CoreController.cpp | 19 +++++++++++++++++++ bsp_q7s/core/CoreController.h | 1 - common/config/eive/definitions.h | 1 + 3 files changed, 20 insertions(+), 1 deletion(-) diff --git a/bsp_q7s/core/CoreController.cpp b/bsp_q7s/core/CoreController.cpp index 359d7c27..398e1e85 100644 --- a/bsp_q7s/core/CoreController.cpp +++ b/bsp_q7s/core/CoreController.cpp @@ -1,6 +1,7 @@ #include "CoreController.h" #include +#include #include #include "OBSWConfig.h" @@ -200,6 +201,24 @@ ReturnValue_t CoreController::executeAction(ActionId_t actionId, MessageQueueId_ return HasActionsIF::EXECUTION_FINISHED; } case (OBSW_UPDATE_FROM_SD_0): { + using namespace std; + using namespace std::filesystem; + // At the very least, chip and copy ID need to be included in the command + if (size < 2) { + return HasActionsIF::INVALID_PARAMETERS; + } + path archivePath = + path(config::SD_0_MOUNT_POINT) / path(config::OBSW_UPDATE_ARCHIVE_FILE_NAME); + if (not exists(archivePath)) { + return HasFileSystemIF::FILE_DOES_NOT_EXIST; + } + std::ostringstream cmd("tar -xJvf"); + cmd << " " << archivePath; + int result = std::system(cmd.str().c_str()); + if (result != 0) { + utility::handleSystemError(result, + "CoreController::executeAction: SW Update Decompression"); + } return HasActionsIF::EXECUTION_FINISHED; } case (SWITCH_IMG_LOCK): { diff --git a/bsp_q7s/core/CoreController.h b/bsp_q7s/core/CoreController.h index 8c4d89b1..4a630863 100644 --- a/bsp_q7s/core/CoreController.h +++ b/bsp_q7s/core/CoreController.h @@ -54,7 +54,6 @@ class CoreController : public ExtendedControllerBase { static constexpr char CONF_FOLDER[] = "conf"; - static constexpr char OBSW_VERSION_FILE_NAME[] = "obsw_version.txt"; static constexpr char VERSION_FILE_NAME[] = "version.txt"; static constexpr char REBOOT_FILE_NAME[] = "reboot.txt"; static constexpr char TIME_FILE_NAME[] = "time.txt"; diff --git a/common/config/eive/definitions.h b/common/config/eive/definitions.h index 7927d280..c5ea5bf9 100644 --- a/common/config/eive/definitions.h +++ b/common/config/eive/definitions.h @@ -10,6 +10,7 @@ static constexpr char SD_1_MOUNT_POINT[] = "/mnt/sd1"; static constexpr char OBSW_UPDATE_ARCHIVE_FILE_NAME[] = "eive-sw-update.tar.xz"; static constexpr char STRIPPED_OBSW_BINARY_FILE_NAME[] = "eive-obsw-stripped"; +static constexpr char OBSW_VERSION_FILE_NAME[] = "obsw_version.txt"; static constexpr uint16_t EIVE_PUS_APID = 0x65; static constexpr uint16_t EIVE_CFDP_APID = 0x66;