From 8e26ad2871657b02abff776a1b703b479844f657 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Thu, 3 Nov 2022 15:10:42 +0100 Subject: [PATCH] simplify max RTD low level handler --- linux/devices/Max31865RtdLowlevelHandler.cpp | 24 ++++++++------------ linux/devices/Max31865RtdLowlevelHandler.h | 2 -- mission/core/GenericFactory.cpp | 6 ++--- mission/devices/Max31865EiveHandler.cpp | 13 +++++++---- mission/tmtc/VirtualChannel.cpp | 2 +- 5 files changed, 22 insertions(+), 25 deletions(-) diff --git a/linux/devices/Max31865RtdLowlevelHandler.cpp b/linux/devices/Max31865RtdLowlevelHandler.cpp index 1be2b1c2..38a9ac11 100644 --- a/linux/devices/Max31865RtdLowlevelHandler.cpp +++ b/linux/devices/Max31865RtdLowlevelHandler.cpp @@ -50,7 +50,7 @@ ReturnValue_t Max31865RtdReader::performOperation(uint8_t operationCode) { } bool Max31865RtdReader::rtdIsActive(uint8_t idx) { - if (rtds[idx]->on and rtds[idx]->active and rtds[idx]->configured) { + if (rtds[idx]->on and rtds[idx]->db.active and rtds[idx]->db.configured) { return true; } return false; @@ -69,7 +69,7 @@ bool Max31865RtdReader::periodicInitHandling() { if (rtd == nullptr) { continue; } - if ((rtd->on or rtd->active) and not rtd->configured and rtd->cd.hasTimedOut()) { + if ((rtd->on or rtd->db.active) and not rtd->db.configured and rtd->cd.hasTimedOut()) { ManualCsLockWrapper mg(csLock, gpioIF, rtd->spiCookie, csTimeoutType, csTimeoutMs); if (mg.lockResult != returnvalue::OK or mg.gpioResult != returnvalue::OK) { sif::error << "Max31865RtdReader::periodicInitHandling: Manual CS lock failed" << std::endl; @@ -95,13 +95,7 @@ bool Max31865RtdReader::periodicInitHandling() { if (result != returnvalue::OK) { handleSpiError(rtd, result, "clearFaultStatus"); } - rtd->configured = true; rtd->db.configured = true; - if (rtd->active) { - rtd->db.active = true; - } - } - if (rtd->active and rtd->configured and not rtd->db.active) { rtd->db.active = true; } } @@ -241,8 +235,8 @@ ReturnValue_t Max31865RtdReader::sendMessage(CookieIF* cookie, const uint8_t* se rtdCookie->cd.setTimeout(MAX31865::WARMUP_MS); rtdCookie->cd.resetTimer(); rtdCookie->on = true; - rtdCookie->active = false; - rtdCookie->configured = false; + rtdCookie->db.active = false; + rtdCookie->db.configured = false; if (sendLen == 5) { thresholdHandler(rtdCookie, sendData); } @@ -254,10 +248,10 @@ ReturnValue_t Max31865RtdReader::sendMessage(CookieIF* cookie, const uint8_t* se rtdCookie->cd.setTimeout(MAX31865::WARMUP_MS); rtdCookie->cd.resetTimer(); rtdCookie->on = true; - rtdCookie->active = true; - rtdCookie->configured = false; + rtdCookie->db.active = true; + rtdCookie->db.configured = false; } else { - rtdCookie->active = true; + rtdCookie->db.active = true; } if (sendLen == 5) { thresholdHandler(rtdCookie, sendData); @@ -266,8 +260,8 @@ ReturnValue_t Max31865RtdReader::sendMessage(CookieIF* cookie, const uint8_t* se } case (EiveMax31855::RtdCommands::OFF): { rtdCookie->on = false; - rtdCookie->active = false; - rtdCookie->configured = false; + rtdCookie->db.active = false; + rtdCookie->db.configured = false; break; } case (EiveMax31855::RtdCommands::HIGH_TRESHOLD): { diff --git a/linux/devices/Max31865RtdLowlevelHandler.h b/linux/devices/Max31865RtdLowlevelHandler.h index d3845bd5..89d66350 100644 --- a/linux/devices/Max31865RtdLowlevelHandler.h +++ b/linux/devices/Max31865RtdLowlevelHandler.h @@ -23,8 +23,6 @@ struct Max31865ReaderCookie : public CookieIF { Countdown cd = Countdown(MAX31865::WARMUP_MS); bool on = false; - bool configured = false; - bool active = false; bool writeLowThreshold = false; bool writeHighThreshold = false; uint16_t lowThreshold = 0; diff --git a/mission/core/GenericFactory.cpp b/mission/core/GenericFactory.cpp index 06627886..0e1926f4 100644 --- a/mission/core/GenericFactory.cpp +++ b/mission/core/GenericFactory.cpp @@ -86,8 +86,8 @@ void ObjectFactory::produceGenericObjects(HealthTableIF** healthTable_, PusTmFun } { - PoolManager::LocalPoolConfig poolCfg = {{300, 16}, {300, 32}, {250, 64}, - {150, 128}, {120, 1024}, {120, 2048}}; + PoolManager::LocalPoolConfig poolCfg = {{300, 16}, {350, 32}, {350, 64}, + {200, 128}, {150, 1024}, {150, 2048}}; tmStore = new PoolManager(objects::TM_STORE, poolCfg); } @@ -114,7 +114,7 @@ void ObjectFactory::produceGenericObjects(HealthTableIF** healthTable_, PusTmFun tcpServer->enableWiretapping(true); #endif /* OBSW_TCP_SERVER_WIRETAPPING == 1 */ #endif /* OBSW_USE_TMTC_TCP_BRIDGE == 0 */ - tcpIpTmtcBridge->setMaxNumberOfPacketsStored(300); + tcpIpTmtcBridge->setMaxNumberOfPacketsStored(150); #endif /* OBSW_ADD_TCPIP_BRIDGE == 1 */ auto* ccsdsDistrib = diff --git a/mission/devices/Max31865EiveHandler.cpp b/mission/devices/Max31865EiveHandler.cpp index 90e4b933..45f3a8d1 100644 --- a/mission/devices/Max31865EiveHandler.cpp +++ b/mission/devices/Max31865EiveHandler.cpp @@ -30,16 +30,13 @@ void Max31865EiveHandler::doStartUp() { } void Max31865EiveHandler::doShutDown() { - updatePeriodicReply(false, EiveMax31855::RtdCommands::EXCHANGE_SET_ID); if (state == InternalState::NONE or state == InternalState::ACTIVE or state == InternalState::ON) { state = InternalState::INACTIVE; transitionOk = false; - } else { - transitionOk = true; } if (state == InternalState::INACTIVE and transitionOk) { - setMode(_MODE_POWER_DOWN); + setMode(MODE_OFF); } } @@ -151,6 +148,14 @@ ReturnValue_t Max31865EiveHandler::interpretDeviceReply(DeviceCommandId_t id, if (getMode() == _MODE_START_UP and exchangeStruct.configured and state == InternalState::ON) { transitionOk = true; } + if (getMode() == _MODE_SHUT_DOWN) { + uint32_t dummy = 0; + } + if (getMode() == _MODE_SHUT_DOWN and not exchangeStruct.active) { + transitionOk = true; + return returnvalue::OK; + } + // Calculate resistance float rtdValue = exchangeStruct.adcCode * EiveMax31855::RTD_RREF_PT1000 / INT16_MAX; // calculate approximation diff --git a/mission/tmtc/VirtualChannel.cpp b/mission/tmtc/VirtualChannel.cpp index 9fe47b1c..b0f9391d 100644 --- a/mission/tmtc/VirtualChannel.cpp +++ b/mission/tmtc/VirtualChannel.cpp @@ -34,7 +34,7 @@ ReturnValue_t VirtualChannel::performOperation() { size_t size = 0; result = tmStore->getData(storeId, &data, &size); if (result != returnvalue::OK) { - sif::warning << "VirtualChannel::performOperation: Failed to read data from IPC store" + sif::warning << "VirtualChannel::performOperation: Failed to read data from TM store" << std::endl; tmStore->deleteData(storeId); return result;