v1.9.0 #175
@ -151,6 +151,17 @@ ReturnValue_t CoreController::executeAction(ActionId_t actionId, MessageQueueId_
|
|||||||
resetRebootCount(xsc::CHIP_1, xsc::COPY_1);
|
resetRebootCount(xsc::CHIP_1, xsc::COPY_1);
|
||||||
return HasActionsIF::EXECUTION_FINISHED;
|
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): {
|
case (REBOOT_OBC): {
|
||||||
return actionPerformReboot(data, size);
|
return actionPerformReboot(data, size);
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
#include "conf.h"
|
#include "conf.h"
|
||||||
|
#include "HasActionsIF.h"
|
||||||
#include "CoreController.h"
|
#include "CoreController.h"
|
||||||
#include "SdCardManager.h"
|
#include "SdCardManager.h"
|
||||||
#include "event.h"
|
#include "event.h"
|
||||||
@ -366,3 +367,61 @@ void CoreController::rewriteRebootFile(RebootFile file) {
|
|||||||
<< static_cast<int>(file.lastCopy) << "\n";
|
<< 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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -1,5 +1,6 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#include "definitions.h"
|
||||||
#include "SdCardManager.h"
|
#include "SdCardManager.h"
|
||||||
|
|
||||||
#include <cstdint>
|
#include <cstdint>
|
||||||
@ -38,7 +39,18 @@ public:
|
|||||||
static xsc::Chip CURRENT_CHIP;
|
static xsc::Chip CURRENT_CHIP;
|
||||||
static xsc::Copy CURRENT_COPY;
|
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();
|
CoreController();
|
||||||
|
|
||||||
|
ReturnValue_t executeAction(ActionId_t actionId, MessageQueueId_t commandedBy,
|
||||||
|
const uint8_t* data, size_t size);
|
||||||
void performRebootFileHandling(bool recreateFile);
|
void performRebootFileHandling(bool recreateFile);
|
||||||
void determineAndExecuteReboot(RebootFile& rf, bool& needsReboot, xsc::Chip& tgtChip,
|
void determineAndExecuteReboot(RebootFile& rf, bool& needsReboot, xsc::Chip& tgtChip,
|
||||||
xsc::Copy& tgtCopy);
|
xsc::Copy& tgtCopy);
|
||||||
|
9
unittest/rebootLogic/HasActionsIF.h
Normal file
9
unittest/rebootLogic/HasActionsIF.h
Normal 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;
|
||||||
|
};
|
5
unittest/rebootLogic/definitions.h
Normal file
5
unittest/rebootLogic/definitions.h
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
#include <cstdint>
|
||||||
|
|
||||||
|
using ActionId_t = uint32_t;
|
||||||
|
using MessageQueueId_t = uint32_t;
|
||||||
|
using ReturnValue_t = uint16_t;
|
Loading…
Reference in New Issue
Block a user