From 06fe113d7f91f63f57fb0ccb2bcbba02ab9b8717 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Fri, 7 Jul 2023 15:33:48 +0200 Subject: [PATCH 1/6] that should be sufficient --- bsp_q7s/boardconfig/busConf.h | 3 +++ bsp_q7s/em/emObjectFactory.cpp | 4 +++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/bsp_q7s/boardconfig/busConf.h b/bsp_q7s/boardconfig/busConf.h index 146386c4..dc3779a7 100644 --- a/bsp_q7s/boardconfig/busConf.h +++ b/bsp_q7s/boardconfig/busConf.h @@ -12,6 +12,9 @@ static constexpr char SPI_RW_DEV[] = "/dev/spi_rw"; static constexpr char I2C_PL_EIVE[] = "/dev/i2c_pl"; //! I2C bus using the I2C peripheral of the ARM processing system (PS) static constexpr char I2C_PS_EIVE[] = "/dev/i2c_ps"; +//! I2C bus using the first I2C peripheral of the ARM processing system (PS). +//! Named like this because it is used by default for the Q7 devices. +static constexpr char I2C_Q7_EIVE[] = "/dev/i2c_q7"; static constexpr char UART_GNSS_DEV[] = "/dev/gps0"; static constexpr char UART_PLOC_MPSOC_DEV[] = "/dev/ul_plmpsoc"; diff --git a/bsp_q7s/em/emObjectFactory.cpp b/bsp_q7s/em/emObjectFactory.cpp index 085d5184..58b9a7f9 100644 --- a/bsp_q7s/em/emObjectFactory.cpp +++ b/bsp_q7s/em/emObjectFactory.cpp @@ -69,8 +69,10 @@ void ObjectFactory::produce(void* args) { {objects::TMP1075_HANDLER_IF_BOARD, addresses::TMP1075_IF_BOARD}, }}; const char* tmpI2cDev = q7s::I2C_PS_EIVE; - if (core::FW_VERSION_MAJOR >= 4) { + if (core::FW_VERSION_MAJOR == 4) { tmpI2cDev = q7s::I2C_PL_EIVE; + } else if(core::FW_VERSION_MAJOR >= 5) { + tmpI2cDev = q7s::I2C_Q7_EIVE; } createTmpComponents(tmpDevsToAdd, tmpI2cDev); dummy::Tmp1075Cfg tmpCfg{}; From a351dcf99e46ccfa1c2a7e9cbb5de6f51701ec61 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Fri, 7 Jul 2023 15:59:15 +0200 Subject: [PATCH 2/6] changelog --- CHANGELOG.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 709436f5..77862553 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -24,6 +24,8 @@ will consitute of a breaking change warranting a new major release: runtime now. This makes it possible to check the firmware version earlier. - The TCS controller will now always command heaters OFF when being blind for thermal components (no sensors available), irrespective of current switch state. +- Make OBSW compatible to prospective FW version v5.0.0, where the Q7 I2C devices were + moved to a PL I2C block and the TMP sensor devices were moved to the PS I2C0. ## Fixed From 647f3d00bbcc5845fd1496c6621a1394ab968609 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Mon, 10 Jul 2023 11:03:17 +0200 Subject: [PATCH 3/6] this should do the job --- bsp_q7s/em/emObjectFactory.cpp | 8 +------- bsp_q7s/fmObjectFactory.cpp | 7 ++----- bsp_q7s/objectFactory.cpp | 10 ++++++++-- bsp_q7s/objectFactory.h | 3 +-- 4 files changed, 12 insertions(+), 16 deletions(-) diff --git a/bsp_q7s/em/emObjectFactory.cpp b/bsp_q7s/em/emObjectFactory.cpp index 58b9a7f9..a7b05e3d 100644 --- a/bsp_q7s/em/emObjectFactory.cpp +++ b/bsp_q7s/em/emObjectFactory.cpp @@ -68,13 +68,7 @@ void ObjectFactory::produce(void* args) { {objects::TMP1075_HANDLER_PLPCDU_1, addresses::TMP1075_PLPCDU_1}, {objects::TMP1075_HANDLER_IF_BOARD, addresses::TMP1075_IF_BOARD}, }}; - const char* tmpI2cDev = q7s::I2C_PS_EIVE; - if (core::FW_VERSION_MAJOR == 4) { - tmpI2cDev = q7s::I2C_PL_EIVE; - } else if(core::FW_VERSION_MAJOR >= 5) { - tmpI2cDev = q7s::I2C_Q7_EIVE; - } - createTmpComponents(tmpDevsToAdd, tmpI2cDev); + createTmpComponents(tmpDevsToAdd); dummy::Tmp1075Cfg tmpCfg{}; tmpCfg.addTcsBrd0 = true; tmpCfg.addTcsBrd1 = true; diff --git a/bsp_q7s/fmObjectFactory.cpp b/bsp_q7s/fmObjectFactory.cpp index 5e2cdb59..e43e3551 100644 --- a/bsp_q7s/fmObjectFactory.cpp +++ b/bsp_q7s/fmObjectFactory.cpp @@ -77,11 +77,8 @@ void ObjectFactory::produce(void* args) { // {objects::TMP1075_HANDLER_PLPCDU_1, addresses::TMP1075_PLPCDU_1}, {objects::TMP1075_HANDLER_IF_BOARD, addresses::TMP1075_IF_BOARD}, }}; - const char* tmpI2cDev = q7s::I2C_PS_EIVE; - if (core::FW_VERSION_MAJOR >= 4) { - tmpI2cDev = q7s::I2C_PL_EIVE; - } - createTmpComponents(tmpDevsToAdd, tmpI2cDev); + + createTmpComponents(tmpDevsToAdd); #endif createSolarArrayDeploymentComponents(*pwrSwitcher, *gpioComIF); createPlPcduComponents(gpioComIF, spiMainComIF, pwrSwitcher, *stackHandler); diff --git a/bsp_q7s/objectFactory.cpp b/bsp_q7s/objectFactory.cpp index a96051f2..c18a48a6 100644 --- a/bsp_q7s/objectFactory.cpp +++ b/bsp_q7s/objectFactory.cpp @@ -161,8 +161,14 @@ void Factory::setStaticFrameworkObjectIds() { void ObjectFactory::setStatics() { Factory::setStaticFrameworkObjectIds(); } -void ObjectFactory::createTmpComponents(std::vector> tmpDevsToAdd, - const char* i2cDev) { +void ObjectFactory::createTmpComponents( + std::vector> tmpDevsToAdd) { + const char* tmpI2cDev = q7s::I2C_PS_EIVE; + if (core::FW_VERSION_MAJOR == 4) { + tmpI2cDev = q7s::I2C_PL_EIVE; + } else if (core::FW_VERSION_MAJOR >= 5) { + tmpI2cDev = q7s::I2C_Q7_EIVE; + } std::vector tmpDevCookies; for (size_t idx = 0; idx < tmpDevsToAdd.size(); idx++) { diff --git a/bsp_q7s/objectFactory.h b/bsp_q7s/objectFactory.h index 779ad204..491720ac 100644 --- a/bsp_q7s/objectFactory.h +++ b/bsp_q7s/objectFactory.h @@ -58,8 +58,7 @@ void createPcduComponents(LinuxLibgpioIF* gpioComIF, PowerSwitchIF** pwrSwitcher bool enableHkSets); void createPlPcduComponents(LinuxLibgpioIF* gpioComIF, SpiComIF* spiComIF, PowerSwitchIF* pwrSwitcher, Stack5VHandler& stackHandler); -void createTmpComponents(std::vector> tmpDevsToAdd, - const char* i2cDev); +void createTmpComponents(std::vector> tmpDevsToAdd); void createRadSensorChipSelect(LinuxLibgpioIF* gpioIF); ReturnValue_t createRadSensorComponent(LinuxLibgpioIF* gpioComIF, Stack5VHandler& handler); void createAcsBoardGpios(GpioCookie& cookie); From 268f10ced5dacf242c086db8a088dae6cc3312ec Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Mon, 10 Jul 2023 11:14:19 +0200 Subject: [PATCH 4/6] COMPILE --- bsp_q7s/objectFactory.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bsp_q7s/objectFactory.cpp b/bsp_q7s/objectFactory.cpp index c18a48a6..e6ae6603 100644 --- a/bsp_q7s/objectFactory.cpp +++ b/bsp_q7s/objectFactory.cpp @@ -173,7 +173,7 @@ void ObjectFactory::createTmpComponents( for (size_t idx = 0; idx < tmpDevsToAdd.size(); idx++) { tmpDevCookies.push_back( - new I2cCookie(tmpDevsToAdd[idx].second, TMP1075::MAX_REPLY_LENGTH, i2cDev)); + new I2cCookie(tmpDevsToAdd[idx].second, TMP1075::MAX_REPLY_LENGTH, tmpI2cDev)); auto* tmpDevHandler = new Tmp1075Handler(tmpDevsToAdd[idx].first, objects::I2C_COM_IF, tmpDevCookies[idx]); tmpDevHandler->setCustomFdir(new TmpDevFdir(tmpDevsToAdd[idx].first)); From 33de08eafc010e78c6c5caa7751801f68adea39f Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Mon, 10 Jul 2023 13:28:36 +0200 Subject: [PATCH 5/6] this should be better --- dummies/TemperatureSensorInserter.cpp | 9 ++++++++- dummies/TemperatureSensorInserter.h | 1 + mission/controller/ThermalController.cpp | 22 ++++++++++++++-------- mission/controller/ThermalController.h | 5 +++-- 4 files changed, 26 insertions(+), 11 deletions(-) diff --git a/dummies/TemperatureSensorInserter.cpp b/dummies/TemperatureSensorInserter.cpp index dc94195e..43065b83 100644 --- a/dummies/TemperatureSensorInserter.cpp +++ b/dummies/TemperatureSensorInserter.cpp @@ -15,7 +15,7 @@ TemperatureSensorInserter::TemperatureSensorInserter( tmp1075DummyMap(std::move(tempTmpSensorDummies_)) {} ReturnValue_t TemperatureSensorInserter::initialize() { - testCase = TestCase::NONE; + testCase = TestCase::COLD_PLOC_STAYS_COLD; return returnvalue::OK; } @@ -126,6 +126,13 @@ ReturnValue_t TemperatureSensorInserter::performOperation(uint8_t opCode) { sif::debug << "Setting CAM temperature back to normal" << std::endl; max31865DummyMap[objects::RTD_2_IC5_4K_CAMERA]->setTemperature(0, true); } + break; + } + case (TestCase::COLD_PLOC_STAYS_COLD): { + if (cycles == 15) { + sif::debug << "Setting cold PLOC temperature" << std::endl; + max31865DummyMap[objects::RTD_0_IC3_PLOC_HEATSPREADER]->setTemperature(-40, true); + } } } cycles++; diff --git a/dummies/TemperatureSensorInserter.h b/dummies/TemperatureSensorInserter.h index 006b0639..9da83bc9 100644 --- a/dummies/TemperatureSensorInserter.h +++ b/dummies/TemperatureSensorInserter.h @@ -33,6 +33,7 @@ class TemperatureSensorInserter : public ExecutableObjectIF, public SystemObject COLD_STR_CONSECUTIVE = 5, COLD_CAMERA = 6, COLD_PLOC_CONSECUTIVE = 7, + COLD_PLOC_STAYS_COLD = 8 }; int iteration = 0; uint32_t cycles = 0; diff --git a/mission/controller/ThermalController.cpp b/mission/controller/ThermalController.cpp index b0f0f9d1..acfa8568 100644 --- a/mission/controller/ThermalController.cpp +++ b/mission/controller/ThermalController.cpp @@ -1791,9 +1791,10 @@ void ThermalController::heaterMaxDurationControl(const HeaterSwitchStates& curre heaterStates[i].switchTransition = false; heaterStates[i].heaterSwitchControlCycles = 0; heaterStates[i].trackHeaterMaxPeriod = false; - heaterHandler.switchHeater(static_cast(i), HeaterHandler::SwitchState::OFF); triggerEvent(tcsCtrl::TCS_HEATER_MAX_BURN_TIME_REACHED, static_cast(i), MAX_HEATER_ON_DURATIONS_MS[i]); + heaterSwitchHelper(static_cast(i), HeaterHandler::SwitchState::OFF, + std::nullopt); // The heater might still be one for some thermal components, so cross-check // those components crossCheckHeaterStateOfComponentsWhenHeaterGoesOff(static_cast(i)); @@ -1847,23 +1848,28 @@ void ThermalController::resetThermalStates() { void ThermalController::heaterSwitchHelper(heater::Switch switchNr, HeaterHandler::SwitchState targetState, - unsigned componentIdx) { + std::optional componentIdx) { timeval currentTime; Clock::getClockMonotonic(¤tTime); if (targetState == HeaterHandler::SwitchState::ON) { heaterHandler.switchHeater(switchNr, targetState); heaterStates[switchNr].target = HeaterHandler::SwitchState::ON; heaterStates[switchNr].switchTransition = true; - thermalStates[componentIdx].sensorIndex = currentSensorIndex; - thermalStates[componentIdx].heaterSwitch = switchNr; - thermalStates[componentIdx].heating = true; - thermalStates[componentIdx].heaterStartTime = currentTime.tv_sec; + if (componentIdx.has_value()) { + unsigned componentIdxVal = componentIdx.value(); + thermalStates[componentIdxVal].sensorIndex = currentSensorIndex; + thermalStates[componentIdxVal].heaterSwitch = switchNr; + thermalStates[componentIdxVal].heating = true; + thermalStates[componentIdxVal].heaterStartTime = currentTime.tv_sec; + } triggerEvent(tcsCtrl::TCS_SWITCHING_HEATER_ON, static_cast(currThermalComponent), static_cast(switchNr)); } else { heaterHandler.switchHeater(switchNr, targetState); - thermalStates[componentIdx].heating = false; - thermalStates[componentIdx].heaterEndTime = currentTime.tv_sec; + if (componentIdx.has_value()) { + thermalStates[componentIdx.value()].heating = false; + thermalStates[componentIdx.value()].heaterEndTime = currentTime.tv_sec; + } triggerEvent(tcsCtrl::TCS_SWITCHING_HEATER_OFF, static_cast(currThermalComponent), static_cast(switchNr)); } diff --git a/mission/controller/ThermalController.h b/mission/controller/ThermalController.h index 74e06cf5..7ba86487 100644 --- a/mission/controller/ThermalController.h +++ b/mission/controller/ThermalController.h @@ -24,6 +24,7 @@ #include #include +#include /** * NOP Limit: Hard limit for device, usually from datasheet. Device damage is possible lif NOP limit @@ -110,7 +111,7 @@ class ThermalController : public ExtendedControllerBase { // 1 hour static constexpr uint32_t DEFAULT_MAX_HEATER_ON_DURATION_MS = 60 * 60 * 1000; static constexpr uint32_t MAX_HEATER_ON_DURATIONS_MS[8] = {// PLOC PROC board - DEFAULT_MAX_HEATER_ON_DURATION_MS, + 60 * 1000, // PCDU PDU DEFAULT_MAX_HEATER_ON_DURATION_MS, // ACS Board @@ -347,7 +348,7 @@ class ThermalController : public ExtendedControllerBase { void heaterSwitchHelperAllOff(); void heaterSwitchHelper(heater::Switch switchNr, HeaterHandler::SwitchState state, - unsigned componentIdx); + std::optional componentIdx); void ctrlAcsBoard(); void ctrlMgt(); From ce2755e161f3a0525d12be0c7e26d84e81a3b5a0 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Mon, 10 Jul 2023 13:56:30 +0200 Subject: [PATCH 6/6] that should be it --- dummies/TemperatureSensorInserter.cpp | 10 +++++++++- dummies/TemperatureSensorInserter.h | 3 ++- mission/controller/ThermalController.cpp | 2 -- mission/controller/ThermalController.h | 2 +- 4 files changed, 12 insertions(+), 5 deletions(-) diff --git a/dummies/TemperatureSensorInserter.cpp b/dummies/TemperatureSensorInserter.cpp index 43065b83..bce48606 100644 --- a/dummies/TemperatureSensorInserter.cpp +++ b/dummies/TemperatureSensorInserter.cpp @@ -15,7 +15,7 @@ TemperatureSensorInserter::TemperatureSensorInserter( tmp1075DummyMap(std::move(tempTmpSensorDummies_)) {} ReturnValue_t TemperatureSensorInserter::initialize() { - testCase = TestCase::COLD_PLOC_STAYS_COLD; + testCase = TestCase::COLD_CAMERA_STAYS_COLD; return returnvalue::OK; } @@ -133,6 +133,14 @@ ReturnValue_t TemperatureSensorInserter::performOperation(uint8_t opCode) { sif::debug << "Setting cold PLOC temperature" << std::endl; max31865DummyMap[objects::RTD_0_IC3_PLOC_HEATSPREADER]->setTemperature(-40, true); } + break; + } + case (TestCase::COLD_CAMERA_STAYS_COLD): { + if (cycles == 15) { + sif::debug << "Setting cold PLOC temperature" << std::endl; + max31865DummyMap[objects::RTD_2_IC5_4K_CAMERA]->setTemperature(-40, true); + } + break; } } cycles++; diff --git a/dummies/TemperatureSensorInserter.h b/dummies/TemperatureSensorInserter.h index 9da83bc9..9ca3c936 100644 --- a/dummies/TemperatureSensorInserter.h +++ b/dummies/TemperatureSensorInserter.h @@ -33,7 +33,8 @@ class TemperatureSensorInserter : public ExecutableObjectIF, public SystemObject COLD_STR_CONSECUTIVE = 5, COLD_CAMERA = 6, COLD_PLOC_CONSECUTIVE = 7, - COLD_PLOC_STAYS_COLD = 8 + COLD_PLOC_STAYS_COLD = 8, + COLD_CAMERA_STAYS_COLD = 9 }; int iteration = 0; uint32_t cycles = 0; diff --git a/mission/controller/ThermalController.cpp b/mission/controller/ThermalController.cpp index acfa8568..7451e684 100644 --- a/mission/controller/ThermalController.cpp +++ b/mission/controller/ThermalController.cpp @@ -1798,8 +1798,6 @@ void ThermalController::heaterMaxDurationControl(const HeaterSwitchStates& curre // The heater might still be one for some thermal components, so cross-check // those components crossCheckHeaterStateOfComponentsWhenHeaterGoesOff(static_cast(i)); - } else if (currentHeaterStates[i] == HeaterHandler::SwitchState::OFF) { - heaterStates[i].heaterOnPeriod.resetTimer(); } } } diff --git a/mission/controller/ThermalController.h b/mission/controller/ThermalController.h index 7ba86487..9399cab1 100644 --- a/mission/controller/ThermalController.h +++ b/mission/controller/ThermalController.h @@ -111,7 +111,7 @@ class ThermalController : public ExtendedControllerBase { // 1 hour static constexpr uint32_t DEFAULT_MAX_HEATER_ON_DURATION_MS = 60 * 60 * 1000; static constexpr uint32_t MAX_HEATER_ON_DURATIONS_MS[8] = {// PLOC PROC board - 60 * 1000, + DEFAULT_MAX_HEATER_ON_DURATION_MS, // PCDU PDU DEFAULT_MAX_HEATER_ON_DURATION_MS, // ACS Board