From 125593be21cdf4f9211f926adac1b3cbf8077a65 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Wed, 28 Jul 2021 19:46:19 +0200 Subject: [PATCH] reading chip and copy works --- bsp_q7s/core/CoreController.cpp | 27 +++++++++++++++------------ bsp_q7s/core/CoreController.h | 4 ++-- 2 files changed, 17 insertions(+), 14 deletions(-) diff --git a/bsp_q7s/core/CoreController.cpp b/bsp_q7s/core/CoreController.cpp index 5d99d3ec..a37db440 100644 --- a/bsp_q7s/core/CoreController.cpp +++ b/bsp_q7s/core/CoreController.cpp @@ -22,17 +22,19 @@ CoreController::CoreController(object_id_t objectId): ExtendedControllerBase(objectId, objects::NO_OBJECT, 5) { ReturnValue_t result = HasReturnvaluesIF::RETURN_OK; try { - result = sdCardInit(); + result = initSdCard(); if(result != HasReturnvaluesIF::RETURN_OK) { sif::warning << "CoreController::CoreController: SD card init failed" << std::endl; } + result = initBootCopy(); + if(result != HasReturnvaluesIF::RETURN_OK) { + sif::warning << "CoreController::CoreController: Boot copy init" << std::endl; + } } catch(const std::filesystem::filesystem_error& e) { - sif::error << "CoreController::CoreController: sdCardInit failed with exception " << + sif::error << "CoreController::CoreController: Failed with exception " << e.what() << std::endl; } - - initBootCopy(); } ReturnValue_t CoreController::handleCommandMessage(CommandMessage *message) { @@ -68,7 +70,7 @@ ReturnValue_t CoreController::checkModeCommand(Mode_t mode, Submode_t submode, return HasReturnvaluesIF::RETURN_OK; } -ReturnValue_t CoreController::sdCardInit() { +ReturnValue_t CoreController::initSdCard() { #if Q7S_SD_CARD_CONFIG == Q7S_SD_NONE sif::info << "No SD card initialization will be performed" << std::endl; return HasReturnvaluesIF::RETURN_OK; @@ -376,12 +378,15 @@ ReturnValue_t CoreController::actionListDirectoryIntoFile(ActionId_t actionId, } ReturnValue_t CoreController::initBootCopy() { - // We could create this file even before the OBSW is started.. std::string fileName = "/tmp/curr_copy.txt"; - std::string cmd = "xsc_boot_copy > " + fileName; - int result = std::system(cmd.c_str()); - if(result != 0) { - utility::handleSystemError(result, "CoreController::initBootCopy"); + if(not std::filesystem::exists(fileName)) { + // Thils file is created by the systemd service eive-early-config so this should + // not happen normally + std::string cmd = "xsc_boot_copy > " + fileName; + int result = std::system(cmd.c_str()); + if(result != 0) { + utility::handleSystemError(result, "CoreController::initBootCopy"); + } } std::ifstream file(fileName); std::string line; @@ -390,10 +395,8 @@ ReturnValue_t CoreController::initBootCopy() { int value = 0; iss >> value; currentChip = static_cast(value); - sif::debug << "Current chip: " << currentChip << std::endl; iss >> value; currentCopy = static_cast(value); - sif::debug << "Current chip: " << currentCopy << std::endl; return HasReturnvaluesIF::RETURN_OK; } diff --git a/bsp_q7s/core/CoreController.h b/bsp_q7s/core/CoreController.h index add107e7..34d72be4 100644 --- a/bsp_q7s/core/CoreController.h +++ b/bsp_q7s/core/CoreController.h @@ -55,14 +55,14 @@ private: ReturnValue_t checkModeCommand(Mode_t mode, Submode_t submode, uint32_t *msToReachTheMode); - ReturnValue_t sdCardInit(); + ReturnValue_t initSdCard(); ReturnValue_t sdCardSetup(SdCardManager& sdcMan, SdCardManager::SdStatusPair& statusPair, sd::SdCard sdCard, sd::SdStatus status, std::string sdString); ReturnValue_t sdCardColdRedundantInit(SdCardManager* sdcMan, SdCardManager::SdStatusPair& statusPair); ReturnValue_t initVersionFile(); - static ReturnValue_t initBootCopy(); + ReturnValue_t initBootCopy(); ReturnValue_t actionListDirectoryIntoFile(ActionId_t actionId, MessageQueueId_t commandedBy, const uint8_t *data, size_t size);