From fcf8c0058981322e2f29888da10d9972435f2f08 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Fri, 16 Jul 2021 20:32:13 +0200 Subject: [PATCH] added JSON lib, bugfixes in FileSystemHandler --- .gitmodules | 3 + CMakeLists.txt | 14 ++ bsp_q7s/boardconfig/q7sConfig.h.in | 2 + bsp_q7s/boardtest/Q7STestTask.cpp | 11 ++ bsp_q7s/core/CoreController.cpp | 182 ++++++++++-------- bsp_q7s/core/CoreController.h | 5 + bsp_q7s/core/ObjectFactory.cpp | 2 + bsp_q7s/memory/FileSystemHandler.cpp | 2 +- bsp_q7s/memory/SdCardManager.cpp | 44 +++-- bsp_q7s/memory/SdCardManager.h | 16 +- bsp_q7s/memory/definitions.h | 7 +- bsp_q7s/memory/scratchApi.h | 26 ++- .../pollingSequenceFactory.cpp | 10 + linux/fsfwconfig/returnvalues/classIds.h | 1 + thirdparty/json | 1 + 15 files changed, 218 insertions(+), 108 deletions(-) create mode 160000 thirdparty/json diff --git a/.gitmodules b/.gitmodules index c7623fa2..41a8c334 100644 --- a/.gitmodules +++ b/.gitmodules @@ -16,3 +16,6 @@ [submodule "generators/fsfwgen"] path = generators/fsfwgen url = https://egit.irs.uni-stuttgart.de/fsfw/fsfw-generators.git +[submodule "thirdparty/json"] + path = thirdparty/json + url = https://github.com/nlohmann/json.git diff --git a/CMakeLists.txt b/CMakeLists.txt index 8decdc8b..1ce477da 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -18,6 +18,8 @@ if(TGT_BSP MATCHES "arm/q7s") endif() option(ADD_ETL_LIB "Add ETL library" ON) +option(ADD_JSON_LIB "Add JSON librara" ON) + if(NOT FSFW_OSAL) set(FSFW_OSAL host CACHE STRING "OS for the FSFW.") endif() @@ -49,6 +51,7 @@ set(LIB_CSP_NAME libcsp) set(LIB_LWGPS_NAME lwgps) set(THIRD_PARTY_FOLDER thirdparty) set(LIB_CXX_FS -lstdc++fs) +set(LIB_JSON_NAME nlohmann_json::nlohmann_json) # Set path names set(FSFW_PATH fsfw) @@ -62,6 +65,7 @@ set(FSFW_HAL_LIB_PATH fsfw_hal) set(CSP_LIB_PATH ${THIRD_PARTY_FOLDER}/libcsp) set(ETL_LIB_PATH ${THIRD_PARTY_FOLDER}/etl) set(LWGPS_LIB_PATH ${THIRD_PARTY_FOLDER}/lwgps) +set(LIB_JSON_PATH ${THIRD_PARTY_FOLDER}/json) set(FSFW_WARNING_SHADOW_LOCAL_GCC OFF) set(ADD_LINUX_FILES False) @@ -137,6 +141,10 @@ if(ADD_LINUX_FILES) add_subdirectory(${LINUX_PATH}) endif() +if(ADD_JSON_LIB) + add_subdirectory(${LIB_JSON_PATH}) +endif() + add_subdirectory(${BSP_PATH}) add_subdirectory(${COMMON_PATH}) @@ -176,6 +184,12 @@ if(ADD_CSP_LIB) ) endif() +if(ADD_JSON_LIB) + target_link_libraries(${TARGET_NAME} PRIVATE + ${LIB_JSON_NAME} + ) +endif() + # Add include paths for all sources. target_include_directories(${TARGET_NAME} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} diff --git a/bsp_q7s/boardconfig/q7sConfig.h.in b/bsp_q7s/boardconfig/q7sConfig.h.in index 11dec25c..2fd52eb7 100644 --- a/bsp_q7s/boardconfig/q7sConfig.h.in +++ b/bsp_q7s/boardconfig/q7sConfig.h.in @@ -24,6 +24,8 @@ #define Q7S_ADD_SPI_TEST 0 #endif +#define Q7S_ADD_SYRLINKS_HANDLER 1 + #define Q7S_SIMPLE_ADD_FILE_SYSTEM_TEST 0 namespace config { diff --git a/bsp_q7s/boardtest/Q7STestTask.cpp b/bsp_q7s/boardtest/Q7STestTask.cpp index a1470b79..2f2c0ffc 100644 --- a/bsp_q7s/boardtest/Q7STestTask.cpp +++ b/bsp_q7s/boardtest/Q7STestTask.cpp @@ -1,9 +1,11 @@ +#include #include "Q7STestTask.h" #include "fsfw/timemanager/Stopwatch.h" #include "fsfw/tasks/TaskFactory.h" #include "bsp_q7s/memory/scratchApi.h" +#include #include #include @@ -15,6 +17,15 @@ Q7STestTask::Q7STestTask(object_id_t objectId): TestTask(objectId) { ReturnValue_t Q7STestTask::performOneShotAction() { //sdCardTests(); testScratchApi(); + Stopwatch stopwatch; + // for convenience + using json = nlohmann::json; + json helloTest; + // add a number that is stored as double (note the implicit conversion of j to an object) + helloTest["pi"] = 3.141; + std::string mntPrefix = SdCardManager::instance()->getCurrentMountPrefix(); + std::ofstream o("/mnt/sd0/pretty.json"); + o << std::setw(4) << helloTest << std::endl; return TestTask::performOneShotAction(); } diff --git a/bsp_q7s/core/CoreController.cpp b/bsp_q7s/core/CoreController.cpp index c4863260..73e407d0 100644 --- a/bsp_q7s/core/CoreController.cpp +++ b/bsp_q7s/core/CoreController.cpp @@ -1,6 +1,7 @@ #include "CoreController.h" #include "q7sConfig.h" +#include "../memory/scratchApi.h" #include "../memory/SdCardManager.h" CoreController::CoreController(object_id_t objectId): @@ -38,7 +39,9 @@ ReturnValue_t CoreController::sdCardInit() { return HasReturnvaluesIF::RETURN_OK; #else SdCardManager* sdcMan = SdCardManager::instance(); - + if(sdcMan == nullptr) { + return HasReturnvaluesIF::RETURN_FAILED; + } // Create update status file ReturnValue_t result = sdcMan->updateSdCardStateFile(); if(result != HasReturnvaluesIF::RETURN_OK) { @@ -46,93 +49,14 @@ ReturnValue_t CoreController::sdCardInit() { << std::endl; } - auto sdStatus = std::pair(sd::SdStatus::OFF, sd::SdStatus::OFF); - result = sdcMan->getSdCardActiveStatus(sdStatus); + auto statusPair = SdCardManager::SdStatusPair(sd::SdStatus::OFF, sd::SdStatus::OFF); + result = sdcMan->getSdCardActiveStatus(statusPair); if(result != HasReturnvaluesIF::RETURN_OK) { sif::warning << "Getting SD card activity status failed" << std::endl; } - // Use a lambda to avoid duplicate code - auto setUpSdCard = [&](sd::SdCard sdCard, sd::SdStatus status, std::string sdString) { - std::string mountString; - if(sdCard == sd::SdCard::SLOT_0) { - mountString = SdCardManager::SD_0_MOUNT_POINT; - } - else { - mountString = SdCardManager::SD_1_MOUNT_POINT; - } - - if(status == sd::SdStatus::OFF) { - sif::info << "Switching on and mounting SD card " << sdString << " at " << - mountString << std::endl; - return sdcMan->switchOnSdCard(sdCard, true, &sdStatus); - } - else if(status == sd::SdStatus::ON) { - sif::info << "Mounting SD card " << sdString << " at " << mountString << std::endl; - return sdcMan->mountSdCard(sdCard); - } - else { - sif::info << "SD card " << sdString << " already on and mounted at " << - mountString << std::endl; - return SdCardManager::ALREADY_MOUNTED; - } - }; - #if Q7S_SD_CARD_CONFIG == Q7S_SD_COLD_REDUNDANT - sd::SdCard preferredSdCard = sd::SdCard::SLOT_0; - result = sdcMan->getPreferredSdCard(preferredSdCard); - if(result != HasReturnvaluesIF::RETURN_OK) { - sif::warning << "Could not get preferred SD card information from the scratch buffer" - << std::endl; - } - std::string preferredString; - sd::SdStatus preferredStatus = sd::SdStatus::OFF; - - sd::SdStatus otherStatus = sd::SdStatus::OFF; - std::string otherString; - sd::SdCard otherSdc = sd::SdCard::SLOT_0; - - if(preferredSdCard == sd::SdCard::SLOT_0) { - preferredStatus = sdStatus.first; - preferredString = "0"; - otherSdc = sd::SdCard::SLOT_1; - otherStatus = sdStatus.second; - otherString = "1"; - } - else { - preferredString = "1"; - preferredStatus = sdStatus.second; - otherStatus = sdStatus.first; - otherSdc = sd::SdCard::SLOT_0; - otherString = "0"; - } - - sif::info << "Cold redundant SD card configuration, preferred SD card " << - preferredString << std::endl; - - result = setUpSdCard(preferredSdCard, preferredStatus, preferredString); - if(result != SdCardManager::ALREADY_MOUNTED and result != HasReturnvaluesIF::RETURN_OK) { - sif::warning << "Setting up preferred card " << otherString << - " in cold redundant mode failed" << std::endl; - // Try other SD card and mark set up operation as failed - setUpSdCard(otherSdc, otherStatus, otherString); - result = HasReturnvaluesIF::RETURN_FAILED; - } - - if(result != HasReturnvaluesIF::RETURN_FAILED and otherStatus != sd::SdStatus::OFF) { - sif::info << "Switching off secondary SD card " << otherString << std::endl; - // Switch off other SD card in cold redundant mode if setting up preferred one walked - // without issues - result = sdcMan->switchOffSdCard(otherSdc, otherStatus, &sdStatus); - if(result != HasReturnvaluesIF::RETURN_OK and result != SdCardManager::ALREADY_OFF) { - sif::warning << "Switching off secondary SD card " << otherString << - " in cold redundant mode failed" << std::endl; - } - } - - // Update status file - sdcMan->updateSdCardStateFile(); - return HasReturnvaluesIF::RETURN_OK; + return sdCardColdRedundantInit(sdcMan, statusPair); #elif Q7S_SD_CARD_CONFIG == Q7S_SD_HOT_REDUNDANT sif::info << "Hot redundant SD card configuration" << std::endl; @@ -146,3 +70,95 @@ ReturnValue_t CoreController::sdCardInit() { #endif /* Q7S_SD_CARD_CONFIG != Q7S_SD_NONE */ } + +ReturnValue_t CoreController::sdCardSetup(SdCardManager& sdcMan, + SdCardManager::SdStatusPair& statusPair,sd::SdCard sdCard, sd::SdStatus status, + std::string sdString) { + std::string mountString; + if(sdCard == sd::SdCard::SLOT_0) { + mountString = SdCardManager::SD_0_MOUNT_POINT; + } + else { + mountString = SdCardManager::SD_1_MOUNT_POINT; + } + + if(status == sd::SdStatus::OFF) { + sif::info << "Switching on and mounting SD card " << sdString << " at " << + mountString << std::endl; + return sdcMan.switchOnSdCard(sdCard, true, &statusPair); + } + else if(status == sd::SdStatus::ON) { + sif::info << "Mounting SD card " << sdString << " at " << mountString << std::endl; + return sdcMan.mountSdCard(sdCard); + } + else { + sif::info << "SD card " << sdString << " already on and mounted at " << + mountString << std::endl; + return SdCardManager::ALREADY_MOUNTED; + } +} + +ReturnValue_t CoreController::sdCardColdRedundantInit(SdCardManager* sdcMan, + SdCardManager::SdStatusPair& statusPair) { + sd::SdCard preferredSdCard = sd::SdCard::SLOT_0; + ReturnValue_t result = sdcMan->getPreferredSdCard(preferredSdCard); + if(result != HasReturnvaluesIF::RETURN_OK) { + if(result == scratch::KEY_NOT_FOUND) { + sif::warning << "CoreController::sdCardInit: " + "Preferred SD card not set. Setting to 0" << std::endl; + sdcMan->setPreferredSdCard(preferredSdCard); + } + else { + sif::warning << "CoreController::sdCardInit: Could not get preferred SD card" + "information from the scratch buffer" << std::endl; + } + } + std::string preferredString; + sd::SdStatus preferredStatus = sd::SdStatus::OFF; + + sd::SdStatus otherStatus = sd::SdStatus::OFF; + std::string otherString; + sd::SdCard otherSdc = sd::SdCard::SLOT_0; + + if(preferredSdCard == sd::SdCard::SLOT_0) { + preferredStatus = statusPair.first; + preferredString = "0"; + otherSdc = sd::SdCard::SLOT_1; + otherStatus = statusPair.second; + otherString = "1"; + } + else { + preferredString = "1"; + preferredStatus = statusPair.second; + otherStatus = statusPair.first; + otherSdc = sd::SdCard::SLOT_0; + otherString = "0"; + } + + sif::info << "Cold redundant SD card configuration, preferred SD card " << + preferredString << std::endl; + + result = sdCardSetup(*sdcMan, statusPair, preferredSdCard, preferredStatus, preferredString); + if(result != SdCardManager::ALREADY_MOUNTED and result != HasReturnvaluesIF::RETURN_OK) { + sif::warning << "Setting up preferred card " << otherString << + " in cold redundant mode failed" << std::endl; + // Try other SD card and mark set up operation as failed + sdCardSetup(*sdcMan, statusPair, preferredSdCard, preferredStatus, preferredString); + result = HasReturnvaluesIF::RETURN_FAILED; + } + + if(result != HasReturnvaluesIF::RETURN_FAILED and otherStatus != sd::SdStatus::OFF) { + sif::info << "Switching off secondary SD card " << otherString << std::endl; + // Switch off other SD card in cold redundant mode if setting up preferred one walked + // without issues + result = sdcMan->switchOffSdCard(otherSdc, otherStatus, &statusPair); + if(result != HasReturnvaluesIF::RETURN_OK and result != SdCardManager::ALREADY_OFF) { + sif::warning << "Switching off secondary SD card " << otherString << + " in cold redundant mode failed" << std::endl; + } + } + + // Update status file + sdcMan->updateSdCardStateFile(); + return HasReturnvaluesIF::RETURN_OK; +} diff --git a/bsp_q7s/core/CoreController.h b/bsp_q7s/core/CoreController.h index 940a9097..fc192d70 100644 --- a/bsp_q7s/core/CoreController.h +++ b/bsp_q7s/core/CoreController.h @@ -2,6 +2,7 @@ #define BSP_Q7S_CORE_CORECONTROLLER_H_ #include "fsfw/controller/ExtendedControllerBase.h" +#include "bsp_q7s/memory/SdCardManager.h" class CoreController: public ExtendedControllerBase { public: @@ -19,6 +20,10 @@ private: uint32_t *msToReachTheMode); ReturnValue_t sdCardInit(); + 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); }; diff --git a/bsp_q7s/core/ObjectFactory.cpp b/bsp_q7s/core/ObjectFactory.cpp index 249b8e59..75ee0e49 100644 --- a/bsp_q7s/core/ObjectFactory.cpp +++ b/bsp_q7s/core/ObjectFactory.cpp @@ -395,6 +395,7 @@ void ObjectFactory::produce(void* args){ solarArrayDeplCookie, objects::PCDU_HANDLER, pcduSwitches::DEPLOYMENT_MECHANISM, gpioIds::DEPLSA1, gpioIds::DEPLSA2, 1000); +#if Q7S_ADD_SYRLINKS_HANDLER == 1 UartCookie* syrlinksUartCookie = new UartCookie(objects::SYRLINKS_HK_HANDLER, std::string("/dev/ttyUL0"), UartModes::NON_CANONICAL, 38400, SYRLINKS::MAX_REPLY_SIZE); syrlinksUartCookie->setParityEven(); @@ -402,6 +403,7 @@ void ObjectFactory::produce(void* args){ SyrlinksHkHandler* syrlinksHkHandler = new SyrlinksHkHandler(objects::SYRLINKS_HK_HANDLER, objects::UART_COM_IF, syrlinksUartCookie); syrlinksHkHandler->setModeNormal(); +#endif #if Q7S_ADD_RTD_DEVICES == 1 GpioCookie* rtdGpioCookie = new GpioCookie; diff --git a/bsp_q7s/memory/FileSystemHandler.cpp b/bsp_q7s/memory/FileSystemHandler.cpp index 1519b92b..a63e38d0 100644 --- a/bsp_q7s/memory/FileSystemHandler.cpp +++ b/bsp_q7s/memory/FileSystemHandler.cpp @@ -91,7 +91,7 @@ void FileSystemHandler::fileSystemCheckup() { " state detected. Preferred SD card is " << sdString << " but does not appear to be mounted. Attempting fix.." << std::endl; // This function will appear to fix the inconsistent state - ReturnValue_t result = sdcMan->sanitizeState(&preferredSdCard, &statusPair); + ReturnValue_t result = sdcMan->sanitizeState(&statusPair, preferredSdCard); if(result != HasReturnvaluesIF::RETURN_OK) { // Oh no. // TODO: Trigger medium severity event diff --git a/bsp_q7s/memory/SdCardManager.cpp b/bsp_q7s/memory/SdCardManager.cpp index 5a50665b..3d309dd4 100644 --- a/bsp_q7s/memory/SdCardManager.cpp +++ b/bsp_q7s/memory/SdCardManager.cpp @@ -32,8 +32,10 @@ SdCardManager* SdCardManager::instance() { ReturnValue_t SdCardManager::switchOnSdCard(sd::SdCard sdCard, bool doMountSdCard, SdStatusPair* statusPair) { ReturnValue_t result = HasReturnvaluesIF::RETURN_OK; + std::unique_ptr sdStatusPtr; if(statusPair == nullptr) { - statusPair = std::make_unique().get(); + sdStatusPtr = std::make_unique(); + statusPair = sdStatusPtr.get(); result = getSdCardActiveStatus(*statusPair); if(result != HasReturnvaluesIF::RETURN_OK) { return result; @@ -226,26 +228,23 @@ ReturnValue_t SdCardManager::unmountSdCard(sd::SdCard sdCard) { return HasReturnvaluesIF::RETURN_OK; } -ReturnValue_t SdCardManager::sanitizeState(sd::SdCard* prefSdCard, SdStatusPair* statusPair) { - if(prefSdCard == nullptr) { - prefSdCard = std::make_unique(sd::SdCard::SLOT_0).get(); - getPreferredSdCard(*prefSdCard); +ReturnValue_t SdCardManager::sanitizeState(SdStatusPair* statusPair, sd::SdCard prefSdCard) { + std::unique_ptr sdStatusPtr; + if(prefSdCard == sd::SdCard::NONE) { + ReturnValue_t result = getPreferredSdCard(prefSdCard); + if(result != HasReturnvaluesIF::RETURN_OK) {} } if(statusPair == nullptr) { - statusPair = std::make_unique().get(); + sdStatusPtr = std::make_unique(); + statusPair = sdStatusPtr.get(); getSdCardActiveStatus(*statusPair); } - auto sanitizerFunc = [&](sd::SdCard prefSdCard) { - if(statusPair->first == sd::SdStatus::ON) { - return mountSdCard(prefSdCard); - } - else { - return switchOnSdCard(prefSdCard, true, statusPair); - } - }; + if(statusPair->first == sd::SdStatus::ON) { + return mountSdCard(prefSdCard); + } - return sanitizerFunc(*prefSdCard); + return switchOnSdCard(prefSdCard, true, statusPair); } void SdCardManager::processSdStatusLine(std::pair &active, @@ -331,3 +330,18 @@ ReturnValue_t SdCardManager::updateSdCardStateFile() { result << std::endl; return HasReturnvaluesIF::RETURN_FAILED; } + +std::string SdCardManager::getCurrentMountPrefix(sd::SdCard prefSdCard) { + if(prefSdCard == sd::SdCard::NONE) { + ReturnValue_t result = getPreferredSdCard(prefSdCard); + if(result != HasReturnvaluesIF::RETURN_OK) { + return SD_0_MOUNT_POINT; + } + } + if(prefSdCard == sd::SdCard::SLOT_0) { + return SD_0_MOUNT_POINT; + } + else { + return SD_1_MOUNT_POINT; + } +} diff --git a/bsp_q7s/memory/SdCardManager.h b/bsp_q7s/memory/SdCardManager.h index 966e6e2a..64eecc36 100644 --- a/bsp_q7s/memory/SdCardManager.h +++ b/bsp_q7s/memory/SdCardManager.h @@ -9,6 +9,7 @@ #include #include #include +#include class MutexIF; @@ -137,14 +138,21 @@ public: * mounted one, this function will sanitize the state by attempting to mount the * currently preferred SD card. If the caller already has state information, it can be * passed into the function. - * @param prefSdCard Preferred SD card captured with #getPreferredSdCard * @param statusPair Current SD card status capture with #getSdCardActiveStatus + * @param prefSdCard Preferred SD card captured with #getPreferredSdCard * @throws std::bad_alloc if one of the two arguments was a nullptr and an allocation failed * @return */ - ReturnValue_t sanitizeState(sd::SdCard* prefSdCard = nullptr, - SdStatusPair* statusPair = nullptr); + ReturnValue_t sanitizeState(SdStatusPair* statusPair = nullptr, + sd::SdCard prefSdCard = sd::SdCard::NONE); + /** + * If sd::SdCard::NONE is passed as an argument, this funtion will get the currently + * preferred SD card from the scratch buffer. + * @param prefSdCardPtr + * @return + */ + std::string getCurrentMountPrefix(sd::SdCard prefSdCardPtr = sd::SdCard::NONE); private: SdCardManager(); @@ -153,6 +161,8 @@ private: void processSdStatusLine(SdStatusPair& active, std::string& line, uint8_t& idx, sd::SdCard& currentSd); + std::string currentPrefix; + static SdCardManager* factoryInstance; }; diff --git a/bsp_q7s/memory/definitions.h b/bsp_q7s/memory/definitions.h index 546a6585..9fcbee08 100644 --- a/bsp_q7s/memory/definitions.h +++ b/bsp_q7s/memory/definitions.h @@ -13,9 +13,10 @@ enum SdStatus: uint8_t { }; enum SdCard: uint8_t { - SLOT_0, - SLOT_1, - BOTH + SLOT_0 = 0, + SLOT_1 = 1, + BOTH, + NONE }; } diff --git a/bsp_q7s/memory/scratchApi.h b/bsp_q7s/memory/scratchApi.h index eceda11a..866f1035 100644 --- a/bsp_q7s/memory/scratchApi.h +++ b/bsp_q7s/memory/scratchApi.h @@ -4,6 +4,7 @@ #include "fsfw/returnvalues/HasReturnvaluesIF.h" #include "fsfw/serviceinterface/ServiceInterface.h" #include "linux/utility/utility.h" +#include "returnvalues/classIds.h" #include #include @@ -18,6 +19,9 @@ namespace scratch { static constexpr char PREFERED_SDC_KEY[] = "PREFSD"; +static constexpr uint8_t INTERFACE_ID = CLASS_ID::SCRATCH_BUFFER; +static constexpr ReturnValue_t KEY_NOT_FOUND = HasReturnvaluesIF::makeReturnCode(INTERFACE_ID, 0); + namespace { static uint8_t counter = 0; } @@ -25,7 +29,7 @@ static uint8_t counter = 0; template::value>::type> inline ReturnValue_t writeNumber(std::string name, T num) noexcept { std::ostringstream oss; - oss << "xsc_scratch write " << name << " " << num; + oss << "xsc_scratch write " << name << " " << std::to_string(num); int result = std::system(oss.str().c_str()); if(result != 0) { utility::handleSystemError(result, "scratch::writeNumber"); @@ -43,8 +47,17 @@ inline ReturnValue_t readNumber(std::string name, T& num) noexcept { int result = std::system(oss.str().c_str()); if(result != 0) { - utility::handleSystemError(result, "scratch::writeNumber"); - return HasReturnvaluesIF::RETURN_FAILED; + if(result == 256) { + sif::warning << "scratch::readNumber: Key " << name << " does not exist" << std::endl; + // Could not find value + std::remove(filename.c_str()); + return KEY_NOT_FOUND; + } + else { + utility::handleSystemError(result, "scratch::readNumber"); + std::remove(filename.c_str()); + return HasReturnvaluesIF::RETURN_FAILED; + } } ifstream file(filename); string line; @@ -53,6 +66,13 @@ inline ReturnValue_t readNumber(std::string name, T& num) noexcept { } size_t pos = line.find("="); + if(pos == string::npos) { + sif::warning << "scratch::readNumber: Output file format invalid, " + "no \"=\" found" << std::endl; + // Could not find value + std::remove(filename.c_str()); + return KEY_NOT_FOUND; + } std::string valueAsString = line.substr(pos + 1); try { num = std::stoi(valueAsString); diff --git a/linux/fsfwconfig/pollingsequence/pollingSequenceFactory.cpp b/linux/fsfwconfig/pollingsequence/pollingSequenceFactory.cpp index a213ca06..77798fa9 100644 --- a/linux/fsfwconfig/pollingsequence/pollingSequenceFactory.cpp +++ b/linux/fsfwconfig/pollingsequence/pollingSequenceFactory.cpp @@ -451,8 +451,10 @@ ReturnValue_t pst::pstUart(FixedTimeslotTaskIF *thisSequence) { thisSequence->addSlot(objects::PLOC_HANDLER, length * 0, DeviceHandlerIF::PERFORM_OPERATION); +#if Q7S_ADD_SYRLINKS_HANDLER == 1 thisSequence->addSlot(objects::SYRLINKS_HK_HANDLER, length * 0, DeviceHandlerIF::PERFORM_OPERATION); +#endif #if OBSW_ADD_ACS_BOARD == 1 thisSequence->addSlot(objects::GPS0_HANDLER, length * 0, DeviceHandlerIF::PERFORM_OPERATION); @@ -462,8 +464,10 @@ ReturnValue_t pst::pstUart(FixedTimeslotTaskIF *thisSequence) { thisSequence->addSlot(objects::PLOC_HANDLER, length * 0.2, DeviceHandlerIF::SEND_WRITE); +#if Q7S_ADD_SYRLINKS_HANDLER == 1 thisSequence->addSlot(objects::SYRLINKS_HK_HANDLER, length * 0.2, DeviceHandlerIF::SEND_WRITE); +#endif #if OBSW_ADD_ACS_BOARD == 1 thisSequence->addSlot(objects::GPS0_HANDLER, length * 0.2, DeviceHandlerIF::SEND_WRITE); @@ -473,8 +477,10 @@ ReturnValue_t pst::pstUart(FixedTimeslotTaskIF *thisSequence) { thisSequence->addSlot(objects::PLOC_HANDLER, length * 0.4, DeviceHandlerIF::GET_WRITE); +#if Q7S_ADD_SYRLINKS_HANDLER == 1 thisSequence->addSlot(objects::SYRLINKS_HK_HANDLER, length * 0.4, DeviceHandlerIF::GET_WRITE); +#endif #if OBSW_ADD_ACS_BOARD == 1 thisSequence->addSlot(objects::GPS0_HANDLER, length * 0.4, DeviceHandlerIF::GET_WRITE); @@ -484,8 +490,10 @@ ReturnValue_t pst::pstUart(FixedTimeslotTaskIF *thisSequence) { thisSequence->addSlot(objects::PLOC_HANDLER, length * 0.6, DeviceHandlerIF::SEND_READ); +#if Q7S_ADD_SYRLINKS_HANDLER == 1 thisSequence->addSlot(objects::SYRLINKS_HK_HANDLER, length * 0.6, DeviceHandlerIF::SEND_READ); +#endif #if OBSW_ADD_ACS_BOARD == 1 thisSequence->addSlot(objects::GPS0_HANDLER, length * 0.6, DeviceHandlerIF::SEND_READ); @@ -495,8 +503,10 @@ ReturnValue_t pst::pstUart(FixedTimeslotTaskIF *thisSequence) { thisSequence->addSlot(objects::PLOC_HANDLER, length * 0.8, DeviceHandlerIF::GET_READ); +#if Q7S_ADD_SYRLINKS_HANDLER == 1 thisSequence->addSlot(objects::SYRLINKS_HK_HANDLER, length * 0.8, DeviceHandlerIF::GET_READ); +#endif #if OBSW_ADD_ACS_BOARD == 1 thisSequence->addSlot(objects::GPS0_HANDLER, length * 0.8, DeviceHandlerIF::GET_READ); diff --git a/linux/fsfwconfig/returnvalues/classIds.h b/linux/fsfwconfig/returnvalues/classIds.h index 79f1a175..b98801e2 100644 --- a/linux/fsfwconfig/returnvalues/classIds.h +++ b/linux/fsfwconfig/returnvalues/classIds.h @@ -14,6 +14,7 @@ enum { CLASS_ID_START = COMMON_CLASS_ID_END, SA_DEPL_HANDLER, //SADPL SD_CARD_MANAGER, //SDMA + SCRATCH_BUFFER, //SCBU CLASS_ID_END // [EXPORT] : [END] }; } diff --git a/thirdparty/json b/thirdparty/json new file mode 160000 index 00000000..fb1ee4f9 --- /dev/null +++ b/thirdparty/json @@ -0,0 +1 @@ +Subproject commit fb1ee4f94b426a398969b2c96df9784be8e007e6