that should get the job done
EIVE/eive-obsw/pipeline/pr-main This commit looks good Details

This commit is contained in:
Robin Müller 2023-10-19 14:43:29 +02:00
parent 2e210a0572
commit 01ce1f154e
Signed by: muellerr
GPG Key ID: A649FB78196E3849
4 changed files with 34 additions and 7 deletions

View File

@ -359,6 +359,29 @@ ReturnValue_t CoreController::executeAction(ActionId_t actionId, MessageQueueId_
case (OBSW_UPDATE_FROM_TMP): {
return executeSwUpdate(SwUpdateSources::TMP_DIR, data, size);
}
case (ENABLE_AUTO_SWITCH): {
if (size < 2) {
return HasActionsIF::INVALID_PARAMETERS;
}
uint8_t chip = data[0];
uint8_t copy = data[1];
if (chip > 1 or copy > 1) {
return HasActionsIF::INVALID_PARAMETERS;
}
std::string value = std::to_string(chip) + std::to_string(copy);
ReturnValue_t result = scratch::writeString(scratch::AUTO_SWITCH_IMAGE, value);
if (result == returnvalue::OK) {
return EXECUTION_FINISHED;
}
return result;
}
case (DISABLE_AUTO_SWITCH): {
ReturnValue_t result = scratch::clearValue(scratch::AUTO_SWITCH_IMAGE);
if (result != returnvalue::OK and result != scratch::KEY_NOT_FOUND) {
return result;
}
return EXECUTION_FINISHED;
}
case (SWITCH_TO_SD_0): {
if (not startSdStateMachine(sd::SdCard::SLOT_0, SdCfgMode::COLD_REDUNDANT, commandedBy,
actionId)) {

View File

@ -19,6 +19,7 @@ namespace scratch {
static constexpr char PREFERED_SDC_KEY[] = "PREFSD";
static constexpr char ALLOC_FAILURE_COUNT[] = "ALLOCERR";
static constexpr char AUTO_SWITCH_IMAGE[] = "ASWI";
static constexpr uint8_t INTERFACE_ID = CLASS_ID::SCRATCH_BUFFER;
static constexpr ReturnValue_t KEY_NOT_FOUND = returnvalue::makeCode(INTERFACE_ID, 0);

View File

@ -1,5 +1,6 @@
#include "obsw.h"
#include <libxiphos.h>
#include <pwd.h>
#include <sys/types.h>
#include <unistd.h>
@ -10,16 +11,15 @@
#include "OBSWConfig.h"
#include "bsp_q7s/core/WatchdogHandler.h"
#include "memory/scratchApi.h"
#include "commonConfig.h"
#include "fsfw/tasks/TaskFactory.h"
#include "fsfw/version.h"
#include "memory/scratchApi.h"
#include "mission/acs/defs.h"
#include "mission/com/defs.h"
#include "mission/system/systemTree.h"
#include "q7sConfig.h"
#include "scheduling.h"
#include <libxiphos.h>
#include "watchdog/definitions.h"
static constexpr int OBSW_ALREADY_RUNNING = -2;
@ -89,20 +89,21 @@ int obsw::obsw(int argc, char* argv[]) {
void obsw::autoSwitchHandling() {
std::string autoSwitchTarget;
auto switchToTarget = [](xsc_libnor_chip_t chip, xsc_libnor_copy_t copy) {
scratch::clearValue("ASWI");
xsc_boot_copy(chip, copy);
scratch::clearValue(scratch::AUTO_SWITCH_IMAGE);
xsc_boot_copy(chip, copy);
};
if (scratch::readString("ASWI", autoSwitchTarget) == returnvalue::OK) {
if (scratch::readString(scratch::AUTO_SWITCH_IMAGE, autoSwitchTarget) == returnvalue::OK) {
if (autoSwitchTarget == "00") {
switchToTarget(XSC_LIBNOR_CHIP_0, XSC_LIBNOR_COPY_NOMINAL);
} else if (autoSwitchTarget == "01") {
switchToTarget(XSC_LIBNOR_CHIP_0, XSC_LIBNOR_COPY_GOLD);
} else if (autoSwitchTarget == "10") {
switchToTarget(XSC_LIBNOR_CHIP_1, XSC_LIBNOR_COPY_NOMINAL);
} else if(autoSwitchTarget == "11") {
} else if (autoSwitchTarget == "11") {
switchToTarget(XSC_LIBNOR_CHIP_1, XSC_LIBNOR_COPY_GOLD);
} else {
sif::warning << "Invalid Auto Switch Image (ASWI) value detected: " << autoSwitchTarget << std::endl;
sif::warning << "Invalid Auto Switch Image (ASWI) value detected: " << autoSwitchTarget
<< std::endl;
}
}
}

View File

@ -75,6 +75,8 @@ static constexpr ActionId_t OBSW_UPDATE_FROM_TMP = 12;
static constexpr ActionId_t SWITCH_TO_SD_0 = 16;
static constexpr ActionId_t SWITCH_TO_SD_1 = 17;
static constexpr ActionId_t SWITCH_TO_BOTH_SD_CARDS = 18;
static constexpr ActionId_t ENABLE_AUTO_SWITCH = 19;
static constexpr ActionId_t DISABLE_AUTO_SWITCH = 20;
//! Reboot using the xsc_boot_copy command
static constexpr ActionId_t XSC_REBOOT_OBC = 32;