core controller bigWIP
EIVE/eive-obsw/pipeline/head There was a failure building this commit Details

This commit is contained in:
Ulrich Mohr 2022-07-28 17:15:33 +02:00
parent d92b1b170d
commit ad88bfa5b4
5 changed files with 121 additions and 91 deletions

View File

@ -163,75 +163,53 @@ ReturnValue_t CoreController::initializeAfterTaskCreation() {
return result;
}
ReturnValue_t CoreController::executeAction(ActionId_t actionId, MessageQueueId_t commandedBy,
const uint8_t *data, size_t size) {
switch (actionId) {
case (LIST_DIRECTORY_INTO_FILE): {
return actionListDirectoryIntoFile(actionId, commandedBy, data, size);
}
case (SWITCH_REBOOT_FILE_HANDLING): {
if (size < 1) {
return HasActionsIF::INVALID_PARAMETERS;
}
std::string path = sdcMan->getCurrentMountPrefix() + REBOOT_FILE;
// Disable the reboot file mechanism
parseRebootFile(path, rebootFile);
if (data[0] == 0) {
rebootFile.enabled = false;
rewriteRebootFile(rebootFile);
} else if (data[0] == 1) {
rebootFile.enabled = true;
rewriteRebootFile(rebootFile);
} else {
return HasActionsIF::INVALID_PARAMETERS;
}
return HasActionsIF::EXECUTION_FINISHED;
}
case (RESET_REBOOT_COUNTERS): {
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]));
}
return HasActionsIF::EXECUTION_FINISHED;
}
case (SWITCH_IMG_LOCK): {
if (size != 3) {
return HasActionsIF::INVALID_PARAMETERS;
}
if (data[1] > 1 or data[2] > 1) {
return HasActionsIF::INVALID_PARAMETERS;
}
setRebootMechanismLock(data[0], static_cast<xsc::Chip>(data[1]),
static_cast<xsc::Copy>(data[2]));
return HasActionsIF::EXECUTION_FINISHED;
}
case (SET_MAX_REBOOT_CNT): {
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];
rewriteRebootFile(rebootFile);
return HasActionsIF::EXECUTION_FINISHED;
}
case (XSC_REBOOT_OBC): {
// Warning: This function will never return, because it reboots the system
return actionXscReboot(data, size);
}
case (REBOOT_OBC): {
// Warning: This function will never return, because it reboots the system
return actionReboot(data, size);
}
default: {
return HasActionsIF::INVALID_ACTION_ID;
}
ReturnValue_t CoreController::handleAction(SwitchRebootFileHandlingAction *action) {
std::string path = sdcMan->getCurrentMountPrefix() + REBOOT_FILE;
// Disable the reboot file mechanism
parseRebootFile(path, rebootFile);
if (action->enableRebootFile == Boolenum::NO) {
rebootFile.enabled = false;
rewriteRebootFile(rebootFile);
} 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]));
}
return HasActionsIF::EXECUTION_FINISHED;
}
ReturnValue_t CoreController::handleAction(SwitchImageLockAction *action) {
if (size != 3) {
return HasActionsIF::INVALID_PARAMETERS;
}
if (data[1] > 1 or data[2] > 1) {
return HasActionsIF::INVALID_PARAMETERS;
}
setRebootMechanismLock(data[0], static_cast<xsc::Chip>(data[1]), static_cast<xsc::Copy>(data[2]));
return HasActionsIF::EXECUTION_FINISHED;
}
ReturnValue_t CoreController::handleAction(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];
rewriteRebootFile(rebootFile);
return HasActionsIF::EXECUTION_FINISHED;
}
ReturnValue_t CoreController::checkModeCommand(Mode_t mode, Submode_t submode,
@ -748,9 +726,7 @@ ReturnValue_t CoreController::initVersionFile() {
return HasReturnvaluesIF::RETURN_OK;
}
ReturnValue_t CoreController::actionListDirectoryIntoFile(ActionId_t actionId,
MessageQueueId_t commandedBy,
const uint8_t *data, size_t size) {
ReturnValue_t CoreController::handleAction(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
@ -857,7 +833,7 @@ void CoreController::initPrint() {
#endif
}
ReturnValue_t CoreController::actionXscReboot(const uint8_t *data, size_t size) {
ReturnValue_t CoreController::handleAction(XscRebootObcAction *action) {
if (size < 1) {
return HasActionsIF::INVALID_PARAMETERS;
}
@ -932,7 +908,7 @@ ReturnValue_t CoreController::actionXscReboot(const uint8_t *data, size_t size)
return HasReturnvaluesIF::RETURN_FAILED;
}
ReturnValue_t CoreController::actionReboot(const uint8_t *data, size_t size) {
ReturnValue_t CoreController::actionReboot(RebootObcAction *action) {
bool protOpPerformed = false;
gracefulShutdownTasks(xsc::Chip::CHIP_0, xsc::Copy::COPY_0, protOpPerformed);
std::system("reboot");

View File

@ -61,18 +61,6 @@ class CoreController : public ExtendedControllerBase {
"/" + std::string(CONF_FOLDER) + "/" + std::string(REBOOT_FILE_NAME);
const std::string TIME_FILE = "/" + std::string(CONF_FOLDER) + "/" + std::string(TIME_FILE_NAME);
static constexpr ActionId_t LIST_DIRECTORY_INTO_FILE = 0;
static constexpr ActionId_t SWITCH_REBOOT_FILE_HANDLING = 5;
static constexpr ActionId_t RESET_REBOOT_COUNTERS = 6;
static constexpr ActionId_t SWITCH_IMG_LOCK = 7;
static constexpr ActionId_t SET_MAX_REBOOT_CNT = 8;
//! Reboot using the xsc_boot_copy command
static constexpr ActionId_t XSC_REBOOT_OBC = 32;
static constexpr ActionId_t MOUNT_OTHER_COPY = 33;
//! Reboot using the reboot command
static constexpr ActionId_t REBOOT_OBC = 34;
static constexpr uint8_t SUBSYSTEM_ID = SUBSYSTEM_ID::CORE;
static constexpr Event ALLOC_FAILURE = event::makeEvent(SUBSYSTEM_ID, 0, severity::MEDIUM);
@ -94,8 +82,7 @@ class CoreController : public ExtendedControllerBase {
ReturnValue_t initializeAfterTaskCreation() override;
ReturnValue_t executeAction(ActionId_t actionId, MessageQueueId_t commandedBy,
const uint8_t* data, size_t size) override;
ReturnValue_t executeAction(Action* action) override;
ReturnValue_t handleCommandMessage(CommandMessage* message) override;
void performControlOperation() override;
@ -224,8 +211,6 @@ class CoreController : public ExtendedControllerBase {
void checkExternalSdCommandStatus();
void performRebootFileHandling(bool recreateFile);
ReturnValue_t actionListDirectoryIntoFile(ActionId_t actionId, MessageQueueId_t commandedBy,
const uint8_t* data, size_t size);
ReturnValue_t actionXscReboot(const uint8_t* data, size_t size);
ReturnValue_t actionReboot(const uint8_t* data, size_t size);

View File

@ -3,8 +3,77 @@
#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;

2
fsfw

@ -1 +1 @@
Subproject commit a1af2cebf3a53dd17e7dd948f1e698d9c4621696
Subproject commit cfdbe0f6cb762f58f0db3f9c118c50c954f0b984

View File

@ -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>