added filesystem down event
All checks were successful
EIVE/eive-obsw/pipeline/pr-main This commit looks good
All checks were successful
EIVE/eive-obsw/pipeline/pr-main This commit looks good
This commit is contained in:
parent
c120ce8617
commit
f0bbc1d090
@ -19,7 +19,9 @@ using namespace returnvalue;
|
||||
|
||||
ScexDeviceHandler::ScexDeviceHandler(object_id_t objectId, ScexUartReader& reader, CookieIF* cookie,
|
||||
SdCardMountedIF& sdcMan)
|
||||
: DeviceHandlerBase(objectId, reader.getObjectId(), cookie), sdcMan(sdcMan), reader(reader) {}
|
||||
: DeviceHandlerBase(objectId, reader.getObjectId(), cookie), sdcMan(sdcMan), reader(reader) {
|
||||
fsUnusableEventCd.timeOut();
|
||||
}
|
||||
|
||||
ScexDeviceHandler::~ScexDeviceHandler() {}
|
||||
|
||||
@ -218,8 +220,12 @@ ReturnValue_t ScexDeviceHandler::interpretDeviceReply(DeviceCommandId_t id, cons
|
||||
}
|
||||
fileNameSet = true;
|
||||
} else {
|
||||
ofstream out(fileName,
|
||||
ofstream::binary | ofstream::app); // append
|
||||
if (!sdcMan.isSdCardUsable(std::nullopt)) {
|
||||
fsUnsableEvent();
|
||||
return returnvalue::FAILED;
|
||||
}
|
||||
// Append to existing file.
|
||||
ofstream out(fileName, ofstream::binary | ofstream::app);
|
||||
if (out.bad()) {
|
||||
sif::error << "ScexDeviceHandler::handleValidReply: Could not open file " << fileName
|
||||
<< 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) {
|
||||
char timeString[64]{};
|
||||
auto activeSd = sdcMan.getActiveSdCard();
|
||||
@ -339,7 +353,8 @@ ReturnValue_t ScexDeviceHandler::generateNewScexFile(const char* cmdName) {
|
||||
|
||||
std::ostringstream oss;
|
||||
auto prefix = sdcMan.getCurrentMountPrefix();
|
||||
if (prefix == nullptr) {
|
||||
if (prefix == nullptr or !sdcMan.isSdCardUsable(std::nullopt)) {
|
||||
fsUnsableEvent();
|
||||
return returnvalue::FAILED;
|
||||
}
|
||||
timeval tv;
|
||||
|
@ -42,6 +42,7 @@ class ScexDeviceHandler : public DeviceHandlerBase {
|
||||
scex::Cmds currCmd = scex::Cmds::PING;
|
||||
SdCardMountedIF &sdcMan;
|
||||
Countdown finishCountdown = Countdown(LONG_CD);
|
||||
Countdown fsUnusableEventCd = Countdown(60000);
|
||||
|
||||
// DeviceHandlerBase private function implementation
|
||||
void doStartUp() override;
|
||||
@ -49,6 +50,7 @@ class ScexDeviceHandler : public DeviceHandlerBase {
|
||||
ScexHelper helper;
|
||||
ScexUartReader &reader;
|
||||
|
||||
void fsUnsableEvent();
|
||||
void performOperationHook() override;
|
||||
ReturnValue_t buildNormalDeviceCommand(DeviceCommandId_t *id) override;
|
||||
ReturnValue_t buildTransitionDeviceCommand(DeviceCommandId_t *id) override;
|
||||
|
@ -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 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
|
||||
static constexpr Event MULTI_PACKET_COMMAND_DONE =
|
||||
event::makeEvent(SUBSYSTEM_ID, 2, severity::INFO);
|
||||
|
Loading…
Reference in New Issue
Block a user