Custom FDIR for tmp devices #598

Merged
muellerr merged 6 commits from tmp_dev_custom_fdir into develop 2023-04-14 18:55:56 +02:00
18 changed files with 123 additions and 49 deletions
Showing only changes of commit 9b1d4de9c5 - Show all commits

6
.gitmodules vendored
View File

@ -10,9 +10,6 @@
[submodule "thirdparty/lwgps"] [submodule "thirdparty/lwgps"]
path = thirdparty/lwgps path = thirdparty/lwgps
url = https://github.com/rmspacefish/lwgps.git url = https://github.com/rmspacefish/lwgps.git
[submodule "thirdparty/arcsec_star_tracker"]
path = thirdparty/arcsec_star_tracker
url = https://egit.irs.uni-stuttgart.de/eive/arcsec_star_tracker.git
[submodule "thirdparty/json"] [submodule "thirdparty/json"]
path = thirdparty/json path = thirdparty/json
url = https://github.com/nlohmann/json.git url = https://github.com/nlohmann/json.git
@ -22,3 +19,6 @@
[submodule "thirdparty/gomspace-sw"] [submodule "thirdparty/gomspace-sw"]
path = thirdparty/gomspace-sw path = thirdparty/gomspace-sw
url = https://egit.irs.uni-stuttgart.de/eive/gomspace-sw.git url = https://egit.irs.uni-stuttgart.de/eive/gomspace-sw.git
[submodule "thirdparty/sagittactl"]
path = thirdparty/sagittactl
url = https://egit.irs.uni-stuttgart.de/eive/sagittactl.git

View File

@ -17,6 +17,7 @@ will consitute of a breaking change warranting a new major release:
# [unreleased] # [unreleased]
- q7s-package: v2.5.0 - q7s-package: v2.5.0
- STR firmware was updated to v10.3
## Fixed ## Fixed
@ -25,6 +26,11 @@ will consitute of a breaking change warranting a new major release:
bytes were not written properly. bytes were not written properly.
- Bugfix for STR where an invalid reply was received for special requests - Bugfix for STR where an invalid reply was received for special requests
like firmware updates. like firmware updates.
- Bugfix for shell command executors in command controller which lead to a crash.
## Changed
- STR `wire` library updated to v10.3. Submodule renamed to `sagittactl`.
## Changed ## Changed
@ -38,6 +44,7 @@ will consitute of a breaking change warranting a new major release:
- Allow setting the preferred SD card via the new parameter interface of the core controller - Allow setting the preferred SD card via the new parameter interface of the core controller
with domain ID 0 and unque ID 0. with domain ID 0 and unque ID 0.
# [v1.44.1] 2023-04-12 # [v1.44.1] 2023-04-12
- eive-tmtc: v2.22.1 - eive-tmtc: v2.22.1

View File

@ -223,7 +223,7 @@ set(LIB_EIVE_MISSION_PATH mission)
set(LIB_ETL_PATH ${THIRD_PARTY_FOLDER}/etl) set(LIB_ETL_PATH ${THIRD_PARTY_FOLDER}/etl)
set(LIB_CATCH2_PATH ${THIRD_PARTY_FOLDER}/Catch2) set(LIB_CATCH2_PATH ${THIRD_PARTY_FOLDER}/Catch2)
set(LIB_LWGPS_PATH ${THIRD_PARTY_FOLDER}/lwgps) set(LIB_LWGPS_PATH ${THIRD_PARTY_FOLDER}/lwgps)
set(LIB_ARCSEC_PATH ${THIRD_PARTY_FOLDER}/arcsec_star_tracker) set(LIB_ARCSEC_PATH ${THIRD_PARTY_FOLDER}/sagittactl)
set(LIB_JSON_PATH ${THIRD_PARTY_FOLDER}/json) set(LIB_JSON_PATH ${THIRD_PARTY_FOLDER}/json)
set(FSFW_WARNING_SHADOW_LOCAL_GCC OFF) set(FSFW_WARNING_SHADOW_LOCAL_GCC OFF)

View File

