Core controlle rincomplete, but compiles
Some checks failed
EIVE/eive-obsw/pipeline/head There was a failure building this commit

This commit is contained in:
Ulrich Mohr 2022-08-17 11:21:35 +02:00
parent 13cc31dca9
commit 60a20acc5b
2 changed files with 35 additions and 25 deletions

View File

@ -52,7 +52,13 @@ class ResetRebootCountersAction
class SwitchImageLockAction
: public TemplateAction<CoreController, SwitchImageLockAction, ActionId> {
public:
FSFW_ENUM(Selection, uint8_t, ((ZERO, "0"))((ONE, "1")))
SwitchImageLockAction(CoreController *owner) : TemplateAction(owner, ActionId::SWITCH_IMG_LOCK){};
Parameter<Boolenum> lock = Parameter<Boolenum>::createParameter(this, "Lock Image");
Parameter<Selection> chip = Parameter<Selection>::createParameter(this, "Chip");
Parameter<Selection> copy = Parameter<Selection>::createParameter(this, "Copy");
};
class SetMaxRebootCntAction
@ -60,6 +66,8 @@ class SetMaxRebootCntAction
public:
SetMaxRebootCntAction(CoreController *owner)
: TemplateAction(owner, ActionId::SET_MAX_REBOOT_CNT){};
Parameter<uint8_t> maxCount = Parameter<uint8_t>::createParameter(this, "Count");
};
class XscRebootObcAction : public TemplateAction<CoreController, XscRebootObcAction, ActionId> {

View File

@ -208,24 +208,24 @@ ReturnValue_t CoreController::handleAction(core::ResetRebootCountersAction *acti
}
ReturnValue_t CoreController::handleAction(core::SwitchImageLockAction *action) {
if (size != 3) {
return HasActionsIF::INVALID_PARAMETERS;
bool lock = action->lock == core::Boolenum::YES;
xsc::Chip chip = xsc::CHIP_0;
if (action->chip == core::SwitchImageLockAction::Selection::ONE) {
chip = xsc::CHIP_1;
}
if (data[1] > 1 or data[2] > 1) {
return HasActionsIF::INVALID_PARAMETERS;
xsc::Copy copy = xsc::COPY_0;
if (action->copy == core::SwitchImageLockAction::Selection::ONE) {
copy = xsc::COPY_0;
}
setRebootMechanismLock(data[0], static_cast<xsc::Chip>(data[1]), static_cast<xsc::Copy>(data[2]));
setRebootMechanismLock(lock, chip, copy);
return HasActionsIF::EXECUTION_FINISHED;
}
ReturnValue_t CoreController::handleAction(core::SetMaxRebootCntAction *action) {
if (size < 1) {
return HasActionsIF::INVALID_PARAMETERS;
}
std::string path = sdcMan->getCurrentMountPrefix() + REBOOT_FILE;
// Disable the reboot file mechanism
parseRebootFile(path, rebootFile);
rebootFile.maxCount = data[0];
rebootFile.maxCount = action->maxCount;
rewriteRebootFile(rebootFile);
return HasActionsIF::EXECUTION_FINISHED;
}
@ -749,23 +749,24 @@ ReturnValue_t CoreController::handleAction(core::ListDirectoryIntoFileAction *ac
// 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
// null termination.
if (size < 14) {
return HasActionsIF::INVALID_PARAMETERS;
}
//TODO make work again
// if (size < 14) {
// return HasActionsIF::INVALID_PARAMETERS;
// }
// We could also make -l optional, but I can't think of a reason why to not use -l..
// This flag specifies to run ls with -a
bool aFlag = data[0];
data += 1;
bool aFlag = 0;//data[0];
//data += 1;
// This flag specifies to run ls with -R
bool RFlag = data[1];
data += 1;
bool RFlag = 0;//data[1];
//data += 1;
size_t remainingSize = size - 2;
size_t remainingSize = 0;//size - 2;
// One larger for null termination, which prevents undefined behaviour if the sent
// strings are not 0 terminated properly
std::vector<uint8_t> repoAndTargetFileBuffer(remainingSize + 1, 0);
std::memcpy(repoAndTargetFileBuffer.data(), data, remainingSize);
//std::memcpy(repoAndTargetFileBuffer.data(), data, remainingSize);
const char *currentCharPtr = reinterpret_cast<const char *>(repoAndTargetFileBuffer.data());
// Full target file name
std::string repoName(currentCharPtr);
@ -792,7 +793,7 @@ ReturnValue_t CoreController::handleAction(core::ListDirectoryIntoFileAction *ac
int result = std::system(oss.str().c_str());
if (result != 0) {
utility::handleSystemError(result, "CoreController::actionListDirectoryIntoFile");
actionHelper.finish(false, action->commandedBy, action->id);
actionHelper.finish(false, action->commandedBy, action->getId());
}
return HasReturnvaluesIF::RETURN_OK;
}
@ -876,8 +877,9 @@ ReturnValue_t CoreController::handleAction(core::XscRebootObcAction *action) {
return HasActionsIF::EXECUTION_FINISHED;
}
#if OBSW_VERBOSE_LEVEL >= 1
sif::info << "CoreController::actionPerformReboot: Rebooting on " << static_cast<int>(action->chip)
<< " " << static_cast<int>(action->copy) << std::endl;
sif::info << "CoreController::actionPerformReboot: Rebooting on "
<< static_cast<uint8_t>(action->chip.value) << " "
<< static_cast<uint8_t>(action->copy.value) << std::endl;
#endif
// Check that the target chip and copy is writeprotected first
@ -885,7 +887,7 @@ ReturnValue_t CoreController::handleAction(core::XscRebootObcAction *action) {
// If any boot copies are unprotected, protect them here
auto tgtChip = xsc::CHIP_0;
if (action->chip == core::XscRebootObcAction::Selection::ONE) {
tgtChip == xsc::CHIP_1;
tgtChip = xsc::CHIP_1;
}
auto tgtCopy = xsc::COPY_0;
if (action->copy == core::XscRebootObcAction::Selection::ONE) {