From 1b919ceaeceaed21e6873565f7c22e1397737553 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Fri, 16 Jun 2023 13:54:50 +0200 Subject: [PATCH 01/16] swap i2cs --- bsp_q7s/core/ObjectFactory.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/bsp_q7s/core/ObjectFactory.cpp b/bsp_q7s/core/ObjectFactory.cpp index 54084089..e13da256 100644 --- a/bsp_q7s/core/ObjectFactory.cpp +++ b/bsp_q7s/core/ObjectFactory.cpp @@ -164,7 +164,7 @@ void ObjectFactory::createTmpComponents() { for (size_t idx = 0; idx < tmpDevIds.size(); idx++) { tmpDevCookies.push_back( - new I2cCookie(tmpDevIds[idx].second, TMP1075::MAX_REPLY_LENGTH, q7s::I2C_PS_EIVE)); + new I2cCookie(tmpDevIds[idx].second, TMP1075::MAX_REPLY_LENGTH, q7s::I2C_PL_EIVE)); auto* tmpDevHandler = new Tmp1075Handler(tmpDevIds[idx].first, objects::I2C_COM_IF, tmpDevCookies[idx]); tmpDevHandler->setCustomFdir(new TmpDevFdir(tmpDevIds[idx].first)); @@ -959,7 +959,7 @@ void ObjectFactory::createImtqComponents(PowerSwitchIF* pwrSwitcher, bool enable imtqAssy->connectModeTreeParent(satsystem::acs::ACS_SUBSYSTEM); new ImtqPollingTask(objects::IMTQ_POLLING, I2C_FATAL_ERRORS); - I2cCookie* imtqI2cCookie = new I2cCookie(addresses::IMTQ, imtq::MAX_REPLY_SIZE, q7s::I2C_PL_EIVE); + I2cCookie* imtqI2cCookie = new I2cCookie(addresses::IMTQ, imtq::MAX_REPLY_SIZE, q7s::I2C_PS_EIVE); auto imtqHandler = new ImtqHandler(objects::IMTQ_HANDLER, objects::IMTQ_POLLING, imtqI2cCookie, power::Switches::PDU1_CH3_MGT_5V, enableHkSets); imtqHandler->enableThermalModule(ThermalStateCfg()); @@ -976,7 +976,7 @@ void ObjectFactory::createImtqComponents(PowerSwitchIF* pwrSwitcher, bool enable } void ObjectFactory::createBpxBatteryComponent(bool enableHkSets) { - I2cCookie* bpxI2cCookie = new I2cCookie(addresses::BPX_BATTERY, 100, q7s::I2C_PL_EIVE); + I2cCookie* bpxI2cCookie = new I2cCookie(addresses::BPX_BATTERY, 100, q7s::I2C_PS_EIVE); BpxBatteryHandler* bpxHandler = new BpxBatteryHandler( objects::BPX_BATT_HANDLER, objects::I2C_COM_IF, bpxI2cCookie, enableHkSets); bpxHandler->setStartUpImmediately(); From d6dd943ebfd84dbe25e5576aa01b828bb8b25f20 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Sat, 17 Jun 2023 15:28:05 +0200 Subject: [PATCH 02/16] tmp is back in the house --- bsp_q7s/core/ObjectFactory.cpp | 19 ++----- bsp_q7s/core/ObjectFactory.h | 2 +- bsp_q7s/core/scheduling.cpp | 11 +++- bsp_q7s/em/emObjectFactory.cpp | 9 +++ bsp_q7s/fmObjectFactory.cpp | 10 +++- mission/pollingSeqTables.cpp | 101 +++++++++++++++++++-------------- mission/pollingSeqTables.h | 12 +++- tmtc | 2 +- 8 files changed, 104 insertions(+), 62 deletions(-) diff --git a/bsp_q7s/core/ObjectFactory.cpp b/bsp_q7s/core/ObjectFactory.cpp index e13da256..371d4c6d 100644 --- a/bsp_q7s/core/ObjectFactory.cpp +++ b/bsp_q7s/core/ObjectFactory.cpp @@ -151,23 +151,16 @@ void Factory::setStaticFrameworkObjectIds() { void ObjectFactory::setStatics() { Factory::setStaticFrameworkObjectIds(); } -void ObjectFactory::createTmpComponents() { - std::vector> tmpDevIds = {{ - {objects::TMP1075_HANDLER_TCS_0, addresses::TMP1075_TCS_0}, - {objects::TMP1075_HANDLER_TCS_1, addresses::TMP1075_TCS_1}, - {objects::TMP1075_HANDLER_PLPCDU_0, addresses::TMP1075_PLPCDU_0}, - // damaged - // {objects::TMP1075_HANDLER_PLPCDU_1, addresses::TMP1075_PLPCDU_1}, - {objects::TMP1075_HANDLER_IF_BOARD, addresses::TMP1075_IF_BOARD}, - }}; +void ObjectFactory::createTmpComponents( + std::vector> tmpDevsToAdd) { std::vector tmpDevCookies; - for (size_t idx = 0; idx < tmpDevIds.size(); idx++) { + for (size_t idx = 0; idx < tmpDevsToAdd.size(); idx++) { tmpDevCookies.push_back( - new I2cCookie(tmpDevIds[idx].second, TMP1075::MAX_REPLY_LENGTH, q7s::I2C_PL_EIVE)); + new I2cCookie(tmpDevsToAdd[idx].second, TMP1075::MAX_REPLY_LENGTH, q7s::I2C_PL_EIVE)); auto* tmpDevHandler = - new Tmp1075Handler(tmpDevIds[idx].first, objects::I2C_COM_IF, tmpDevCookies[idx]); - tmpDevHandler->setCustomFdir(new TmpDevFdir(tmpDevIds[idx].first)); + new Tmp1075Handler(tmpDevsToAdd[idx].first, objects::I2C_COM_IF, tmpDevCookies[idx]); + tmpDevHandler->setCustomFdir(new TmpDevFdir(tmpDevsToAdd[idx].first)); tmpDevHandler->connectModeTreeParent(satsystem::tcs::SUBSYSTEM); // TODO: Remove this after TCS subsystem was added // These devices are connected to the 3V3 stack and should be powered permanently. Therefore, diff --git a/bsp_q7s/core/ObjectFactory.h b/bsp_q7s/core/ObjectFactory.h index a2edec4c..25d06090 100644 --- a/bsp_q7s/core/ObjectFactory.h +++ b/bsp_q7s/core/ObjectFactory.h @@ -58,7 +58,7 @@ void createPcduComponents(LinuxLibgpioIF* gpioComIF, PowerSwitchIF** pwrSwitcher bool enableHkSets); void createPlPcduComponents(LinuxLibgpioIF* gpioComIF, SpiComIF* spiComIF, PowerSwitchIF* pwrSwitcher, Stack5VHandler& stackHandler); -void createTmpComponents(); +void createTmpComponents(std::vector> tmpDevsToAdd); void createRadSensorChipSelect(LinuxLibgpioIF* gpioIF); ReturnValue_t createRadSensorComponent(LinuxLibgpioIF* gpioComIF, Stack5VHandler& handler); void createAcsBoardGpios(GpioCookie& cookie); diff --git a/bsp_q7s/core/scheduling.cpp b/bsp_q7s/core/scheduling.cpp index 71da5bdc..f355d384 100644 --- a/bsp_q7s/core/scheduling.cpp +++ b/bsp_q7s/core/scheduling.cpp @@ -21,6 +21,7 @@ #include "mission/pollingSeqTables.h" #include "mission/scheduling.h" #include "mission/utility/InitMission.h" +#include "q7sConfig.h" /* This is configured for linux without CR */ #ifdef PLATFORM_UNIX @@ -527,7 +528,15 @@ void scheduling::createPstTasks(TaskFactory& factory, TaskDeadlineMissedFunction FixedTimeslotTaskIF* i2cPst = factory.createFixedTimeslotTask("I2C_PS_PST", 60, PeriodicTaskIF::MINIMUM_STACK_SIZE * 4, 0.6, missedDeadlineFunc, &RR_SCHEDULING); - result = pst::pstI2cProcessingSystem(i2cPst); + pst::TmpSchedConfig tmpSchedConf; +#if OBSW_Q7S_EM == 1 + tmpSchedConf.scheduleTmpDev0 = false; + tmpSchedConf.scheduleTmpDev1 = false; + tmpSchedConf.schedulePlPcduDev0 = true; + tmpSchedConf.schedulePlPcduDev1 = true; + tmpSchedConf.scheduleIfBoardDev = true; +#endif + result = pst::pstProgammableLogicI2c(tmpSchedConf, i2cPst); if (result != returnvalue::OK) { if (result == FixedTimeslotTaskIF::SLOT_LIST_EMPTY) { sif::warning << "scheduling::initTasks: I2C PST is empty" << std::endl; diff --git a/bsp_q7s/em/emObjectFactory.cpp b/bsp_q7s/em/emObjectFactory.cpp index 464b3398..91ca0d00 100644 --- a/bsp_q7s/em/emObjectFactory.cpp +++ b/bsp_q7s/em/emObjectFactory.cpp @@ -12,6 +12,7 @@ #include "bsp_q7s/core/CoreController.h" #include "bsp_q7s/core/ObjectFactory.h" #include "busConf.h" +#include "common/config/devices/addresses.h" #include "devConf.h" #include "dummies/helperFactory.h" #include "eive/objects.h" @@ -60,6 +61,14 @@ void ObjectFactory::produce(void* args) { #if OBSW_ADD_PLOC_SUPERVISOR == 1 || OBSW_ADD_PLOC_MPSOC == 1 dummyCfg.addPlocDummies = false; #endif +#if OBSW_ADD_TMP_DEVICES == 1 + std::vector> tmpDevsToAdd = {{ + {objects::TMP1075_HANDLER_PLPCDU_0, addresses::TMP1075_PLPCDU_0}, + {objects::TMP1075_HANDLER_PLPCDU_1, addresses::TMP1075_PLPCDU_1}, + {objects::TMP1075_HANDLER_IF_BOARD, addresses::TMP1075_IF_BOARD}, + }}; + createTmpComponents(tmpDevsToAdd); +#endif #if OBSW_ADD_GOMSPACE_PCDU == 1 dummyCfg.addPowerDummies = false; // The ACU broke. diff --git a/bsp_q7s/fmObjectFactory.cpp b/bsp_q7s/fmObjectFactory.cpp index 413e5648..25fb221c 100644 --- a/bsp_q7s/fmObjectFactory.cpp +++ b/bsp_q7s/fmObjectFactory.cpp @@ -67,7 +67,15 @@ void ObjectFactory::produce(void* args) { HeaterHandler* heaterHandler; createHeaterComponents(gpioComIF, pwrSwitcher, healthTable, heaterHandler); #if OBSW_ADD_TMP_DEVICES == 1 - createTmpComponents(); + std::vector> tmpDevsToAdd = {{ + {objects::TMP1075_HANDLER_TCS_0, addresses::TMP1075_TCS_0}, + {objects::TMP1075_HANDLER_TCS_1, addresses::TMP1075_TCS_1}, + {objects::TMP1075_HANDLER_PLPCDU_0, addresses::TMP1075_PLPCDU_0}, + // damaged + // {objects::TMP1075_HANDLER_PLPCDU_1, addresses::TMP1075_PLPCDU_1}, + {objects::TMP1075_HANDLER_IF_BOARD, addresses::TMP1075_IF_BOARD}, + }}; + createTmpComponents(tmpDevsToAdd); #endif createSolarArrayDeploymentComponents(*pwrSwitcher, *gpioComIF); createPlPcduComponents(gpioComIF, spiMainComIF, pwrSwitcher, *stackHandler); diff --git a/mission/pollingSeqTables.cpp b/mission/pollingSeqTables.cpp index 0367ef27..d065b5aa 100644 --- a/mission/pollingSeqTables.cpp +++ b/mission/pollingSeqTables.cpp @@ -39,56 +39,69 @@ ReturnValue_t pst::pstSyrlinks(FixedTimeslotTaskIF *thisSequence) { // I don't think this needs to be in a PST because linux takes care of bus serialization, but // keep it like this for now, it works -ReturnValue_t pst::pstI2cProcessingSystem(FixedTimeslotTaskIF *thisSequence) { +ReturnValue_t pst::pstProgammableLogicI2c(TmpSchedConfig schedConf, + FixedTimeslotTaskIF *thisSequence) { // Length of a communication cycle uint32_t length = thisSequence->getPeriodMs(); static_cast(length); - // These are actually part of another bus, but this works, so keep it like this for now - thisSequence->addSlot(objects::TMP1075_HANDLER_TCS_0, length * 0.2, - DeviceHandlerIF::PERFORM_OPERATION); - thisSequence->addSlot(objects::TMP1075_HANDLER_TCS_0, length * 0.2, DeviceHandlerIF::SEND_WRITE); - thisSequence->addSlot(objects::TMP1075_HANDLER_TCS_0, length * 0.2, DeviceHandlerIF::GET_WRITE); - thisSequence->addSlot(objects::TMP1075_HANDLER_TCS_0, length * 0.3, DeviceHandlerIF::SEND_READ); - thisSequence->addSlot(objects::TMP1075_HANDLER_TCS_0, length * 0.3, DeviceHandlerIF::GET_READ); + if (schedConf.scheduleTmpDev0) { + thisSequence->addSlot(objects::TMP1075_HANDLER_TCS_0, length * 0.2, + DeviceHandlerIF::PERFORM_OPERATION); + thisSequence->addSlot(objects::TMP1075_HANDLER_TCS_0, length * 0.2, + DeviceHandlerIF::SEND_WRITE); + thisSequence->addSlot(objects::TMP1075_HANDLER_TCS_0, length * 0.2, DeviceHandlerIF::GET_WRITE); + thisSequence->addSlot(objects::TMP1075_HANDLER_TCS_0, length * 0.3, DeviceHandlerIF::SEND_READ); + thisSequence->addSlot(objects::TMP1075_HANDLER_TCS_0, length * 0.3, DeviceHandlerIF::GET_READ); + } - thisSequence->addSlot(objects::TMP1075_HANDLER_TCS_1, length * 0.4, - DeviceHandlerIF::PERFORM_OPERATION); - thisSequence->addSlot(objects::TMP1075_HANDLER_TCS_1, length * 0.4, DeviceHandlerIF::SEND_WRITE); - thisSequence->addSlot(objects::TMP1075_HANDLER_TCS_1, length * 0.4, DeviceHandlerIF::GET_WRITE); - thisSequence->addSlot(objects::TMP1075_HANDLER_TCS_1, length * 0.5, DeviceHandlerIF::SEND_READ); - thisSequence->addSlot(objects::TMP1075_HANDLER_TCS_1, length * 0.5, DeviceHandlerIF::GET_READ); + if (schedConf.scheduleTmpDev1) { + thisSequence->addSlot(objects::TMP1075_HANDLER_TCS_1, length * 0.4, + DeviceHandlerIF::PERFORM_OPERATION); + thisSequence->addSlot(objects::TMP1075_HANDLER_TCS_1, length * 0.4, + DeviceHandlerIF::SEND_WRITE); + thisSequence->addSlot(objects::TMP1075_HANDLER_TCS_1, length * 0.4, DeviceHandlerIF::GET_WRITE); + thisSequence->addSlot(objects::TMP1075_HANDLER_TCS_1, length * 0.5, DeviceHandlerIF::SEND_READ); + thisSequence->addSlot(objects::TMP1075_HANDLER_TCS_1, length * 0.5, DeviceHandlerIF::GET_READ); + } - thisSequence->addSlot(objects::TMP1075_HANDLER_PLPCDU_0, length * 0.6, - DeviceHandlerIF::PERFORM_OPERATION); - thisSequence->addSlot(objects::TMP1075_HANDLER_PLPCDU_0, length * 0.6, - DeviceHandlerIF::SEND_WRITE); - thisSequence->addSlot(objects::TMP1075_HANDLER_PLPCDU_0, length * 0.6, - DeviceHandlerIF::GET_WRITE); - thisSequence->addSlot(objects::TMP1075_HANDLER_PLPCDU_0, length * 0.7, - DeviceHandlerIF::SEND_READ); - thisSequence->addSlot(objects::TMP1075_HANDLER_PLPCDU_0, length * 0.7, DeviceHandlerIF::GET_READ); - // damaged - /* - thisSequence->addSlot(objects::TMP1075_HANDLER_PLPCDU_1, length * 0.4, - DeviceHandlerIF::PERFORM_OPERATION); - thisSequence->addSlot(objects::TMP1075_HANDLER_PLPCDU_1, length * 0.4, - DeviceHandlerIF::SEND_WRITE); - thisSequence->addSlot(objects::TMP1075_HANDLER_PLPCDU_1, length * 0.4, - DeviceHandlerIF::GET_WRITE); - thisSequence->addSlot(objects::TMP1075_HANDLER_PLPCDU_1, length * 0.4, - DeviceHandlerIF::SEND_READ); - thisSequence->addSlot(objects::TMP1075_HANDLER_PLPCDU_1, length * 0.4, DeviceHandlerIF::GET_READ); - */ - thisSequence->addSlot(objects::TMP1075_HANDLER_IF_BOARD, length * 0.8, - DeviceHandlerIF::PERFORM_OPERATION); - thisSequence->addSlot(objects::TMP1075_HANDLER_IF_BOARD, length * 0.8, - DeviceHandlerIF::SEND_WRITE); - thisSequence->addSlot(objects::TMP1075_HANDLER_IF_BOARD, length * 0.8, - DeviceHandlerIF::GET_WRITE); - thisSequence->addSlot(objects::TMP1075_HANDLER_IF_BOARD, length * 0.9, - DeviceHandlerIF::SEND_READ); - thisSequence->addSlot(objects::TMP1075_HANDLER_IF_BOARD, length * 0.9, DeviceHandlerIF::GET_READ); + if (schedConf.schedulePlPcduDev0) { + thisSequence->addSlot(objects::TMP1075_HANDLER_PLPCDU_0, length * 0.6, + DeviceHandlerIF::PERFORM_OPERATION); + thisSequence->addSlot(objects::TMP1075_HANDLER_PLPCDU_0, length * 0.6, + DeviceHandlerIF::SEND_WRITE); + thisSequence->addSlot(objects::TMP1075_HANDLER_PLPCDU_0, length * 0.6, + DeviceHandlerIF::GET_WRITE); + thisSequence->addSlot(objects::TMP1075_HANDLER_PLPCDU_0, length * 0.7, + DeviceHandlerIF::SEND_READ); + thisSequence->addSlot(objects::TMP1075_HANDLER_PLPCDU_0, length * 0.7, + DeviceHandlerIF::GET_READ); + } + if (schedConf.schedulePlPcduDev1) { + thisSequence->addSlot(objects::TMP1075_HANDLER_PLPCDU_1, length * 0.4, + DeviceHandlerIF::PERFORM_OPERATION); + thisSequence->addSlot(objects::TMP1075_HANDLER_PLPCDU_1, length * 0.4, + DeviceHandlerIF::SEND_WRITE); + thisSequence->addSlot(objects::TMP1075_HANDLER_PLPCDU_1, length * 0.4, + DeviceHandlerIF::GET_WRITE); + thisSequence->addSlot(objects::TMP1075_HANDLER_PLPCDU_1, length * 0.4, + DeviceHandlerIF::SEND_READ); + thisSequence->addSlot(objects::TMP1075_HANDLER_PLPCDU_1, length * 0.4, + DeviceHandlerIF::GET_READ); + } + + if (schedConf.scheduleIfBoardDev) { + thisSequence->addSlot(objects::TMP1075_HANDLER_IF_BOARD, length * 0.8, + DeviceHandlerIF::PERFORM_OPERATION); + thisSequence->addSlot(objects::TMP1075_HANDLER_IF_BOARD, length * 0.8, + DeviceHandlerIF::SEND_WRITE); + thisSequence->addSlot(objects::TMP1075_HANDLER_IF_BOARD, length * 0.8, + DeviceHandlerIF::GET_WRITE); + thisSequence->addSlot(objects::TMP1075_HANDLER_IF_BOARD, length * 0.9, + DeviceHandlerIF::SEND_READ); + thisSequence->addSlot(objects::TMP1075_HANDLER_IF_BOARD, length * 0.9, + DeviceHandlerIF::GET_READ); + } static_cast(length); return thisSequence->checkSequence(); } diff --git a/mission/pollingSeqTables.h b/mission/pollingSeqTables.h index e3bc0ad0..831d78be 100644 --- a/mission/pollingSeqTables.h +++ b/mission/pollingSeqTables.h @@ -39,6 +39,16 @@ struct AcsPstCfg { bool scheduleStr = true; }; +// Default config is for FM. +struct TmpSchedConfig { + bool scheduleTmpDev0 = true; + bool scheduleTmpDev1 = true; + bool schedulePlPcduDev0 = true; + // damaged on FM + bool schedulePlPcduDev1 = false; + bool scheduleIfBoardDev = true; +}; + /** * @brief This function creates the PST for all gomspace devices. * @details @@ -51,7 +61,7 @@ ReturnValue_t pstSyrlinks(FixedTimeslotTaskIF* thisSequence); ReturnValue_t pstTcsAndAcs(FixedTimeslotTaskIF* thisSequence, AcsPstCfg cfg); -ReturnValue_t pstI2cProcessingSystem(FixedTimeslotTaskIF* thisSequence); +ReturnValue_t pstProgammableLogicI2c(TmpSchedConfig schedConf, FixedTimeslotTaskIF* thisSequence); /** * Generic test PST diff --git a/tmtc b/tmtc index 936dcdf3..970c8998 160000 --- a/tmtc +++ b/tmtc @@ -1 +1 @@ -Subproject commit 936dcdf334c2258d2256373cd4995b2574202a59 +Subproject commit 970c8998f0bb719ab4b289fa95406d7037b2bb35 From 269d5f6a0afe957d649acddd7500f5ad240f0910 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Sat, 17 Jun 2023 17:01:01 +0200 Subject: [PATCH 03/16] stupid tmps --- bsp_q7s/em/emObjectFactory.cpp | 9 ++++- dummies/TemperatureSensorInserter.cpp | 12 +++--- dummies/TemperatureSensorInserter.h | 4 +- dummies/helperFactory.cpp | 56 +++++++++++++++++---------- dummies/helperFactory.h | 10 +++++ mission/pollingSeqTables.cpp | 41 ++++++++++---------- 6 files changed, 82 insertions(+), 50 deletions(-) diff --git a/bsp_q7s/em/emObjectFactory.cpp b/bsp_q7s/em/emObjectFactory.cpp index 91ca0d00..52754b8a 100644 --- a/bsp_q7s/em/emObjectFactory.cpp +++ b/bsp_q7s/em/emObjectFactory.cpp @@ -45,7 +45,7 @@ void ObjectFactory::produce(void* args) { SpiComIF* spiMainComIF = nullptr; I2cComIF* i2cComIF = nullptr; createCommunicationInterfaces(&gpioComIF, &uartComIF, &spiMainComIF, &i2cComIF); - /* Adding gpios for chip select decoding to the gpioComIf */ + // Adding GPIOs for chip select decoding and initializing them. q7s::gpioCallbacks::initSpiCsDecoder(gpioComIF); gpioCallbacks::disableAllDecoder(gpioComIF); createPlI2cResetGpio(gpioComIF); @@ -68,6 +68,13 @@ void ObjectFactory::produce(void* args) { {objects::TMP1075_HANDLER_IF_BOARD, addresses::TMP1075_IF_BOARD}, }}; createTmpComponents(tmpDevsToAdd); + dummy::Tmp1075Cfg tmpCfg {}; + tmpCfg.addTcsBrd0 = true; + tmpCfg.addTcsBrd1 = true; + tmpCfg.addPlPcdu0 = false; + tmpCfg.addPlPcdu1 = false; + tmpCfg.addIfBrd = false; + dummyCfg.tmp1075Cfg = tmpCfg; #endif #if OBSW_ADD_GOMSPACE_PCDU == 1 dummyCfg.addPowerDummies = false; diff --git a/dummies/TemperatureSensorInserter.cpp b/dummies/TemperatureSensorInserter.cpp index 14a005aa..0e5d7421 100644 --- a/dummies/TemperatureSensorInserter.cpp +++ b/dummies/TemperatureSensorInserter.cpp @@ -7,9 +7,9 @@ #include #include -TemperatureSensorInserter::TemperatureSensorInserter(object_id_t objectId, - Max31865DummyMap tempSensorDummies_, - Tmp1075DummyMap tempTmpSensorDummies_) +TemperatureSensorInserter::TemperatureSensorInserter( + object_id_t objectId, Max31865DummyMap tempSensorDummies_, + std::optional tempTmpSensorDummies_) : SystemObject(objectId), max31865DummyMap(std::move(tempSensorDummies_)), tmp1075DummyMap(std::move(tempTmpSensorDummies_)) {} @@ -25,8 +25,10 @@ ReturnValue_t TemperatureSensorInserter::performOperation(uint8_t opCode) { for (auto& rtdDummy : max31865DummyMap) { rtdDummy.second->setTemperature(10, true); } - for (auto& tmpDummy : tmp1075DummyMap) { - tmpDummy.second->setTemperature(10, true); + if (tmp1075DummyMap.has_value()) { + for (auto& tmpDummy : tmp1075DummyMap.value()) { + tmpDummy.second->setTemperature(10, true); + } } tempsWereInitialized = true; } diff --git a/dummies/TemperatureSensorInserter.h b/dummies/TemperatureSensorInserter.h index eb6cc1ba..d710b680 100644 --- a/dummies/TemperatureSensorInserter.h +++ b/dummies/TemperatureSensorInserter.h @@ -12,7 +12,7 @@ class TemperatureSensorInserter : public ExecutableObjectIF, public SystemObject using Max31865DummyMap = std::map; using Tmp1075DummyMap = std::map; explicit TemperatureSensorInserter(object_id_t objectId, Max31865DummyMap tempSensorDummies_, - Tmp1075DummyMap tempTmpSensorDummies_); + std::optional tempTmpSensorDummies_); ReturnValue_t initialize() override; ReturnValue_t initializeAfterTaskCreation() override; @@ -22,7 +22,7 @@ class TemperatureSensorInserter : public ExecutableObjectIF, public SystemObject private: Max31865DummyMap max31865DummyMap; - Tmp1075DummyMap tmp1075DummyMap; + std::optional tmp1075DummyMap; enum TestCase { NONE = 0, diff --git a/dummies/helperFactory.cpp b/dummies/helperFactory.cpp index 157d11d3..6cd78f93 100644 --- a/dummies/helperFactory.cpp +++ b/dummies/helperFactory.cpp @@ -191,25 +191,36 @@ void dummy::createDummies(DummyCfg cfg, PowerSwitchIF& pwrSwitcher, GpioIF* gpio objects::RTD_15_IC18_IMTQ, new Max31865Dummy(objects::RTD_15_IC18_IMTQ, objects::DUMMY_COM_IF, comCookieDummy)); - std::map tmpSensorDummies; - tmpSensorDummies.emplace( - objects::TMP1075_HANDLER_TCS_0, - new Tmp1075Dummy(objects::TMP1075_HANDLER_TCS_0, objects::DUMMY_COM_IF, comCookieDummy)); - tmpSensorDummies.emplace( - objects::TMP1075_HANDLER_TCS_1, - new Tmp1075Dummy(objects::TMP1075_HANDLER_TCS_1, objects::DUMMY_COM_IF, comCookieDummy)); - tmpSensorDummies.emplace( - objects::TMP1075_HANDLER_PLPCDU_0, - new Tmp1075Dummy(objects::TMP1075_HANDLER_PLPCDU_0, objects::DUMMY_COM_IF, comCookieDummy)); - // damaged. - // tmpSensorDummies.emplace( - // objects::TMP1075_HANDLER_PLPCDU_1, - // new Tmp1075Dummy(objects::TMP1075_HANDLER_PLPCDU_1, objects::DUMMY_COM_IF, - // comCookieDummy)); - tmpSensorDummies.emplace( - objects::TMP1075_HANDLER_IF_BOARD, - new Tmp1075Dummy(objects::TMP1075_HANDLER_IF_BOARD, objects::DUMMY_COM_IF, comCookieDummy)); - + std::optional tmpSensorDummies; + TemperatureSensorInserter::Tmp1075DummyMap tmpDummyMap; + if (cfg.addTmpDummies) { + tmpSensorDummies = tmpDummyMap; + if (cfg.tmp1075Cfg.addTcsBrd0) { + tmpDummyMap.emplace(objects::TMP1075_HANDLER_TCS_0, + new Tmp1075Dummy(objects::TMP1075_HANDLER_TCS_0, objects::DUMMY_COM_IF, + comCookieDummy)); + } + if (cfg.tmp1075Cfg.addTcsBrd1) { + tmpDummyMap.emplace(objects::TMP1075_HANDLER_TCS_1, + new Tmp1075Dummy(objects::TMP1075_HANDLER_TCS_1, objects::DUMMY_COM_IF, + comCookieDummy)); + } + if (cfg.tmp1075Cfg.addPlPcdu0) { + tmpDummyMap.emplace(objects::TMP1075_HANDLER_PLPCDU_0, + new Tmp1075Dummy(objects::TMP1075_HANDLER_PLPCDU_0, + objects::DUMMY_COM_IF, comCookieDummy)); + } + if (cfg.tmp1075Cfg.addPlPcdu1) { + tmpDummyMap.emplace(objects::TMP1075_HANDLER_PLPCDU_1, + new Tmp1075Dummy(objects::TMP1075_HANDLER_PLPCDU_1, + objects::DUMMY_COM_IF, comCookieDummy)); + } + if (cfg.tmp1075Cfg.addIfBrd) { + tmpDummyMap.emplace(objects::TMP1075_HANDLER_IF_BOARD, + new Tmp1075Dummy(objects::TMP1075_HANDLER_IF_BOARD, + objects::DUMMY_COM_IF, comCookieDummy)); + } + } new TemperatureSensorInserter(objects::THERMAL_TEMP_INSERTER, rtdSensorDummies, tmpSensorDummies); TcsBoardAssembly* tcsBoardAssy = @@ -217,8 +228,11 @@ void dummy::createDummies(DummyCfg cfg, PowerSwitchIF& pwrSwitcher, GpioIF* gpio for (auto& rtd : rtdSensorDummies) { rtd.second->connectModeTreeParent(*tcsBoardAssy); } - for (auto& tmp : tmpSensorDummies) { - tmp.second->connectModeTreeParent(satsystem::tcs::SUBSYSTEM); + if(tmpSensorDummies.has_value()) { + for (auto& tmp : tmpSensorDummies.value()) { + printf("Hello, connecting parent to %08x\n", tmp.second->getObjectId()); + tmp.second->connectModeTreeParent(satsystem::tcs::SUBSYSTEM); + } } } if (cfg.addCamSwitcherDummy) { diff --git a/dummies/helperFactory.h b/dummies/helperFactory.h index bab9d8d8..9c1a93d3 100644 --- a/dummies/helperFactory.h +++ b/dummies/helperFactory.h @@ -6,6 +6,14 @@ class GpioIF; namespace dummy { +struct Tmp1075Cfg { + bool addTcsBrd0 = true; + bool addTcsBrd1 = true; + bool addPlPcdu0 = true; + bool addPlPcdu1 = true; + bool addIfBrd = true; +}; + // Default values targeted towards EM. struct DummyCfg { bool addCoreCtrlCfg = true; @@ -19,6 +27,8 @@ struct DummyCfg { bool addTempSensorDummies = true; bool addRtdComIFDummy = true; bool addPlocDummies = true; + bool addTmpDummies = true; + Tmp1075Cfg tmp1075Cfg; bool addCamSwitcherDummy = false; }; diff --git a/mission/pollingSeqTables.cpp b/mission/pollingSeqTables.cpp index d065b5aa..e2fba92c 100644 --- a/mission/pollingSeqTables.cpp +++ b/mission/pollingSeqTables.cpp @@ -46,47 +46,46 @@ ReturnValue_t pst::pstProgammableLogicI2c(TmpSchedConfig schedConf, static_cast(length); if (schedConf.scheduleTmpDev0) { - thisSequence->addSlot(objects::TMP1075_HANDLER_TCS_0, length * 0.2, + thisSequence->addSlot(objects::TMP1075_HANDLER_TCS_0, length * 0, DeviceHandlerIF::PERFORM_OPERATION); - thisSequence->addSlot(objects::TMP1075_HANDLER_TCS_0, length * 0.2, - DeviceHandlerIF::SEND_WRITE); - thisSequence->addSlot(objects::TMP1075_HANDLER_TCS_0, length * 0.2, DeviceHandlerIF::GET_WRITE); - thisSequence->addSlot(objects::TMP1075_HANDLER_TCS_0, length * 0.3, DeviceHandlerIF::SEND_READ); - thisSequence->addSlot(objects::TMP1075_HANDLER_TCS_0, length * 0.3, DeviceHandlerIF::GET_READ); + thisSequence->addSlot(objects::TMP1075_HANDLER_TCS_0, length * 0, DeviceHandlerIF::SEND_WRITE); + thisSequence->addSlot(objects::TMP1075_HANDLER_TCS_0, length * 0.1, DeviceHandlerIF::GET_WRITE); + thisSequence->addSlot(objects::TMP1075_HANDLER_TCS_0, length * 0.1, DeviceHandlerIF::SEND_READ); + thisSequence->addSlot(objects::TMP1075_HANDLER_TCS_0, length * 0.1, DeviceHandlerIF::GET_READ); } if (schedConf.scheduleTmpDev1) { - thisSequence->addSlot(objects::TMP1075_HANDLER_TCS_1, length * 0.4, + thisSequence->addSlot(objects::TMP1075_HANDLER_TCS_1, length * 0.2, DeviceHandlerIF::PERFORM_OPERATION); - thisSequence->addSlot(objects::TMP1075_HANDLER_TCS_1, length * 0.4, + thisSequence->addSlot(objects::TMP1075_HANDLER_TCS_1, length * 0.2, DeviceHandlerIF::SEND_WRITE); - thisSequence->addSlot(objects::TMP1075_HANDLER_TCS_1, length * 0.4, DeviceHandlerIF::GET_WRITE); - thisSequence->addSlot(objects::TMP1075_HANDLER_TCS_1, length * 0.5, DeviceHandlerIF::SEND_READ); - thisSequence->addSlot(objects::TMP1075_HANDLER_TCS_1, length * 0.5, DeviceHandlerIF::GET_READ); + thisSequence->addSlot(objects::TMP1075_HANDLER_TCS_1, length * 0.2, DeviceHandlerIF::GET_WRITE); + thisSequence->addSlot(objects::TMP1075_HANDLER_TCS_1, length * 0.3, DeviceHandlerIF::SEND_READ); + thisSequence->addSlot(objects::TMP1075_HANDLER_TCS_1, length * 0.3, DeviceHandlerIF::GET_READ); } if (schedConf.schedulePlPcduDev0) { - thisSequence->addSlot(objects::TMP1075_HANDLER_PLPCDU_0, length * 0.6, + thisSequence->addSlot(objects::TMP1075_HANDLER_PLPCDU_0, length * 0.4, DeviceHandlerIF::PERFORM_OPERATION); - thisSequence->addSlot(objects::TMP1075_HANDLER_PLPCDU_0, length * 0.6, + thisSequence->addSlot(objects::TMP1075_HANDLER_PLPCDU_0, length * 0.4, DeviceHandlerIF::SEND_WRITE); - thisSequence->addSlot(objects::TMP1075_HANDLER_PLPCDU_0, length * 0.6, + thisSequence->addSlot(objects::TMP1075_HANDLER_PLPCDU_0, length * 0.4, DeviceHandlerIF::GET_WRITE); - thisSequence->addSlot(objects::TMP1075_HANDLER_PLPCDU_0, length * 0.7, + thisSequence->addSlot(objects::TMP1075_HANDLER_PLPCDU_0, length * 0.5, DeviceHandlerIF::SEND_READ); - thisSequence->addSlot(objects::TMP1075_HANDLER_PLPCDU_0, length * 0.7, + thisSequence->addSlot(objects::TMP1075_HANDLER_PLPCDU_0, length * 0.5, DeviceHandlerIF::GET_READ); } if (schedConf.schedulePlPcduDev1) { - thisSequence->addSlot(objects::TMP1075_HANDLER_PLPCDU_1, length * 0.4, + thisSequence->addSlot(objects::TMP1075_HANDLER_PLPCDU_1, length * 0.6, DeviceHandlerIF::PERFORM_OPERATION); - thisSequence->addSlot(objects::TMP1075_HANDLER_PLPCDU_1, length * 0.4, + thisSequence->addSlot(objects::TMP1075_HANDLER_PLPCDU_1, length * 0.6, DeviceHandlerIF::SEND_WRITE); - thisSequence->addSlot(objects::TMP1075_HANDLER_PLPCDU_1, length * 0.4, + thisSequence->addSlot(objects::TMP1075_HANDLER_PLPCDU_1, length * 0.6, DeviceHandlerIF::GET_WRITE); - thisSequence->addSlot(objects::TMP1075_HANDLER_PLPCDU_1, length * 0.4, + thisSequence->addSlot(objects::TMP1075_HANDLER_PLPCDU_1, length * 0.7, DeviceHandlerIF::SEND_READ); - thisSequence->addSlot(objects::TMP1075_HANDLER_PLPCDU_1, length * 0.4, + thisSequence->addSlot(objects::TMP1075_HANDLER_PLPCDU_1, length * 0.7, DeviceHandlerIF::GET_READ); } From 727050520b45f9b09bbdb85c82af4c8d587cdbbb Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Sat, 17 Jun 2023 17:24:51 +0200 Subject: [PATCH 04/16] that should do the job --- dummies/helperFactory.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/dummies/helperFactory.cpp b/dummies/helperFactory.cpp index 6cd78f93..cbe979bf 100644 --- a/dummies/helperFactory.cpp +++ b/dummies/helperFactory.cpp @@ -192,9 +192,8 @@ void dummy::createDummies(DummyCfg cfg, PowerSwitchIF& pwrSwitcher, GpioIF* gpio new Max31865Dummy(objects::RTD_15_IC18_IMTQ, objects::DUMMY_COM_IF, comCookieDummy)); std::optional tmpSensorDummies; - TemperatureSensorInserter::Tmp1075DummyMap tmpDummyMap; if (cfg.addTmpDummies) { - tmpSensorDummies = tmpDummyMap; + TemperatureSensorInserter::Tmp1075DummyMap tmpDummyMap; if (cfg.tmp1075Cfg.addTcsBrd0) { tmpDummyMap.emplace(objects::TMP1075_HANDLER_TCS_0, new Tmp1075Dummy(objects::TMP1075_HANDLER_TCS_0, objects::DUMMY_COM_IF, @@ -220,6 +219,7 @@ void dummy::createDummies(DummyCfg cfg, PowerSwitchIF& pwrSwitcher, GpioIF* gpio new Tmp1075Dummy(objects::TMP1075_HANDLER_IF_BOARD, objects::DUMMY_COM_IF, comCookieDummy)); } + tmpSensorDummies = std::move(tmpDummyMap); } new TemperatureSensorInserter(objects::THERMAL_TEMP_INSERTER, rtdSensorDummies, tmpSensorDummies); From 07bb293816d5e77851d29f095f902b2dc7b11639 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Sun, 18 Jun 2023 13:38:00 +0200 Subject: [PATCH 05/16] tmp1075 workssssss --- bsp_q7s/core/scheduling.cpp | 4 ++-- bsp_q7s/em/emObjectFactory.cpp | 2 +- dummies/Tmp1075Dummy.cpp | 17 ++++++++++++++--- dummies/helperFactory.cpp | 7 +++---- mission/tcs/Tmp1075Handler.cpp | 6 +----- tmtc | 2 +- 6 files changed, 22 insertions(+), 16 deletions(-) diff --git a/bsp_q7s/core/scheduling.cpp b/bsp_q7s/core/scheduling.cpp index f355d384..b257ea13 100644 --- a/bsp_q7s/core/scheduling.cpp +++ b/bsp_q7s/core/scheduling.cpp @@ -530,8 +530,8 @@ void scheduling::createPstTasks(TaskFactory& factory, TaskDeadlineMissedFunction missedDeadlineFunc, &RR_SCHEDULING); pst::TmpSchedConfig tmpSchedConf; #if OBSW_Q7S_EM == 1 - tmpSchedConf.scheduleTmpDev0 = false; - tmpSchedConf.scheduleTmpDev1 = false; + tmpSchedConf.scheduleTmpDev0 = true; + tmpSchedConf.scheduleTmpDev1 = true; tmpSchedConf.schedulePlPcduDev0 = true; tmpSchedConf.schedulePlPcduDev1 = true; tmpSchedConf.scheduleIfBoardDev = true; diff --git a/bsp_q7s/em/emObjectFactory.cpp b/bsp_q7s/em/emObjectFactory.cpp index 52754b8a..a2d5662a 100644 --- a/bsp_q7s/em/emObjectFactory.cpp +++ b/bsp_q7s/em/emObjectFactory.cpp @@ -68,7 +68,7 @@ void ObjectFactory::produce(void* args) { {objects::TMP1075_HANDLER_IF_BOARD, addresses::TMP1075_IF_BOARD}, }}; createTmpComponents(tmpDevsToAdd); - dummy::Tmp1075Cfg tmpCfg {}; + dummy::Tmp1075Cfg tmpCfg{}; tmpCfg.addTcsBrd0 = true; tmpCfg.addTcsBrd1 = true; tmpCfg.addPlPcdu0 = false; diff --git a/dummies/Tmp1075Dummy.cpp b/dummies/Tmp1075Dummy.cpp index 91a50774..96d1f775 100644 --- a/dummies/Tmp1075Dummy.cpp +++ b/dummies/Tmp1075Dummy.cpp @@ -8,35 +8,46 @@ using namespace returnvalue; Tmp1075Dummy::Tmp1075Dummy(object_id_t objectId, object_id_t comif, CookieIF *comCookie) : DeviceHandlerBase(objectId, comif, comCookie), set(this) {} -void Tmp1075Dummy::doStartUp() { setMode(MODE_NORMAL); } +void Tmp1075Dummy::doStartUp() { setMode(MODE_ON); } void Tmp1075Dummy::doShutDown() { setMode(MODE_OFF); } ReturnValue_t Tmp1075Dummy::buildNormalDeviceCommand(DeviceCommandId_t *id) { return NOTHING_TO_SEND; } -ReturnValue_t Tmp1075Dummy::buildTransitionDeviceCommand(DeviceCommandId_t *id) { return OK; } + +ReturnValue_t Tmp1075Dummy::buildTransitionDeviceCommand(DeviceCommandId_t *id) { + return NOTHING_TO_SEND; +} + ReturnValue_t Tmp1075Dummy::buildCommandFromCommand(DeviceCommandId_t deviceCommand, const uint8_t *commandData, size_t commandDataLen) { - return 0; + return NOTHING_TO_SEND; } + ReturnValue_t Tmp1075Dummy::scanForReply(const uint8_t *start, size_t len, DeviceCommandId_t *foundId, size_t *foundLen) { return 0; } + ReturnValue_t Tmp1075Dummy::interpretDeviceReply(DeviceCommandId_t id, const uint8_t *packet) { return 0; } + void Tmp1075Dummy::setTemperature(float temperature, bool valid) { PoolReadGuard pg(&set); set.temperatureCelcius.value = temperature; set.setValidity(valid, true); } + void Tmp1075Dummy::fillCommandAndReplyMap() {} + uint32_t Tmp1075Dummy::getTransitionDelayMs(Mode_t modeFrom, Mode_t modeTo) { return 1000; } + ReturnValue_t Tmp1075Dummy::initializeLocalDataPool(localpool::DataPool &localDataPoolMap, LocalDataPoolManager &poolManager) { localDataPoolMap.emplace(TMP1075::TEMPERATURE_C_TMP1075, new PoolEntry({10.0}, true)); return OK; } + LocalPoolDataSetBase *Tmp1075Dummy::getDataSetHandle(sid_t sid) { return &set; } diff --git a/dummies/helperFactory.cpp b/dummies/helperFactory.cpp index cbe979bf..84d6acc9 100644 --- a/dummies/helperFactory.cpp +++ b/dummies/helperFactory.cpp @@ -211,8 +211,8 @@ void dummy::createDummies(DummyCfg cfg, PowerSwitchIF& pwrSwitcher, GpioIF* gpio } if (cfg.tmp1075Cfg.addPlPcdu1) { tmpDummyMap.emplace(objects::TMP1075_HANDLER_PLPCDU_1, - new Tmp1075Dummy(objects::TMP1075_HANDLER_PLPCDU_1, - objects::DUMMY_COM_IF, comCookieDummy)); + new Tmp1075Dummy(objects::TMP1075_HANDLER_PLPCDU_1, + objects::DUMMY_COM_IF, comCookieDummy)); } if (cfg.tmp1075Cfg.addIfBrd) { tmpDummyMap.emplace(objects::TMP1075_HANDLER_IF_BOARD, @@ -228,9 +228,8 @@ void dummy::createDummies(DummyCfg cfg, PowerSwitchIF& pwrSwitcher, GpioIF* gpio for (auto& rtd : rtdSensorDummies) { rtd.second->connectModeTreeParent(*tcsBoardAssy); } - if(tmpSensorDummies.has_value()) { + if (tmpSensorDummies.has_value()) { for (auto& tmp : tmpSensorDummies.value()) { - printf("Hello, connecting parent to %08x\n", tmp.second->getObjectId()); tmp.second->connectModeTreeParent(satsystem::tcs::SUBSYSTEM); } } diff --git a/mission/tcs/Tmp1075Handler.cpp b/mission/tcs/Tmp1075Handler.cpp index 30331e1f..07f3703c 100644 --- a/mission/tcs/Tmp1075Handler.cpp +++ b/mission/tcs/Tmp1075Handler.cpp @@ -11,11 +11,7 @@ Tmp1075Handler::Tmp1075Handler(object_id_t objectId, object_id_t comIF, CookieIF Tmp1075Handler::~Tmp1075Handler() {} -void Tmp1075Handler::doStartUp() { - if (getMode() == _MODE_START_UP) { - setMode(MODE_ON); - } -} +void Tmp1075Handler::doStartUp() { setMode(MODE_ON); } void Tmp1075Handler::doShutDown() { communicationStep = CommunicationStep::START_ADC_CONVERSION; diff --git a/tmtc b/tmtc index 970c8998..b9038f1c 160000 --- a/tmtc +++ b/tmtc @@ -1 +1 @@ -Subproject commit 970c8998f0bb719ab4b289fa95406d7037b2bb35 +Subproject commit b9038f1c86fb2b3cb9cae5be42fafd678e12de52 From 0cd5526de491237e8621b372977e85d331a51919 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Sun, 18 Jun 2023 14:19:19 +0200 Subject: [PATCH 06/16] always add TMP devs now --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 3c7e1c1e..78657b95 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -150,7 +150,7 @@ set(OBSW_ADD_SYRLINKS 1 CACHE STRING "Add Syrlinks module") set(OBSW_ADD_TMP_DEVICES - ${INIT_VAL} + 1 CACHE STRING "Add TMP devices") set(OBSW_ADD_GOMSPACE_PCDU 1 From ecb8de155065e18d0f1b7827f92a74057e851d52 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Sun, 18 Jun 2023 16:23:08 +0200 Subject: [PATCH 07/16] need to verify some things here later.. --- bsp_q7s/em/emObjectFactory.cpp | 2 +- mission/controller/ThermalController.cpp | 27 +++++++++++++----------- mission/controller/ThermalController.h | 5 +++-- mission/genericFactory.cpp | 4 ++-- mission/genericFactory.h | 2 +- tmtc | 2 +- 6 files changed, 23 insertions(+), 19 deletions(-) diff --git a/bsp_q7s/em/emObjectFactory.cpp b/bsp_q7s/em/emObjectFactory.cpp index a2d5662a..9aecc7ba 100644 --- a/bsp_q7s/em/emObjectFactory.cpp +++ b/bsp_q7s/em/emObjectFactory.cpp @@ -172,6 +172,6 @@ void ObjectFactory::produce(void* args) { createAcsController(true, enableHkSets); HeaterHandler* heaterHandler; createHeaterComponents(gpioComIF, pwrSwitcher, healthTable, heaterHandler); - createThermalController(*heaterHandler); + createThermalController(*heaterHandler, true); satsystem::init(); } diff --git a/mission/controller/ThermalController.cpp b/mission/controller/ThermalController.cpp index 53babbd5..9e7b7d24 100644 --- a/mission/controller/ThermalController.cpp +++ b/mission/controller/ThermalController.cpp @@ -24,9 +24,11 @@ #define LOWER_RW_UPPER_LIMITS 0 ThermalController::ThermalController(object_id_t objectId, HeaterHandler& heater, - const std::atomic_bool& tcsBoardShortUnavailable) + const std::atomic_bool& tcsBoardShortUnavailable, + bool pollPcdu1Tmp) : ExtendedControllerBase(objectId), heaterHandler(heater), + pollPcdu1Tmp(pollPcdu1Tmp), sensorTemperatures(this), susTemperatures(this), deviceTemperatures(this), @@ -56,7 +58,7 @@ ThermalController::ThermalController(object_id_t objectId, HeaterHandler& heater tmp1075SetTcs1(objects::TMP1075_HANDLER_TCS_1), tmp1075SetPlPcdu0(objects::TMP1075_HANDLER_PLPCDU_0), // damaged - // tmp1075SetPlPcdu1(objects::TMP1075_HANDLER_PLPCDU_1), + tmp1075SetPlPcdu1(objects::TMP1075_HANDLER_PLPCDU_1), tmp1075SetIfBoard(objects::TMP1075_HANDLER_IF_BOARD), susSet0(objects::SUS_0_N_LOC_XFYFZM_PT_XF), susSet1(objects::SUS_1_N_LOC_XBYFZM_PT_XB), @@ -536,19 +538,20 @@ void ThermalController::copySensors() { } } } - // damaged - /* - { - PoolReadGuard pg(&tmp1075SetPlPcdu1, MutexIF::TimeoutType::WAITING, MUTEX_TIMEOUT); - if (pg.getReadResult() == returnvalue::OK) { - sensorTemperatures.tmp1075PlPcdu1.value = tmp1075SetPlPcdu1.temperatureCelcius.value; - sensorTemperatures.tmp1075PlPcdu1.setValid(tmp1075SetPlPcdu1.temperatureCelcius.isValid()); - if (not tmp1075SetPlPcdu1.temperatureCelcius.isValid()) { - sensorTemperatures.tmp1075PlPcdu1.value = INVALID_TEMPERATURE; + // damaged on FM, and no dummies for now + + if (pollPcdu1Tmp) { + { + PoolReadGuard pg(&tmp1075SetPlPcdu1, MutexIF::TimeoutType::WAITING, MUTEX_TIMEOUT); + if (pg.getReadResult() == returnvalue::OK) { + sensorTemperatures.tmp1075PlPcdu1.value = tmp1075SetPlPcdu1.temperatureCelcius.value; + sensorTemperatures.tmp1075PlPcdu1.setValid(tmp1075SetPlPcdu1.temperatureCelcius.isValid()); + if (not tmp1075SetPlPcdu1.temperatureCelcius.isValid()) { + sensorTemperatures.tmp1075PlPcdu1.value = INVALID_TEMPERATURE; + } } } } - */ { PoolReadGuard pg(&tmp1075SetIfBoard, MutexIF::TimeoutType::WAITING, MUTEX_TIMEOUT); if (pg.getReadResult() == returnvalue::OK) { diff --git a/mission/controller/ThermalController.h b/mission/controller/ThermalController.h index 4eb41c67..ab5ddd09 100644 --- a/mission/controller/ThermalController.h +++ b/mission/controller/ThermalController.h @@ -103,7 +103,7 @@ class ThermalController : public ExtendedControllerBase { static constexpr int16_t SANITY_LIMIT_UPPER_TEMP = 160; ThermalController(object_id_t objectId, HeaterHandler& heater, - const std::atomic_bool& tcsBoardShortUnavailable); + const std::atomic_bool& tcsBoardShortUnavailable, bool pollPcdu1Tmp); ReturnValue_t initialize() override; @@ -142,6 +142,7 @@ class ThermalController : public ExtendedControllerBase { HeaterHandler& heaterHandler; + bool pollPcdu1Tmp; tcsCtrl::SensorTemperatures sensorTemperatures; tcsCtrl::SusTemperatures susTemperatures; tcsCtrl::DeviceTemperatures deviceTemperatures; @@ -173,7 +174,7 @@ class ThermalController : public ExtendedControllerBase { TMP1075::Tmp1075Dataset tmp1075SetTcs1; TMP1075::Tmp1075Dataset tmp1075SetPlPcdu0; // damaged - // TMP1075::Tmp1075Dataset tmp1075SetPlPcdu1; + TMP1075::Tmp1075Dataset tmp1075SetPlPcdu1; TMP1075::Tmp1075Dataset tmp1075SetIfBoard; // SUS diff --git a/mission/genericFactory.cpp b/mission/genericFactory.cpp index cbe78c7f..db3b7282 100644 --- a/mission/genericFactory.cpp +++ b/mission/genericFactory.cpp @@ -305,9 +305,9 @@ void ObjectFactory::createGenericHeaterComponents(GpioIF& gpioIF, PowerSwitchIF& heaterHandler->connectModeTreeParent(satsystem::tcs::SUBSYSTEM); } -void ObjectFactory::createThermalController(HeaterHandler& heaterHandler) { +void ObjectFactory::createThermalController(HeaterHandler& heaterHandler, bool pollPlPcduTmp1) { auto* tcsCtrl = new ThermalController(objects::THERMAL_CONTROLLER, heaterHandler, - tcs::TCS_BOARD_SHORTLY_UNAVAILABLE); + tcs::TCS_BOARD_SHORTLY_UNAVAILABLE, pollPlPcduTmp1); tcsCtrl->connectModeTreeParent(satsystem::tcs::SUBSYSTEM); } void ObjectFactory::createRwAssy(PowerSwitchIF& pwrSwitcher, power::Switch_t theSwitch, diff --git a/mission/genericFactory.h b/mission/genericFactory.h index a3a52704..c9ad778d 100644 --- a/mission/genericFactory.h +++ b/mission/genericFactory.h @@ -49,7 +49,7 @@ void produceGenericObjects(HealthTableIF** healthTable, PusTmFunnel** pusFunnel, void createGenericHeaterComponents(GpioIF& gpioIF, PowerSwitchIF& pwrSwitcher, HeaterHandler*& heaterHandler); -void createThermalController(HeaterHandler& heaterHandler); +void createThermalController(HeaterHandler& heaterHandler, bool pollPlPcduTmp1); void createRwAssy(PowerSwitchIF& pwrSwitcher, power::Switch_t theSwitch, std::array rws, std::array rwIds); void createSusAssy(PowerSwitchIF& pwrSwitcher, std::array suses); diff --git a/tmtc b/tmtc index b9038f1c..79060acf 160000 --- a/tmtc +++ b/tmtc @@ -1 +1 @@ -Subproject commit b9038f1c86fb2b3cb9cae5be42fafd678e12de52 +Subproject commit 79060acfb688a8896cf56c27d83da14e5630f091 From 322151acf884dbad3a5df22418112d7f7c655ac7 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Sun, 18 Jun 2023 16:34:07 +0200 Subject: [PATCH 08/16] tmp fdir bugfix: use strange reply counter --- mission/system/tcs/TmpDevFdir.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/mission/system/tcs/TmpDevFdir.cpp b/mission/system/tcs/TmpDevFdir.cpp index d501dd1a..8123debc 100644 --- a/mission/system/tcs/TmpDevFdir.cpp +++ b/mission/system/tcs/TmpDevFdir.cpp @@ -29,7 +29,9 @@ ReturnValue_t TmpDevFdir::eventReceived(EventMessage* event) { case DeviceHandlerIF::DEVICE_BUILDING_COMMAND_FAILED: // These faults all mean that there were stupid replies from a device. // With now way to do a recovery, set the device to faulty immediately. - setFaulty(event->getEvent()); + if (strangeReplyCount.incrementAndCheck()) { + setFaulty(event->getEvent()); + } break; case DeviceHandlerIF::DEVICE_SENDING_COMMAND_FAILED: case DeviceHandlerIF::DEVICE_REQUESTING_REPLY_FAILED: From 97268af5554438130a8e1406a3a7997c66d7a806 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Sun, 18 Jun 2023 17:11:38 +0200 Subject: [PATCH 09/16] another tmp FDIR fix --- mission/system/tcs/TmpDevFdir.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/mission/system/tcs/TmpDevFdir.cpp b/mission/system/tcs/TmpDevFdir.cpp index 8123debc..4034f2e3 100644 --- a/mission/system/tcs/TmpDevFdir.cpp +++ b/mission/system/tcs/TmpDevFdir.cpp @@ -42,7 +42,9 @@ ReturnValue_t TmpDevFdir::eventReceived(EventMessage* event) { break; } // else - setFaulty(event->getEvent()); + if (missedReplyCount.incrementAndCheck()) { + setFaulty(event->getEvent()); + } break; case StorageManagerIF::GET_DATA_FAILED: case StorageManagerIF::STORE_DATA_FAILED: From 8f7d3dd815e4da45cb7b4550c9e158f623c88ff8 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Sun, 18 Jun 2023 17:24:19 +0200 Subject: [PATCH 10/16] changelog --- CHANGELOG.md | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index a6b35942..a4bae081 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -18,8 +18,17 @@ will consitute of a breaking change warranting a new major release: ## Fixed -- SUS total vector was not reset to being a zero vector during eclipse due to a wrong memcpy +- SUS total vector was not reset to being a zero vector during eclipse due to a wrong `memcpy` length. +- TMP device FDIR + +## Changed + +- Swapped PL and PS I2C, BPX battery and MGT are connected to PS I2C now. + +## Added + +- Added TMP devices for EM build. # [v4.0.0] to be released From df4e657ec3f729af9323c45b63073a084bf56e4e Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Sun, 18 Jun 2023 17:36:50 +0200 Subject: [PATCH 11/16] create TCS CTRL TMP1075 PLCDU 1 se tdynamically --- bsp_q7s/em/emObjectFactory.cpp | 15 --------------- bsp_q7s/fmObjectFactory.cpp | 2 +- mission/controller/ThermalController.cpp | 20 +++++++++++++------- mission/controller/ThermalController.h | 3 ++- 4 files changed, 16 insertions(+), 24 deletions(-) diff --git a/bsp_q7s/em/emObjectFactory.cpp b/bsp_q7s/em/emObjectFactory.cpp index 9aecc7ba..b319c5b6 100644 --- a/bsp_q7s/em/emObjectFactory.cpp +++ b/bsp_q7s/em/emObjectFactory.cpp @@ -100,21 +100,6 @@ void ObjectFactory::produce(void* args) { new CoreController(objects::CORE_CONTROLLER, enableHkSets); - // Regular FM code, does not work for EM if the hardware is not connected - // createPcduComponents(gpioComIF, &pwrSwitcher); - // createPlPcduComponents(gpioComIF, spiMainComIF, pwrSwitcher); - // createSyrlinksComponents(pwrSwitcher); - // createSunSensorComponents(gpioComIF, spiMainComIF, pwrSwitcher, q7s::SPI_DEFAULT_DEV); - // createRtdComponents(q7s::SPI_DEFAULT_DEV, gpioComIF, pwrSwitcher, spiMainComIF); - // createTmpComponents(); - // createSolarArrayDeploymentComponents(); - // createPayloadComponents(gpioComIF); - // createHeaterComponents(gpioComIF, pwrSwitcher, healthTable); - - // TODO: Careful! Switching this on somehow messes with the communication with the ProASIC - // and will cause xsc_boot_copy commands to always boot to 0 0 - // createRadSensorComponent(gpioComIF); - #if OBSW_ADD_ACS_BOARD == 1 // Still initialize chip select to avoid SPI bus issues. createRadSensorChipSelect(gpioComIF); diff --git a/bsp_q7s/fmObjectFactory.cpp b/bsp_q7s/fmObjectFactory.cpp index 25fb221c..419b27a8 100644 --- a/bsp_q7s/fmObjectFactory.cpp +++ b/bsp_q7s/fmObjectFactory.cpp @@ -121,7 +121,7 @@ void ObjectFactory::produce(void* args) { #endif /* OBSW_ADD_TEST_CODE == 1 */ createMiscComponents(); - createThermalController(*heaterHandler); + createThermalController(*heaterHandler, false); createAcsController(true, enableHkSets); satsystem::init(); } diff --git a/mission/controller/ThermalController.cpp b/mission/controller/ThermalController.cpp index 9e7b7d24..05011b1f 100644 --- a/mission/controller/ThermalController.cpp +++ b/mission/controller/ThermalController.cpp @@ -57,8 +57,6 @@ ThermalController::ThermalController(object_id_t objectId, HeaterHandler& heater tmp1075SetTcs0(objects::TMP1075_HANDLER_TCS_0), tmp1075SetTcs1(objects::TMP1075_HANDLER_TCS_1), tmp1075SetPlPcdu0(objects::TMP1075_HANDLER_PLPCDU_0), - // damaged - tmp1075SetPlPcdu1(objects::TMP1075_HANDLER_PLPCDU_1), tmp1075SetIfBoard(objects::TMP1075_HANDLER_IF_BOARD), susSet0(objects::SUS_0_N_LOC_XFYFZM_PT_XF), susSet1(objects::SUS_1_N_LOC_XBYFZM_PT_XB), @@ -73,6 +71,9 @@ ThermalController::ThermalController(object_id_t objectId, HeaterHandler& heater susSet10(objects::SUS_10_N_LOC_XMYBZF_PT_ZF), susSet11(objects::SUS_11_R_LOC_XBYMZB_PT_ZB), tcsBrdShortlyUnavailable(tcsBoardShortUnavailable) { + if (pollPcdu1Tmp) { + tmp1075SetPlPcdu1 = new TMP1075::Tmp1075Dataset(objects::TMP1075_HANDLER_PLPCDU_1); + } resetSensorsArray(); } @@ -539,14 +540,13 @@ void ThermalController::copySensors() { } } // damaged on FM, and no dummies for now - if (pollPcdu1Tmp) { { - PoolReadGuard pg(&tmp1075SetPlPcdu1, MutexIF::TimeoutType::WAITING, MUTEX_TIMEOUT); + PoolReadGuard pg(tmp1075SetPlPcdu1, MutexIF::TimeoutType::WAITING, MUTEX_TIMEOUT); if (pg.getReadResult() == returnvalue::OK) { - sensorTemperatures.tmp1075PlPcdu1.value = tmp1075SetPlPcdu1.temperatureCelcius.value; - sensorTemperatures.tmp1075PlPcdu1.setValid(tmp1075SetPlPcdu1.temperatureCelcius.isValid()); - if (not tmp1075SetPlPcdu1.temperatureCelcius.isValid()) { + sensorTemperatures.tmp1075PlPcdu1.value = tmp1075SetPlPcdu1->temperatureCelcius.value; + sensorTemperatures.tmp1075PlPcdu1.setValid(tmp1075SetPlPcdu1->temperatureCelcius.isValid()); + if (not tmp1075SetPlPcdu1->temperatureCelcius.isValid()) { sensorTemperatures.tmp1075PlPcdu1.value = INVALID_TEMPERATURE; } } @@ -1831,6 +1831,12 @@ void ThermalController::heaterSwitchHelperAllOff() { } } +ThermalController::~ThermalController() { + if (tmp1075SetPlPcdu1 != nullptr) { + delete tmp1075SetPlPcdu1; + } +} + void ThermalController::tooHotHandlerWhichClearsOneShotFlag(object_id_t object, bool& oneShotFlag) { // Clear the one shot flag is the component is in acceptable temperature range. if (not tooHotHandler(object, oneShotFlag) and not componentAboveUpperLimit) { diff --git a/mission/controller/ThermalController.h b/mission/controller/ThermalController.h index ab5ddd09..bcbfc004 100644 --- a/mission/controller/ThermalController.h +++ b/mission/controller/ThermalController.h @@ -104,6 +104,7 @@ class ThermalController : public ExtendedControllerBase { ThermalController(object_id_t objectId, HeaterHandler& heater, const std::atomic_bool& tcsBoardShortUnavailable, bool pollPcdu1Tmp); + virtual ~ThermalController(); ReturnValue_t initialize() override; @@ -174,7 +175,7 @@ class ThermalController : public ExtendedControllerBase { TMP1075::Tmp1075Dataset tmp1075SetTcs1; TMP1075::Tmp1075Dataset tmp1075SetPlPcdu0; // damaged - TMP1075::Tmp1075Dataset tmp1075SetPlPcdu1; + TMP1075::Tmp1075Dataset* tmp1075SetPlPcdu1; TMP1075::Tmp1075Dataset tmp1075SetIfBoard; // SUS From 9ece676313a1c21b6c71b1c196f9100a35889e2e Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Mon, 3 Jul 2023 16:55:45 +0200 Subject: [PATCH 12/16] lets see if this works --- bsp_q7s/CMakeLists.txt | 3 +- bsp_q7s/core/CMakeLists.txt | 5 +-- bsp_q7s/core/CoreController.cpp | 23 ++--------- bsp_q7s/core/CoreController.h | 2 +- bsp_q7s/core/{CoreDefinitions.h => defs.h} | 12 ++++-- bsp_q7s/em/emObjectFactory.cpp | 3 +- bsp_q7s/fmObjectFactory.cpp | 3 +- .../ObjectFactory.cpp => objectFactory.cpp} | 41 ++++++++++++++++++- .../{core/ObjectFactory.h => objectFactory.h} | 1 + bsp_q7s/obsw.cpp | 2 +- bsp_q7s/{core => }/scheduling.cpp | 2 +- bsp_q7s/{core => }/scheduling.h | 0 dummies/CoreControllerDummy.cpp | 2 +- mission/controller/ThermalController.cpp | 2 +- mission/controller/ThermalController.h | 2 +- 15 files changed, 67 insertions(+), 36 deletions(-) rename bsp_q7s/core/{CoreDefinitions.h => defs.h} (81%) rename bsp_q7s/{core/ObjectFactory.cpp => objectFactory.cpp} (96%) rename bsp_q7s/{core/ObjectFactory.h => objectFactory.h} (98%) rename bsp_q7s/{core => }/scheduling.cpp (99%) rename bsp_q7s/{core => }/scheduling.h (100%) diff --git a/bsp_q7s/CMakeLists.txt b/bsp_q7s/CMakeLists.txt index cf8fcacd..e3232363 100644 --- a/bsp_q7s/CMakeLists.txt +++ b/bsp_q7s/CMakeLists.txt @@ -7,7 +7,8 @@ target_link_libraries(${SIMPLE_OBSW_NAME} PUBLIC ${LIB_FSFW_NAME}) target_compile_definitions(${SIMPLE_OBSW_NAME} PRIVATE "Q7S_SIMPLE_MODE") add_subdirectory(simple) -target_sources(${OBSW_NAME} PUBLIC main.cpp obsw.cpp) +target_sources(${OBSW_NAME} PUBLIC main.cpp obsw.cpp scheduling.cpp + objectFactory.cpp) add_subdirectory(boardtest) diff --git a/bsp_q7s/core/CMakeLists.txt b/bsp_q7s/core/CMakeLists.txt index b726885b..33550144 100644 --- a/bsp_q7s/core/CMakeLists.txt +++ b/bsp_q7s/core/CMakeLists.txt @@ -1,4 +1 @@ -target_sources(${OBSW_NAME} PRIVATE CoreController.cpp scheduling.cpp - ObjectFactory.cpp WatchdogHandler.cpp) - -target_sources(${SIMPLE_OBSW_NAME} PRIVATE scheduling.cpp) +target_sources(${OBSW_NAME} PRIVATE CoreController.cpp WatchdogHandler.cpp) diff --git a/bsp_q7s/core/CoreController.cpp b/bsp_q7s/core/CoreController.cpp index cea6c700..c2e73c52 100644 --- a/bsp_q7s/core/CoreController.cpp +++ b/bsp_q7s/core/CoreController.cpp @@ -188,17 +188,6 @@ ReturnValue_t CoreController::initialize() { } triggerEvent(core::REBOOT_SW, CURRENT_CHIP, CURRENT_COPY); announceCurrentImageInfo(); - // This has to come before the version announce because it might be required for retrieving - // the firmware version. - if (common::OBSW_VERSION_MAJOR >= 6 or common::OBSW_VERSION_MAJOR == 4) { - UioMapper sysRomMapper(q7s::UIO_SYS_ROM); - result = sysRomMapper.getMappedAdress(&mappedSysRomAddr, UioMapper::Permissions::READ_ONLY); - if (result != returnvalue::OK) { - // TODO: This might be a reason to switch to another image.. - sif::error << "Getting mapped SYS ROM UIO address failed" << std::endl; - result = ObjectManager::CHILD_INIT_FAILED; - } - } announceVersionInfo(); return result; @@ -2526,14 +2515,10 @@ void CoreController::announceVersionInfo() { } triggerEvent(VERSION_INFO, p1, p2); - - if (common::OBSW_VERSION_MAJOR >= 6 or common::OBSW_VERSION_MAJOR == 4) { - if (mappedSysRomAddr != nullptr) { - uint32_t p1Firmware = *(reinterpret_cast(mappedSysRomAddr)); - uint32_t p2Firmware = *(reinterpret_cast(mappedSysRomAddr) + 1); - triggerEvent(FIRMWARE_INFO, p1Firmware, p2Firmware); - } - } + p1 = (core::FW_VERSION_MAJOR << 24) | (core::FW_VERSION_MINOR << 16) | + (core::FW_VERSION_REVISION << 8) | (core::FW_VERSION_HAS_SHA); + std::memcpy(&p2, core::FW_VERSION_GIT_SHA, 4); + triggerEvent(FIRMWARE_INFO, p1, p2); } void CoreController::announceCurrentImageInfo() { diff --git a/bsp_q7s/core/CoreController.h b/bsp_q7s/core/CoreController.h index b68ae158..b6bc9bfb 100644 --- a/bsp_q7s/core/CoreController.h +++ b/bsp_q7s/core/CoreController.h @@ -1,6 +1,7 @@ #ifndef BSP_Q7S_CORE_CORECONTROLLER_H_ #define BSP_Q7S_CORE_CORECONTROLLER_H_ +#include #include #include #include @@ -14,7 +15,6 @@ #include #include -#include "CoreDefinitions.h" #include "OBSWConfig.h" #include "bsp_q7s/fs/SdCardManager.h" #include "events/subsystemIdRanges.h" diff --git a/bsp_q7s/core/CoreDefinitions.h b/bsp_q7s/core/defs.h similarity index 81% rename from bsp_q7s/core/CoreDefinitions.h rename to bsp_q7s/core/defs.h index 91896301..a82c1c56 100644 --- a/bsp_q7s/core/CoreDefinitions.h +++ b/bsp_q7s/core/defs.h @@ -1,10 +1,16 @@ -#ifndef BSP_Q7S_CORE_COREDEFINITIONS_H_ -#define BSP_Q7S_CORE_COREDEFINITIONS_H_ +#ifndef BSP_Q7S_CORE_DEFS_H_ +#define BSP_Q7S_CORE_DEFS_H_ #include namespace core { +extern uint8_t FW_VERSION_MAJOR; +extern uint8_t FW_VERSION_MINOR; +extern uint8_t FW_VERSION_REVISION; +extern bool FW_VERSION_HAS_SHA; +extern char FW_VERSION_GIT_SHA[4]; + static const uint8_t HK_SET_ENTRIES = 3; static const uint32_t HK_SET_ID = 5; @@ -36,4 +42,4 @@ class HkSet : public StaticLocalDataSet { } // namespace core -#endif /* BSP_Q7S_CORE_COREDEFINITIONS_H_ */ +#endif /* BSP_Q7S_CORE_DEFS_H_ */ diff --git a/bsp_q7s/em/emObjectFactory.cpp b/bsp_q7s/em/emObjectFactory.cpp index a6e10e57..68855d01 100644 --- a/bsp_q7s/em/emObjectFactory.cpp +++ b/bsp_q7s/em/emObjectFactory.cpp @@ -1,4 +1,5 @@ #include +#include #include #include #include @@ -10,7 +11,6 @@ #include "OBSWConfig.h" #include "bsp_q7s/core/CoreController.h" -#include "bsp_q7s/core/ObjectFactory.h" #include "busConf.h" #include "common/config/devices/addresses.h" #include "devConf.h" @@ -36,6 +36,7 @@ void ObjectFactory::produce(void* args) { #endif PersistentTmStores stores; + readFirmwareVersion(); ObjectFactory::produceGenericObjects(&healthTable, &pusFunnel, &cfdpFunnel, *SdCardManager::instance(), &ipcStore, &tmStore, stores, 200, enableHkSets); diff --git a/bsp_q7s/fmObjectFactory.cpp b/bsp_q7s/fmObjectFactory.cpp index f4bb461a..e97930d2 100644 --- a/bsp_q7s/fmObjectFactory.cpp +++ b/bsp_q7s/fmObjectFactory.cpp @@ -1,4 +1,5 @@ #include +#include #include #include #include @@ -7,7 +8,6 @@ #include "OBSWConfig.h" #include "bsp_q7s/core/CoreController.h" -#include "bsp_q7s/core/ObjectFactory.h" #include "busConf.h" #include "devConf.h" #include "eive/objects.h" @@ -32,6 +32,7 @@ void ObjectFactory::produce(void* args) { #endif PersistentTmStores stores; + readFirmwareVersion(); ObjectFactory::produceGenericObjects(&healthTable, &pusFunnel, &cfdpFunnel, *SdCardManager::instance(), &ipcStore, &tmStore, stores, 200, true); diff --git a/bsp_q7s/core/ObjectFactory.cpp b/bsp_q7s/objectFactory.cpp similarity index 96% rename from bsp_q7s/core/ObjectFactory.cpp rename to bsp_q7s/objectFactory.cpp index ca09be97..ed07b131 100644 --- a/bsp_q7s/core/ObjectFactory.cpp +++ b/bsp_q7s/objectFactory.cpp @@ -1,8 +1,9 @@ -#include "ObjectFactory.h" +#include "objectFactory.h" #include #include #include +#include #include #include #include @@ -32,6 +33,9 @@ #include #include +#include +#include + #include "OBSWConfig.h" #include "bsp_q7s/boardtest/Q7STestTask.h" #include "bsp_q7s/callbacks/gnssCallback.h" @@ -100,6 +104,7 @@ #include +#include "bsp_q7s/core/defs.h" #include "fsfw/datapoollocal/LocalDataPoolManager.h" #include "fsfw/tmtcpacket/pus/tm.h" #include "fsfw/tmtcservices/CommandingServiceBase.h" @@ -130,6 +135,11 @@ ResetArgs RESET_ARGS_GNSS; std::atomic_bool LINK_STATE = CcsdsIpCoreHandler::LINK_DOWN; std::atomic_bool PTME_LOCKED = false; std::atomic_uint16_t I2C_FATAL_ERRORS = 0; +uint8_t core::FW_VERSION_MAJOR = 0; +uint8_t core::FW_VERSION_MINOR = 0; +uint8_t core::FW_VERSION_REVISION = 0; +bool core::FW_VERSION_HAS_SHA = false; +char core::FW_VERSION_GIT_SHA[4] = {}; void Factory::setStaticFrameworkObjectIds() { PusServiceBase::PUS_DISTRIBUTOR = objects::PUS_PACKET_DISTRIBUTOR; @@ -1025,3 +1035,32 @@ void ObjectFactory::createPlI2cResetGpio(LinuxLibgpioIF* gpioIF) { gpioIF->pullHigh(gpioIds::PL_I2C_ARESETN); } } + +ReturnValue_t ObjectFactory::readFirmwareVersion() { + uint32_t* mappedSysRomAddr = nullptr; + // The SYS ROM FPGA block is only available in those versions. + if (not(common::OBSW_VERSION_MAJOR >= 6) or (common::OBSW_VERSION_MAJOR == 4)) { + return returnvalue::OK; + } + // This has to come before the version announce because it might be required for retrieving + // the firmware version. + UioMapper sysRomMapper(q7s::UIO_SYS_ROM); + ReturnValue_t result = + sysRomMapper.getMappedAdress(&mappedSysRomAddr, UioMapper::Permissions::READ_ONLY); + if (result != returnvalue::OK) { + sif::error << "Getting mapped SYS ROM UIO address failed" << std::endl; + return returnvalue::FAILED; + } + if (mappedSysRomAddr != nullptr) { + uint32_t firstEntry = *(reinterpret_cast(mappedSysRomAddr)); + uint32_t secondEntry = *(reinterpret_cast(mappedSysRomAddr) + 1); + core::FW_VERSION_MAJOR = (firstEntry >> 24) & 0xff; + core::FW_VERSION_MINOR = (firstEntry >> 16) & 0xff; + core::FW_VERSION_REVISION = (firstEntry >> 8) & 0xff; + bool hasGitSha = (firstEntry & 0x0b1); + if (hasGitSha) { + std::memcpy(core::FW_VERSION_GIT_SHA, &secondEntry, 4); + } + } + return returnvalue::OK; +} diff --git a/bsp_q7s/core/ObjectFactory.h b/bsp_q7s/objectFactory.h similarity index 98% rename from bsp_q7s/core/ObjectFactory.h rename to bsp_q7s/objectFactory.h index 25d06090..e4694bf4 100644 --- a/bsp_q7s/core/ObjectFactory.h +++ b/bsp_q7s/objectFactory.h @@ -75,6 +75,7 @@ void createSyrlinksComponents(PowerSwitchIF* pwrSwitcher); void createPayloadComponents(LinuxLibgpioIF* gpioComIF, PowerSwitchIF& pwrSwitcher); void createReactionWheelComponents(LinuxLibgpioIF* gpioComIF, PowerSwitchIF* pwrSwitcher); ReturnValue_t createCcsdsComponents(CcsdsComponentArgs& args); +ReturnValue_t readFirmwareVersion(); void createMiscComponents(); void createTestComponents(LinuxLibgpioIF* gpioComIF); diff --git a/bsp_q7s/obsw.cpp b/bsp_q7s/obsw.cpp index dc547b03..fc49c369 100644 --- a/bsp_q7s/obsw.cpp +++ b/bsp_q7s/obsw.cpp @@ -11,13 +11,13 @@ #include "OBSWConfig.h" #include "bsp_q7s/core/WatchdogHandler.h" #include "commonConfig.h" -#include "core/scheduling.h" #include "fsfw/tasks/TaskFactory.h" #include "fsfw/version.h" #include "mission/acs/defs.h" #include "mission/com/defs.h" #include "mission/system/systemTree.h" #include "q7sConfig.h" +#include "scheduling.h" #include "watchdog/definitions.h" static constexpr int OBSW_ALREADY_RUNNING = -2; diff --git a/bsp_q7s/core/scheduling.cpp b/bsp_q7s/scheduling.cpp similarity index 99% rename from bsp_q7s/core/scheduling.cpp rename to bsp_q7s/scheduling.cpp index a7c41bb6..b41eade2 100644 --- a/bsp_q7s/core/scheduling.cpp +++ b/bsp_q7s/scheduling.cpp @@ -9,7 +9,6 @@ #include #include "OBSWConfig.h" -#include "bsp_q7s/core/ObjectFactory.h" #include "fsfw/objectmanager/ObjectManager.h" #include "fsfw/objectmanager/ObjectManagerIF.h" #include "fsfw/platform.h" @@ -21,6 +20,7 @@ #include "mission/pollingSeqTables.h" #include "mission/scheduling.h" #include "mission/utility/InitMission.h" +#include "objectFactory.h" #include "q7sConfig.h" /* This is configured for linux without CR */ diff --git a/bsp_q7s/core/scheduling.h b/bsp_q7s/scheduling.h similarity index 100% rename from bsp_q7s/core/scheduling.h rename to bsp_q7s/scheduling.h diff --git a/dummies/CoreControllerDummy.cpp b/dummies/CoreControllerDummy.cpp index 8a027dbf..df2bef03 100644 --- a/dummies/CoreControllerDummy.cpp +++ b/dummies/CoreControllerDummy.cpp @@ -1,6 +1,6 @@ #include "CoreControllerDummy.h" -#include +#include #include #include diff --git a/mission/controller/ThermalController.cpp b/mission/controller/ThermalController.cpp index 05011b1f..fca71acc 100644 --- a/mission/controller/ThermalController.cpp +++ b/mission/controller/ThermalController.cpp @@ -1,6 +1,6 @@ #include "ThermalController.h" -#include +#include #include #include #include diff --git a/mission/controller/ThermalController.h b/mission/controller/ThermalController.h index bcbfc004..2518a13e 100644 --- a/mission/controller/ThermalController.h +++ b/mission/controller/ThermalController.h @@ -1,7 +1,7 @@ #ifndef MISSION_CONTROLLER_THERMALCONTROLLER_H_ #define MISSION_CONTROLLER_THERMALCONTROLLER_H_ -#include +#include #include #include #include From 25c7058da5eab75c73499c9ecfb0b81a9a03c6d8 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Mon, 3 Jul 2023 16:56:36 +0200 Subject: [PATCH 13/16] changelog --- CHANGELOG.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 8397f4d9..a13d3d1d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -20,6 +20,8 @@ will consitute of a breaking change warranting a new major release: - Swapped PL and PS I2C, BPX battery and MGT are connected to PS I2C now for firmware versions above v4. However, this software version ins compatible to both v3 and v4 of the firmware. +- The firmware version variables are global statics inititalized early during the program + runtime now. This makes it possible to check the firmware version earlier. # [v6.0.0] 2023-07-02 From d1b9608a1465e971f12963bd5a08a43345881452 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Mon, 3 Jul 2023 17:13:11 +0200 Subject: [PATCH 14/16] that should do the job --- bsp_q7s/core/CoreController.cpp | 2 +- bsp_q7s/em/emObjectFactory.cpp | 14 +++++++++++--- bsp_q7s/fmObjectFactory.cpp | 14 +++++++++++--- bsp_q7s/objectFactory.cpp | 15 ++++++++------- bsp_q7s/objectFactory.h | 7 ++++--- 5 files changed, 35 insertions(+), 17 deletions(-) diff --git a/bsp_q7s/core/CoreController.cpp b/bsp_q7s/core/CoreController.cpp index c2e73c52..00c7f248 100644 --- a/bsp_q7s/core/CoreController.cpp +++ b/bsp_q7s/core/CoreController.cpp @@ -2516,7 +2516,7 @@ void CoreController::announceVersionInfo() { triggerEvent(VERSION_INFO, p1, p2); p1 = (core::FW_VERSION_MAJOR << 24) | (core::FW_VERSION_MINOR << 16) | - (core::FW_VERSION_REVISION << 8) | (core::FW_VERSION_HAS_SHA); + (core::FW_VERSION_REVISION << 8) | (core::FW_VERSION_HAS_SHA); std::memcpy(&p2, core::FW_VERSION_GIT_SHA, 4); triggerEvent(FIRMWARE_INFO, p1, p2); } diff --git a/bsp_q7s/em/emObjectFactory.cpp b/bsp_q7s/em/emObjectFactory.cpp index 68855d01..28fabe7a 100644 --- a/bsp_q7s/em/emObjectFactory.cpp +++ b/bsp_q7s/em/emObjectFactory.cpp @@ -68,7 +68,11 @@ void ObjectFactory::produce(void* args) { {objects::TMP1075_HANDLER_PLPCDU_1, addresses::TMP1075_PLPCDU_1}, {objects::TMP1075_HANDLER_IF_BOARD, addresses::TMP1075_IF_BOARD}, }}; - createTmpComponents(tmpDevsToAdd); + const char* tmpI2cDev = q7s::I2C_PS_EIVE; + if (core::FW_VERSION_MAJOR >= 4) { + tmpI2cDev = q7s::I2C_PL_EIVE; + } + createTmpComponents(tmpDevsToAdd, tmpI2cDev); dummy::Tmp1075Cfg tmpCfg{}; tmpCfg.addTcsBrd0 = true; tmpCfg.addTcsBrd1 = true; @@ -114,8 +118,12 @@ void ObjectFactory::produce(void* args) { gpioChecker(gpioComIF->addGpios(acsBoardGpios), "ACS Board"); #endif + const char* battAndImtqI2cDev = q7s::I2C_PL_EIVE; + if (core::FW_VERSION_MAJOR >= 4) { + battAndImtqI2cDev = q7s::I2C_PS_EIVE; + } #if OBSW_ADD_MGT == 1 - createImtqComponents(pwrSwitcher, enableHkSets); + createImtqComponents(pwrSwitcher, enableHkSets, battAndImtqI2cDev); #endif #if OBSW_ADD_SYRLINKS == 1 @@ -127,7 +135,7 @@ void ObjectFactory::produce(void* args) { #endif #if OBSW_ADD_BPX_BATTERY_HANDLER == 1 - createBpxBatteryComponent(enableHkSets); + createBpxBatteryComponent(enableHkSets, battAndImtqI2cDev); #endif #if OBSW_ADD_STAR_TRACKER == 1 diff --git a/bsp_q7s/fmObjectFactory.cpp b/bsp_q7s/fmObjectFactory.cpp index e97930d2..74b3e725 100644 --- a/bsp_q7s/fmObjectFactory.cpp +++ b/bsp_q7s/fmObjectFactory.cpp @@ -76,7 +76,11 @@ void ObjectFactory::produce(void* args) { // {objects::TMP1075_HANDLER_PLPCDU_1, addresses::TMP1075_PLPCDU_1}, {objects::TMP1075_HANDLER_IF_BOARD, addresses::TMP1075_IF_BOARD}, }}; - createTmpComponents(tmpDevsToAdd); + const char* tmpI2cDev = q7s::I2C_PS_EIVE; + if (core::FW_VERSION_MAJOR >= 4) { + tmpI2cDev = q7s::I2C_PL_EIVE; + } + createTmpComponents(tmpDevsToAdd, tmpI2cDev); #endif createSolarArrayDeploymentComponents(*pwrSwitcher, *gpioComIF); createPlPcduComponents(gpioComIF, spiMainComIF, pwrSwitcher, *stackHandler); @@ -86,13 +90,17 @@ void ObjectFactory::produce(void* args) { createRtdComponents(q7s::SPI_DEFAULT_DEV, gpioComIF, pwrSwitcher, spiMainComIF); createPayloadComponents(gpioComIF, *pwrSwitcher); + const char* battAndImtqI2cDev = q7s::I2C_PL_EIVE; + if (core::FW_VERSION_MAJOR >= 4) { + battAndImtqI2cDev = q7s::I2C_PS_EIVE; + } #if OBSW_ADD_MGT == 1 - createImtqComponents(pwrSwitcher, enableHkSets); + createImtqComponents(pwrSwitcher, enableHkSets, battAndImtqI2cDev); #endif createReactionWheelComponents(gpioComIF, pwrSwitcher); #if OBSW_ADD_BPX_BATTERY_HANDLER == 1 - createBpxBatteryComponent(enableHkSets); + createBpxBatteryComponent(enableHkSets, battAndImtqI2cDev); #endif #if OBSW_ADD_STAR_TRACKER == 1 diff --git a/bsp_q7s/objectFactory.cpp b/bsp_q7s/objectFactory.cpp index ed07b131..cd4dd32c 100644 --- a/bsp_q7s/objectFactory.cpp +++ b/bsp_q7s/objectFactory.cpp @@ -161,13 +161,13 @@ void Factory::setStaticFrameworkObjectIds() { void ObjectFactory::setStatics() { Factory::setStaticFrameworkObjectIds(); } -void ObjectFactory::createTmpComponents( - std::vector> tmpDevsToAdd) { +void ObjectFactory::createTmpComponents(std::vector> tmpDevsToAdd, + const char* i2cDev) { std::vector tmpDevCookies; for (size_t idx = 0; idx < tmpDevsToAdd.size(); idx++) { tmpDevCookies.push_back( - new I2cCookie(tmpDevsToAdd[idx].second, TMP1075::MAX_REPLY_LENGTH, q7s::I2C_PL_EIVE)); + new I2cCookie(tmpDevsToAdd[idx].second, TMP1075::MAX_REPLY_LENGTH, i2cDev)); auto* tmpDevHandler = new Tmp1075Handler(tmpDevsToAdd[idx].first, objects::I2C_COM_IF, tmpDevCookies[idx]); tmpDevHandler->setCustomFdir(new TmpDevFdir(tmpDevsToAdd[idx].first)); @@ -957,12 +957,13 @@ void ObjectFactory::createStrComponents(PowerSwitchIF* pwrSwitcher) { starTracker->setCustomFdir(strFdir); } -void ObjectFactory::createImtqComponents(PowerSwitchIF* pwrSwitcher, bool enableHkSets) { +void ObjectFactory::createImtqComponents(PowerSwitchIF* pwrSwitcher, bool enableHkSets, + const char* i2cDev) { auto* imtqAssy = new ImtqAssembly(objects::IMTQ_ASSY); imtqAssy->connectModeTreeParent(satsystem::acs::ACS_SUBSYSTEM); new ImtqPollingTask(objects::IMTQ_POLLING, I2C_FATAL_ERRORS); - I2cCookie* imtqI2cCookie = new I2cCookie(addresses::IMTQ, imtq::MAX_REPLY_SIZE, q7s::I2C_PS_EIVE); + I2cCookie* imtqI2cCookie = new I2cCookie(addresses::IMTQ, imtq::MAX_REPLY_SIZE, i2cDev); auto imtqHandler = new ImtqHandler(objects::IMTQ_HANDLER, objects::IMTQ_POLLING, imtqI2cCookie, power::Switches::PDU1_CH3_MGT_5V, enableHkSets); imtqHandler->enableThermalModule(ThermalStateCfg()); @@ -978,8 +979,8 @@ void ObjectFactory::createImtqComponents(PowerSwitchIF* pwrSwitcher, bool enable #endif } -void ObjectFactory::createBpxBatteryComponent(bool enableHkSets) { - I2cCookie* bpxI2cCookie = new I2cCookie(addresses::BPX_BATTERY, 100, q7s::I2C_PS_EIVE); +void ObjectFactory::createBpxBatteryComponent(bool enableHkSets, const char* i2cDev) { + I2cCookie* bpxI2cCookie = new I2cCookie(addresses::BPX_BATTERY, 100, i2cDev); BpxBatteryHandler* bpxHandler = new BpxBatteryHandler( objects::BPX_BATT_HANDLER, objects::I2C_COM_IF, bpxI2cCookie, enableHkSets); bpxHandler->setStartUpImmediately(); diff --git a/bsp_q7s/objectFactory.h b/bsp_q7s/objectFactory.h index e4694bf4..779ad204 100644 --- a/bsp_q7s/objectFactory.h +++ b/bsp_q7s/objectFactory.h @@ -58,7 +58,8 @@ void createPcduComponents(LinuxLibgpioIF* gpioComIF, PowerSwitchIF** pwrSwitcher bool enableHkSets); void createPlPcduComponents(LinuxLibgpioIF* gpioComIF, SpiComIF* spiComIF, PowerSwitchIF* pwrSwitcher, Stack5VHandler& stackHandler); -void createTmpComponents(std::vector> tmpDevsToAdd); +void createTmpComponents(std::vector> tmpDevsToAdd, + const char* i2cDev); void createRadSensorChipSelect(LinuxLibgpioIF* gpioIF); ReturnValue_t createRadSensorComponent(LinuxLibgpioIF* gpioComIF, Stack5VHandler& handler); void createAcsBoardGpios(GpioCookie& cookie); @@ -67,8 +68,8 @@ void createAcsBoardComponents(SpiComIF& spiComIF, LinuxLibgpioIF* gpioComIF, Ser adis1650x::Type adisType); void createHeaterComponents(GpioIF* gpioIF, PowerSwitchIF* pwrSwitcher, HealthTableIF* healthTable, HeaterHandler*& heaterHandler); -void createImtqComponents(PowerSwitchIF* pwrSwitcher, bool enableHkSets); -void createBpxBatteryComponent(bool enableHkSets); +void createImtqComponents(PowerSwitchIF* pwrSwitcher, bool enableHkSets, const char* i2cDev); +void createBpxBatteryComponent(bool enableHkSets, const char* i2cDev); void createStrComponents(PowerSwitchIF* pwrSwitcher); void createSolarArrayDeploymentComponents(PowerSwitchIF& pwrSwitcher, GpioIF& gpioIF); void createSyrlinksComponents(PowerSwitchIF* pwrSwitcher); From d8ab6abc4939232cf8005f5ba30595c0e4b7a46a Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Mon, 3 Jul 2023 17:16:51 +0200 Subject: [PATCH 15/16] FM should build again --- bsp_q7s/fmObjectFactory.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/bsp_q7s/fmObjectFactory.cpp b/bsp_q7s/fmObjectFactory.cpp index 74b3e725..fa6e7220 100644 --- a/bsp_q7s/fmObjectFactory.cpp +++ b/bsp_q7s/fmObjectFactory.cpp @@ -1,5 +1,5 @@ #include -#include +#include #include #include #include @@ -10,6 +10,7 @@ #include "bsp_q7s/core/CoreController.h" #include "busConf.h" #include "devConf.h" +#include "devices/addresses.h" #include "eive/objects.h" #include "fsfw_hal/linux/gpio/LinuxLibgpioIF.h" #include "linux/ObjectFactory.h" From 5c430212e70acf404c1632081bdd3c3094306a47 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Mon, 3 Jul 2023 17:32:35 +0200 Subject: [PATCH 16/16] that should fix the host build --- bsp_hosted/ObjectFactory.cpp | 2 +- unittest/controller/testThermalController.cpp | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/bsp_hosted/ObjectFactory.cpp b/bsp_hosted/ObjectFactory.cpp index 23f1a79f..4873bc58 100644 --- a/bsp_hosted/ObjectFactory.cpp +++ b/bsp_hosted/ObjectFactory.cpp @@ -113,7 +113,7 @@ void ObjectFactory::produce(void* args) { if (heaterHandler == nullptr) { sif::error << "HeaterHandler could not be created" << std::endl; } else { - ObjectFactory::createThermalController(*heaterHandler); + ObjectFactory::createThermalController(*heaterHandler, true); } new TestTask(objects::TEST_TASK); } diff --git a/unittest/controller/testThermalController.cpp b/unittest/controller/testThermalController.cpp index c2166ca0..287943ce 100644 --- a/unittest/controller/testThermalController.cpp +++ b/unittest/controller/testThermalController.cpp @@ -30,7 +30,8 @@ TEST_CASE("Thermal Controller", "[ThermalController]") { // testEnvironment::initialize(); - ThermalController controller(THERMAL_CONTROLLER_ID, *heaterHandler, tcsBrdShortlyUnavailable); + ThermalController controller(THERMAL_CONTROLLER_ID, *heaterHandler, tcsBrdShortlyUnavailable, + true); ReturnValue_t result = controller.initialize(); REQUIRE(result == returnvalue::OK);