added missing command
Some checks failed
EIVE/eive-obsw/pipeline/pr-develop There was a failure building this commit

This commit is contained in:
Robin Müller 2022-02-28 16:55:49 +01:00
parent 8e8fe3d0c9
commit d4dcd8c03f
No known key found for this signature in database
GPG Key ID: 11D4952C8CCEF814
5 changed files with 96 additions and 0 deletions

View File

@ -151,6 +151,17 @@ ReturnValue_t CoreController::executeAction(ActionId_t actionId, MessageQueueId_
resetRebootCount(xsc::CHIP_1, xsc::COPY_1);
return HasActionsIF::EXECUTION_FINISHED;
}
case(SET_MAX_REBOOT_CNT): {
if(size < 1) {
return HasActionsIF::INVALID_PARAMETERS;
}
std::string path = sdcMan->getCurrentMountPrefix(sdInfo.pref) + REBOOT_FILE;
// Disable the reboot file mechanism
parseRebootFile(path, rebootFile);
rebootFile.maxCount = data[0];
rewriteRebootFile(rebootFile);
return HasActionsIF::EXECUTION_FINISHED;
}
case (REBOOT_OBC): {
return actionPerformReboot(data, size);
}

View File

@ -1,4 +1,5 @@
#include "conf.h"
#include "HasActionsIF.h"
#include "CoreController.h"
#include "SdCardManager.h"
#include "event.h"
@ -366,3 +367,61 @@ void CoreController::rewriteRebootFile(RebootFile file) {
<< static_cast<int>(file.lastCopy) << "\n";
}
}
ReturnValue_t CoreController::executeAction(ActionId_t actionId, MessageQueueId_t commandedBy,
const uint8_t *data, size_t size) {
switch (actionId) {
case (SWITCH_REBOOT_FILE_HANDLING): {
if (size < 1) {
return HasActionsIF::INVALID_PARAMETERS;
}
std::string path = sdcMan->getCurrentMountPrefix(sdInfo.pref) + 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_ALL_REBOOT_COUNTERS): {
resetRebootCount(xsc::ALL_CHIP, xsc::ALL_COPY);
return HasActionsIF::EXECUTION_FINISHED;
}
case (RESET_REBOOT_COUNTER_00): {
resetRebootCount(xsc::CHIP_0, xsc::COPY_0);
return HasActionsIF::EXECUTION_FINISHED;
}
case (RESET_REBOOT_COUNTER_01): {
resetRebootCount(xsc::CHIP_0, xsc::COPY_1);
return HasActionsIF::EXECUTION_FINISHED;
}
case (RESET_REBOOT_COUNTER_10): {
resetRebootCount(xsc::CHIP_1, xsc::COPY_0);
return HasActionsIF::EXECUTION_FINISHED;
}
case (RESET_REBOOT_COUNTER_11): {
resetRebootCount(xsc::CHIP_1, xsc::COPY_1);
return HasActionsIF::EXECUTION_FINISHED;
}
case(SET_MAX_REBOOT_CNT): {
if(size < 1) {
return HasActionsIF::INVALID_PARAMETERS;
}
std::string path = sdcMan->getCurrentMountPrefix(sdInfo.pref) + REBOOT_FILE;
// Disable the reboot file mechanism
parseRebootFile(path, rebootFile);
rebootFile.maxCount = data[0];
rewriteRebootFile(rebootFile);
return HasActionsIF::EXECUTION_FINISHED;
}
default: {
return HasActionsIF::INVALID_ACTION_ID;
}
}
}

View File

@ -1,5 +1,6 @@
#pragma once
#include "definitions.h"
#include "SdCardManager.h"
#include <cstdint>
@ -38,7 +39,18 @@ public:
static xsc::Chip CURRENT_CHIP;
static xsc::Copy CURRENT_COPY;
static constexpr ActionId_t SWITCH_REBOOT_FILE_HANDLING = 5;
static constexpr ActionId_t RESET_ALL_REBOOT_COUNTERS = 6;
static constexpr ActionId_t RESET_REBOOT_COUNTER_00 = 7;
static constexpr ActionId_t RESET_REBOOT_COUNTER_01 = 8;
static constexpr ActionId_t RESET_REBOOT_COUNTER_10 = 9;
static constexpr ActionId_t RESET_REBOOT_COUNTER_11 = 10;
static constexpr ActionId_t SET_MAX_REBOOT_CNT = 11;
CoreController();
ReturnValue_t executeAction(ActionId_t actionId, MessageQueueId_t commandedBy,
const uint8_t* data, size_t size);
void performRebootFileHandling(bool recreateFile);
void determineAndExecuteReboot(RebootFile& rf, bool& needsReboot, xsc::Chip& tgtChip,
xsc::Copy& tgtCopy);

View File

@ -0,0 +1,9 @@
#include "definitions.h"
class HasActionsIF {
public:
static const ReturnValue_t IS_BUSY = 1;
static const ReturnValue_t INVALID_PARAMETERS = 2;
static const ReturnValue_t EXECUTION_FINISHED = 3;
static const ReturnValue_t INVALID_ACTION_ID = 4;
};

View File

@ -0,0 +1,5 @@
#include <cstdint>
using ActionId_t = uint32_t;
using MessageQueueId_t = uint32_t;
using ReturnValue_t = uint16_t;