Reboot Feature #72

Merged
meierj merged 4 commits from mueller/reboot-feature into develop 2021-08-04 10:03:14 +02:00
9 changed files with 56 additions and 19 deletions

View File

@ -4,6 +4,11 @@
#include <iostream> #include <iostream>
#include <cstdlib> #include <cstdlib>
enum SdCard {
SDC0,
SDC1
};
FileSystemTest::FileSystemTest() { FileSystemTest::FileSystemTest() {
using namespace std; using namespace std;
SdCard sdCard = SdCard::SDC0; SdCard sdCard = SdCard::SDC0;

View File

@ -1,11 +1,6 @@
#ifndef BSP_Q7S_BOARDTEST_FILESYSTEMTEST_H_ #ifndef BSP_Q7S_BOARDTEST_FILESYSTEMTEST_H_
#define BSP_Q7S_BOARDTEST_FILESYSTEMTEST_H_ #define BSP_Q7S_BOARDTEST_FILESYSTEMTEST_H_
enum SdCard {
SDC0,
SDC1
};
class FileSystemTest { class FileSystemTest {
public: public:
FileSystemTest(); FileSystemTest();

View File

@ -24,8 +24,8 @@ ReturnValue_t Q7STestTask::performOneShotAction() {
//testScratchApi(); //testScratchApi();
//testJsonLibDirect(); //testJsonLibDirect();
//testDummyParams(); //testDummyParams();
FsOpCodes opCode = FsOpCodes::ATTEMPT_DIR_REMOVAL_NON_EMPTY; //FsOpCodes opCode = FsOpCodes::ATTEMPT_DIR_REMOVAL_NON_EMPTY;
testFileSystemHandlerDirect(opCode); //testFileSystemHandlerDirect(opCode);
return TestTask::performOneShotAction(); return TestTask::performOneShotAction();
} }

View File

@ -49,7 +49,7 @@ CoreController::CoreController(object_id_t objectId):
} }
ReturnValue_t CoreController::handleCommandMessage(CommandMessage *message) { ReturnValue_t CoreController::handleCommandMessage(CommandMessage *message) {
return HasReturnvaluesIF::RETURN_OK; return ExtendedControllerBase::handleCommandMessage(message);
} }
void CoreController::performControlOperation() { void CoreController::performControlOperation() {
@ -74,7 +74,7 @@ ReturnValue_t CoreController::initialize() {
"count failed" << std::endl; "count failed" << std::endl;
} }
return HasReturnvaluesIF::RETURN_OK; return ExtendedControllerBase::initialize();
} }
ReturnValue_t CoreController::checkModeCommand(Mode_t mode, Submode_t submode, ReturnValue_t CoreController::checkModeCommand(Mode_t mode, Submode_t submode,
@ -159,8 +159,7 @@ ReturnValue_t CoreController::executeAction(ActionId_t actionId, MessageQueueId_
return actionListDirectoryIntoFile(actionId, commandedBy, data, size); return actionListDirectoryIntoFile(actionId, commandedBy, data, size);
} }
case(REBOOT_OBC): { case(REBOOT_OBC): {
return HasReturnvaluesIF::RETURN_OK; return actionPerformReboot(data, size);
break;
} }
default: { default: {
return HasActionsIF::INVALID_ACTION_ID; return HasActionsIF::INVALID_ACTION_ID;
@ -457,6 +456,43 @@ void CoreController::initPrint() {
#endif #endif
} }
ReturnValue_t CoreController::actionPerformReboot(const uint8_t *data, size_t size) {
if(size < 1) {
return HasActionsIF::INVALID_PARAMETERS;
}
bool rebootSameBootCopy = data[0];
if(rebootSameBootCopy) {
#if OBSW_VERBOSE_LEVEL >= 1
sif::info << "CoreController::actionPerformReboot: Rebooting on current image" << std::endl;
#endif
// Attempt graceful shutdown by unmounting and switching off SD cards
SdCardManager::instance()->switchOffSdCard(sd::SdCard::SLOT_0);
SdCardManager::instance()->switchOffSdCard(sd::SdCard::SLOT_1);
int result = std::system("xsc_boot_copy -r");
if(result != 0) {
utility::handleSystemError(result, "CoreController::executeAction");
return HasReturnvaluesIF::RETURN_FAILED;
}
return HasActionsIF::EXECUTION_FINISHED;
}
if(size < 3) {
return HasActionsIF::INVALID_PARAMETERS;
}
#if OBSW_VERBOSE_LEVEL >= 1
sif::info << "CoreController::actionPerformReboot: Rebooting on " <<
static_cast<int>(data[1]) << " " << static_cast<int>(data[2]) << std::endl;
#endif
// The second byte in data is the target chip, the third byte is the target copy
std::string cmdString = "xsc_boot_copy " + std::to_string(data[1]) + " " +
std::to_string(data[2]);
int result = std::system(cmdString.c_str());
if(result != 0) {
utility::handleSystemError(result, "CoreController::executeAction");
return HasReturnvaluesIF::RETURN_FAILED;
}
return HasActionsIF::EXECUTION_FINISHED;
}
void CoreController::performWatchdogControlOperation() { void CoreController::performWatchdogControlOperation() {
// Only perform each fifth iteration // Only perform each fifth iteration
if(watchdogFifoFd != 0 and opDivider.checkAndIncrement()) { if(watchdogFifoFd != 0 and opDivider.checkAndIncrement()) {

View File

@ -24,7 +24,7 @@ public:
}; };
static constexpr ActionId_t LIST_DIRECTORY_INTO_FILE = 0; static constexpr ActionId_t LIST_DIRECTORY_INTO_FILE = 0;
static constexpr ActionId_t REBOOT_OBC = 1; static constexpr ActionId_t REBOOT_OBC = 32;
static constexpr uint8_t SUBSYSTEM_ID = SUBSYSTEM_ID::CORE; static constexpr uint8_t SUBSYSTEM_ID = SUBSYSTEM_ID::CORE;
@ -68,6 +68,7 @@ private:
ReturnValue_t actionListDirectoryIntoFile(ActionId_t actionId, MessageQueueId_t commandedBy, ReturnValue_t actionListDirectoryIntoFile(ActionId_t actionId, MessageQueueId_t commandedBy,
const uint8_t *data, size_t size); const uint8_t *data, size_t size);
ReturnValue_t actionPerformReboot(const uint8_t *data, size_t size);
void initPrint(); void initPrint();

View File

@ -5,6 +5,6 @@
// Use TCP instead of UDP for the TMTC bridge. This allows using the TMTC client locally // Use TCP instead of UDP for the TMTC bridge. This allows using the TMTC client locally
// because UDP packets are not allowed in the VPN // because UDP packets are not allowed in the VPN
#define OBSW_USE_TMTC_TCP_BRIDGE 0 #define OBSW_USE_TMTC_TCP_BRIDGE 1
#endif /* COMMON_CONFIG_COMMONCONFIG_H_ */ #endif /* COMMON_CONFIG_COMMONCONFIG_H_ */

2
fsfw

@ -1 +1 @@
Subproject commit 0ff81294e7e209bb4a26171b10d80fe522e65bcf Subproject commit 296c587e3de10c579847e04af3176b3acaa2d701

2
tmtc

@ -1 +1 @@
Subproject commit 477743f6264689327528beb5344c39247af6c49e Subproject commit bc32472d88a0d7a1566f53c05a1bc49f3c377985