OBSW Update Commands #302

Merged
meierj merged 42 commits from mueller/obsw-update-cmds into develop 2022-09-29 13:24:17 +02:00
11 changed files with 226 additions and 248 deletions
Showing only changes of commit 90962c9f8e - Show all commits

View File

@ -16,16 +16,6 @@
/** Other flags */ /** Other flags */
/*******************************************************************/ /*******************************************************************/
#define Q7S_SD_NONE 0
#define Q7S_SD_COLD_REDUNDANT 1
#define Q7S_SD_HOT_REDUNDANT 2
// The OBSW will perform different actions to set up the SD cards depending on the flag set here
// Set to Q7S_SD_NONE: Don't do anything
// Set to Q7S_COLD_REDUNDANT: On startup, get the prefered SD card, turn it on and mount it, and
// turn off the second SD card if it is on
// Set to Q7S_HOT_REDUNDANT: On startup, turn on both SD cards and mount them
#define Q7S_SD_CARD_CONFIG Q7S_SD_COLD_REDUNDANT
// Probably better if this is disabled for mission code. Convenient for development // Probably better if this is disabled for mission code. Convenient for development
#define Q7S_CHECK_FOR_ALREADY_RUNNING_IMG 1 #define Q7S_CHECK_FOR_ALREADY_RUNNING_IMG 1

View File

