Core controlle rincomplete, but compiles
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
13cc31dca9
commit
60a20acc5b
@ -52,7 +52,13 @@ class ResetRebootCountersAction
|
|||||||
class SwitchImageLockAction
|
class SwitchImageLockAction
|
||||||
: public TemplateAction<CoreController, SwitchImageLockAction, ActionId> {
|
: public TemplateAction<CoreController, SwitchImageLockAction, ActionId> {
|
||||||
public:
|
public:
|
||||||
|
FSFW_ENUM(Selection, uint8_t, ((ZERO, "0"))((ONE, "1")))
|
||||||
|
|
||||||
SwitchImageLockAction(CoreController *owner) : TemplateAction(owner, ActionId::SWITCH_IMG_LOCK){};
|
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
|
class SetMaxRebootCntAction
|
||||||
@ -60,6 +66,8 @@ class SetMaxRebootCntAction
|
|||||||
public:
|
public:
|
||||||
SetMaxRebootCntAction(CoreController *owner)
|
SetMaxRebootCntAction(CoreController *owner)
|
||||||
: TemplateAction(owner, ActionId::SET_MAX_REBOOT_CNT){};
|
: TemplateAction(owner, ActionId::SET_MAX_REBOOT_CNT){};
|
||||||
|
|
||||||
|
Parameter<uint8_t> maxCount = Parameter<uint8_t>::createParameter(this, "Count");
|
||||||
};
|
};
|
||||||
|
|
||||||
class XscRebootObcAction : public TemplateAction<CoreController, XscRebootObcAction, ActionId> {
|
class XscRebootObcAction : public TemplateAction<CoreController, XscRebootObcAction, ActionId> {
|
||||||
|
@ -208,24 +208,24 @@ ReturnValue_t CoreController::handleAction(core::ResetRebootCountersAction *acti
|
|||||||
}
|
}
|
||||||
|
|
||||||
ReturnValue_t CoreController::handleAction(core::SwitchImageLockAction *action) {
|
ReturnValue_t CoreController::handleAction(core::SwitchImageLockAction *action) {
|
||||||
if (size != 3) {
|
bool lock = action->lock == core::Boolenum::YES;
|
||||||
return HasActionsIF::INVALID_PARAMETERS;
|
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) {
|
xsc::Copy copy = xsc::COPY_0;
|
||||||
return HasActionsIF::INVALID_PARAMETERS;
|
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;
|
return HasActionsIF::EXECUTION_FINISHED;
|
||||||
}
|
}
|
||||||
|
|
||||||
ReturnValue_t CoreController::handleAction(core::SetMaxRebootCntAction *action) {
|
ReturnValue_t CoreController::handleAction(core::SetMaxRebootCntAction *action) {
|
||||||
if (size < 1) {
|
|
||||||
return HasActionsIF::INVALID_PARAMETERS;
|
|
||||||
}
|
|
||||||
std::string path = sdcMan->getCurrentMountPrefix() + REBOOT_FILE;
|
std::string path = sdcMan->getCurrentMountPrefix() + REBOOT_FILE;
|
||||||
// Disable the reboot file mechanism
|
// Disable the reboot file mechanism
|
||||||
parseRebootFile(path, rebootFile);
|
parseRebootFile(path, rebootFile);
|
||||||
rebootFile.maxCount = data[0];
|
rebootFile.maxCount = action->maxCount;
|
||||||
rewriteRebootFile(rebootFile);
|
rewriteRebootFile(rebootFile);
|
||||||
return HasActionsIF::EXECUTION_FINISHED;
|
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
|
// 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, at least 7 bytes for minimum target file name /tmp/a with
|
||||||
// null termination.
|
// null termination.
|
||||||
if (size < 14) {
|
//TODO make work again
|
||||||
return HasActionsIF::INVALID_PARAMETERS;
|
// 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..
|
// 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
|
// This flag specifies to run ls with -a
|
||||||
bool aFlag = data[0];
|
bool aFlag = 0;//data[0];
|
||||||
data += 1;
|
//data += 1;
|
||||||
// This flag specifies to run ls with -R
|
// This flag specifies to run ls with -R
|
||||||
bool RFlag = data[1];
|
bool RFlag = 0;//data[1];
|
||||||
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
|
// One larger for null termination, which prevents undefined behaviour if the sent
|
||||||
// strings are not 0 terminated properly
|
// strings are not 0 terminated properly
|
||||||
std::vector<uint8_t> repoAndTargetFileBuffer(remainingSize + 1, 0);
|
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());
|
const char *currentCharPtr = reinterpret_cast<const char *>(repoAndTargetFileBuffer.data());
|
||||||
// Full target file name
|
// Full target file name
|
||||||
std::string repoName(currentCharPtr);
|
std::string repoName(currentCharPtr);
|
||||||
@ -792,7 +793,7 @@ ReturnValue_t CoreController::handleAction(core::ListDirectoryIntoFileAction *ac
|
|||||||
int result = std::system(oss.str().c_str());
|
int result = std::system(oss.str().c_str());
|
||||||
if (result != 0) {
|
if (result != 0) {
|
||||||
utility::handleSystemError(result, "CoreController::actionListDirectoryIntoFile");
|
utility::handleSystemError(result, "CoreController::actionListDirectoryIntoFile");
|
||||||
actionHelper.finish(false, action->commandedBy, action->id);
|
actionHelper.finish(false, action->commandedBy, action->getId());
|
||||||
}
|
}
|
||||||
return HasReturnvaluesIF::RETURN_OK;
|
return HasReturnvaluesIF::RETURN_OK;
|
||||||
}
|
}
|
||||||
@ -876,19 +877,20 @@ ReturnValue_t CoreController::handleAction(core::XscRebootObcAction *action) {
|
|||||||
return HasActionsIF::EXECUTION_FINISHED;
|
return HasActionsIF::EXECUTION_FINISHED;
|
||||||
}
|
}
|
||||||
#if OBSW_VERBOSE_LEVEL >= 1
|
#if OBSW_VERBOSE_LEVEL >= 1
|
||||||
sif::info << "CoreController::actionPerformReboot: Rebooting on " << static_cast<int>(action->chip)
|
sif::info << "CoreController::actionPerformReboot: Rebooting on "
|
||||||
<< " " << static_cast<int>(action->copy) << std::endl;
|
<< static_cast<uint8_t>(action->chip.value) << " "
|
||||||
|
<< static_cast<uint8_t>(action->copy.value) << std::endl;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Check that the target chip and copy is writeprotected first
|
// Check that the target chip and copy is writeprotected first
|
||||||
generateChipStateFile();
|
generateChipStateFile();
|
||||||
// If any boot copies are unprotected, protect them here
|
// If any boot copies are unprotected, protect them here
|
||||||
auto tgtChip = xsc::CHIP_0;
|
auto tgtChip = xsc::CHIP_0;
|
||||||
if (action->chip == core::XscRebootObcAction::Selection::ONE){
|
if (action->chip == core::XscRebootObcAction::Selection::ONE) {
|
||||||
tgtChip == xsc::CHIP_1;
|
tgtChip = xsc::CHIP_1;
|
||||||
}
|
}
|
||||||
auto tgtCopy = xsc::COPY_0;
|
auto tgtCopy = xsc::COPY_0;
|
||||||
if (action->copy == core::XscRebootObcAction::Selection::ONE){
|
if (action->copy == core::XscRebootObcAction::Selection::ONE) {
|
||||||
tgtCopy = xsc::COPY_1;
|
tgtCopy = xsc::COPY_1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user