added filesystem down event
All checks were successful
EIVE/eive-obsw/pipeline/pr-main This commit looks good

This commit is contained in:
Robin Müller 2023-08-02 09:39:42 +02:00
parent c120ce8617
commit f0bbc1d090
Signed by: muellerr
GPG Key ID: A649FB78196E3849
3 changed files with 22 additions and 4 deletions

View File

@ -19,7 +19,9 @@ using namespace returnvalue;
ScexDeviceHandler::ScexDeviceHandler(object_id_t objectId, ScexUartReader& reader, CookieIF* cookie, ScexDeviceHandler::ScexDeviceHandler(object_id_t objectId, ScexUartReader& reader, CookieIF* cookie,
SdCardMountedIF& sdcMan) SdCardMountedIF& sdcMan)
: DeviceHandlerBase(objectId, reader.getObjectId(), cookie), sdcMan(sdcMan), reader(reader) {} : DeviceHandlerBase(objectId, reader.getObjectId(), cookie), sdcMan(sdcMan), reader(reader) {
fsUnusableEventCd.timeOut();
}
ScexDeviceHandler::~ScexDeviceHandler() {} ScexDeviceHandler::~ScexDeviceHandler() {}
@ -218,8 +220,12 @@ ReturnValue_t ScexDeviceHandler::interpretDeviceReply(DeviceCommandId_t id, cons
} }
fileNameSet = true; fileNameSet = true;
} else { } else {
ofstream out(fileName, if (!sdcMan.isSdCardUsable(std::nullopt)) {
ofstream::binary | ofstream::app); // append fsUnsableEvent();
return returnvalue::FAILED;
}
// Append to existing file.
ofstream out(fileName, ofstream::binary | ofstream::app);
if (out.bad()) { if (out.bad()) {
sif::error << "ScexDeviceHandler::handleValidReply: Could not open file " << fileName sif::error << "ScexDeviceHandler::handleValidReply: Could not open file " << fileName
<< std::endl; << std::endl;
@ -330,6 +336,14 @@ void ScexDeviceHandler::filesystemChecks() {
} }
} }
void ScexDeviceHandler::fsUnsableEvent() {
if (fsUnusableEventCd.isBusy()) {
return;
}
triggerEvent(scex::FS_UNUSABLE);
fsUnusableEventCd.resetTimer();
}
ReturnValue_t ScexDeviceHandler::generateNewScexFile(const char* cmdName) { ReturnValue_t ScexDeviceHandler::generateNewScexFile(const char* cmdName) {
char timeString[64]{}; char timeString[64]{};
auto activeSd = sdcMan.getActiveSdCard(); auto activeSd = sdcMan.getActiveSdCard();
@ -339,7 +353,8 @@ ReturnValue_t ScexDeviceHandler::generateNewScexFile(const char* cmdName) {
std::ostringstream oss; std::ostringstream oss;
auto prefix = sdcMan.getCurrentMountPrefix(); auto prefix = sdcMan.getCurrentMountPrefix();
if (prefix == nullptr) { if (prefix == nullptr or !sdcMan.isSdCardUsable(std::nullopt)) {
fsUnsableEvent();
return returnvalue::FAILED; return returnvalue::FAILED;
} }
timeval tv; timeval tv;

View File

@ -42,6 +42,7 @@ class ScexDeviceHandler : public DeviceHandlerBase {
scex::Cmds currCmd = scex::Cmds::PING; scex::Cmds currCmd = scex::Cmds::PING;
SdCardMountedIF &sdcMan; SdCardMountedIF &sdcMan;
Countdown finishCountdown = Countdown(LONG_CD); Countdown finishCountdown = Countdown(LONG_CD);
Countdown fsUnusableEventCd = Countdown(60000);
// DeviceHandlerBase private function implementation // DeviceHandlerBase private function implementation
void doStartUp() override; void doStartUp() override;
@ -49,6 +50,7 @@ class ScexDeviceHandler : public DeviceHandlerBase {
ScexHelper helper; ScexHelper helper;
ScexUartReader &reader; ScexUartReader &reader;
void fsUnsableEvent();
void performOperationHook() override; void performOperationHook() override;
ReturnValue_t buildNormalDeviceCommand(DeviceCommandId_t *id) override; ReturnValue_t buildNormalDeviceCommand(DeviceCommandId_t *id) override;
ReturnValue_t buildTransitionDeviceCommand(DeviceCommandId_t *id) override; ReturnValue_t buildTransitionDeviceCommand(DeviceCommandId_t *id) override;

View File

@ -17,6 +17,7 @@ static constexpr uint8_t SUBSYSTEM_ID = SUBSYSTEM_ID::SCEX_HANDLER;
static constexpr Event MISSING_PACKET = event::makeEvent(SUBSYSTEM_ID, 0, severity::LOW); static constexpr Event MISSING_PACKET = event::makeEvent(SUBSYSTEM_ID, 0, severity::LOW);
static constexpr Event EXPERIMENT_TIMEDOUT = event::makeEvent(SUBSYSTEM_ID, 1, severity::LOW); static constexpr Event EXPERIMENT_TIMEDOUT = event::makeEvent(SUBSYSTEM_ID, 1, severity::LOW);
static constexpr Event FS_UNUSABLE = event::makeEvent(SUBSYSTEM_ID, 2, severity::LOW);
//! FRAM, One Cell or All cells command finished. P1: Command ID //! FRAM, One Cell or All cells command finished. P1: Command ID
static constexpr Event MULTI_PACKET_COMMAND_DONE = static constexpr Event MULTI_PACKET_COMMAND_DONE =
event::makeEvent(SUBSYSTEM_ID, 2, severity::INFO); event::makeEvent(SUBSYSTEM_ID, 2, severity::INFO);