@ -62,6 +62,8 @@ CoreController::CoreController(object_id_t objectId)
eventQueue = QueueFactory::instance()->createMessageQueue(5, EventMessage::MAX_MESSAGE_SIZE); eventQueue = QueueFactory::instance()->createMessageQueue(5, EventMessage::MAX_MESSAGE_SIZE);
} }
CoreController::~CoreController() {}
ReturnValue_t CoreController::handleCommandMessage(CommandMessage *message) { ReturnValue_t CoreController::handleCommandMessage(CommandMessage *message) {
return ExtendedControllerBase::handleCommandMessage(message); return ExtendedControllerBase::handleCommandMessage(message);
} }
@ -141,8 +143,8 @@ ReturnValue_t CoreController::initialize() {
ReturnValue_t CoreController::initializeAfterTaskCreation() { ReturnValue_t CoreController::initializeAfterTaskCreation() {
ReturnValue_t result = returnvalue::OK; ReturnValue_t result = returnvalue::OK;
sdInfo.pref = sdcMan->getPreferredSdCard(); sdInfo.active = sdcMan->getPreferredSdCard();
sdcMan->setActiveSdCard(sdInfo.pref); sdcMan->setActiveSdCard(sdInfo.active);
currMntPrefix = sdcMan->getCurrentMountPrefix(); currMntPrefix = sdcMan->getCurrentMountPrefix();
if (BLOCKING_SD_INIT) { if (BLOCKING_SD_INIT) {
ReturnValue_t result = initSdCardBlocking(); ReturnValue_t result = initSdCardBlocking();
@ -209,6 +211,33 @@ ReturnValue_t CoreController::executeAction(ActionId_t actionId, MessageQueueId_
case (OBSW_UPDATE_FROM_TMP): { case (OBSW_UPDATE_FROM_TMP): {
return executeSwUpdate(SwUpdateSources::TMP_DIR, data, size); return executeSwUpdate(SwUpdateSources::TMP_DIR, data, size);
} }
case (SWITCH_TO_SD_0): {
if (not startSdStateMachine(sd::SdCard::SLOT_0, SdCfgMode::COLD_REDUNDANT)) {
return HasActionsIF::IS_BUSY;
}
return returnvalue::OK;
}
case (SWITCH_TO_SD_1): {
if (not startSdStateMachine(sd::SdCard::SLOT_1, SdCfgMode::COLD_REDUNDANT)) {
return HasActionsIF::IS_BUSY;
}
return returnvalue::OK;
}
case (SWITCH_TO_BOTH_SD_CARDS): {
// An active SD still needs to be specified because the system needs to know which SD
// card to use for regular operations like telemetry storage.
if (size != 1) {
return HasActionsIF::INVALID_PARAMETERS;
}
if (data[0] != 0 and data[1] != 1) {
return HasActionsIF::INVALID_PARAMETERS;
}
auto active = static_cast<sd::SdCard>(data[0]);
if (not startSdStateMachine(active, SdCfgMode::HOT_REDUNDANT)) {
return HasActionsIF::IS_BUSY;
}
return returnvalue::OK;
}
case (SWITCH_IMG_LOCK): { case (SWITCH_IMG_LOCK): {
if (size != 3) { if (size != 3) {
return HasActionsIF::INVALID_PARAMETERS; return HasActionsIF::INVALID_PARAMETERS;
@ -256,60 +285,59 @@ ReturnValue_t CoreController::initSdCardBlocking() {
if (result != returnvalue::OK) { if (result != returnvalue::OK) {
sif::warning << "CoreController::initialize: Updating SD card state file failed" << std::endl; sif::warning << "CoreController::initialize: Updating SD card state file failed" << std::endl;
} }
#if Q7S_SD_CARD_CONFIG == Q7S_SD_NONE if (sdInfo.cfgMode == SdCfgMode::PASSIVE) {
sif::info << "No SD card initialization will be performed" << std::endl; sif::info << "No SD card initialization will be performed" << std::endl;
return returnvalue::OK; return returnvalue::OK;
#else }
result = sdcMan->getSdCardsStatus(sdInfo.currentState); result = sdcMan->getSdCardsStatus(sdInfo.currentState);
if (result != returnvalue::OK) { if (result != returnvalue::OK) {
sif::warning << "Getting SD card activity status failed" << std::endl; sif::warning << "Getting SD card activity status failed" << std::endl;
} }
#if Q7S_SD_CARD_CONFIG == Q7S_SD_COLD_REDUNDANT if (sdInfo.cfgMode == SdCfgMode::COLD_REDUNDANT) {
updateSdInfoOther(); updateSdInfoOther();
sif::info << "Cold redundant SD card configuration, preferred SD card: " sif::info << "Cold redundant SD card configuration, preferred SD card: "
<< static_cast<int>(sdInfo.pref) << std::endl; << static_cast<int>(sdInfo.active) << std::endl;
result = sdColdRedundantBlockingInit(); result = sdColdRedundantBlockingInit();
// Update status file // Update status file
sdcMan->updateSdCardStateFile(); sdcMan->updateSdCardStateFile();
return result; return result;
#elif Q7S_SD_CARD_CONFIG == Q7S_SD_HOT_REDUNDANT }
sif::info << "Hot redundant SD card configuration" << std::endl; if (sdInfo.cfgMode == SdCfgMode::HOT_REDUNDANT) {
sdCardSetup(sd::SdCard::SLOT_0, sd::SdState::MOUNTED, "0", false); sif::info << "Hot redundant SD card configuration" << std::endl;
sdCardSetup(sd::SdCard::SLOT_1, sd::SdState::MOUNTED, "1", false); sdCardSetup(sd::SdCard::SLOT_0, sd::SdState::MOUNTED, "0", false);
// Update status file sdCardSetup(sd::SdCard::SLOT_1, sd::SdState::MOUNTED, "1", false);
sdcMan->updateSdCardStateFile(); // Update status file
sdcMan->updateSdCardStateFile();
}
return returnvalue::OK; return returnvalue::OK;
#endif
#endif /* Q7S_SD_CARD_CONFIG != Q7S_SD_NONE */
} }
ReturnValue_t CoreController::sdStateMachine() { ReturnValue_t CoreController::sdStateMachine() {
ReturnValue_t result = returnvalue::OK; ReturnValue_t result = returnvalue::OK;
SdCardManager::Operations operation; SdCardManager::Operations operation;
if (sdInfo.state == SdStates::IDLE) { if (sdFsmState == SdStates::IDLE) {
// Nothing to do // Nothing to do
return result; return result;
} }
if (sdInfo.state == SdStates::START) { if (sdFsmState == SdStates::START) {
// Init will be performed by separate function // Init will be performed by separate function
if (BLOCKING_SD_INIT) { if (BLOCKING_SD_INIT) {
sdInfo.state = SdStates::IDLE; sdFsmState = SdStates::IDLE;
sdInfo.initFinished = true; sdInfo.initFinished = true;
return result; return result;
} else { } else {
// Still update SD state file // Still update SD state file
#if Q7S_SD_CARD_CONFIG == Q7S_SD_NONE if (sdInfo.cfgMode == SdCfgMode::PASSIVE) {
sdInfo.state = SdStates::UPDATE_INFO; sdFsmState = SdStates::UPDATE_INFO;
#else } else {
sdInfo.cycleCount = 0; sdInfo.cycleCount = 0;
sdInfo.commandExecuted = false; sdInfo.commandExecuted = false;
sdInfo.state = SdStates::GET_INFO; sdFsmState = SdStates::GET_INFO;
#endif }
} }
} }
@ -319,7 +347,7 @@ ReturnValue_t CoreController::sdStateMachine() {
std::string opPrintout) { std::string opPrintout) {
SdCardManager::OpStatus status = sdcMan->checkCurrentOp(operation); SdCardManager::OpStatus status = sdcMan->checkCurrentOp(operation);
if (status == SdCardManager::OpStatus::SUCCESS) { if (status == SdCardManager::OpStatus::SUCCESS) {
sdInfo.state = newStateOnSuccess; sdFsmState = newStateOnSuccess;
sdInfo.commandExecuted = false; sdInfo.commandExecuted = false;
sdInfo.cycleCount = 0; sdInfo.cycleCount = 0;
return true; return true;
@ -331,9 +359,9 @@ ReturnValue_t CoreController::sdStateMachine() {
return false; return false;
}; };
if (sdInfo.state == SdStates::GET_INFO) { if (sdFsmState == SdStates::GET_INFO) {
if (not sdInfo.commandExecuted) { if (not sdInfo.commandExecuted) {
// Create update status file // Create updated status file
result = sdcMan->updateSdCardStateFile(); result = sdcMan->updateSdCardStateFile();
if (result != returnvalue::OK) { if (result != returnvalue::OK) {
sif::warning << "CoreController::initialize: Updating SD card state file failed" sif::warning << "CoreController::initialize: Updating SD card state file failed"
@ -345,139 +373,141 @@ ReturnValue_t CoreController::sdStateMachine() {
} }
} }
if (sdInfo.state == SdStates::SET_STATE_SELF) { if (sdFsmState == SdStates::SET_STATE_SELF) {
if (not sdInfo.commandExecuted) { if (not sdInfo.commandExecuted) {
result = sdcMan->getSdCardsStatus(sdInfo.currentState); result = sdcMan->getSdCardsStatus(sdInfo.currentState);
sdInfo.pref = sdcMan->getPreferredSdCard();
updateSdInfoOther(); updateSdInfoOther();
if (sdInfo.pref != sd::SdCard::SLOT_0 and sdInfo.pref != sd::SdCard::SLOT_1) { if (sdInfo.active != sd::SdCard::SLOT_0 and sdInfo.active != sd::SdCard::SLOT_1) {
sif::warning << "Preferred SD card invalid. Setting to card 0.." << std::endl; sif::warning << "Preferred SD card invalid. Setting to card 0.." << std::endl;
sdInfo.pref = sd::SdCard::SLOT_0; sdInfo.active = sd::SdCard::SLOT_0;
} }
if (result != returnvalue::OK) { if (result != returnvalue::OK) {
sif::warning << "Getting SD card activity status failed" << std::endl; sif::warning << "Getting SD card activity status failed" << std::endl;
} }
#if Q7S_SD_CARD_CONFIG == Q7S_SD_COLD_REDUNDANT if (sdInfo.cfgMode == SdCfgMode::COLD_REDUNDANT) {
sif::info << "Cold redundant SD card configuration, preferred SD card: " sif::info << "Cold redundant SD card configuration, preferred SD card: "
<< static_cast<int>(sdInfo.pref) << std::endl; << static_cast<int>(sdInfo.active) << std::endl;
#endif }
if (sdInfo.prefState == sd::SdState::MOUNTED) { if (sdInfo.activeState == sd::SdState::MOUNTED) {
#if OBSW_VERBOSE_LEVEL >= 1 #if OBSW_VERBOSE_LEVEL >= 1
std::string mountString; std::string mountString;
if (sdInfo.pref == sd::SdCard::SLOT_0) { if (sdInfo.active == sd::SdCard::SLOT_0) {
mountString = config::SD_0_MOUNT_POINT; mountString = config::SD_0_MOUNT_POINT;
} else { } else {
mountString = config::SD_1_MOUNT_POINT; mountString = config::SD_1_MOUNT_POINT;
} }
sif::info << "SD card " << sdInfo.prefChar << " already on and mounted at " << mountString sif::info << "SD card " << sdInfo.activeChar << " already on and mounted at " << mountString
<< std::endl; << std::endl;
#endif #endif
sdInfo.state = SdStates::DETERMINE_OTHER; sdcMan->setActiveSdCard(sdInfo.active);
} else if (sdInfo.prefState == sd::SdState::OFF) { sdFsmState = SdStates::DETERMINE_OTHER;
sdCardSetup(sdInfo.pref, sd::SdState::ON, sdInfo.prefChar, false); } else if (sdInfo.activeState == sd::SdState::OFF) {
sdCardSetup(sdInfo.active, sd::SdState::ON, sdInfo.activeChar, false);
sdInfo.commandExecuted = true; sdInfo.commandExecuted = true;
} else if (sdInfo.prefState == sd::SdState::ON) { } else if (sdInfo.activeState == sd::SdState::ON) {
sdInfo.state = SdStates::MOUNT_SELF; sdFsmState = SdStates::MOUNT_SELF;
} }
} else { } else {
if (nonBlockingOpChecking(SdStates::MOUNT_SELF, 10, "Setting SDC state")) { if (nonBlockingOpChecking(SdStates::MOUNT_SELF, 10, "Setting SDC state")) {
sdInfo.prefState = sd::SdState::ON; sdInfo.activeState = sd::SdState::ON;
currentStateSetter(sdInfo.pref, sd::SdState::ON); currentStateSetter(sdInfo.active, sd::SdState::ON);
} }
} }
} }
if (sdInfo.state == SdStates::MOUNT_SELF) { if (sdFsmState == SdStates::MOUNT_SELF) {
if (not sdInfo.commandExecuted) { if (not sdInfo.commandExecuted) {
result = sdCardSetup(sdInfo.pref, sd::SdState::MOUNTED, sdInfo.prefChar); result = sdCardSetup(sdInfo.active, sd::SdState::MOUNTED, sdInfo.activeChar);
sdInfo.commandExecuted = true; sdInfo.commandExecuted = true;
} else { } else {
if (nonBlockingOpChecking(SdStates::DETERMINE_OTHER, 5, "Mounting SD card")) { if (nonBlockingOpChecking(SdStates::DETERMINE_OTHER, 5, "Mounting SD card")) {
sdInfo.prefState = sd::SdState::MOUNTED; sdcMan->setActiveSdCard(sdInfo.active);
currentStateSetter(sdInfo.pref, sd::SdState::MOUNTED); sdInfo.activeState = sd::SdState::MOUNTED;
currentStateSetter(sdInfo.active, sd::SdState::MOUNTED);
} }
} }
} }
if (sdInfo.state == SdStates::DETERMINE_OTHER) { if (sdFsmState == SdStates::DETERMINE_OTHER) {
// Determine whether any additional operations have to be done for the other SD card // Determine whether any additional operations have to be done for the other SD card
// 1. Cold redundant case: Other SD card needs to be unmounted and switched off // 1. Cold redundant case: Other SD card needs to be unmounted and switched off
// 2. Hot redundant case: Other SD card needs to be mounted and switched on // 2. Hot redundant case: Other SD card needs to be mounted and switched on
#if Q7S_SD_CARD_CONFIG == Q7S_SD_COLD_REDUNDANT if (sdInfo.cfgMode == SdCfgMode::COLD_REDUNDANT) {
if (sdInfo.otherState == sd::SdState::ON) { if (sdInfo.otherState == sd::SdState::ON) {
sdInfo.state = SdStates::SET_STATE_OTHER; sdFsmState = SdStates::SET_STATE_OTHER;
} else if (sdInfo.otherState == sd::SdState::MOUNTED) { } else if (sdInfo.otherState == sd::SdState::MOUNTED) {
sdInfo.state = SdStates::MOUNT_UNMOUNT_OTHER; sdFsmState = SdStates::MOUNT_UNMOUNT_OTHER;
} else { } else {
// Is already off, update info, but with a small delay // Is already off, update info, but with a small delay
sdInfo.state = SdStates::SKIP_CYCLE_BEFORE_INFO_UPDATE; sdFsmState = SdStates::SKIP_CYCLE_BEFORE_INFO_UPDATE;
}
} else if (sdInfo.cfgMode == SdCfgMode::HOT_REDUNDANT) {
if (sdInfo.otherState == sd::SdState::OFF) {
sdFsmState = SdStates::SET_STATE_OTHER;
} else if (sdInfo.otherState == sd::SdState::ON) {
sdFsmState = SdStates::MOUNT_UNMOUNT_OTHER;
} else {
// Is already on and mounted, update info
sdFsmState = SdStates::SKIP_CYCLE_BEFORE_INFO_UPDATE;
}
} }
#elif Q7S_SD_CARD_CONFIG == Q7S_SD_HOT_REDUNDANT
if (sdInfo.otherState == sd::SdState::OFF) {
sdInfo.state = SdStates::SET_STATE_OTHER;
} else if (sdInfo.otherState == sd::SdState::ON) {
sdInfo.state = SdStates::MOUNT_UNMOUNT_OTHER;
} else {
// Is already on and mounted, update info
sdInfo.state = SdStates::SKIP_CYCLE_BEFORE_INFO_UPDATE;
}
#endif
} }
if (sdInfo.state == SdStates::SET_STATE_OTHER) { if (sdFsmState == SdStates::SET_STATE_OTHER) {
// Set state of other SD card to ON or OFF, depending on redundancy mode // Set state of other SD card to ON or OFF, depending on redundancy mode
#if Q7S_SD_CARD_CONFIG == Q7S_SD_COLD_REDUNDANT if (sdInfo.cfgMode == SdCfgMode::COLD_REDUNDANT) {
if (not sdInfo.commandExecuted) { if (not sdInfo.commandExecuted) {
result = sdCardSetup(sdInfo.other, sd::SdState::OFF, sdInfo.otherChar, false); result = sdCardSetup(sdInfo.other, sd::SdState::OFF, sdInfo.otherChar, false);
sdInfo.commandExecuted = true; sdInfo.commandExecuted = true;
} else { } else {
if (nonBlockingOpChecking(SdStates::SKIP_CYCLE_BEFORE_INFO_UPDATE, 10, if (nonBlockingOpChecking(SdStates::SKIP_CYCLE_BEFORE_INFO_UPDATE, 10,
"Switching off other SD card")) { "Switching off other SD card")) {
sdInfo.otherState = sd::SdState::OFF; sdInfo.otherState = sd::SdState::OFF;
currentStateSetter(sdInfo.other, sd::SdState::OFF); currentStateSetter(sdInfo.other, sd::SdState::OFF);
}
}
} else if (sdInfo.cfgMode == SdCfgMode::HOT_REDUNDANT) {
if (not sdInfo.commandExecuted) {
result = sdCardSetup(sdInfo.other, sd::SdState::ON, sdInfo.otherChar, false);
sdInfo.commandExecuted = true;
} else {
if (nonBlockingOpChecking(SdStates::MOUNT_UNMOUNT_OTHER, 10,
"Switching on other SD card")) {
sdInfo.otherState = sd::SdState::ON;
currentStateSetter(sdInfo.other, sd::SdState::ON);
}
} }
} }
#elif Q7S_SD_CARD_CONFIG == Q7S_SD_HOT_REDUNDANT
if (not sdInfo.commandExecuted) {
result = sdCardSetup(sdInfo.other, sd::SdState::ON, sdInfo.otherChar, false);
sdInfo.commandExecuted = true;
} else {
if (nonBlockingOpChecking(SdStates::MOUNT_UNMOUNT_OTHER, 10, "Switching on other SD card")) {
sdInfo.otherState = sd::SdState::ON;
currentStateSetter(sdInfo.other, sd::SdState::ON);
}
}
#endif
} }
if (sdInfo.state == SdStates::MOUNT_UNMOUNT_OTHER) { if (sdFsmState == SdStates::MOUNT_UNMOUNT_OTHER) {
// Mount or unmount other SD card, depending on redundancy mode // Mount or unmount other SD card, depending on redundancy mode
#if Q7S_SD_CARD_CONFIG == Q7S_SD_COLD_REDUNDANT if (sdInfo.cfgMode == SdCfgMode::COLD_REDUNDANT) {
if (not sdInfo.commandExecuted) { if (not sdInfo.commandExecuted) {
result = sdCardSetup(sdInfo.other, sd::SdState::ON, sdInfo.otherChar); result = sdCardSetup(sdInfo.other, sd::SdState::ON, sdInfo.otherChar);
sdInfo.commandExecuted = true; sdInfo.commandExecuted = true;
} else { } else {
if (nonBlockingOpChecking(SdStates::SET_STATE_OTHER, 10, "Unmounting other SD card")) { if (nonBlockingOpChecking(SdStates::SET_STATE_OTHER, 10, "Unmounting other SD card")) {
sdInfo.otherState = sd::SdState::ON; sdInfo.otherState = sd::SdState::ON;
currentStateSetter(sdInfo.other, sd::SdState::ON); currentStateSetter(sdInfo.other, sd::SdState::ON);
}
}
} else if (sdInfo.cfgMode == SdCfgMode::HOT_REDUNDANT) {
if (not sdInfo.commandExecuted) {
result = sdCardSetup(sdInfo.other, sd::SdState::MOUNTED, sdInfo.otherChar);
sdInfo.commandExecuted = true;
} else {
if (nonBlockingOpChecking(SdStates::UPDATE_INFO, 4, "Mounting other SD card")) {
sdInfo.otherState = sd::SdState::MOUNTED;
currentStateSetter(sdInfo.other, sd::SdState::MOUNTED);
}
} }
} }
#elif Q7S_SD_CARD_CONFIG == Q7S_SD_HOT_REDUNDANT
if (not sdInfo.commandExecuted) {
result = sdCardSetup(sdInfo.other, sd::SdState::MOUNTED, sdInfo.otherChar);
sdInfo.commandExecuted = true;
} else {
if (nonBlockingOpChecking(SdStates::UPDATE_INFO, 4, "Mounting other SD card")) {
sdInfo.otherState = sd::SdState::MOUNTED;
currentStateSetter(sdInfo.other, sd::SdState::MOUNTED);
}
}
#endif
} }
if (sdInfo.state == SdStates::SKIP_CYCLE_BEFORE_INFO_UPDATE) { if (sdFsmState == SdStates::SKIP_CYCLE_BEFORE_INFO_UPDATE) {
sdInfo.state = SdStates::UPDATE_INFO; sdFsmState = SdStates::UPDATE_INFO;
} else if (sdInfo.state == SdStates::UPDATE_INFO) { } else if (sdFsmState == SdStates::UPDATE_INFO) {
// It is assumed that all tasks are running by the point this section is reached. // It is assumed that all tasks are running by the point this section is reached.
// Therefore, perform this operation in blocking mode because it does not take long // Therefore, perform this operation in blocking mode because it does not take long
// and the ready state of the SD card is available sooner // and the ready state of the SD card is available sooner
@ -488,10 +518,15 @@ ReturnValue_t CoreController::sdStateMachine() {
sif::warning << "CoreController::initialize: Updating SD card state file failed" << std::endl; sif::warning << "CoreController::initialize: Updating SD card state file failed" << std::endl;
} }
sdInfo.commandExecuted = false; sdInfo.commandExecuted = false;
sdInfo.state = SdStates::IDLE; sdFsmState = SdStates::IDLE;
sdInfo.cycleCount = 0; sdInfo.cycleCount = 0;
sdcMan->setBlocking(false); sdcMan->setBlocking(false);
sdcMan->getSdCardsStatus(sdInfo.currentState); sdcMan->getSdCardsStatus(sdInfo.currentState);
if (sdCommandingInfo.cmdPending) {
sdCommandingInfo.cmdPending = false;
actionHelper.finish(true, sdCommandingInfo.commander, sdCommandingInfo.actionId,
returnvalue::OK);
}
if (not sdInfo.initFinished) { if (not sdInfo.initFinished) {
updateSdInfoOther(); updateSdInfoOther();
sdInfo.initFinished = true; sdInfo.initFinished = true;
@ -499,81 +534,10 @@ ReturnValue_t CoreController::sdStateMachine() {
} }
} }
if (sdInfo.state == SdStates::SET_STATE_FROM_COMMAND) {
if (not sdInfo.commandExecuted) {
executeNextExternalSdCommand();
} else {
checkExternalSdCommandStatus();
}
}
sdInfo.cycleCount++; sdInfo.cycleCount++;
return returnvalue::OK; return returnvalue::OK;
} }
void CoreController::executeNextExternalSdCommand() {
std::string sdChar;
sd::SdState currentStateOfCard = sd::SdState::OFF;
if (sdInfo.commandedCard == sd::SdCard::SLOT_0) {
sdChar = "0";
currentStateOfCard = sdInfo.currentState.first;
} else {
sdChar = "1";
currentStateOfCard = sdInfo.currentState.second;
}
if (currentStateOfCard == sd::SdState::OFF) {
if (sdInfo.commandedState == sd::SdState::ON) {
sdInfo.currentlyCommandedState = sdInfo.commandedState;
} else if (sdInfo.commandedState == sd::SdState::MOUNTED) {
sdInfo.currentlyCommandedState = sd::SdState::ON;
} else {
// SD card is already on target state
sdInfo.commandFinished = true;
sdInfo.state = SdStates::IDLE;
}
} else if (currentStateOfCard == sd::SdState::ON) {
if (sdInfo.commandedState == sd::SdState::OFF or
sdInfo.commandedState == sd::SdState::MOUNTED) {
sdInfo.currentlyCommandedState = sdInfo.commandedState;
} else {
// Already on target state
sdInfo.commandFinished = true;
sdInfo.state = SdStates::IDLE;
}
} else if (currentStateOfCard == sd::SdState::MOUNTED) {
if (sdInfo.commandedState == sd::SdState::ON) {
sdInfo.currentlyCommandedState = sdInfo.commandedState;
} else if (sdInfo.commandedState == sd::SdState::OFF) {
// This causes an unmount in sdCardSetup
sdInfo.currentlyCommandedState = sd::SdState::ON;
} else {
sdInfo.commandFinished = true;
}
}
sdCardSetup(sdInfo.commandedCard, sdInfo.commandedState, sdChar);
sdInfo.commandExecuted = true;
}
void CoreController::checkExternalSdCommandStatus() {
SdCardManager::Operations operation;
SdCardManager::OpStatus status = sdcMan->checkCurrentOp(operation);
if (status == SdCardManager::OpStatus::SUCCESS) {
if (sdInfo.currentlyCommandedState == sdInfo.commandedState) {
sdInfo.state = SdStates::SKIP_CYCLE_BEFORE_INFO_UPDATE;
sdInfo.commandFinished = true;
} else {
// stay on same state machine state because the target state was not reached yet.
sdInfo.cycleCount = 0;
}
currentStateSetter(sdInfo.commandedCard, sdInfo.currentlyCommandedState);
sdInfo.commandExecuted = false;
} else if (sdInfo.cycleCount > 4) {
sif::warning << "CoreController::sdStateMachine: Commanding SD state "
"takes too long"
<< std::endl;
}
}
void CoreController::currentStateSetter(sd::SdCard sdCard, sd::SdState newState) { void CoreController::currentStateSetter(sd::SdCard sdCard, sd::SdState newState) {
if (sdCard == sd::SdCard::SLOT_0) { if (sdCard == sd::SdCard::SLOT_0) {
sdInfo.currentState.first = newState; sdInfo.currentState.first = newState;
@ -645,12 +609,12 @@ ReturnValue_t CoreController::sdCardSetup(sd::SdCard sdCard, sd::SdState targetS
ReturnValue_t CoreController::sdColdRedundantBlockingInit() { ReturnValue_t CoreController::sdColdRedundantBlockingInit() {
ReturnValue_t result = returnvalue::OK; ReturnValue_t result = returnvalue::OK;
result = sdCardSetup(sdInfo.pref, sd::SdState::MOUNTED, sdInfo.prefChar); result = sdCardSetup(sdInfo.active, sd::SdState::MOUNTED, sdInfo.activeChar);
if (result != SdCardManager::ALREADY_MOUNTED and result != returnvalue::OK) { if (result != SdCardManager::ALREADY_MOUNTED and result != returnvalue::OK) {
sif::warning << "Setting up preferred card " << sdInfo.otherChar sif::warning << "Setting up preferred card " << sdInfo.otherChar
<< " in cold redundant mode failed" << std::endl; << " in cold redundant mode failed" << std::endl;
// Try other SD card and mark set up operation as failed // Try other SD card and mark set up operation as failed
sdCardSetup(sdInfo.pref, sd::SdState::MOUNTED, sdInfo.prefChar); sdCardSetup(sdInfo.active, sd::SdState::MOUNTED, sdInfo.activeChar);
result = returnvalue::FAILED; result = returnvalue::FAILED;
} }
@ -967,21 +931,19 @@ ReturnValue_t CoreController::gracefulShutdownTasks(xsc::Chip chip, xsc::Copy co
return result; return result;
} }
CoreController::~CoreController() {}
void CoreController::updateSdInfoOther() { void CoreController::updateSdInfoOther() {
if (sdInfo.pref == sd::SdCard::SLOT_0) { if (sdInfo.active == sd::SdCard::SLOT_0) {
sdInfo.prefChar = "0"; sdInfo.activeChar = "0";
sdInfo.otherChar = "1"; sdInfo.otherChar = "1";
sdInfo.otherState = sdInfo.currentState.second; sdInfo.otherState = sdInfo.currentState.second;
sdInfo.prefState = sdInfo.currentState.first; sdInfo.activeState = sdInfo.currentState.first;
sdInfo.other = sd::SdCard::SLOT_1; sdInfo.other = sd::SdCard::SLOT_1;
} else if (sdInfo.pref == sd::SdCard::SLOT_1) { } else if (sdInfo.active == sd::SdCard::SLOT_1) {
sdInfo.prefChar = "1"; sdInfo.activeChar = "1";
sdInfo.otherChar = "0"; sdInfo.otherChar = "0";
sdInfo.otherState = sdInfo.currentState.first; sdInfo.otherState = sdInfo.currentState.first;
sdInfo.prefState = sdInfo.currentState.second; sdInfo.activeState = sdInfo.currentState.second;
sdInfo.other = sd::SdCard::SLOT_0; sdInfo.other = sd::SdCard::SLOT_0;
} else { } else {
sif::warning << "CoreController::updateSdInfoOther: Invalid SD card passed" << std::endl; sif::warning << "CoreController::updateSdInfoOther: Invalid SD card passed" << std::endl;
@ -1254,7 +1216,7 @@ void CoreController::performWatchdogControlOperation() {
void CoreController::performMountedSdCardOperations() { void CoreController::performMountedSdCardOperations() {
auto mountedSdCardOp = [&](bool &mntSwitch, sd::SdCard sdCard, std::string mntPoint) { auto mountedSdCardOp = [&](bool &mntSwitch, sd::SdCard sdCard, std::string mntPoint) {
if (mntSwitch) { if (mntSwitch) {
bool sdCardMounted = sdcMan->isSdCardMounted(sdCard); bool sdCardMounted = sdcMan->isSdCardUsable(sdCard);
if (sdCardMounted and not performOneShotSdCardOpsSwitch) { if (sdCardMounted and not performOneShotSdCardOpsSwitch) {
std::ostringstream path; std::ostringstream path;
path << mntPoint << "/" << CONF_FOLDER; path << mntPoint << "/" << CONF_FOLDER;
@ -1269,7 +1231,7 @@ void CoreController::performMountedSdCardOperations() {
mntSwitch = false; mntSwitch = false;
} }
}; };
if (sdInfo.pref == sd::SdCard::SLOT_1) { if (sdInfo.active == sd::SdCard::SLOT_1) {
mountedSdCardOp(sdInfo.mountSwitch.second, sd::SdCard::SLOT_1, config::SD_1_MOUNT_POINT); mountedSdCardOp(sdInfo.mountSwitch.second, sd::SdCard::SLOT_1, config::SD_1_MOUNT_POINT);
mountedSdCardOp(sdInfo.mountSwitch.first, sd::SdCard::SLOT_0, config::SD_0_MOUNT_POINT); mountedSdCardOp(sdInfo.mountSwitch.first, sd::SdCard::SLOT_0, config::SD_0_MOUNT_POINT);
} else { } else {
@ -1283,13 +1245,15 @@ ReturnValue_t CoreController::performSdCardCheck() {
bool mountedReadOnly = false; bool mountedReadOnly = false;
SdCardManager::SdStatePair active; SdCardManager::SdStatePair active;
sdcMan->getSdCardsStatus(active); sdcMan->getSdCardsStatus(active);
if (sdFsmState != SdStates::IDLE) {
return returnvalue::OK;
}
auto sdCardCheck = [&](sd::SdCard sdCard) { auto sdCardCheck = [&](sd::SdCard sdCard) {
ReturnValue_t result = sdcMan->isSdCardMountedReadOnly(sdCard, mountedReadOnly); ReturnValue_t result = sdcMan->isSdCardMountedReadOnly(sdCard, mountedReadOnly);
if (result != returnvalue::OK) { if (result != returnvalue::OK) {
sif::error << "CoreController::performSdCardCheck: Could not check " sif::error << "CoreController::performSdCardCheck: Could not check "
"read-only mount state" "read-only mount state"
<< std::endl; << std::endl;
mountedReadOnly = true;
} }
if (mountedReadOnly) { if (mountedReadOnly) {
int linuxErrno = 0; int linuxErrno = 0;
@ -1986,6 +1950,17 @@ ReturnValue_t CoreController::executeSwUpdate(SwUpdateSources sourceDir, const u
return HasActionsIF::EXECUTION_FINISHED; return HasActionsIF::EXECUTION_FINISHED;
} }
bool CoreController::startSdStateMachine(sd::SdCard targetActiveSd, SdCfgMode mode) {
if (sdFsmState != SdStates::IDLE or sdCommandingInfo.cmdPending) {
return false;
}
sdFsmState = SdStates::START;
sdInfo.active = targetActiveSd;
sdInfo.cfgMode = mode;
sdCommandingInfo.cmdPending = true;
return true;
}
bool CoreController::isNumber(const std::string &s) { bool CoreController::isNumber(const std::string &s) {
return !s.empty() && std::find_if(s.begin(), s.end(), return !s.empty() && std::find_if(s.begin(), s.end(),
[](unsigned char c) { return !std::isdigit(c); }) == s.end(); [](unsigned char c) { return !std::isdigit(c); }) == s.end();

View File

@ -79,6 +79,10 @@ class CoreController : public ExtendedControllerBase {
static constexpr ActionId_t OBSW_UPDATE_FROM_SD_1 = 11; static constexpr ActionId_t OBSW_UPDATE_FROM_SD_1 = 11;
static constexpr ActionId_t OBSW_UPDATE_FROM_TMP = 12; 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;
//! Reboot using the xsc_boot_copy command //! Reboot using the xsc_boot_copy command
static constexpr ActionId_t XSC_REBOOT_OBC = 32; static constexpr ActionId_t XSC_REBOOT_OBC = 32;
static constexpr ActionId_t MOUNT_OTHER_COPY = 33; static constexpr ActionId_t MOUNT_OTHER_COPY = 33;
@ -164,9 +168,7 @@ class CoreController : public ExtendedControllerBase {
SKIP_CYCLE_BEFORE_INFO_UPDATE, SKIP_CYCLE_BEFORE_INFO_UPDATE,
UPDATE_INFO, UPDATE_INFO,
// SD initialization done // SD initialization done
IDLE, IDLE
// Used if SD switches or mount commands are issued via telecommand
SET_STATE_FROM_COMMAND,
}; };
enum class SwUpdateSources { SD_0, SD_1, TMP_DIR }; enum class SwUpdateSources { SD_0, SD_1, TMP_DIR };
@ -176,27 +178,31 @@ class CoreController : public ExtendedControllerBase {
SdCardManager* sdcMan = nullptr; SdCardManager* sdcMan = nullptr;
MessageQueueIF* eventQueue = nullptr; MessageQueueIF* eventQueue = nullptr;
struct SdInfo { SdStates sdFsmState = SdStates::START;
sd::SdCard pref = sd::SdCard::NONE; enum SdCfgMode { PASSIVE, COLD_REDUNDANT, HOT_REDUNDANT };
struct SdFsmParams {
SdCfgMode cfgMode = SdCfgMode::COLD_REDUNDANT;
sd::SdCard active = sd::SdCard::NONE;
sd::SdCard other = sd::SdCard::NONE; sd::SdCard other = sd::SdCard::NONE;
sd::SdState prefState = sd::SdState::OFF; sd::SdState activeState = sd::SdState::OFF;
sd::SdState otherState = sd::SdState::OFF; sd::SdState otherState = sd::SdState::OFF;
std::string prefChar = "0"; std::string activeChar = "0";
std::string otherChar = "1"; std::string otherChar = "1";
std::pair<bool, bool> mountSwitch = {true, true}; std::pair<bool, bool> mountSwitch = {true, true};
SdStates state = SdStates::START;
// Used to track whether a command was executed // Used to track whether a command was executed
bool commandExecuted = true; bool commandExecuted = true;
bool initFinished = false; bool initFinished = false;
SdCardManager::SdStatePair currentState; SdCardManager::SdStatePair currentState;
uint16_t cycleCount = 0; uint16_t cycleCount = 0;
// These two flags are related to external commanding
bool commandIssued = false;
bool commandFinished = false;
sd::SdState currentlyCommandedState = sd::SdState::OFF;
sd::SdCard commandedCard = sd::SdCard::NONE;
sd::SdState commandedState = sd::SdState::OFF;
} sdInfo; } sdInfo;
struct SdCommanding {
bool cmdPending = false;
MessageQueueId_t commander = MessageQueueIF::NO_QUEUE;
DeviceCommandId_t actionId;
} sdCommandingInfo;
RebootFile rebootFile = {}; RebootFile rebootFile = {};
std::string currMntPrefix; std::string currMntPrefix;
bool performOneShotSdCardOpsSwitch = true; bool performOneShotSdCardOpsSwitch = true;
@ -227,6 +233,7 @@ class CoreController : public ExtendedControllerBase {
ReturnValue_t initBootCopy(); ReturnValue_t initBootCopy();
ReturnValue_t initWatchdogFifo(); ReturnValue_t initWatchdogFifo();
ReturnValue_t initSdCardBlocking(); ReturnValue_t initSdCardBlocking();
bool startSdStateMachine(sd::SdCard targetActiveSd, SdCfgMode mode);
void initPrint(); void initPrint();
ReturnValue_t sdStateMachine(); ReturnValue_t sdStateMachine();

View File

@ -16,13 +16,13 @@ ReturnValue_t FilesystemHelper::checkPath(std::string path) {
return returnvalue::FAILED; return returnvalue::FAILED;
} }
if (path.substr(0, sizeof(config::SD_0_MOUNT_POINT)) == std::string(config::SD_0_MOUNT_POINT)) { if (path.substr(0, sizeof(config::SD_0_MOUNT_POINT)) == std::string(config::SD_0_MOUNT_POINT)) {
if (!sdcMan->isSdCardMounted(sd::SLOT_0)) { if (!sdcMan->isSdCardUsable(sd::SLOT_0)) {
sif::warning << "FilesystemHelper::checkPath: SD card 0 not mounted" << std::endl; sif::warning << "FilesystemHelper::checkPath: SD card 0 not mounted" << std::endl;
return SD_NOT_MOUNTED; return SD_NOT_MOUNTED;
} }
} else if (path.substr(0, sizeof(config::SD_1_MOUNT_POINT)) == } else if (path.substr(0, sizeof(config::SD_1_MOUNT_POINT)) ==
std::string(config::SD_1_MOUNT_POINT)) { std::string(config::SD_1_MOUNT_POINT)) {
if (!sdcMan->isSdCardMounted(sd::SLOT_0)) { if (!sdcMan->isSdCardUsable(sd::SLOT_0)) {
sif::warning << "FilesystemHelper::checkPath: SD card 1 not mounted" << std::endl; sif::warning << "FilesystemHelper::checkPath: SD card 1 not mounted" << std::endl;
return SD_NOT_MOUNTED; return SD_NOT_MOUNTED;
} }

View File

@ -213,6 +213,9 @@ ReturnValue_t SdCardManager::getSdCardsStatus(SdStatePair& active) {
while (std::getline(sdStatus, line)) { while (std::getline(sdStatus, line)) {
processSdStatusLine(active, line, idx, currentSd); processSdStatusLine(active, line, idx, currentSd);
} }
if (active.first != sd::SdState::MOUNTED && active.second != sd::SdState::MOUNTED) {
sdCardActive = false;
}
return returnvalue::OK; return returnvalue::OK;
} }
@ -466,7 +469,7 @@ void SdCardManager::setBlocking(bool blocking) { this->blocking = blocking; }
void SdCardManager::setPrintCommandOutput(bool print) { this->printCmdOutput = print; } void SdCardManager::setPrintCommandOutput(bool print) { this->printCmdOutput = print; }
bool SdCardManager::isSdCardMounted(sd::SdCard sdCard) { bool SdCardManager::isSdCardUsable(sd::SdCard sdCard) {
SdCardManager::SdStatePair active; SdCardManager::SdStatePair active;
ReturnValue_t result = this->getSdCardsStatus(active); ReturnValue_t result = this->getSdCardsStatus(active);
@ -496,8 +499,10 @@ ReturnValue_t SdCardManager::isSdCardMountedReadOnly(sd::SdCard sdcard, bool& re
std::ostringstream command; std::ostringstream command;
if (sdcard == sd::SdCard::SLOT_0) { if (sdcard == sd::SdCard::SLOT_0) {
command << "grep -q '" << config::SD_0_MOUNT_POINT << " vfat ro,' /proc/mounts"; command << "grep -q '" << config::SD_0_MOUNT_POINT << " vfat ro,' /proc/mounts";
} else { } else if (sdcard == sd::SdCard::SLOT_1) {
command << "grep -q '" << config::SD_1_MOUNT_POINT << " vfat ro,' /proc/mounts"; command << "grep -q '" << config::SD_1_MOUNT_POINT << " vfat ro,' /proc/mounts";
} else {
return returnvalue::FAILED;
} }
ReturnValue_t result = cmdExecutor.load(command.str(), true, false); ReturnValue_t result = cmdExecutor.load(command.str(), true, false);
if (result != returnvalue::OK) { if (result != returnvalue::OK) {

View File

@ -206,7 +206,7 @@ class SdCardManager : public SystemObject, public SdCardMountedIF {
* *
* @return true if mounted, otherwise false * @return true if mounted, otherwise false
*/ */
bool isSdCardMounted(sd::SdCard sdCard) override; bool isSdCardUsable(sd::SdCard sdCard) override;
ReturnValue_t isSdCardMountedReadOnly(sd::SdCard sdcard, bool& readOnly); ReturnValue_t isSdCardMountedReadOnly(sd::SdCard sdcard, bool& readOnly);
@ -218,6 +218,7 @@ class SdCardManager : public SystemObject, public SdCardMountedIF {
CommandExecutor cmdExecutor; CommandExecutor cmdExecutor;
Operations currentOp = Operations::IDLE; Operations currentOp = Operations::IDLE;
bool blocking = false; bool blocking = false;
bool sdCardActive = true;
bool printCmdOutput = true; bool printCmdOutput = true;
MutexIF* mutex = nullptr; MutexIF* mutex = nullptr;

View File

@ -543,13 +543,13 @@ ReturnValue_t StrHelper::checkReplyPosition(uint32_t expectedPosition) {
#ifdef XIPHOS_Q7S #ifdef XIPHOS_Q7S
ReturnValue_t StrHelper::checkPath(std::string name) { ReturnValue_t StrHelper::checkPath(std::string name) {
if (name.substr(0, sizeof(config::SD_0_MOUNT_POINT)) == std::string(config::SD_0_MOUNT_POINT)) { if (name.substr(0, sizeof(config::SD_0_MOUNT_POINT)) == std::string(config::SD_0_MOUNT_POINT)) {
if (!sdcMan->isSdCardMounted(sd::SLOT_0)) { if (!sdcMan->isSdCardUsable(sd::SLOT_0)) {
sif::warning << "StrHelper::checkPath: SD card 0 not mounted" << std::endl; sif::warning << "StrHelper::checkPath: SD card 0 not mounted" << std::endl;
return SD_NOT_MOUNTED; return SD_NOT_MOUNTED;
} }
} else if (name.substr(0, sizeof(config::SD_1_MOUNT_POINT)) == } else if (name.substr(0, sizeof(config::SD_1_MOUNT_POINT)) ==
std::string(config::SD_1_MOUNT_POINT)) { std::string(config::SD_1_MOUNT_POINT)) {
if (!sdcMan->isSdCardMounted(sd::SLOT_0)) { if (!sdcMan->isSdCardUsable(sd::SLOT_0)) {
sif::warning << "StrHelper::checkPath: SD card 1 not mounted" << std::endl; sif::warning << "StrHelper::checkPath: SD card 1 not mounted" << std::endl;
return SD_NOT_MOUNTED; return SD_NOT_MOUNTED;
} }

View File

@ -492,7 +492,7 @@ void PayloadPcduHandler::checkAdcValues() {
void PayloadPcduHandler::checkJsonFileInit() { void PayloadPcduHandler::checkJsonFileInit() {
if (not jsonFileInitComplete) { if (not jsonFileInitComplete) {
sd::SdCard activeSd = sdcMan->getActiveSdCard(); sd::SdCard activeSd = sdcMan->getActiveSdCard();
if (sdcMan->isSdCardMounted(activeSd)) { if (sdcMan->isSdCardUsable(activeSd)) {
params.initialize(sdcMan->getCurrentMountPrefix()); params.initialize(sdcMan->getCurrentMountPrefix());
jsonFileInitComplete = true; jsonFileInitComplete = true;
} }

View File

@ -9,7 +9,7 @@ class SdCardMountedIF {
public: public:
virtual ~SdCardMountedIF(){}; virtual ~SdCardMountedIF(){};
virtual std::string getCurrentMountPrefix() const = 0; virtual std::string getCurrentMountPrefix() const = 0;
virtual bool isSdCardMounted(sd::SdCard sdCard) = 0; virtual bool isSdCardUsable(sd::SdCard sdCard) = 0;
virtual sd::SdCard getPreferredSdCard() const = 0; virtual sd::SdCard getPreferredSdCard() const = 0;
virtual void setActiveSdCard(sd::SdCard sdCard) = 0; virtual void setActiveSdCard(sd::SdCard sdCard) = 0;
virtual sd::SdCard getActiveSdCard() const = 0; virtual sd::SdCard getActiveSdCard() const = 0;

View File

@ -21,7 +21,7 @@ CoreController::CoreController() {
void CoreController::performRebootFileHandling(bool recreateFile) { void CoreController::performRebootFileHandling(bool recreateFile) {
using namespace std; using namespace std;
std::string path = sdcMan->getCurrentMountPrefix(sdInfo.pref) + REBOOT_FILE; std::string path = sdcMan->getCurrentMountPrefix(sdInfo.active) + REBOOT_FILE;
if (not std::filesystem::exists(path) or recreateFile) { if (not std::filesystem::exists(path) or recreateFile) {
#if OBSW_VERBOSE_LEVEL >= 1 #if OBSW_VERBOSE_LEVEL >= 1
sif::info << "CoreController::performRebootFileHandling: Recreating reboot file" << std::endl; sif::info << "CoreController::performRebootFileHandling: Recreating reboot file" << std::endl;
@ -400,7 +400,7 @@ bool CoreController::parseRebootFile(std::string path, RebootFile &rf) {
} }
void CoreController::resetRebootCount(xsc::Chip tgtChip, xsc::Copy tgtCopy) { void CoreController::resetRebootCount(xsc::Chip tgtChip, xsc::Copy tgtCopy) {
std::string path = sdcMan->getCurrentMountPrefix(sdInfo.pref) + REBOOT_FILE; std::string path = sdcMan->getCurrentMountPrefix(sdInfo.active) + REBOOT_FILE;
// Disable the reboot file mechanism // Disable the reboot file mechanism
parseRebootFile(path, rebootFile); parseRebootFile(path, rebootFile);
if (tgtChip == xsc::ALL_CHIP and tgtCopy == xsc::ALL_COPY) { if (tgtChip == xsc::ALL_CHIP and tgtCopy == xsc::ALL_COPY) {
@ -427,7 +427,7 @@ void CoreController::resetRebootCount(xsc::Chip tgtChip, xsc::Copy tgtCopy) {
} }
void CoreController::rewriteRebootFile(RebootFile file) { void CoreController::rewriteRebootFile(RebootFile file) {
std::string path = sdcMan->getCurrentMountPrefix(sdInfo.pref) + REBOOT_FILE; std::string path = sdcMan->getCurrentMountPrefix(sdInfo.active) + REBOOT_FILE;
std::ofstream rebootFile(path); std::ofstream rebootFile(path);
if (rebootFile.is_open()) { if (rebootFile.is_open()) {
// Initiate reboot file first. Reboot handling will be on on initialization // Initiate reboot file first. Reboot handling will be on on initialization
@ -450,7 +450,7 @@ ReturnValue_t CoreController::executeAction(ActionId_t actionId, MessageQueueId_
if (size < 1) { if (size < 1) {
return HasActionsIF::INVALID_PARAMETERS; return HasActionsIF::INVALID_PARAMETERS;
} }
std::string path = sdcMan->getCurrentMountPrefix(sdInfo.pref) + REBOOT_FILE; std::string path = sdcMan->getCurrentMountPrefix(sdInfo.active) + REBOOT_FILE;
// Disable the reboot file mechanism // Disable the reboot file mechanism
parseRebootFile(path, rebootFile); parseRebootFile(path, rebootFile);
if (data[0] == 0) { if (data[0] == 0) {
@ -490,7 +490,7 @@ ReturnValue_t CoreController::executeAction(ActionId_t actionId, MessageQueueId_
if (size < 1) { if (size < 1) {
return HasActionsIF::INVALID_PARAMETERS; return HasActionsIF::INVALID_PARAMETERS;
} }
std::string path = sdcMan->getCurrentMountPrefix(sdInfo.pref) + REBOOT_FILE; std::string path = sdcMan->getCurrentMountPrefix(sdInfo.active) + REBOOT_FILE;
// Disable the reboot file mechanism // Disable the reboot file mechanism
parseRebootFile(path, rebootFile); parseRebootFile(path, rebootFile);
rebootFile.maxCount = data[0]; rebootFile.maxCount = data[0];
@ -504,7 +504,7 @@ ReturnValue_t CoreController::executeAction(ActionId_t actionId, MessageQueueId_
} }
void CoreController::setRebootMechanismLock(bool lock, xsc::Chip tgtChip, xsc::Copy tgtCopy) { void CoreController::setRebootMechanismLock(bool lock, xsc::Chip tgtChip, xsc::Copy tgtCopy) {
std::string path = sdcMan->getCurrentMountPrefix(sdInfo.pref) + REBOOT_FILE; std::string path = sdcMan->getCurrentMountPrefix(sdInfo.active) + REBOOT_FILE;
// Disable the reboot file mechanism // Disable the reboot file mechanism
parseRebootFile(path, rebootFile); parseRebootFile(path, rebootFile);
if (tgtChip == xsc::CHIP_0) { if (tgtChip == xsc::CHIP_0) {

View File

@ -66,9 +66,9 @@ class CoreController {
void rewriteRebootFile(RebootFile file); void rewriteRebootFile(RebootFile file);
private: private:
struct SdInfo { struct SdFsmParams {
sd::SdCard pref = sd::SdCard::NONE; sd::SdCard active = sd::SdCard::NONE;
sd::SdState prefState = sd::SdState::OFF; sd::SdState activeState = sd::SdState::OFF;
sd::SdCard other = sd::SdCard::NONE; sd::SdCard other = sd::SdCard::NONE;
sd::SdState otherState = sd::SdState::OFF; sd::SdState otherState = sd::SdState::OFF;
} sdInfo; } sdInfo;