correction for prefix handling on Q7S
All checks were successful
EIVE/eive-obsw/pipeline/pr-develop This commit looks good

This commit is contained in:
Robin Müller 2023-02-22 18:06:34 +01:00
parent 9633359db3
commit 90c1d45f20
No known key found for this signature in database
GPG Key ID: 11D4952C8CCEF814
19 changed files with 66 additions and 30 deletions

View File

@ -22,6 +22,10 @@ will consitute of a breaking change warranting a new major release:
telemetry. telemetry.
PR: https://egit.irs.uni-stuttgart.de/eive/eive-obsw/pulls/320/files PR: https://egit.irs.uni-stuttgart.de/eive/eive-obsw/pulls/320/files
## Changed
- Changed format of `getCurrentMountPrefix` to return a `const char*`.
# [v1.30.0] # [v1.30.0]
eive-tmtc: v2.14.0 eive-tmtc: v2.14.0

View File

@ -159,6 +159,9 @@ ReturnValue_t CoreController::initializeAfterTaskCreation() {
} }
sdcMan->setActiveSdCard(sdInfo.active); sdcMan->setActiveSdCard(sdInfo.active);
currMntPrefix = sdcMan->getCurrentMountPrefix(); currMntPrefix = sdcMan->getCurrentMountPrefix();
if (currMntPrefix == "") {
return ObjectManagerIF::CHILD_INIT_FAILED;
}
if (BLOCKING_SD_INIT) { if (BLOCKING_SD_INIT) {
result = initSdCardBlocking(); result = initSdCardBlocking();
if (result != returnvalue::OK and result != SdCardManager::ALREADY_MOUNTED) { if (result != returnvalue::OK and result != SdCardManager::ALREADY_MOUNTED) {

View File

@ -23,7 +23,8 @@ void ObjectFactory::produce(void* args) {
HealthTableIF* healthTable = nullptr; HealthTableIF* healthTable = nullptr;
PusTmFunnel* pusFunnel = nullptr; PusTmFunnel* pusFunnel = nullptr;
CfdpTmFunnel* cfdpFunnel = nullptr; CfdpTmFunnel* cfdpFunnel = nullptr;
ObjectFactory::produceGenericObjects(&healthTable, &pusFunnel, &cfdpFunnel, *SdCardManager::instance()); ObjectFactory::produceGenericObjects(&healthTable, &pusFunnel, &cfdpFunnel,
*SdCardManager::instance());
LinuxLibgpioIF* gpioComIF = nullptr; LinuxLibgpioIF* gpioComIF = nullptr;
SerialComIF* uartComIF = nullptr; SerialComIF* uartComIF = nullptr;

View File

@ -410,9 +410,12 @@ ReturnValue_t SdCardManager::updateSdCardStateFile() {
return result; return result;
} }
const std::string& SdCardManager::getCurrentMountPrefix() const { const char* SdCardManager::getCurrentMountPrefix() const {
MutexGuard mg(mutex); MutexGuard mg(mutex);
return currentPrefix; if (currentPrefix.has_value()) {
return currentPrefix.value().c_str();
}
return nullptr;
} }
SdCardManager::OpStatus SdCardManager::checkCurrentOp(Operations& currentOp) { SdCardManager::OpStatus SdCardManager::checkCurrentOp(Operations& currentOp) {

View File

@ -187,7 +187,7 @@ class SdCardManager : public SystemObject, public SdCardMountedIF {
* @param prefSdCardPtr * @param prefSdCardPtr
* @return * @return
*/ */
const std::string& getCurrentMountPrefix() const override; const char* getCurrentMountPrefix() const override;
OpStatus checkCurrentOp(Operations& currentOp); OpStatus checkCurrentOp(Operations& currentOp);
@ -232,7 +232,7 @@ class SdCardManager : public SystemObject, public SdCardMountedIF {
void processSdStatusLine(SdStatePair& active, std::string& line, uint8_t& idx, void processSdStatusLine(SdStatePair& active, std::string& line, uint8_t& idx,
sd::SdCard& currentSd); sd::SdCard& currentSd);
std::string currentPrefix; std::optional<std::string> currentPrefix;
static SdCardManager* INSTANCE; static SdCardManager* INSTANCE;
}; };

View File

@ -3,6 +3,9 @@
std::filesystem::path fshelpers::getPrefixedPath(SdCardManager &man, std::filesystem::path fshelpers::getPrefixedPath(SdCardManager &man,
std::filesystem::path pathWihtoutPrefix) { std::filesystem::path pathWihtoutPrefix) {
auto prefix = man.getCurrentMountPrefix(); auto prefix = man.getCurrentMountPrefix();
if (prefix == nullptr) {
return pathWihtoutPrefix;
}
auto resPath = prefix / pathWihtoutPrefix; auto resPath = prefix / pathWihtoutPrefix;
return resPath; return resPath;
} }

View File

@ -25,5 +25,6 @@ target_sources(
PlocMpsocDummy.cpp PlocMpsocDummy.cpp
PlocSupervisorDummy.cpp PlocSupervisorDummy.cpp
helpers.cpp helpers.cpp
RtdPollingDummy.cpp
MgmRm3100Dummy.cpp MgmRm3100Dummy.cpp
Tmp1075Dummy.cpp) Tmp1075Dummy.cpp)

View File

@ -1,3 +1,5 @@
#include "RtdPollingDummy.h" #include "RtdPollingDummy.h"
RtdPollingDummy::RtdPollingDummy(object_id_t objectId): SystemObject(objectId) {} RtdPollingDummy::RtdPollingDummy(object_id_t objectId) : SystemObject(objectId) {}
ReturnValue_t RtdPollingDummy::performOperation(uint8_t operationCode) { return returnvalue::OK; }

View File

@ -2,10 +2,12 @@
#define DUMMIES_RTDPOLLINGDUMMY_H_ #define DUMMIES_RTDPOLLINGDUMMY_H_
#include <fsfw/objectmanager/SystemObject.h> #include <fsfw/objectmanager/SystemObject.h>
#include <fsfw/tasks/ExecutableObjectIF.h>
class RtdPollingDummy: public SystemObject { class RtdPollingDummy : public ExecutableObjectIF, public SystemObject {
public: public:
RtdPollingDummy(object_id_t objectId); RtdPollingDummy(object_id_t objectId);
ReturnValue_t performOperation(uint8_t operationCode = 0) override;
}; };
#endif /* DUMMIES_RTDPOLLINGDUMMY_H_ */ #endif /* DUMMIES_RTDPOLLINGDUMMY_H_ */

View File

@ -46,7 +46,7 @@ void dummy::createDummies(DummyCfg cfg, PowerSwitchIF& pwrSwitcher, GpioIF* gpio
new CoreControllerDummy(objects::CORE_CONTROLLER); new CoreControllerDummy(objects::CORE_CONTROLLER);
} }
if (cfg.addRtdComIFDummy) { if (cfg.addRtdComIFDummy) {
new ComIFDummy(objects::SPI_RTD_COM_IF); new RtdPollingDummy(objects::SPI_RTD_COM_IF);
} }
std::array<object_id_t, 4> rwIds = {objects::RW1, objects::RW2, objects::RW3, objects::RW4}; std::array<object_id_t, 4> rwIds = {objects::RW1, objects::RW2, objects::RW3, objects::RW4};
std::array<DeviceHandlerBase*, 4> rws; std::array<DeviceHandlerBase*, 4> rws;
@ -193,7 +193,6 @@ void dummy::createDummies(DummyCfg cfg, PowerSwitchIF& pwrSwitcher, GpioIF* gpio
objects::TMP1075_HANDLER_IF_BOARD, objects::TMP1075_HANDLER_IF_BOARD,
new Tmp1075Dummy(objects::TMP1075_HANDLER_IF_BOARD, objects::DUMMY_COM_IF, comCookieDummy)); new Tmp1075Dummy(objects::TMP1075_HANDLER_IF_BOARD, objects::DUMMY_COM_IF, comCookieDummy));
new RtdPollingDummy(objects::SPI_RTD_COM_IF);
new TemperatureSensorInserter(objects::THERMAL_TEMP_INSERTER, rtdSensorDummies, new TemperatureSensorInserter(objects::THERMAL_TEMP_INSERTER, rtdSensorDummies,
tmpSensorDummies); tmpSensorDummies);
TcsBoardAssembly* tcsBoardAssy = ObjectFactory::createTcsBoardAssy(pwrSwitcher); TcsBoardAssembly* tcsBoardAssy = ObjectFactory::createTcsBoardAssy(pwrSwitcher);

View File

@ -1742,18 +1742,21 @@ ReturnValue_t PlocSupervisorHandler::createMramDumpFile() {
std::string filename = "mram-dump--" + timeStamp + ".bin"; std::string filename = "mram-dump--" + timeStamp + ".bin";
#ifdef XIPHOS_Q7S #ifdef XIPHOS_Q7S
std::string currentMountPrefix = sdcMan->getCurrentMountPrefix(); const char* currentMountPrefix = sdcMan->getCurrentMountPrefix();
#else #else
std::string currentMountPrefix("/mnt/sd0"); const char* currentMountPrefix = "/mnt/sd0";
#endif /* BOARD_TE0720 == 0 */ #endif /* BOARD_TE0720 == 0 */
if (currentMountPrefix == nullptr) {
return returnvalue::FAILED;
}
// Check if path to PLOC directory exists // Check if path to PLOC directory exists
if (not std::filesystem::exists(std::string(currentMountPrefix + "/" + supervisorFilePath))) { if (not std::filesystem::exists(std::string(currentMountPrefix) + "/" + supervisorFilePath)) {
sif::warning << "PlocSupervisorHandler::createMramDumpFile: Supervisor path does not exist" sif::warning << "PlocSupervisorHandler::createMramDumpFile: Supervisor path does not exist"
<< std::endl; << std::endl;
return result::PATH_DOES_NOT_EXIST; return result::PATH_DOES_NOT_EXIST;
} }
activeMramFile = currentMountPrefix + "/" + supervisorFilePath + "/" + filename; activeMramFile = std::string(currentMountPrefix) + "/" + supervisorFilePath + "/" + filename;
// Create new file // Create new file
std::ofstream file(activeMramFile, std::ios_base::out); std::ofstream file(activeMramFile, std::ios_base::out);
file.close(); file.close();

View File

@ -517,6 +517,9 @@ void PayloadPcduHandler::checkJsonFileInit() {
if (not jsonFileInitComplete) { if (not jsonFileInitComplete) {
auto activeSd = sdcMan->getActiveSdCard(); auto activeSd = sdcMan->getActiveSdCard();
if (activeSd and sdcMan->isSdCardUsable(activeSd.value())) { if (activeSd and sdcMan->isSdCardUsable(activeSd.value())) {
if (sdcMan->getCurrentMountPrefix() == nullptr) {
return;
}
params.initialize(sdcMan->getCurrentMountPrefix()); params.initialize(sdcMan->getCurrentMountPrefix());
jsonFileInitComplete = true; jsonFileInitComplete = true;
} }

View File

@ -214,6 +214,9 @@ ReturnValue_t ScexDeviceHandler::interpretDeviceReply(DeviceCommandId_t id, cons
fileId = date_time_string(); fileId = date_time_string();
std::ostringstream oss; std::ostringstream oss;
auto prefix = sdcMan.getCurrentMountPrefix(); auto prefix = sdcMan.getCurrentMountPrefix();
if (prefix == nullptr) {
return returnvalue::FAILED;
}
oss << prefix << "/scex/scex-" << cmdName << fileId << ".bin"; oss << prefix << "/scex/scex-" << cmdName << fileId << ".bin";
fileName = oss.str(); fileName = oss.str();
ofstream out(fileName, ofstream::binary); ofstream out(fileName, ofstream::binary);
@ -234,6 +237,9 @@ ReturnValue_t ScexDeviceHandler::interpretDeviceReply(DeviceCommandId_t id, cons
fileId = date_time_string(); fileId = date_time_string();
std::ostringstream oss; std::ostringstream oss;
auto prefix = sdcMan.getCurrentMountPrefix(); auto prefix = sdcMan.getCurrentMountPrefix();
if (prefix == nullptr) {
return returnvalue::FAILED;
}
oss << prefix << "/scex/scex-" << cmdName << fileId << ".bin"; oss << prefix << "/scex/scex-" << cmdName << fileId << ".bin";
fileName = oss.str(); fileName = oss.str();
fileNameSet = true; fileNameSet = true;
@ -310,6 +316,16 @@ ReturnValue_t ScexDeviceHandler::interpretDeviceReply(DeviceCommandId_t id, cons
} }
void ScexDeviceHandler::performOperationHook() { void ScexDeviceHandler::performOperationHook() {
auto mntPrefix = sdcMan.getCurrentMountPrefix();
if (mntPrefix != nullptr) {
std::filesystem::path fullFilePath = mntPrefix;
fullFilePath /= "scex";
bool fileExists = std::filesystem::exists(fullFilePath);
if (not fileExists) {
std::filesystem::create_directory(fullFilePath);
}
}
uint32_t remainingMillis = finishCountdown.getRemainingMillis(); uint32_t remainingMillis = finishCountdown.getRemainingMillis();
if (commandActive and finishCountdown.hasTimedOut()) { if (commandActive and finishCountdown.hasTimedOut()) {
triggerEvent(scex::EXPERIMENT_TIMEDOUT, currCmd, 0); triggerEvent(scex::EXPERIMENT_TIMEDOUT, currCmd, 0);
@ -373,13 +389,5 @@ void ScexDeviceHandler::setPowerSwitcher(PowerSwitchIF& powerSwitcher, power::Sw
} }
ReturnValue_t ScexDeviceHandler::initializeAfterTaskCreation() { ReturnValue_t ScexDeviceHandler::initializeAfterTaskCreation() {
auto mntPrefix = sdcMan.getCurrentMountPrefix();
std::filesystem::path fullFilePath = mntPrefix;
fullFilePath /= "scex";
bool fileExists = std::filesystem::exists(fullFilePath);
if (not fileExists) {
std::filesystem::create_directory(fullFilePath);
}
return DeviceHandlerBase::initializeAfterTaskCreation(); return DeviceHandlerBase::initializeAfterTaskCreation();
} }

View File

@ -9,7 +9,7 @@
class SdCardMountedIF { class SdCardMountedIF {
public: public:
virtual ~SdCardMountedIF(){}; virtual ~SdCardMountedIF(){};
virtual const std::string& getCurrentMountPrefix() const = 0; virtual const char* getCurrentMountPrefix() const = 0;
virtual bool isSdCardUsable(std::optional<sd::SdCard> sdCard) = 0; virtual bool isSdCardUsable(std::optional<sd::SdCard> sdCard) = 0;
virtual std::optional<sd::SdCard> getPreferredSdCard() const = 0; virtual std::optional<sd::SdCard> getPreferredSdCard() const = 0;
virtual void setActiveSdCard(sd::SdCard sdCard) = 0; virtual void setActiveSdCard(sd::SdCard sdCard) = 0;

View File

@ -52,7 +52,7 @@ ReturnValue_t PersistentTmStore::assignAndOrCreateMostRecentFile() {
time_t fileEpoch = timegm(&time); time_t fileEpoch = timegm(&time);
// There is still a file within the active time window, so re-use that file for new TMs to // There is still a file within the active time window, so re-use that file for new TMs to
// store. // store.
if (fileEpoch + rolloverDiffSeconds > currentTv.tv_sec) { if (fileEpoch + static_cast<time_t>(rolloverDiffSeconds) > currentTv.tv_sec) {
activeFileTv.tv_sec = fileEpoch; activeFileTv.tv_sec = fileEpoch;
activeFile = file.path(); activeFile = file.path();
break; break;
@ -191,14 +191,18 @@ void PersistentTmStore::calcDiffSeconds(RolloverInterval intervalUnit, uint32_t
} }
} }
void PersistentTmStore::updateBaseDir() { bool PersistentTmStore::updateBaseDir() {
using namespace std::filesystem; using namespace std::filesystem;
std::string currentPrefix = sdcMan.getCurrentMountPrefix(); const char* currentPrefix = sdcMan.getCurrentMountPrefix();
if (currentPrefix == nullptr) {
return false;
}
basePath = path(currentPrefix) / baseDir / baseName; basePath = path(currentPrefix) / baseDir / baseName;
if (not exists(basePath)) { if (not exists(basePath)) {
create_directories(basePath); create_directories(basePath);
} }
baseDirUninitialized = false; baseDirUninitialized = false;
return true;
} }
void PersistentTmStore::addApid(uint16_t apid) { void PersistentTmStore::addApid(uint16_t apid) {

View File

@ -77,7 +77,7 @@ class PersistentTmStore : public TmStoreFrontendSimpleIF, public SystemObject {
ReturnValue_t createMostRecentFile(); ReturnValue_t createMostRecentFile();
static ReturnValue_t pathToTm(const std::filesystem::path& path, struct tm& time); static ReturnValue_t pathToTm(const std::filesystem::path& path, struct tm& time);
void fileToPackets(const std::filesystem::path& path, uint32_t unixStamp, TmFunnelBase& funnel); void fileToPackets(const std::filesystem::path& path, uint32_t unixStamp, TmFunnelBase& funnel);
void updateBaseDir(); bool updateBaseDir();
ReturnValue_t assignAndOrCreateMostRecentFile(); ReturnValue_t assignAndOrCreateMostRecentFile();
ReturnValue_t storePacket(PusTmReader& reader); ReturnValue_t storePacket(PusTmReader& reader);
}; };

View File

@ -144,7 +144,7 @@ ReturnValue_t PusTmFunnel::handleTmPacket(TmTcMessage &message) {
const char *PusTmFunnel::getName() const { return "PUS TM Funnel"; } const char *PusTmFunnel::getName() const { return "PUS TM Funnel"; }
void PusTmFunnel::initStoresIfPossible(bool sdCardUsable) { void PusTmFunnel::initStoresIfPossible(bool sdCardUsable) {
if (not storesInitialized and sdCardUsable) { if (not storesInitialized and sdCardUsable and sdcMan.getCurrentMountPrefix() != nullptr) {
miscStore.initializeTmStore(); miscStore.initializeTmStore();
okStore.initializeTmStore(); okStore.initializeTmStore();
hkStore.initializeTmStore(); hkStore.initializeTmStore();

View File

@ -2,7 +2,7 @@
DummySdCardManager::DummySdCardManager(std::string prefix) : prefix(std::move(prefix)) {} DummySdCardManager::DummySdCardManager(std::string prefix) : prefix(std::move(prefix)) {}
const std::string& DummySdCardManager::getCurrentMountPrefix() const { return prefix; } const char* DummySdCardManager::getCurrentMountPrefix() const { return prefix.c_str(); }
bool DummySdCardManager::isSdCardUsable(std::optional<sd::SdCard> sdCard) { return true; } bool DummySdCardManager::isSdCardUsable(std::optional<sd::SdCard> sdCard) { return true; }

View File

@ -5,7 +5,7 @@
class DummySdCardManager : public SdCardMountedIF { class DummySdCardManager : public SdCardMountedIF {
public: public:
DummySdCardManager(std::string prefix); DummySdCardManager(std::string prefix);
const std::string& getCurrentMountPrefix() const override; const char* getCurrentMountPrefix() const override;
bool isSdCardUsable(std::optional<sd::SdCard> sdCard) override; bool isSdCardUsable(std::optional<sd::SdCard> sdCard) override;
std::optional<sd::SdCard> getPreferredSdCard() const override; std::optional<sd::SdCard> getPreferredSdCard() const override;
void setActiveSdCard(sd::SdCard sdCard) override; void setActiveSdCard(sd::SdCard sdCard) override;