add non-blocking shell cmd executor
All checks were successful
EIVE/eive-obsw/pipeline/pr-develop This commit looks good
All checks were successful
EIVE/eive-obsw/pipeline/pr-develop This commit looks good
This commit is contained in:
@ -313,7 +313,7 @@ ReturnValue_t CoreController::executeAction(ActionId_t actionId, MessageQueueId_
|
|||||||
}
|
}
|
||||||
core::SystemctlCmd cmdType = static_cast<core::SystemctlCmd>(data[0]);
|
core::SystemctlCmd cmdType = static_cast<core::SystemctlCmd>(data[0]);
|
||||||
std::string unitName = std::string(reinterpret_cast<const char *>(data + 1), size - 1);
|
std::string unitName = std::string(reinterpret_cast<const char *>(data + 1), size - 1);
|
||||||
std::ostringstream oss("systemctl ");
|
std::ostringstream oss("systemctl ", std::ostringstream::ate);
|
||||||
switch (cmdType) {
|
switch (cmdType) {
|
||||||
case (core::SystemctlCmd::START): {
|
case (core::SystemctlCmd::START): {
|
||||||
oss << "start ";
|
oss << "start ";
|
||||||
@ -327,6 +327,9 @@ ReturnValue_t CoreController::executeAction(ActionId_t actionId, MessageQueueId_
|
|||||||
oss << "restart ";
|
oss << "restart ";
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
default: {
|
||||||
|
return HasActionsIF::INVALID_PARAMETERS;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
oss << unitName;
|
oss << unitName;
|
||||||
int result = std::system(oss.str().c_str());
|
int result = std::system(oss.str().c_str());
|
||||||
@ -366,6 +369,14 @@ ReturnValue_t CoreController::executeAction(ActionId_t actionId, MessageQueueId_
|
|||||||
return actionReboot(data, size);
|
return actionReboot(data, size);
|
||||||
}
|
}
|
||||||
case (EXECUTE_SHELL_CMD_BLOCKING): {
|
case (EXECUTE_SHELL_CMD_BLOCKING): {
|
||||||
|
std::string cmd = std::string(cmd, size);
|
||||||
|
int result = std::system(cmd.c_str());
|
||||||
|
if (result != 0) {
|
||||||
|
return returnvalue::FAILED;
|
||||||
|
}
|
||||||
|
return EXECUTION_FINISHED;
|
||||||
|
}
|
||||||
|
case (EXECUTE_SHELL_CMD_NON_BLOCKING): {
|
||||||
std::string cmd = std::string(cmd, size);
|
std::string cmd = std::string(cmd, size);
|
||||||
if (cmdExecutor.getCurrentState() == CommandExecutor::States::PENDING or
|
if (cmdExecutor.getCurrentState() == CommandExecutor::States::PENDING or
|
||||||
shellCmdIsExecuting) {
|
shellCmdIsExecuting) {
|
||||||
|
@ -56,6 +56,7 @@ static constexpr ActionId_t MOUNT_OTHER_COPY = 33;
|
|||||||
static constexpr ActionId_t REBOOT_OBC = 34;
|
static constexpr ActionId_t REBOOT_OBC = 34;
|
||||||
|
|
||||||
static constexpr ActionId_t EXECUTE_SHELL_CMD_BLOCKING = 40;
|
static constexpr ActionId_t EXECUTE_SHELL_CMD_BLOCKING = 40;
|
||||||
|
static constexpr ActionId_t EXECUTE_SHELL_CMD_NON_BLOCKING = 41;
|
||||||
static constexpr ActionId_t SYSTEMCTL_CMD_EXECUTOR = 42;
|
static constexpr ActionId_t SYSTEMCTL_CMD_EXECUTOR = 42;
|
||||||
|
|
||||||
static constexpr uint8_t SUBSYSTEM_ID = SUBSYSTEM_ID::CORE;
|
static constexpr uint8_t SUBSYSTEM_ID = SUBSYSTEM_ID::CORE;
|
||||||
|
2
tmtc
2
tmtc
Submodule tmtc updated: 8993ccdf66...005e15b21b
Reference in New Issue
Block a user