diff --git a/CHANGELOG.md b/CHANGELOG.md index 56cf7e33..d67d6130 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -28,6 +28,9 @@ list yields a list of all related PRs for each release. was adapted to burn each channel for half of the burn time by default. PR: https://egit.irs.uni-stuttgart.de/eive/eive-obsw/pulls/347 TMTC PR: https://egit.irs.uni-stuttgart.de/eive/eive-tmtc/pulls/127 +- `Max31865RtdLowlevelHandler.cpp`: For each RTD device, the config is now re-written before + every read. This seems to fix some issue with invalid temperature sensor readings. + PR: https://egit.irs.uni-stuttgart.de/eive/eive-obsw/pulls/345 ## Fixed diff --git a/linux/devices/Max31865RtdLowlevelHandler.cpp b/linux/devices/Max31865RtdLowlevelHandler.cpp index 38a9ac11..14ef9659 100644 --- a/linux/devices/Max31865RtdLowlevelHandler.cpp +++ b/linux/devices/Max31865RtdLowlevelHandler.cpp @@ -143,7 +143,7 @@ ReturnValue_t Max31865RtdReader::periodicReadHandling() { auto result = returnvalue::OK; MutexGuard mg(readerMutex); if (mg.getLockResult() != returnvalue::OK) { - sif::warning << "Max31865RtdReader::periodicReadReqHandling: Mutex lock failed" << std::endl; + sif::warning << "Max31865RtdReader::periodicReadHandling: Mutex lock failed" << std::endl; return returnvalue::FAILED; } // Now read the RTD values @@ -154,6 +154,10 @@ ReturnValue_t Max31865RtdReader::periodicReadHandling() { if (rtdIsActive(rtd->idx)) { uint16_t rtdVal = 0; bool faultBitSet = false; + result = writeCfgReg(rtd->spiCookie, BASE_CFG); + if (result != returnvalue::OK) { + handleSpiError(rtd, result, "writeCfgReg"); + } result = readRtdVal(rtd->spiCookie, rtdVal, faultBitSet); if (result != returnvalue::OK) { handleSpiError(rtd, result, "readRtdVal"); @@ -282,7 +286,13 @@ ReturnValue_t Max31865RtdReader::sendMessage(CookieIF* cookie, const uint8_t* se } break; } - case (EiveMax31855::RtdCommands::CFG): + case (EiveMax31855::RtdCommands::CFG): { + ReturnValue_t result = writeCfgReg(rtdCookie->spiCookie, BASE_CFG); + if (result != returnvalue::OK) { + handleSpiError(rtdCookie, result, "writeCfgReg"); + } + break; + } default: { // TODO: Only implement if needed break; diff --git a/linux/ipcore/PdecConfig.cpp b/linux/ipcore/PdecConfig.cpp index 321e5940..21de4610 100644 --- a/linux/ipcore/PdecConfig.cpp +++ b/linux/ipcore/PdecConfig.cpp @@ -9,8 +9,12 @@ PdecConfig::~PdecConfig() {} void PdecConfig::initialize() { uint32_t word = 0; word |= (VERSION_ID << 30); + + // Setting the bypass flag and the control command flag should not have any + // implication on the operation of the PDEC IP Core word |= (BYPASS_FLAG << 29); word |= (CONTROL_COMMAND_FLAG << 28); + word |= (RESERVED_FIELD_A << 26); word |= (SPACECRAFT_ID << 16); word |= (VIRTUAL_CHANNEL << 10); diff --git a/mission/devices/Max31865EiveHandler.cpp b/mission/devices/Max31865EiveHandler.cpp index db6f5a83..433f7b58 100644 --- a/mission/devices/Max31865EiveHandler.cpp +++ b/mission/devices/Max31865EiveHandler.cpp @@ -69,7 +69,8 @@ ReturnValue_t Max31865EiveHandler::buildCommandFromCommand(DeviceCommandId_t dev switch (cmdTyped) { case (EiveMax31855::RtdCommands::ON): case (EiveMax31855::RtdCommands::ACTIVE): - case (EiveMax31855::RtdCommands::OFF): { + case (EiveMax31855::RtdCommands::OFF): + case (EiveMax31855::RtdCommands::CFG): { simpleCommand(cmdTyped); break; } @@ -77,9 +78,6 @@ ReturnValue_t Max31865EiveHandler::buildCommandFromCommand(DeviceCommandId_t dev case (EiveMax31855::RtdCommands::HIGH_TRESHOLD): { break; } - case (EiveMax31855::RtdCommands::CFG): { - break; - } default: return NOTHING_TO_SEND; } @@ -100,6 +98,7 @@ void Max31865EiveHandler::simpleCommand(EiveMax31855::RtdCommands cmd) { rawPacket = cmdBuf.data(); rawPacketLen = 1; } + void Max31865EiveHandler::doTransition(Mode_t modeFrom, Submode_t subModeFrom) { if (getMode() == _MODE_TO_NORMAL) { if (state != InternalState::ACTIVE) { @@ -117,6 +116,7 @@ void Max31865EiveHandler::fillCommandAndReplyMap() { insertInCommandMap(EiveMax31855::RtdCommands::ON); insertInCommandMap(EiveMax31855::RtdCommands::ACTIVE); insertInCommandMap(EiveMax31855::RtdCommands::OFF); + insertInCommandMap(EiveMax31855::RtdCommands::CFG); insertInReplyMap(EiveMax31855::RtdCommands::EXCHANGE_SET_ID, 200, &sensorDataset, 0, true); }