added JSON lib, bugfixes in FileSystemHandler
This commit is contained in:
parent
b3dfbcf7fe
commit
434a0f6a7a
3
.gitmodules
vendored
3
.gitmodules
vendored
@ -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
|
||||
|
@ -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}
|
||||
|
@ -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 {
|
||||
|
@ -1,9 +1,11 @@
|
||||
#include <bsp_q7s/memory/SdCardManager.h>
|
||||
#include "Q7STestTask.h"
|
||||
|
||||
#include "fsfw/timemanager/Stopwatch.h"
|
||||
#include "fsfw/tasks/TaskFactory.h"
|
||||
|
||||
#include "bsp_q7s/memory/scratchApi.h"
|
||||
#include <nlohmann/json.hpp>
|
||||
|
||||
#include <iostream>
|
||||
#include <fstream>
|
||||
@ -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();
|
||||
}
|
||||
|
||||
|
@ -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, sd::SdStatus>(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;
|
||||
}
|
||||
|
@ -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);
|
||||
};
|
||||
|
||||
|
||||
|
@ -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;
|
||||
|
@ -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
|
||||
|
@ -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<SdStatusPair> sdStatusPtr;
|
||||
if(statusPair == nullptr) {
|
||||
statusPair = std::make_unique<SdStatusPair>().get();
|
||||
sdStatusPtr = std::make_unique<SdStatusPair>();
|
||||
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>(sd::SdCard::SLOT_0).get();
|
||||
getPreferredSdCard(*prefSdCard);
|
||||
ReturnValue_t SdCardManager::sanitizeState(SdStatusPair* statusPair, sd::SdCard prefSdCard) {
|
||||
std::unique_ptr<SdStatusPair> sdStatusPtr;
|
||||
if(prefSdCard == sd::SdCard::NONE) {
|
||||
ReturnValue_t result = getPreferredSdCard(prefSdCard);
|
||||
if(result != HasReturnvaluesIF::RETURN_OK) {}
|
||||
}
|
||||
if(statusPair == nullptr) {
|
||||
statusPair = std::make_unique<SdStatusPair>().get();
|
||||
sdStatusPtr = std::make_unique<SdStatusPair>();
|
||||
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<sd::SdStatus, sd::SdStatus> &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;
|
||||
}
|
||||
}
|
||||
|
@ -9,6 +9,7 @@
|
||||
#include <cstdint>
|
||||
#include <utility>
|
||||
#include <string>
|
||||
#include <optional>
|
||||
|
||||
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;
|
||||
};
|
||||
|
||||
|
@ -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
|
||||
};
|
||||
|
||||
}
|
||||
|
@ -4,6 +4,7 @@
|
||||
#include "fsfw/returnvalues/HasReturnvaluesIF.h"
|
||||
#include "fsfw/serviceinterface/ServiceInterface.h"
|
||||
#include "linux/utility/utility.h"
|
||||
#include "returnvalues/classIds.h"
|
||||
|
||||
#include <iostream>
|
||||
#include <fstream>
|
||||
@ -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<typename T, class = typename std::enable_if<std::is_integral<T>::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);
|
||||
|
@ -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);
|
||||
|
@ -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]
|
||||
};
|
||||
}
|
||||
|
1
thirdparty/json
vendored
Submodule
1
thirdparty/json
vendored
Submodule
@ -0,0 +1 @@
|
||||
Subproject commit fb1ee4f94b426a398969b2c96df9784be8e007e6
|
Loading…
Reference in New Issue
Block a user