diff --git a/bsp_q7s/core/ObjectFactory.cpp b/bsp_q7s/core/ObjectFactory.cpp index d7bd02e5..15cd4baf 100644 --- a/bsp_q7s/core/ObjectFactory.cpp +++ b/bsp_q7s/core/ObjectFactory.cpp @@ -347,6 +347,7 @@ void ObjectFactory::createAcsBoardComponents(LinuxLibgpioIF* gpioComIF, SerialCo SpiCookie* spiCookie = new SpiCookie(addresses::MGM_0_LIS3, gpioIds::MGM_0_LIS3_CS, MGMLIS3MDL::MAX_BUFFER_SIZE, spi::DEFAULT_LIS3_MODE, spi::DEFAULT_LIS3_SPEED); + spiCookie->setMutexParams(MutexIF::TimeoutType::WAITING, 40); auto mgmLis3Handler0 = new MgmLIS3MDLHandler( objects::MGM_0_LIS3_HANDLER, objects::SPI_MAIN_COM_IF, spiCookie, spi::LIS3_TRANSITION_DELAY); fdir = new AcsBoardFdir(objects::MGM_0_LIS3_HANDLER); @@ -362,6 +363,7 @@ void ObjectFactory::createAcsBoardComponents(LinuxLibgpioIF* gpioComIF, SerialCo spiCookie = new SpiCookie(addresses::MGM_1_RM3100, gpioIds::MGM_1_RM3100_CS, RM3100::MAX_BUFFER_SIZE, spi::DEFAULT_RM3100_MODE, spi::DEFAULT_RM3100_SPEED); + spiCookie->setMutexParams(MutexIF::TimeoutType::WAITING, 40); auto mgmRm3100Handler1 = new MgmRM3100Handler(objects::MGM_1_RM3100_HANDLER, objects::SPI_MAIN_COM_IF, spiCookie, spi::RM3100_TRANSITION_DELAY); @@ -378,6 +380,7 @@ void ObjectFactory::createAcsBoardComponents(LinuxLibgpioIF* gpioComIF, SerialCo spiCookie = new SpiCookie(addresses::MGM_2_LIS3, gpioIds::MGM_2_LIS3_CS, MGMLIS3MDL::MAX_BUFFER_SIZE, spi::DEFAULT_LIS3_MODE, spi::DEFAULT_LIS3_SPEED); + spiCookie->setMutexParams(MutexIF::TimeoutType::WAITING, 40); auto* mgmLis3Handler2 = new MgmLIS3MDLHandler( objects::MGM_2_LIS3_HANDLER, objects::SPI_MAIN_COM_IF, spiCookie, spi::LIS3_TRANSITION_DELAY); fdir = new AcsBoardFdir(objects::MGM_2_LIS3_HANDLER); @@ -393,6 +396,7 @@ void ObjectFactory::createAcsBoardComponents(LinuxLibgpioIF* gpioComIF, SerialCo spiCookie = new SpiCookie(addresses::MGM_3_RM3100, gpioIds::MGM_3_RM3100_CS, RM3100::MAX_BUFFER_SIZE, spi::DEFAULT_RM3100_MODE, spi::DEFAULT_RM3100_SPEED); + spiCookie->setMutexParams(MutexIF::TimeoutType::WAITING, 40); auto* mgmRm3100Handler3 = new MgmRM3100Handler(objects::MGM_3_RM3100_HANDLER, objects::SPI_MAIN_COM_IF, spiCookie, spi::RM3100_TRANSITION_DELAY); @@ -411,6 +415,7 @@ void ObjectFactory::createAcsBoardComponents(LinuxLibgpioIF* gpioComIF, SerialCo spiCookie = new SpiCookie(addresses::GYRO_0_ADIS, gpioIds::GYRO_0_ADIS_CS, ADIS1650X::MAXIMUM_REPLY_SIZE, spi::DEFAULT_ADIS16507_MODE, spi::DEFAULT_ADIS16507_SPEED); + spiCookie->setMutexParams(MutexIF::TimeoutType::WAITING, 40); auto adisHandler = new GyroADIS1650XHandler(objects::GYRO_0_ADIS_HANDLER, objects::SPI_MAIN_COM_IF, spiCookie, ADIS1650X::Type::ADIS16505); @@ -427,6 +432,7 @@ void ObjectFactory::createAcsBoardComponents(LinuxLibgpioIF* gpioComIF, SerialCo // Gyro 1 Side A spiCookie = new SpiCookie(addresses::GYRO_1_L3G, gpioIds::GYRO_1_L3G_CS, L3GD20H::MAX_BUFFER_SIZE, spi::DEFAULT_L3G_MODE, spi::DEFAULT_L3G_SPEED); + spiCookie->setMutexParams(MutexIF::TimeoutType::WAITING, 40); auto gyroL3gHandler1 = new GyroHandlerL3GD20H( objects::GYRO_1_L3G_HANDLER, objects::SPI_MAIN_COM_IF, spiCookie, spi::L3G_TRANSITION_DELAY); fdir = new AcsBoardFdir(objects::GYRO_1_L3G_HANDLER); @@ -443,6 +449,7 @@ void ObjectFactory::createAcsBoardComponents(LinuxLibgpioIF* gpioComIF, SerialCo spiCookie = new SpiCookie(addresses::GYRO_2_ADIS, gpioIds::GYRO_2_ADIS_CS, ADIS1650X::MAXIMUM_REPLY_SIZE, spi::DEFAULT_ADIS16507_MODE, spi::DEFAULT_ADIS16507_SPEED); + spiCookie->setMutexParams(MutexIF::TimeoutType::WAITING, 40); adisHandler = new GyroADIS1650XHandler(objects::GYRO_2_ADIS_HANDLER, objects::SPI_MAIN_COM_IF, spiCookie, ADIS1650X::Type::ADIS16505); fdir = new AcsBoardFdir(objects::GYRO_2_ADIS_HANDLER); @@ -455,6 +462,7 @@ void ObjectFactory::createAcsBoardComponents(LinuxLibgpioIF* gpioComIF, SerialCo // Gyro 3 Side B spiCookie = new SpiCookie(addresses::GYRO_3_L3G, gpioIds::GYRO_3_L3G_CS, L3GD20H::MAX_BUFFER_SIZE, spi::DEFAULT_L3G_MODE, spi::DEFAULT_L3G_SPEED); + spiCookie->setMutexParams(MutexIF::TimeoutType::WAITING, 40); auto gyroL3gHandler3 = new GyroHandlerL3GD20H( objects::GYRO_3_L3G_HANDLER, objects::SPI_MAIN_COM_IF, spiCookie, spi::L3G_TRANSITION_DELAY); fdir = new AcsBoardFdir(objects::GYRO_3_L3G_HANDLER); diff --git a/linux/devices/Max31865RtdLowlevelHandler.cpp b/linux/devices/Max31865RtdLowlevelHandler.cpp index 14ef9659..594389d3 100644 --- a/linux/devices/Max31865RtdLowlevelHandler.cpp +++ b/linux/devices/Max31865RtdLowlevelHandler.cpp @@ -58,17 +58,17 @@ bool Max31865RtdReader::rtdIsActive(uint8_t idx) { bool Max31865RtdReader::periodicInitHandling() { using namespace MAX31865; - MutexGuard mg(readerMutex); ReturnValue_t result = returnvalue::OK; - if (mg.getLockResult() != returnvalue::OK) { - sif::warning << "Max31865RtdReader::periodicInitHandling: Mutex lock failed" << std::endl; - return false; - } for (auto& rtd : rtds) { if (rtd == nullptr) { continue; } + MutexGuard mg(readerMutex); + if (mg.getLockResult() != returnvalue::OK) { + sif::warning << "Max31865RtdReader::periodicInitHandling: Mutex lock failed" << std::endl; + return false; + } if ((rtd->on or rtd->db.active) and not rtd->db.configured and rtd->cd.hasTimedOut()) { ManualCsLockWrapper mg(csLock, gpioIF, rtd->spiCookie, csTimeoutType, csTimeoutMs); if (mg.lockResult != returnvalue::OK or mg.gpioResult != returnvalue::OK) { @@ -116,16 +116,16 @@ bool Max31865RtdReader::periodicInitHandling() { ReturnValue_t Max31865RtdReader::periodicReadReqHandling() { using namespace MAX31865; - MutexGuard mg(readerMutex); - if (mg.getLockResult() != returnvalue::OK) { - sif::warning << "Max31865RtdReader::periodicReadReqHandling: Mutex lock failed" << std::endl; - return returnvalue::FAILED; - } // Now request one shot config for all active RTDs for (auto& rtd : rtds) { if (rtd == nullptr) { continue; } + MutexGuard mg(readerMutex); + if (mg.getLockResult() != returnvalue::OK) { + sif::warning << "Max31865RtdReader::periodicReadReqHandling: Mutex lock failed" << std::endl; + return returnvalue::FAILED; + } if (rtdIsActive(rtd->idx)) { ReturnValue_t result = writeCfgReg(rtd->spiCookie, BASE_CFG | (1 << CfgBitPos::ONE_SHOT)); if (result != returnvalue::OK) { @@ -141,16 +141,16 @@ ReturnValue_t Max31865RtdReader::periodicReadReqHandling() { ReturnValue_t Max31865RtdReader::periodicReadHandling() { using namespace MAX31865; auto result = returnvalue::OK; - MutexGuard mg(readerMutex); - if (mg.getLockResult() != returnvalue::OK) { - sif::warning << "Max31865RtdReader::periodicReadHandling: Mutex lock failed" << std::endl; - return returnvalue::FAILED; - } // Now read the RTD values for (auto& rtd : rtds) { if (rtd == nullptr) { continue; } + MutexGuard mg(readerMutex); + if (mg.getLockResult() != returnvalue::OK) { + sif::warning << "Max31865RtdReader::periodicReadHandling: Mutex lock failed" << std::endl; + return returnvalue::FAILED; + } if (rtdIsActive(rtd->idx)) { uint16_t rtdVal = 0; bool faultBitSet = false; diff --git a/linux/devices/ploc/PlocSupervisorHandler.cpp b/linux/devices/ploc/PlocSupervisorHandler.cpp index 17657b50..8537d011 100644 --- a/linux/devices/ploc/PlocSupervisorHandler.cpp +++ b/linux/devices/ploc/PlocSupervisorHandler.cpp @@ -704,8 +704,9 @@ ReturnValue_t PlocSupervisorHandler::initializeLocalDataPool(localpool::DataPool localDataPoolMap.emplace(supv::NVM0_1_STATE, new PoolEntry({0})); localDataPoolMap.emplace(supv::NVM3_STATE, new PoolEntry({0})); localDataPoolMap.emplace(supv::MISSION_IO_STATE, new PoolEntry({0})); - localDataPoolMap.emplace(supv::FMC_STATE, new PoolEntry({0})); + localDataPoolMap.emplace(supv::FMC_STATE, &fmcStateEntry); localDataPoolMap.emplace(supv::NUM_TCS, new PoolEntry({0})); + localDataPoolMap.emplace(supv::TEMP_SUP, &tempSupEntry); localDataPoolMap.emplace(supv::UPTIME, new PoolEntry({0})); localDataPoolMap.emplace(supv::CPULOAD, new PoolEntry({0})); localDataPoolMap.emplace(supv::AVAILABLEHEAP, new PoolEntry({0})); @@ -718,6 +719,8 @@ ReturnValue_t PlocSupervisorHandler::initializeLocalDataPool(localpool::DataPool localDataPoolMap.emplace(supv::BP0_STATE, new PoolEntry({0})); localDataPoolMap.emplace(supv::BP1_STATE, new PoolEntry({0})); localDataPoolMap.emplace(supv::BP2_STATE, new PoolEntry({0})); + localDataPoolMap.emplace(supv::BOOT_STATE, &bootStateEntry); + localDataPoolMap.emplace(supv::BOOT_CYCLES, &bootCyclesEntry); localDataPoolMap.emplace(supv::LATCHUP_ID, new PoolEntry({0})); localDataPoolMap.emplace(supv::CNT0, new PoolEntry({0})); diff --git a/linux/devices/ploc/PlocSupervisorHandler.h b/linux/devices/ploc/PlocSupervisorHandler.h index 52e2619b..dcad9d09 100644 --- a/linux/devices/ploc/PlocSupervisorHandler.h +++ b/linux/devices/ploc/PlocSupervisorHandler.h @@ -156,6 +156,11 @@ class PlocSupervisorHandler : public DeviceHandlerBase { Countdown bootTimeout = Countdown(BOOT_TIMEOUT); Countdown mramDumpTimeout = Countdown(MRAM_DUMP_TIMEOUT); + PoolEntry fmcStateEntry = PoolEntry(1); + PoolEntry bootStateEntry = PoolEntry(1); + PoolEntry bootCyclesEntry = PoolEntry(1); + PoolEntry tempSupEntry = PoolEntry(1); + /** * @brief Adjusts the timeout of the execution report dependent on command */ diff --git a/mission/system/tree/system.cpp b/mission/system/tree/system.cpp index aae11110..e8f9d5b1 100644 --- a/mission/system/tree/system.cpp +++ b/mission/system/tree/system.cpp @@ -80,7 +80,8 @@ void buildSafeSequence(Subsystem& ss, ModeListEntry& eh) { iht(objects::PL_SUBSYSTEM, OFF, 0, EIVE_TABLE_SAFE_TGT.second); check(ss.addTable(TableEntry(EIVE_TABLE_SAFE_TGT.first, &EIVE_TABLE_SAFE_TGT.second)), ctxc); - // Build SAFE transition 0 + // Build SAFE transition 0. Two transitions to reduce number of consecutive events and because + // consecutive commanding of TCS and ACS can lead to SPI issues. iht(objects::TCS_SUBSYSTEM, NML, 0, EIVE_TABLE_SAFE_TRANS_0.second); check(ss.addTable(TableEntry(EIVE_TABLE_SAFE_TRANS_0.first, &EIVE_TABLE_SAFE_TRANS_0.second)), ctxc); @@ -94,7 +95,7 @@ void buildSafeSequence(Subsystem& ss, ModeListEntry& eh) { // Build Safe sequence ihs(EIVE_SEQUENCE_SAFE.second, EIVE_TABLE_SAFE_TGT.first, 0, false); ihs(EIVE_SEQUENCE_SAFE.second, EIVE_TABLE_SAFE_TRANS_0.first, 0, false); - ihs(EIVE_SEQUENCE_SAFE.second, EIVE_TABLE_SAFE_TRANS_1.first, 0, false); + ihs(EIVE_SEQUENCE_SAFE.second, EIVE_TABLE_SAFE_TRANS_1.first, 3, false); check(ss.addSequence(SequenceEntry(EIVE_SEQUENCE_SAFE.first, &EIVE_SEQUENCE_SAFE.second, EIVE_SEQUENCE_SAFE.first)), ctxc);