@ -9,7 +9,6 @@
#include "fsfw/serviceinterface/ServiceInterface.h" #include "fsfw/serviceinterface/ServiceInterface.h"
#include "fsfw/timemanager/Stopwatch.h" #include "fsfw/timemanager/Stopwatch.h"
#include "fsfw/version.h" #include "fsfw/version.h"
#include "mission/sysDefs.h"
#include "watchdog/definitions.h" #include "watchdog/definitions.h"
#if OBSW_ADD_TMTC_UDP_SERVER == 1 #if OBSW_ADD_TMTC_UDP_SERVER == 1
#include "fsfw/osal/common/UdpTmTcBridge.h" #include "fsfw/osal/common/UdpTmTcBridge.h"
@ -118,7 +117,7 @@ void CoreController::performControlOperation() {
bool replyReceived = false; bool replyReceived = false;
// TODO: We could read the data in the ring buffer and send it as an action data reply. // 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) { if (cmdExecutor.check(replyReceived) == CommandExecutor::EXECUTION_FINISHED) {
actionHelper.finish(true, successRecipient, core::EXECUTE_SHELL_CMD); actionHelper.finish(true, successRecipient, core::EXECUTE_SHELL_CMD_BLOCKING);
shellCmdIsExecuting = false; shellCmdIsExecuting = false;
cmdReplyBuf.clear(); cmdReplyBuf.clear();
while (not cmdRepliesSizes.empty()) { while (not cmdRepliesSizes.empty()) {
@ -304,6 +303,41 @@ ReturnValue_t CoreController::executeAction(ActionId_t actionId, MessageQueueId_
// Completion will be reported by SD card state machine // Completion will be reported by SD card state machine
return returnvalue::OK; return returnvalue::OK;
} }
case (SYSTEMCTL_CMD_EXECUTOR): {
// Expect one byte systemctl command type and a unit name with at least one byte as minimum.
if (size < 2) {
return HasActionsIF::INVALID_PARAMETERS;
}
if (data[0] >= core::SystemctlCmd::NUM_CMDS) {
return HasActionsIF::INVALID_PARAMETERS;
}
core::SystemctlCmd cmdType = static_cast<core::SystemctlCmd>(data[0]);
std::string unitName = std::string(reinterpret_cast<const char *>(data + 1), size - 1);
std::ostringstream oss("systemctl ", std::ostringstream::ate);
switch (cmdType) {
case (core::SystemctlCmd::START): {
oss << "start ";
break;
}
case (core::SystemctlCmd::STOP): {
oss << "stop ";
break;
}
case (core::SystemctlCmd::RESTART): {
oss << "restart ";
break;
}
default: {
return HasActionsIF::INVALID_PARAMETERS;
}
}
oss << unitName;
int result = std::system(oss.str().c_str());
if (result != 0) {
return returnvalue::FAILED;
}
return EXECUTION_FINISHED;
}
case (SWITCH_IMG_LOCK): { case (SWITCH_IMG_LOCK): {
if (size != 3) { if (size != 3) {
return HasActionsIF::INVALID_PARAMETERS; return HasActionsIF::INVALID_PARAMETERS;
@ -334,13 +368,22 @@ ReturnValue_t CoreController::executeAction(ActionId_t actionId, MessageQueueId_
// Warning: This function will never return, because it reboots the system // Warning: This function will never return, because it reboots the system
return actionReboot(data, size); return actionReboot(data, size);
} }
case (EXECUTE_SHELL_CMD): { case (EXECUTE_SHELL_CMD_BLOCKING): {
std::string cmd = std::string(cmd, size); std::string cmdToExecute = std::string(reinterpret_cast<const char*>(data), size);
int result = std::system(cmdToExecute.c_str());
if (result != 0) {
// TODO: Data reply with returnalue maybe?
return returnvalue::FAILED;
}
return EXECUTION_FINISHED;
}
case (EXECUTE_SHELL_CMD_NON_BLOCKING): {
std::string cmdToExecute = std::string(reinterpret_cast<const char*>(data), size);
if (cmdExecutor.getCurrentState() == CommandExecutor::States::PENDING or if (cmdExecutor.getCurrentState() == CommandExecutor::States::PENDING or
shellCmdIsExecuting) { shellCmdIsExecuting) {
return HasActionsIF::IS_BUSY; return HasActionsIF::IS_BUSY;
} }
cmdExecutor.load(cmd, false, false); cmdExecutor.load(cmdToExecute, false, false);
ReturnValue_t result = cmdExecutor.execute(); ReturnValue_t result = cmdExecutor.execute();
if (result != returnvalue::OK) { if (result != returnvalue::OK) {
return result; return result;
@ -1308,7 +1351,7 @@ void CoreController::performMountedSdCardOperations() {
auto mountedSdCardOp = [&](sd::SdCard sdCard, std::string mntPoint) { auto mountedSdCardOp = [&](sd::SdCard sdCard, std::string mntPoint) {
if (not performOneShotSdCardOpsSwitch) { if (not performOneShotSdCardOpsSwitch) {
std::ostringstream path; std::ostringstream path;
path << mntPoint << "/" << CONF_FOLDER; path << mntPoint << "/" << core::CONF_FOLDER;
std::error_code e; std::error_code e;
if (not std::filesystem::exists(path.str()), e) { if (not std::filesystem::exists(path.str()), e) {
bool created = std::filesystem::create_directory(path.str(), e); bool created = std::filesystem::create_directory(path.str(), e);

View File

@ -18,17 +18,11 @@
#include "bsp_q7s/fs/SdCardManager.h" #include "bsp_q7s/fs/SdCardManager.h"
#include "events/subsystemIdRanges.h" #include "events/subsystemIdRanges.h"
#include "fsfw/controller/ExtendedControllerBase.h" #include "fsfw/controller/ExtendedControllerBase.h"
#include "mission/sysDefs.h"
class Timer; class Timer;
class SdCardManager; class SdCardManager;
namespace xsc {
enum Chip : int { CHIP_0, CHIP_1, NO_CHIP, SELF_CHIP, ALL_CHIP };
enum Copy : int { COPY_0, COPY_1, NO_COPY, SELF_COPY, ALL_COPY };
} // namespace xsc
struct RebootFile { struct RebootFile {
static constexpr uint8_t DEFAULT_MAX_BOOT_CNT = 10; static constexpr uint8_t DEFAULT_MAX_BOOT_CNT = 10;
@ -61,18 +55,12 @@ class CoreController : public ExtendedControllerBase, public ReceivesParameterMe
static constexpr char CHIP_STATE_FILE[] = "/tmp/chip_prot_status.txt"; static constexpr char CHIP_STATE_FILE[] = "/tmp/chip_prot_status.txt";
static constexpr char CURR_COPY_FILE[] = "/tmp/curr_copy.txt"; static constexpr char CURR_COPY_FILE[] = "/tmp/curr_copy.txt";
static constexpr char CONF_FOLDER[] = "conf";
static constexpr char VERSION_FILE_NAME[] = "version.txt";
static constexpr char REBOOT_FILE_NAME[] = "reboot.txt";
static constexpr char TIME_FILE_NAME[] = "time_backup.txt";
const std::string VERSION_FILE = const std::string VERSION_FILE =
"/" + std::string(CONF_FOLDER) + "/" + std::string(VERSION_FILE_NAME); "/" + std::string(core::CONF_FOLDER) + "/" + std::string(core::VERSION_FILE_NAME);
const std::string REBOOT_FILE = const std::string REBOOT_FILE =
"/" + std::string(CONF_FOLDER) + "/" + std::string(REBOOT_FILE_NAME); "/" + std::string(core::CONF_FOLDER) + "/" + std::string(core::REBOOT_FILE_NAME);
const std::string BACKUP_TIME_FILE = const std::string BACKUP_TIME_FILE =
"/" + std::string(CONF_FOLDER) + "/" + std::string(TIME_FILE_NAME); "/" + std::string(core::CONF_FOLDER) + "/" + std::string(core::TIME_FILE_NAME);
static constexpr char CHIP_0_COPY_0_MOUNT_DIR[] = "/tmp/mntupdate-xdi-qspi0-nom-rootfs"; static constexpr char CHIP_0_COPY_0_MOUNT_DIR[] = "/tmp/mntupdate-xdi-qspi0-nom-rootfs";
static constexpr char CHIP_0_COPY_1_MOUNT_DIR[] = "/tmp/mntupdate-xdi-qspi0-gold-rootfs"; static constexpr char CHIP_0_COPY_1_MOUNT_DIR[] = "/tmp/mntupdate-xdi-qspi0-gold-rootfs";

View File

@ -1,6 +1,10 @@
target_sources( target_sources(${OBSW_NAME} PUBLIC AcsBoardPolling.cpp ImtqPollingTask.cpp
${OBSW_NAME} PUBLIC AcsBoardPolling.cpp ImtqPollingTask.cpp RwPollingTask.cpp RwPollingTask.cpp SusPolling.cpp)
SusPolling.cpp StrComHandler.cpp)
# Dependency on proprietary library
if(TGT_BSP MATCHES "arm/q7s")
target_sources(${OBSW_NAME} PUBLIC StrComHandler.cpp)
endif()
if(EIVE_BUILD_GPSD_GPS_HANDLER) if(EIVE_BUILD_GPSD_GPS_HANDLER)
target_sources(${OBSW_NAME} PRIVATE GpsHyperionLinuxController.cpp) target_sources(${OBSW_NAME} PRIVATE GpsHyperionLinuxController.cpp)

View File

@ -11,8 +11,6 @@
#include "bsp_q7s/fs/SdCardManager.h" #include "bsp_q7s/fs/SdCardManager.h"
#endif #endif
#include "arcsec/client/generated/actionreq.h"
#include "arcsec/common/generated/tmtcstructs.h"
#include "fsfw/devicehandlers/CookieIF.h" #include "fsfw/devicehandlers/CookieIF.h"
#include "fsfw/objectmanager/SystemObject.h" #include "fsfw/objectmanager/SystemObject.h"
#include "fsfw/osal/linux/BinarySemaphore.h" #include "fsfw/osal/linux/BinarySemaphore.h"
@ -20,6 +18,10 @@
#include "fsfw/tasks/ExecutableObjectIF.h" #include "fsfw/tasks/ExecutableObjectIF.h"
#include "fsfw_hal/linux/serial/SerialComIF.h" #include "fsfw_hal/linux/serial/SerialComIF.h"
extern "C" {
#include <sagitta/client/arc_client.h>
}
/** /**
* @brief Helper class for the star tracker handler to accelerate large data transfers. * @brief Helper class for the star tracker handler to accelerate large data transfers.
* *

View File

@ -1,4 +1,8 @@
#include <mission/acs/str/ArcsecDatalinkLayer.h> #include "ArcsecDatalinkLayer.h"
extern "C" {
#include <wire/common/misc.h>
}
ArcsecDatalinkLayer::ArcsecDatalinkLayer() : decodeRingBuf(BUFFER_LENGTHS, true) { slipInit(); } ArcsecDatalinkLayer::ArcsecDatalinkLayer() : decodeRingBuf(BUFFER_LENGTHS, true) { slipInit(); }
@ -18,13 +22,10 @@ ReturnValue_t ArcsecDatalinkLayer::checkRingBufForFrame(const uint8_t** decodedF
case ARC_DEC_INPROGRESS: { case ARC_DEC_INPROGRESS: {
break; break;
} }
case ARC_DEC_ERROR_FRAME_SHORT: { case ARC_DEC_ERROR: {
decodeRingBuf.deleteData(idx); decodeRingBuf.deleteData(idx);
return REPLY_TOO_SHORT; return returnvalue::FAILED;
} }
case ARC_DEC_ERROR_CHECKSUM:
decodeRingBuf.deleteData(idx);
return CRC_FAILURE;
case ARC_DEC_ASYNC: case ARC_DEC_ASYNC:
case ARC_DEC_SYNC: { case ARC_DEC_SYNC: {
// Reset length of SLIP struct for next frame // Reset length of SLIP struct for next frame

View File

@ -5,10 +5,13 @@
#include <fsfw/devicehandlers/CookieIF.h> #include <fsfw/devicehandlers/CookieIF.h>
#include <mission/acs/str/strHelpers.h> #include <mission/acs/str/strHelpers.h>
#include "arcsec/common/misc.h"
#include "eive/resultClassIds.h" #include "eive/resultClassIds.h"
#include "fsfw/returnvalues/returnvalue.h" #include "fsfw/returnvalues/returnvalue.h"
extern "C" {
#include <wire/common/SLIP.h>
}
/** /**
* @brief Helper class to handle the datalinklayer of replies from the star tracker of arcsec. * @brief Helper class to handle the datalinklayer of replies from the star tracker of arcsec.
*/ */

View File

@ -3,6 +3,10 @@
#include "arcsecJsonKeys.h" #include "arcsecJsonKeys.h"
extern "C" {
#include <wire/common/genericstructs.h>
}
ArcsecJsonParamBase::ArcsecJsonParamBase(std::string setName) : setName(setName) {} ArcsecJsonParamBase::ArcsecJsonParamBase(std::string setName) : setName(setName) {}
ReturnValue_t ArcsecJsonParamBase::create(uint8_t* buffer) { ReturnValue_t ArcsecJsonParamBase::create(uint8_t* buffer) {

View File

@ -7,8 +7,6 @@
#include <fstream> #include <fstream>
#include <nlohmann/json.hpp> #include <nlohmann/json.hpp>
#include "arcsec/common/generated/tmtcstructs.h"
#include "arcsec/common/genericstructs.h"
#include "eive/resultClassIds.h" #include "eive/resultClassIds.h"
#include "fsfw/returnvalues/returnvalue.h" #include "fsfw/returnvalues/returnvalue.h"

View File

@ -1,18 +1,18 @@
#include <arcsec/client/generated/actionreq.h>
#include <arcsec/client/generated/parameter.h>
#include <arcsec/client/generated/telemetry.h>
#include <fsfw/ipc/QueueFactory.h> #include <fsfw/ipc/QueueFactory.h>
#include <fsfw/timemanager/Stopwatch.h> #include <fsfw/timemanager/Stopwatch.h>
#include <mission/acs/str/StarTrackerHandler.h> #include <mission/acs/str/StarTrackerHandler.h>
#include <mission/acs/str/strHelpers.h> #include <mission/acs/str/strHelpers.h>
#include <mission/acs/str/strJsonCommands.h> #include <mission/acs/str/strJsonCommands.h>
extern "C" {
#include <sagitta/client/arc_client.h>
}
#include <atomic> #include <atomic>
#include <fstream> #include <fstream>
#include <thread> #include <thread>
#include "OBSWConfig.h" #include "OBSWConfig.h"
#include "arcsec/common/misc.h"
std::atomic_bool JCFG_DONE(false); std::atomic_bool JCFG_DONE(false);

View File

@ -10,12 +10,15 @@
#include <thread> #include <thread>
#include "OBSWConfig.h" #include "OBSWConfig.h"
#include "arcsec/common/SLIP.h"
#include "devices/powerSwitcherList.h" #include "devices/powerSwitcherList.h"
#include "fsfw/devicehandlers/DeviceHandlerBase.h" #include "fsfw/devicehandlers/DeviceHandlerBase.h"
#include "fsfw/src/fsfw/serialize/SerializeAdapter.h" #include "fsfw/src/fsfw/serialize/SerializeAdapter.h"
#include "fsfw/timemanager/Countdown.h" #include "fsfw/timemanager/Countdown.h"
extern "C" {
#include <wire/common/SLIP.h>
}
/** /**
* @brief This is the device handler for the star tracker from arcsec. * @brief This is the device handler for the star tracker from arcsec.
* *

View File

@ -13,7 +13,25 @@ enum Mode : Mode_t { BOOT = 5, SAFE = acs::AcsMode::SAFE, PTG_IDLE = acs::AcsMod
} }
namespace xsc {
enum Chip : int { CHIP_0, CHIP_1, NO_CHIP, SELF_CHIP, ALL_CHIP };
enum Copy : int { COPY_0, COPY_1, NO_COPY, SELF_COPY, ALL_COPY };
} // namespace xsc
namespace core { namespace core {
// TODO: Support for status? Or maybe some command to quickly get information whether a unit
// is running.
enum SystemctlCmd : uint8_t { START = 0, STOP = 1, RESTART = 2, NUM_CMDS = 3 };
static constexpr char CONF_FOLDER[] = "conf";
static constexpr char VERSION_FILE_NAME[] = "version.txt";
static constexpr char REBOOT_FILE_NAME[] = "reboot.txt";
static constexpr char TIME_FILE_NAME[] = "time_backup.txt";
static constexpr ActionId_t LIST_DIRECTORY_INTO_FILE = 0; static constexpr ActionId_t LIST_DIRECTORY_INTO_FILE = 0;
static constexpr ActionId_t ANNOUNCE_VERSION = 1; static constexpr ActionId_t ANNOUNCE_VERSION = 1;
static constexpr ActionId_t ANNOUNCE_CURRENT_IMAGE = 2; static constexpr ActionId_t ANNOUNCE_CURRENT_IMAGE = 2;
@ -37,7 +55,9 @@ static constexpr ActionId_t MOUNT_OTHER_COPY = 33;
//! Reboot using the reboot command //! Reboot using the reboot command
static constexpr ActionId_t REBOOT_OBC = 34; static constexpr ActionId_t REBOOT_OBC = 34;
static constexpr ActionId_t EXECUTE_SHELL_CMD = 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 uint8_t SUBSYSTEM_ID = SUBSYSTEM_ID::CORE; static constexpr uint8_t SUBSYSTEM_ID = SUBSYSTEM_ID::CORE;

View File

@ -4,7 +4,8 @@ endif()
# Dependency on proprietary library # Dependency on proprietary library
if(TGT_BSP MATCHES "arm/q7s") if(TGT_BSP MATCHES "arm/q7s")
add_subdirectory(arcsec_star_tracker) # Only add required folder for wire library.
add_subdirectory(sagittactl/wire)
endif() endif()
add_subdirectory(rapidcsv) add_subdirectory(rapidcsv)

@ -1 +0,0 @@
Subproject commit 2823952e0902726e6e35dd7c159761f76bf7e505

1
thirdparty/sagittactl vendored Submodule

@ -0,0 +1 @@
Subproject commit 64332216c193fa6483258060b53fc2842c08dcf4

2
tmtc

@ -1 +1 @@
Subproject commit 33fd280e517a55175072ea336c7f8e85bce6e55a Subproject commit f8da9cff7c5d6d6bdd483f90ccefb67b2d1e11a4