PLOC commands #462

Merged
muellerr merged 11 commits from meier/ploc-commands into develop 2023-03-14 13:08:47 +01:00
7 changed files with 53 additions and 8 deletions
Showing only changes of commit a83adb148e - Show all commits

View File

@ -16,10 +16,15 @@ will consitute of a breaking change warranting a new major release:
# [unreleased]
## Added
- Added `EXECUTE_SHELL_CMD` action command for `CoreController` to execute arbitrary Linux commands.
## Fixed
- Pointing control of the `AcsController` was still expecting submodes instead of modes.
- Limitation of RW speeds was done before converting them to the correct unit scale.
- The Syrlinks task now has a proper name instead of `MAIN_SPI`.
# [v1.37.0] 2023-03-11

View File

@ -32,7 +32,9 @@ xsc::Chip CoreController::CURRENT_CHIP = xsc::Chip::NO_CHIP;
xsc::Copy CoreController::CURRENT_COPY = xsc::Copy::NO_COPY;
CoreController::CoreController(object_id_t objectId)
: ExtendedControllerBase(objectId, 5), opDivider5(5), opDivider10(10), hkSet(this) {
: ExtendedControllerBase(objectId, 5), cmdExecutor(4096), cmdReplyBuf(4096, true), cmdRepliesSizes(128),
opDivider5(5), opDivider10(10), hkSet(this) {
cmdExecutor.setRingBuffer(&cmdReplyBuf, &cmdRepliesSizes);
try {
sdcMan = SdCardManager::instance();
if (sdcMan == nullptr) {
@ -100,6 +102,19 @@ void CoreController::performControlOperation() {
sdStateMachine();
performMountedSdCardOperations();
readHkData();
if(shellCmdIsExecuting) {
bool replyReceived = false;
// TODO: We could read the data in the ring buffer and send it as an action data reply.
if(cmdExecutor.check(replyReceived) == CommandExecutor::EXECUTION_FINISHED) {
actionHelper.finish(true, successRecipient, EXECUTE_SHELL_CMD);
shellCmdIsExecuting = false;
cmdReplyBuf.clear();
while(not cmdRepliesSizes.empty()) {
cmdRepliesSizes.pop();
}
successRecipient = MessageQueueIF::NO_QUEUE;
}
}
opDivider5.checkAndIncrement();
opDivider10.checkAndIncrement();
}
@ -301,6 +316,20 @@ ReturnValue_t CoreController::executeAction(ActionId_t actionId, MessageQueueId_
// Warning: This function will never return, because it reboots the system
return actionReboot(data, size);
}
case(EXECUTE_SHELL_CMD): {
std::string cmd = std::string(cmd, size);
if(cmdExecutor.getCurrentState() == CommandExecutor::States::PENDING or shellCmdIsExecuting) {
return HasActionsIF::IS_BUSY;
}
cmdExecutor.load(cmd, false, false);
ReturnValue_t result = cmdExecutor.execute();
if(result != returnvalue::OK) {
return result;
}
shellCmdIsExecuting = true;
successRecipient = commandedBy;
return returnvalue::OK;
}
default: {
return HasActionsIF::INVALID_ACTION_ID;
}

View File

@ -1,6 +1,8 @@
#ifndef BSP_Q7S_CORE_CORECONTROLLER_H_
#define BSP_Q7S_CORE_CORECONTROLLER_H_
#include <fsfw/container/DynamicFIFO.h>
#include <fsfw/container/SimpleRingBuffer.h>
#include <fsfw/globalfunctions/PeriodicOperationDivider.h>
#include <libxiphos.h>
@ -98,6 +100,8 @@ class CoreController : public ExtendedControllerBase {
//! Reboot using the reboot command
static constexpr ActionId_t REBOOT_OBC = 34;
static constexpr ActionId_t EXECUTE_SHELL_CMD = 40;
static constexpr uint8_t SUBSYSTEM_ID = SUBSYSTEM_ID::CORE;
static constexpr Event ALLOC_FAILURE = event::makeEvent(SUBSYSTEM_ID, 0, severity::MEDIUM);
@ -227,6 +231,13 @@ class CoreController : public ExtendedControllerBase {
} sdCommandingInfo;
RebootFile rebootFile = {};
CommandExecutor cmdExecutor;
SimpleRingBuffer cmdReplyBuf;
DynamicFIFO<uint16_t> cmdRepliesSizes;
bool shellCmdIsExecuting = false;
MessageQueueId_t successRecipient = MessageQueueIF::NO_QUEUE;
std::string currMntPrefix;
bool timeFileInitDone = false;
bool performOneShotSdCardOpsSwitch = false;

View File

@ -472,9 +472,9 @@ void scheduling::createPstTasks(TaskFactory& factory, TaskDeadlineMissedFunction
/* Polling Sequence Table Default */
#if OBSW_ADD_SPI_TEST_CODE == 0
FixedTimeslotTaskIF* spiPst = factory.createFixedTimeslotTask(
"MAIN_SPI", 45, PeriodicTaskIF::MINIMUM_STACK_SIZE * 4, 0.5, missedDeadlineFunc);
result = pst::pstSpiAndSyrlinks(spiPst);
FixedTimeslotTaskIF* syrlinksPst = factory.createFixedTimeslotTask(
"SYRLINKS", 45, PeriodicTaskIF::MINIMUM_STACK_SIZE * 4, 0.5, missedDeadlineFunc);
result = pst::pstSyrlinks(syrlinksPst);
if (result != returnvalue::OK) {
if (result == FixedTimeslotTaskIF::SLOT_LIST_EMPTY) {
sif::warning << "scheduling::initTasks: SPI PST is empty" << std::endl;
@ -482,7 +482,7 @@ void scheduling::createPstTasks(TaskFactory& factory, TaskDeadlineMissedFunction
sif::error << "scheduling::initTasks: Creating SPI PST failed!" << std::endl;
}
} else {
taskVec.push_back(spiPst);
taskVec.push_back(syrlinksPst);
}
#endif

2
fsfw

@ -1 +1 @@
Subproject commit 4d6f6e6b23b5c0486dad6be8abba7681114a05fe
Subproject commit 9a8d775eb1a8788ad844215bf2a42d9f707767c0

View File

@ -18,7 +18,7 @@
#define RPI_TEST_GPS_HANDLER 0
#endif
ReturnValue_t pst::pstSpiAndSyrlinks(FixedTimeslotTaskIF *thisSequence) {
ReturnValue_t pst::pstSyrlinks(FixedTimeslotTaskIF *thisSequence) {
uint32_t length = thisSequence->getPeriodMs();
#if OBSW_ADD_SYRLINKS == 1

View File

@ -47,7 +47,7 @@ struct AcsPstCfg {
*/
ReturnValue_t pstGompaceCan(FixedTimeslotTaskIF* thisSequence);
ReturnValue_t pstSpiAndSyrlinks(FixedTimeslotTaskIF* thisSequence);
ReturnValue_t pstSyrlinks(FixedTimeslotTaskIF* thisSequence);
ReturnValue_t pstTcsAndAcs(FixedTimeslotTaskIF* thisSequence, AcsPstCfg cfg);