simplify max RTD low level handler

This commit is contained in:
Robin Müller 2022-11-03 15:10:42 +01:00
parent 9044a5476c
commit 8e26ad2871
No known key found for this signature in database
GPG Key ID: 71B58F8A3CDFA9AC
5 changed files with 22 additions and 25 deletions

View File

@ -50,7 +50,7 @@ ReturnValue_t Max31865RtdReader::performOperation(uint8_t operationCode) {
} }
bool Max31865RtdReader::rtdIsActive(uint8_t idx) { 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 true;
} }
return false; return false;
@ -69,7 +69,7 @@ bool Max31865RtdReader::periodicInitHandling() {
if (rtd == nullptr) { if (rtd == nullptr) {
continue; 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); ManualCsLockWrapper mg(csLock, gpioIF, rtd->spiCookie, csTimeoutType, csTimeoutMs);
if (mg.lockResult != returnvalue::OK or mg.gpioResult != returnvalue::OK) { if (mg.lockResult != returnvalue::OK or mg.gpioResult != returnvalue::OK) {
sif::error << "Max31865RtdReader::periodicInitHandling: Manual CS lock failed" << std::endl; sif::error << "Max31865RtdReader::periodicInitHandling: Manual CS lock failed" << std::endl;
@ -95,13 +95,7 @@ bool Max31865RtdReader::periodicInitHandling() {
if (result != returnvalue::OK) { if (result != returnvalue::OK) {
handleSpiError(rtd, result, "clearFaultStatus"); handleSpiError(rtd, result, "clearFaultStatus");
} }
rtd->configured = true;
rtd->db.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; 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.setTimeout(MAX31865::WARMUP_MS);
rtdCookie->cd.resetTimer(); rtdCookie->cd.resetTimer();
rtdCookie->on = true; rtdCookie->on = true;
rtdCookie->active = false; rtdCookie->db.active = false;
rtdCookie->configured = false; rtdCookie->db.configured = false;
if (sendLen == 5) { if (sendLen == 5) {
thresholdHandler(rtdCookie, sendData); 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.setTimeout(MAX31865::WARMUP_MS);
rtdCookie->cd.resetTimer(); rtdCookie->cd.resetTimer();
rtdCookie->on = true; rtdCookie->on = true;
rtdCookie->active = true; rtdCookie->db.active = true;
rtdCookie->configured = false; rtdCookie->db.configured = false;
} else { } else {
rtdCookie->active = true; rtdCookie->db.active = true;
} }
if (sendLen == 5) { if (sendLen == 5) {
thresholdHandler(rtdCookie, sendData); thresholdHandler(rtdCookie, sendData);
@ -266,8 +260,8 @@ ReturnValue_t Max31865RtdReader::sendMessage(CookieIF* cookie, const uint8_t* se
} }
case (EiveMax31855::RtdCommands::OFF): { case (EiveMax31855::RtdCommands::OFF): {
rtdCookie->on = false; rtdCookie->on = false;
rtdCookie->active = false; rtdCookie->db.active = false;
rtdCookie->configured = false; rtdCookie->db.configured = false;
break; break;
} }
case (EiveMax31855::RtdCommands::HIGH_TRESHOLD): { case (EiveMax31855::RtdCommands::HIGH_TRESHOLD): {

View File

@ -23,8 +23,6 @@ struct Max31865ReaderCookie : public CookieIF {
Countdown cd = Countdown(MAX31865::WARMUP_MS); Countdown cd = Countdown(MAX31865::WARMUP_MS);
bool on = false; bool on = false;
bool configured = false;
bool active = false;
bool writeLowThreshold = false; bool writeLowThreshold = false;
bool writeHighThreshold = false; bool writeHighThreshold = false;
uint16_t lowThreshold = 0; uint16_t lowThreshold = 0;

View File

@ -86,8 +86,8 @@ void ObjectFactory::produceGenericObjects(HealthTableIF** healthTable_, PusTmFun
} }
{ {
PoolManager::LocalPoolConfig poolCfg = {{300, 16}, {300, 32}, {250, 64}, PoolManager::LocalPoolConfig poolCfg = {{300, 16}, {350, 32}, {350, 64},
{150, 128}, {120, 1024}, {120, 2048}}; {200, 128}, {150, 1024}, {150, 2048}};
tmStore = new PoolManager(objects::TM_STORE, poolCfg); tmStore = new PoolManager(objects::TM_STORE, poolCfg);
} }
@ -114,7 +114,7 @@ void ObjectFactory::produceGenericObjects(HealthTableIF** healthTable_, PusTmFun
tcpServer->enableWiretapping(true); tcpServer->enableWiretapping(true);
#endif /* OBSW_TCP_SERVER_WIRETAPPING == 1 */ #endif /* OBSW_TCP_SERVER_WIRETAPPING == 1 */
#endif /* OBSW_USE_TMTC_TCP_BRIDGE == 0 */ #endif /* OBSW_USE_TMTC_TCP_BRIDGE == 0 */
tcpIpTmtcBridge->setMaxNumberOfPacketsStored(300); tcpIpTmtcBridge->setMaxNumberOfPacketsStored(150);
#endif /* OBSW_ADD_TCPIP_BRIDGE == 1 */ #endif /* OBSW_ADD_TCPIP_BRIDGE == 1 */
auto* ccsdsDistrib = auto* ccsdsDistrib =

View File

@ -30,16 +30,13 @@ void Max31865EiveHandler::doStartUp() {
} }
void Max31865EiveHandler::doShutDown() { void Max31865EiveHandler::doShutDown() {
updatePeriodicReply(false, EiveMax31855::RtdCommands::EXCHANGE_SET_ID);
if (state == InternalState::NONE or state == InternalState::ACTIVE or if (state == InternalState::NONE or state == InternalState::ACTIVE or
state == InternalState::ON) { state == InternalState::ON) {
state = InternalState::INACTIVE; state = InternalState::INACTIVE;
transitionOk = false; transitionOk = false;
} else {
transitionOk = true;
} }
if (state == InternalState::INACTIVE and transitionOk) { 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) { if (getMode() == _MODE_START_UP and exchangeStruct.configured and state == InternalState::ON) {
transitionOk = true; 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 // Calculate resistance
float rtdValue = exchangeStruct.adcCode * EiveMax31855::RTD_RREF_PT1000 / INT16_MAX; float rtdValue = exchangeStruct.adcCode * EiveMax31855::RTD_RREF_PT1000 / INT16_MAX;
// calculate approximation // calculate approximation

View File

@ -34,7 +34,7 @@ ReturnValue_t VirtualChannel::performOperation() {
size_t size = 0; size_t size = 0;
result = tmStore->getData(storeId, &data, &size); result = tmStore->getData(storeId, &data, &size);
if (result != returnvalue::OK) { 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; << std::endl;
tmStore->deleteData(storeId); tmStore->deleteData(storeId);
return result; return result;