working on core controller
Some checks failed
EIVE/eive-obsw/pipeline/head There was a failure building this commit
Some checks failed
EIVE/eive-obsw/pipeline/head There was a failure building this commit
This commit is contained in:
parent
ad88bfa5b4
commit
13cc31dca9
84
bsp_q7s/core/CoreActions.h
Normal file
84
bsp_q7s/core/CoreActions.h
Normal file
@ -0,0 +1,84 @@
|
||||
#pragma once
|
||||
|
||||
#include <fsfw/action/MinMaxParameter.h>
|
||||
#include <fsfw/action/TemplateAction.h>
|
||||
#include <fsfw/introspection/Enum.h>
|
||||
|
||||
class CoreController;
|
||||
|
||||
namespace core {
|
||||
|
||||
FSFW_ENUM(ActionId, ActionId_t,
|
||||
((LIST_DIRECTORY_INTO_FILE, 0, "List Directory into file"))(
|
||||
(SWITCH_REBOOT_FILE_HANDLING, 5,
|
||||
"Switch Reboot File Handling"))((RESET_REBOOT_COUNTERS, 6, "Reset Boot Counters"))(
|
||||
(SWITCH_IMG_LOCK, 7, "Switch Image Lock"))((SET_MAX_REBOOT_CNT, 8,
|
||||
"Set maximum reboot Count"))(
|
||||
(XSC_REBOOT_OBC, 32, "Reboot using the xsc_boot_copy command"))(
|
||||
(MOUNT_OTHER_COPY, 33, "Mount Other Copy"))((REBOOT_OBC, 34,
|
||||
"Reboot using the reboot command")))
|
||||
|
||||
FSFW_ENUM(Boolenum, uint8_t, ((NO, 0, "NO"))((YES, 1, "Yes")))
|
||||
|
||||
class ListDirectoryIntoFileAction
|
||||
: public TemplateAction<CoreController, ListDirectoryIntoFileAction, ActionId> {
|
||||
public:
|
||||
ListDirectoryIntoFileAction(CoreController *owner)
|
||||
: TemplateAction(owner, ActionId::LIST_DIRECTORY_INTO_FILE){};
|
||||
};
|
||||
|
||||
class SwitchRebootFileHandlingAction
|
||||
: public TemplateAction<CoreController, SwitchRebootFileHandlingAction, ActionId> {
|
||||
public:
|
||||
SwitchRebootFileHandlingAction(CoreController *owner)
|
||||
: TemplateAction(owner, ActionId::SWITCH_REBOOT_FILE_HANDLING){};
|
||||
|
||||
Parameter<Boolenum> enableRebootFile =
|
||||
Parameter<Boolenum>::createParameter(this, "Enable Reboot File");
|
||||
};
|
||||
|
||||
class ResetRebootCountersAction
|
||||
: public TemplateAction<CoreController, ResetRebootCountersAction, ActionId> {
|
||||
public:
|
||||
FSFW_ENUM(Selection, uint8_t, ((ZERO, "0"))((ONE, "1"))((ALL, "All")))
|
||||
|
||||
ResetRebootCountersAction(CoreController *owner)
|
||||
: TemplateAction(owner, ActionId::RESET_REBOOT_COUNTERS){};
|
||||
|
||||
Parameter<Selection> chip = Parameter<Selection>::createParameter(this, "Chip");
|
||||
Parameter<Selection> copy = Parameter<Selection>::createParameter(this, "Copy");
|
||||
};
|
||||
|
||||
class SwitchImageLockAction
|
||||
: public TemplateAction<CoreController, SwitchImageLockAction, ActionId> {
|
||||
public:
|
||||
SwitchImageLockAction(CoreController *owner) : TemplateAction(owner, ActionId::SWITCH_IMG_LOCK){};
|
||||
};
|
||||
|
||||
class SetMaxRebootCntAction
|
||||
: public TemplateAction<CoreController, SetMaxRebootCntAction, ActionId> {
|
||||
public:
|
||||
SetMaxRebootCntAction(CoreController *owner)
|
||||
: TemplateAction(owner, ActionId::SET_MAX_REBOOT_CNT){};
|
||||
};
|
||||
|
||||
class XscRebootObcAction : public TemplateAction<CoreController, XscRebootObcAction, ActionId> {
|
||||
public:
|
||||
FSFW_ENUM(Selection, uint8_t, ((ZERO, "0"))((ONE, "1"))((SAME, "Same")))
|
||||
XscRebootObcAction(CoreController *owner) : TemplateAction(owner, ActionId::XSC_REBOOT_OBC){};
|
||||
|
||||
Parameter<Selection> chip = Parameter<Selection>::createParameter(this, "Chip");
|
||||
Parameter<Selection> copy = Parameter<Selection>::createParameter(this, "Copy");
|
||||
};
|
||||
|
||||
class MountOtherCopyAction : public TemplateAction<CoreController, MountOtherCopyAction, ActionId> {
|
||||
public:
|
||||
MountOtherCopyAction(CoreController *owner) : TemplateAction(owner, ActionId::MOUNT_OTHER_COPY){};
|
||||
};
|
||||
|
||||
class RebootObcAction : public TemplateAction<CoreController, RebootObcAction, ActionId> {
|
||||
public:
|
||||
RebootObcAction(CoreController *owner) : TemplateAction(owner, ActionId::REBOOT_OBC){};
|
||||
};
|
||||
|
||||
} // namespace core
|
@ -163,33 +163,51 @@ ReturnValue_t CoreController::initializeAfterTaskCreation() {
|
||||
return result;
|
||||
}
|
||||
|
||||
ReturnValue_t CoreController::handleAction(SwitchRebootFileHandlingAction *action) {
|
||||
ReturnValue_t CoreController::handleAction(core::SwitchRebootFileHandlingAction *action) {
|
||||
std::string path = sdcMan->getCurrentMountPrefix() + REBOOT_FILE;
|
||||
// Disable the reboot file mechanism
|
||||
parseRebootFile(path, rebootFile);
|
||||
if (action->enableRebootFile == Boolenum::NO) {
|
||||
if (action->enableRebootFile == core::Boolenum::NO) {
|
||||
rebootFile.enabled = false;
|
||||
rewriteRebootFile(rebootFile);
|
||||
} else
|
||||
} else {
|
||||
rebootFile.enabled = true;
|
||||
rewriteRebootFile(rebootFile);
|
||||
}
|
||||
return HasActionsIF::EXECUTION_FINISHED;
|
||||
}
|
||||
|
||||
ReturnValue_t CoreController::handleAction(ResetRebootCountersAction *action) {
|
||||
if (size == 0) {
|
||||
resetRebootCount(xsc::ALL_CHIP, xsc::ALL_COPY);
|
||||
} else if (size == 2) {
|
||||
if (data[0] > 1 or data[1] > 1) {
|
||||
return HasActionsIF::INVALID_PARAMETERS;
|
||||
}
|
||||
resetRebootCount(static_cast<xsc::Chip>(data[0]), static_cast<xsc::Copy>(data[1]));
|
||||
ReturnValue_t CoreController::handleAction(core::ResetRebootCountersAction *action) {
|
||||
xsc::Chip chip = xsc::NO_CHIP;
|
||||
switch (action->chip) {
|
||||
case core::ResetRebootCountersAction::Selection::ALL:
|
||||
chip = xsc::ALL_CHIP;
|
||||
break;
|
||||
case core::ResetRebootCountersAction::Selection::ZERO:
|
||||
chip = xsc::CHIP_0;
|
||||
break;
|
||||
case core::ResetRebootCountersAction::Selection::ONE:
|
||||
chip = xsc::CHIP_1;
|
||||
break;
|
||||
}
|
||||
xsc::Copy copy = xsc::NO_COPY;
|
||||
switch (action->copy) {
|
||||
case core::ResetRebootCountersAction::Selection::ALL:
|
||||
copy = xsc::ALL_COPY;
|
||||
break;
|
||||
case core::ResetRebootCountersAction::Selection::ZERO:
|
||||
copy = xsc::COPY_0;
|
||||
break;
|
||||
case core::ResetRebootCountersAction::Selection::ONE:
|
||||
copy = xsc::COPY_1;
|
||||
break;
|
||||
}
|
||||
resetRebootCount(chip, copy);
|
||||
|
||||
return HasActionsIF::EXECUTION_FINISHED;
|
||||
}
|
||||
|
||||
ReturnValue_t CoreController::handleAction(SwitchImageLockAction *action) {
|
||||
ReturnValue_t CoreController::handleAction(core::SwitchImageLockAction *action) {
|
||||
if (size != 3) {
|
||||
return HasActionsIF::INVALID_PARAMETERS;
|
||||
}
|
||||
@ -200,7 +218,7 @@ ReturnValue_t CoreController::handleAction(SwitchImageLockAction *action) {
|
||||
return HasActionsIF::EXECUTION_FINISHED;
|
||||
}
|
||||
|
||||
ReturnValue_t CoreController::handleAction(SetMaxRebootCntAction *action) {
|
||||
ReturnValue_t CoreController::handleAction(core::SetMaxRebootCntAction *action) {
|
||||
if (size < 1) {
|
||||
return HasActionsIF::INVALID_PARAMETERS;
|
||||
}
|
||||
@ -726,7 +744,7 @@ ReturnValue_t CoreController::initVersionFile() {
|
||||
return HasReturnvaluesIF::RETURN_OK;
|
||||
}
|
||||
|
||||
ReturnValue_t CoreController::handleAction(ListDirectoryIntoFileAction *action) {
|
||||
ReturnValue_t CoreController::handleAction(core::ListDirectoryIntoFileAction *action) {
|
||||
// TODO: Packet definition for clean deserialization
|
||||
// 2 bytes for a and R flag, at least 5 bytes for minimum valid path /tmp with
|
||||
// null termination, at least 7 bytes for minimum target file name /tmp/a with
|
||||
@ -774,7 +792,7 @@ ReturnValue_t CoreController::handleAction(ListDirectoryIntoFileAction *action)
|
||||
int result = std::system(oss.str().c_str());
|
||||
if (result != 0) {
|
||||
utility::handleSystemError(result, "CoreController::actionListDirectoryIntoFile");
|
||||
actionHelper.finish(false, commandedBy, actionId);
|
||||
actionHelper.finish(false, action->commandedBy, action->id);
|
||||
}
|
||||
return HasReturnvaluesIF::RETURN_OK;
|
||||
}
|
||||
@ -833,11 +851,16 @@ void CoreController::initPrint() {
|
||||
#endif
|
||||
}
|
||||
|
||||
ReturnValue_t CoreController::handleAction(XscRebootObcAction *action) {
|
||||
if (size < 1) {
|
||||
ReturnValue_t CoreController::handleAction(core::XscRebootObcAction *action) {
|
||||
if (action->chip == core::XscRebootObcAction::Selection::SAME and
|
||||
not(action->copy == core::XscRebootObcAction::Selection::SAME)) {
|
||||
return HasActionsIF::INVALID_PARAMETERS;
|
||||
}
|
||||
bool rebootSameBootCopy = data[0];
|
||||
bool rebootSameBootCopy = false;
|
||||
if (action->chip == core::XscRebootObcAction::Selection::SAME and
|
||||
action->copy == core::XscRebootObcAction::Selection::SAME) {
|
||||
rebootSameBootCopy = true;
|
||||
}
|
||||
bool protOpPerformed = false;
|
||||
SdCardManager::instance()->setBlocking(true);
|
||||
if (rebootSameBootCopy) {
|
||||
@ -852,19 +875,22 @@ ReturnValue_t CoreController::handleAction(XscRebootObcAction *action) {
|
||||
}
|
||||
return HasActionsIF::EXECUTION_FINISHED;
|
||||
}
|
||||
if (size < 3 or (data[1] > 1 or data[2] > 1)) {
|
||||
return HasActionsIF::INVALID_PARAMETERS;
|
||||
}
|
||||
#if OBSW_VERBOSE_LEVEL >= 1
|
||||
sif::info << "CoreController::actionPerformReboot: Rebooting on " << static_cast<int>(data[1])
|
||||
<< " " << static_cast<int>(data[2]) << std::endl;
|
||||
sif::info << "CoreController::actionPerformReboot: Rebooting on " << static_cast<int>(action->chip)
|
||||
<< " " << static_cast<int>(action->copy) << std::endl;
|
||||
#endif
|
||||
|
||||
// Check that the target chip and copy is writeprotected first
|
||||
generateChipStateFile();
|
||||
// If any boot copies are unprotected, protect them here
|
||||
auto tgtChip = static_cast<xsc::Chip>(data[1]);
|
||||
auto tgtCopy = static_cast<xsc::Copy>(data[2]);
|
||||
auto tgtChip = xsc::CHIP_0;
|
||||
if (action->chip == core::XscRebootObcAction::Selection::ONE){
|
||||
tgtChip == xsc::CHIP_1;
|
||||
}
|
||||
auto tgtCopy = xsc::COPY_0;
|
||||
if (action->copy == core::XscRebootObcAction::Selection::ONE){
|
||||
tgtCopy = xsc::COPY_1;
|
||||
}
|
||||
|
||||
// This function can not really fail
|
||||
gracefulShutdownTasks(tgtChip, tgtCopy, protOpPerformed);
|
||||
@ -908,7 +934,7 @@ ReturnValue_t CoreController::handleAction(XscRebootObcAction *action) {
|
||||
return HasReturnvaluesIF::RETURN_FAILED;
|
||||
}
|
||||
|
||||
ReturnValue_t CoreController::actionReboot(RebootObcAction *action) {
|
||||
ReturnValue_t CoreController::handleAction(core::RebootObcAction *action) {
|
||||
bool protOpPerformed = false;
|
||||
gracefulShutdownTasks(xsc::Chip::CHIP_0, xsc::Copy::COPY_0, protOpPerformed);
|
||||
std::system("reboot");
|
||||
@ -1668,24 +1694,20 @@ void CoreController::resetRebootCount(xsc::Chip tgtChip, xsc::Copy tgtCopy) {
|
||||
std::string path = currMntPrefix + REBOOT_FILE;
|
||||
// Disable the reboot file mechanism
|
||||
parseRebootFile(path, rebootFile);
|
||||
if (tgtChip == xsc::ALL_CHIP and tgtCopy == xsc::ALL_COPY) {
|
||||
rebootFile.img00Cnt = 0;
|
||||
rebootFile.img01Cnt = 0;
|
||||
rebootFile.img10Cnt = 0;
|
||||
rebootFile.img11Cnt = 0;
|
||||
} else {
|
||||
if (tgtChip == xsc::CHIP_0) {
|
||||
if (tgtCopy == xsc::COPY_0) {
|
||||
rebootFile.img00Cnt = 0;
|
||||
} else {
|
||||
rebootFile.img01Cnt = 0;
|
||||
}
|
||||
} else {
|
||||
if (tgtCopy == xsc::COPY_0) {
|
||||
rebootFile.img10Cnt = 0;
|
||||
} else {
|
||||
rebootFile.img11Cnt = 0;
|
||||
}
|
||||
if (tgtChip == xsc::ALL_CHIP or tgtChip == xsc::CHIP_0) {
|
||||
if (tgtCopy == xsc::ALL_COPY or tgtCopy == xsc::COPY_0) {
|
||||
rebootFile.img00Cnt = 0;
|
||||
}
|
||||
if (tgtCopy == xsc::ALL_COPY or tgtCopy == xsc::COPY_1) {
|
||||
rebootFile.img01Cnt = 0;
|
||||
}
|
||||
}
|
||||
if (tgtChip == xsc::ALL_CHIP or tgtChip == xsc::CHIP_1) {
|
||||
if (tgtCopy == xsc::ALL_COPY or tgtCopy == xsc::COPY_0) {
|
||||
rebootFile.img10Cnt = 0;
|
||||
}
|
||||
if (tgtCopy == xsc::ALL_COPY or tgtCopy == xsc::COPY_1) {
|
||||
rebootFile.img11Cnt = 0;
|
||||
}
|
||||
}
|
||||
rewriteRebootFile(rebootFile);
|
||||
|
@ -6,6 +6,7 @@
|
||||
|
||||
#include <cstddef>
|
||||
|
||||
#include "CoreActions.h"
|
||||
#include "CoreDefinitions.h"
|
||||
#include "bsp_q7s/memory/SdCardManager.h"
|
||||
#include "events/subsystemIdRanges.h"
|
||||
@ -84,6 +85,15 @@ class CoreController : public ExtendedControllerBase {
|
||||
|
||||
ReturnValue_t executeAction(Action* action) override;
|
||||
|
||||
ReturnValue_t handleAction(core::ListDirectoryIntoFileAction* action);
|
||||
ReturnValue_t handleAction(core::SwitchRebootFileHandlingAction* action);
|
||||
ReturnValue_t handleAction(core::ResetRebootCountersAction* action);
|
||||
ReturnValue_t handleAction(core::SwitchImageLockAction* action);
|
||||
ReturnValue_t handleAction(core::SetMaxRebootCntAction* action);
|
||||
ReturnValue_t handleAction(core::XscRebootObcAction* action);
|
||||
ReturnValue_t handleAction(core::MountOtherCopyAction* action);
|
||||
ReturnValue_t handleAction(core::RebootObcAction* action);
|
||||
|
||||
ReturnValue_t handleCommandMessage(CommandMessage* message) override;
|
||||
void performControlOperation() override;
|
||||
|
||||
|
@ -3,77 +3,8 @@
|
||||
|
||||
#include <fsfw/datapoollocal/StaticLocalDataSet.h>
|
||||
|
||||
#include <fsfw/action/MinMaxParameter.h>
|
||||
#include <fsfw/action/TemplateAction.h>
|
||||
#include <fsfw/introspection/Enum.h>
|
||||
|
||||
class CoreController;
|
||||
|
||||
namespace core {
|
||||
|
||||
FSFW_ENUM(ActionId, ActionId_t, ((LIST_DIRECTORY_INTO_FILE, 0, "List Directory into file"))
|
||||
((SWITCH_REBOOT_FILE_HANDLING, 5, "Switch Reboot File Handling"))
|
||||
((RESET_REBOOT_COUNTERS, 6, "Reset Boot Counters"))
|
||||
((SWITCH_IMG_LOCK, 7, "Switch Image Lock"))
|
||||
((SET_MAX_REBOOT_CNT, 8, "Set maximum reboot Count"))
|
||||
((XSC_REBOOT_OBC, 32, "Reboot using the xsc_boot_copy command"))
|
||||
((MOUNT_OTHER_COPY, 33, "Mount Other Copy"))
|
||||
((REBOOT_OBC, 34, "Reboot using the reboot command")))
|
||||
|
||||
FSFW_ENUM(Boolenum, uint8_t, ((NO, 0, "NO"))((YES, 1, "Yes")))
|
||||
|
||||
|
||||
class ListDirectoryIntoFileAction : public TemplateAction<CoreController, ListDirectoryIntoFileAction, ActionId> {
|
||||
public:
|
||||
ListDirectoryIntoFileAction(CoreController *owner)
|
||||
: TemplateAction(owner, ActionId::LIST_DIRECTORY_INTO_FILE){};
|
||||
};
|
||||
|
||||
class SwitchRebootFileHandlingAction : public TemplateAction<CoreController, SwitchRebootFileHandlingAction, ActionId> {
|
||||
public:
|
||||
SwitchRebootFileHandlingAction(CoreController *owner)
|
||||
: TemplateAction(owner, ActionId::SWITCH_REBOOT_FILE_HANDLING){};
|
||||
|
||||
Parameter<Boolenum> enableRebootFile = Parameter<Boolenum>::createParameter(this, "Enable Reboot File");
|
||||
};
|
||||
|
||||
class ResetRebootCountersAction : public TemplateAction<CoreController, ResetRebootCountersAction, ActionId> {
|
||||
public:
|
||||
ResetRebootCountersAction(CoreController *owner)
|
||||
: TemplateAction(owner, ActionId::RESET_REBOOT_COUNTERS){};
|
||||
};
|
||||
|
||||
class SwitchImageLockAction : public TemplateAction<CoreController, SwitchImageLockAction, ActionId> {
|
||||
public:
|
||||
SwitchImageLockAction(CoreController *owner)
|
||||
: TemplateAction(owner, ActionId::SWITCH_IMG_LOCK){};
|
||||
};
|
||||
|
||||
class SetMaxRebootCntAction : public TemplateAction<CoreController, SetMaxRebootCntAction, ActionId> {
|
||||
public:
|
||||
SetMaxRebootCntAction(CoreController *owner)
|
||||
: TemplateAction(owner, ActionId::SET_MAX_REBOOT_CNT){};
|
||||
};
|
||||
|
||||
class XscRebootObcAction : public TemplateAction<CoreController, XscRebootObcAction, ActionId> {
|
||||
public:
|
||||
XscRebootObcAction(CoreController *owner)
|
||||
: TemplateAction(owner, ActionId::XSC_REBOOT_OBC){};
|
||||
};
|
||||
|
||||
class MountOtherCopyAction : public TemplateAction<CoreController, MountOtherCopyAction, ActionId> {
|
||||
public:
|
||||
MountOtherCopyAction(CoreController *owner)
|
||||
: TemplateAction(owner, ActionId::MOUNT_OTHER_COPY){};
|
||||
};
|
||||
|
||||
class RebootObcAction : public TemplateAction<CoreController, RebootObcAction, ActionId> {
|
||||
public:
|
||||
RebootObcAction(CoreController *owner)
|
||||
: TemplateAction(owner, ActionId::REBOOT_OBC){};
|
||||
};
|
||||
|
||||
|
||||
static const uint8_t HK_SET_ENTRIES = 3;
|
||||
static const uint32_t HK_SET_ID = 5;
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
#include "ThermalController.h"
|
||||
|
||||
//#include <bsp_q7s/core/CoreDefinitions.h>
|
||||
#include <bsp_q7s/core/CoreDefinitions.h>
|
||||
#include <fsfw/datapool/PoolReadGuard.h>
|
||||
#include <fsfw_hal/devicehandlers/devicedefinitions/MgmLIS3HandlerDefs.h>
|
||||
#include <linux/devices/devicedefinitions/StarTrackerDefinitions.h>
|
||||
|
Loading…
Reference in New Issue
Block a user