From be1c26ddf7f1fe43bc259ce3ffa93e5d8c75f404 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Fri, 13 May 2022 01:17:23 +0200 Subject: [PATCH] rtd testing --- linux/ObjectFactory.cpp | 16 ++++++++--- linux/devices/Max31865RtdLowlevelHandler.cpp | 8 +++++- mission/devices/Max31865EiveHandler.cpp | 6 ++++- mission/devices/Max31865PT1000Handler.cpp | 28 ++++++++++---------- 4 files changed, 38 insertions(+), 20 deletions(-) diff --git a/linux/ObjectFactory.cpp b/linux/ObjectFactory.cpp index 0e24b5fc..69a67340 100644 --- a/linux/ObjectFactory.cpp +++ b/linux/ObjectFactory.cpp @@ -297,6 +297,12 @@ void ObjectFactory::createRtdComponents(std::string spiDev, GpioIF* gpioComIF, new Max31865PT1000Handler(rtdInfos[idx].first, objects::SPI_MAIN_COM_IF, rtdCookies[idx]); rtds[idx] = typedHandler; typedHandler->setDeviceInfo(idx + 3, rtdInfos[idx].second); +#if OBSW_DEBUG_RTD == 1 + typedHandler->setDebugMode(true); +#endif +#if OBSW_TEST_RTD == 1 + typedHandler->setInstantNormal(true); +#endif }; auto lowLevelRtdsCreator = [&](uint8_t idx) { Max31865ReaderCookie* rtdLowLevelCookie = @@ -305,6 +311,12 @@ void ObjectFactory::createRtdComponents(std::string spiDev, GpioIF* gpioComIF, new Max31865EiveHandler(rtdInfos[idx].first, objects::SPI_RTD_COM_IF, rtdLowLevelCookie); rtds[idx] = typedHandler; typedHandler->setDeviceInfo(idx, rtdInfos[idx].second); +#if OBSW_DEBUG_RTD == 1 + // typedHandler->setDebugMode(true); +#endif +#if OBSW_TEST_RTD == 1 + typedHandler->setInstantNormal(true); +#endif }; for (uint8_t idx = 0; idx < NUM_RTDS; idx++) { rtdCookies[idx] = new SpiCookie(cookieArgs[idx].first, cookieArgs[idx].second, @@ -317,12 +329,8 @@ void ObjectFactory::createRtdComponents(std::string spiDev, GpioIF* gpioComIF, rtds[idx]->setParent(objects::TCS_BOARD_ASS); rtdFdir = new RtdFdir(rtdInfos[idx].first); rtds[idx]->setCustomFdir(rtdFdir); -#if OBSW_DEBUG_RTD == 1 - rtds[idx]->setDebugMode(true); -#endif #if OBSW_TEST_RTD == 1 rtds[idx]->setStartUpImmediately(); - rtds[idx]->setInstantNormal(true); #endif // OBSW_TEST_RTD == 1 } diff --git a/linux/devices/Max31865RtdLowlevelHandler.cpp b/linux/devices/Max31865RtdLowlevelHandler.cpp index 75503a94..9a1c1539 100644 --- a/linux/devices/Max31865RtdLowlevelHandler.cpp +++ b/linux/devices/Max31865RtdLowlevelHandler.cpp @@ -54,7 +54,8 @@ bool Max31865RtdReader::periodicInitHandling() { if (rtd == nullptr) { continue; } - if (rtd->on and not rtd->configured) { + if ((rtd->on or rtd->active) and not rtd->configured) { + sif::debug << "crap1" << std::endl; if (rtd->cd.hasTimedOut()) { uint8_t cfg = (Bias::OFF << CfgBitPos::BIAS_SEL) | (Wires::FOUR_WIRE << CfgBitPos::WIRE_SEL) | @@ -117,7 +118,9 @@ void Max31865RtdReader::periodicReadReqHandling() { if (rtd == nullptr) { continue; } + sif::debug << "crap2" << std::endl; if (rtdIsActive(rtd->idx)) { + sif::debug << "crap3" << std::endl; uint8_t currentCfg = 0; auto result = readCfgReg(rtd->spiCookie, currentCfg); if (result != RETURN_OK) { @@ -151,6 +154,9 @@ void Max31865RtdReader::periodicReadHandling() { handleSpiError(rtd, result, "readRtdVal"); continue; } + if(rtd->idx == 0) { + sif::debug << "Read RAW rtd val 0: " << rtdVal << std::endl; + } if (faultBitSet) { rtd->db.faultBitSet = faultBitSet; } diff --git a/mission/devices/Max31865EiveHandler.cpp b/mission/devices/Max31865EiveHandler.cpp index 5b837317..9d7ff441 100644 --- a/mission/devices/Max31865EiveHandler.cpp +++ b/mission/devices/Max31865EiveHandler.cpp @@ -103,7 +103,10 @@ void Max31865EiveHandler::doTransition(Mode_t modeFrom, Submode_t subModeFrom) { } void Max31865EiveHandler::fillCommandAndReplyMap() { - insertInReplyMap(EiveMax31855::RtdCommands::EXCHANGE_SET_ID, 2, &sensorDataset); + insertInCommandMap(EiveMax31855::RtdCommands::ON); + insertInCommandMap(EiveMax31855::RtdCommands::ACTIVE); + insertInCommandMap(EiveMax31855::RtdCommands::OFF); + insertInReplyMap(EiveMax31855::RtdCommands::EXCHANGE_SET_ID, 2, &sensorDataset, 0, true); } ReturnValue_t Max31865EiveHandler::scanForReply(const uint8_t* start, size_t remainingSize, @@ -116,6 +119,7 @@ ReturnValue_t Max31865EiveHandler::scanForReply(const uint8_t* start, size_t rem } *foundId = EiveMax31855::RtdCommands::EXCHANGE_SET_ID; *foundLen = remainingSize; + sif::info << "Max31865EiveHandler::scanForReply: Reply size " << remainingSize << std::endl; return RETURN_OK; } diff --git a/mission/devices/Max31865PT1000Handler.cpp b/mission/devices/Max31865PT1000Handler.cpp index c65a3464..7c8dbfec 100644 --- a/mission/devices/Max31865PT1000Handler.cpp +++ b/mission/devices/Max31865PT1000Handler.cpp @@ -441,20 +441,20 @@ ReturnValue_t Max31865PT1000Handler::interpretDeviceReply(DeviceCommandId_t id, } case (MAX31865::REQUEST_FAULT_BYTE): { faultByte = packet[1]; -#if OBSW_VERBOSE_LEVEL >= 1 -#if FSFW_CPP_OSTREAM_ENABLED == 1 - sif::warning << "Max31865PT1000Handler::interpretDeviceReply: Object ID: " << std::hex - << this->getObjectId() - << ": Fault byte" - " is: 0b" - << std::bitset<8>(faultByte) << std::endl; -#else - sif::printWarning( - "Max31865PT1000Handler::interpretDeviceReply: Fault byte" - " is: 0b" BYTE_TO_BINARY_PATTERN "\n", - BYTE_TO_BINARY(faultByte)); -#endif -#endif +//#if OBSW_VERBOSE_LEVEL >= 1 +//#if FSFW_CPP_OSTREAM_ENABLED == 1 +// sif::warning << "Max31865PT1000Handler::interpretDeviceReply: Object ID: " << std::hex +// << this->getObjectId() +// << ": Fault byte" +// " is: 0b" +// << std::bitset<8>(faultByte) << std::endl; +//#else +// sif::printWarning( +// "Max31865PT1000Handler::interpretDeviceReply: Fault byte" +// " is: 0b" BYTE_TO_BINARY_PATTERN "\n", +// BYTE_TO_BINARY(faultByte)); +//#endif +//#endif ReturnValue_t result = sensorDataset.read(); if (result != HasReturnvaluesIF::RETURN_OK) { // Configuration error