From b12ffb6f44c2bf120a9d82548afe8f658568faf9 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Mon, 4 Apr 2022 13:39:35 +0200 Subject: [PATCH 01/14] PL PCDU switch states like mode bitmask now --- bsp_q7s/core/ObjectFactory.cpp | 6 +- .../PlocSupervisorDefinitions.h | 2 +- linux/devices/ploc/PlocMPSoCHandler.cpp | 131 +++++++++--------- linux/devices/ploc/PlocSupervisorHandler.cpp | 21 ++- linux/devices/ploc/PlocUpdater.cpp | 23 ++- .../devices/startracker/StarTrackerHandler.h | 2 +- mission/devices/P60DockHandler.cpp | 3 + mission/devices/PayloadPcduHandler.cpp | 34 +++-- mission/devices/RadiationSensorHandler.cpp | 24 ++-- mission/devices/SyrlinksHkHandler.cpp | 31 +++-- mission/devices/SyrlinksHkHandler.h | 3 +- .../payloadPcduDefinitions.h | 17 +-- mission/system/AcsBoardAssembly.cpp | 30 ++-- 13 files changed, 165 insertions(+), 162 deletions(-) diff --git a/bsp_q7s/core/ObjectFactory.cpp b/bsp_q7s/core/ObjectFactory.cpp index 123ef60e..2d28a095 100644 --- a/bsp_q7s/core/ObjectFactory.cpp +++ b/bsp_q7s/core/ObjectFactory.cpp @@ -662,9 +662,9 @@ void ObjectFactory::createPayloadComponents(LinuxLibgpioIF* gpioComIF) { auto supvGpioCookie = new GpioCookie; supvGpioCookie->addGpio(gpioIds::ENABLE_SUPV_UART, gpioConfigSupv); gpioComIF->addGpios(supvGpioCookie); - auto supervisorCookie = new UartCookie( - objects::PLOC_SUPERVISOR_HANDLER, q7s::UART_PLOC_SUPERVSIOR_DEV, UartModes::NON_CANONICAL, - uart::PLOC_SUPERVISOR_BAUD, supv::MAX_PACKET_SIZE * 20); + auto supervisorCookie = new UartCookie(objects::PLOC_SUPERVISOR_HANDLER, + q7s::UART_PLOC_SUPERVSIOR_DEV, UartModes::NON_CANONICAL, + uart::PLOC_SUPERVISOR_BAUD, supv::MAX_PACKET_SIZE * 20); supervisorCookie->setNoFixedSizeReply(); new PlocSupervisorHandler(objects::PLOC_SUPERVISOR_HANDLER, objects::UART_COM_IF, supervisorCookie, Gpio(gpioIds::ENABLE_SUPV_UART, gpioComIF), diff --git a/linux/devices/devicedefinitions/PlocSupervisorDefinitions.h b/linux/devices/devicedefinitions/PlocSupervisorDefinitions.h index 96e72f86..58166e98 100644 --- a/linux/devices/devicedefinitions/PlocSupervisorDefinitions.h +++ b/linux/devices/devicedefinitions/PlocSupervisorDefinitions.h @@ -1541,6 +1541,6 @@ class LatchupStatusReport : public StaticLocalDataSet { lp_var_t isSet = lp_var_t(sid.objectId, PoolIds::LATCHUP_RPT_TIME_IS_SET, this); }; -} // namespace PLOC_SPV +} // namespace supv #endif /* MISSION_DEVICES_DEVICEDEFINITIONS_PLOCSVPDEFINITIONS_H_ */ diff --git a/linux/devices/ploc/PlocMPSoCHandler.cpp b/linux/devices/ploc/PlocMPSoCHandler.cpp index d6777afd..13fa9ed7 100644 --- a/linux/devices/ploc/PlocMPSoCHandler.cpp +++ b/linux/devices/ploc/PlocMPSoCHandler.cpp @@ -1,9 +1,9 @@ #include "PlocMPSoCHandler.h" -#include "linux/devices/devicedefinitions/PlocSupervisorDefinitions.h" #include "OBSWConfig.h" #include "fsfw/datapool/PoolReadGuard.h" #include "fsfw/globalfunctions/CRC.h" +#include "linux/devices/devicedefinitions/PlocSupervisorDefinitions.h" PlocMPSoCHandler::PlocMPSoCHandler(object_id_t objectId, object_id_t uartComIFid, CookieIF* comCookie, PlocMPSoCHelper* plocMPSoCHelper, @@ -87,8 +87,8 @@ void PlocMPSoCHandler::performOperationHook() { } } CommandMessage message; - for (ReturnValue_t result = commandActionHelperQueue->receiveMessage(&message); result == RETURN_OK; - result = commandActionHelperQueue->receiveMessage(&message)) { + for (ReturnValue_t result = commandActionHelperQueue->receiveMessage(&message); + result == RETURN_OK; result = commandActionHelperQueue->receiveMessage(&message)) { result = commandActionHelper.handleReply(&message); if (result == RETURN_OK) { continue; @@ -133,31 +133,31 @@ ReturnValue_t PlocMPSoCHandler::executeAction(ActionId_t actionId, MessageQueueI } void PlocMPSoCHandler::doStartUp() { - switch(powerState) { - case PowerState::OFF: + switch (powerState) { + case PowerState::OFF: commandActionHelper.commandAction(supervisorHandler, supv::START_MPSOC); powerState = PowerState::BOOTING; break; - case PowerState::ON: + case PowerState::ON: setMode(_MODE_TO_ON); uartIsolatorSwitch.pullHigh(); break; - default: + default: break; } } void PlocMPSoCHandler::doShutDown() { - switch(powerState) { - case PowerState::ON: + switch (powerState) { + case PowerState::ON: uartIsolatorSwitch.pullLow(); commandActionHelper.commandAction(supervisorHandler, supv::SHUTDOWN_MPSOC); powerState = PowerState::SHUTDOWN; break; - case PowerState::OFF: + case PowerState::OFF: setMode(_MODE_POWER_DOWN); break; - default: + default: break; } } @@ -703,64 +703,57 @@ size_t PlocMPSoCHandler::getNextReplyLength(DeviceCommandId_t commandId) { return replyLen; } -MessageQueueIF* PlocMPSoCHandler::getCommandQueuePtr() { - return commandActionHelperQueue; -} +MessageQueueIF* PlocMPSoCHandler::getCommandQueuePtr() { return commandActionHelperQueue; } -void PlocMPSoCHandler::stepSuccessfulReceived(ActionId_t actionId, uint8_t step) { - return; -} +void PlocMPSoCHandler::stepSuccessfulReceived(ActionId_t actionId, uint8_t step) { return; } void PlocMPSoCHandler::stepFailedReceived(ActionId_t actionId, uint8_t step, - ReturnValue_t returnCode) { - switch (actionId) { - case supv::START_MPSOC: - sif::warning << "PlocMPSoCHandler::stepFailedReceived: Failed to start MPSoC" - << std::endl; - powerState = PowerState::OFF; - break; - case supv::SHUTDOWN_MPSOC: - triggerEvent(MPSOC_SHUTDOWN_FAILED); - sif::warning << "PlocMPSoCHandler::stepFailedReceived: Failed to shutdown MPSoC" - << std::endl; - // TODO: Setting state to on or off here? - powerState = PowerState::ON; - break; - default: - sif::debug - << "PlocMPSoCHandler::stepFailedReceived: Received unexpected action reply" - << std::endl; - break; - } + ReturnValue_t returnCode) { + switch (actionId) { + case supv::START_MPSOC: + sif::warning << "PlocMPSoCHandler::stepFailedReceived: Failed to start MPSoC" << std::endl; + powerState = PowerState::OFF; + break; + case supv::SHUTDOWN_MPSOC: + triggerEvent(MPSOC_SHUTDOWN_FAILED); + sif::warning << "PlocMPSoCHandler::stepFailedReceived: Failed to shutdown MPSoC" << std::endl; + // TODO: Setting state to on or off here? + powerState = PowerState::ON; + break; + default: + sif::debug << "PlocMPSoCHandler::stepFailedReceived: Received unexpected action reply" + << std::endl; + break; + } } void PlocMPSoCHandler::dataReceived(ActionId_t actionId, const uint8_t* data, uint32_t size) { - return; + return; } void PlocMPSoCHandler::completionSuccessfulReceived(ActionId_t actionId) { - if (actionId != supv::EXE_REPORT) { - sif::debug << "PlocMPSoCHandler::completionSuccessfulReceived: Did not expect this action " - << "ID" << std::endl; - return; - } - switch(powerState) { + if (actionId != supv::EXE_REPORT) { + sif::debug << "PlocMPSoCHandler::completionSuccessfulReceived: Did not expect this action " + << "ID" << std::endl; + return; + } + switch (powerState) { case PowerState::BOOTING: { - powerState = PowerState::ON; - break; + powerState = PowerState::ON; + break; } case PowerState::SHUTDOWN: { - powerState = PowerState::OFF; - break; + powerState = PowerState::OFF; + break; } default: { break; } - } + } } void PlocMPSoCHandler::completionFailedReceived(ActionId_t actionId, ReturnValue_t returnCode) { - handleActionCommandFailure(actionId); + handleActionCommandFailure(actionId); } void PlocMPSoCHandler::handleDeviceTM(const uint8_t* data, size_t dataSize, @@ -862,27 +855,27 @@ void PlocMPSoCHandler::handleActionCommandFailure(ActionId_t actionId) { switch (actionId) { case supv::ACK_REPORT: case supv::EXE_REPORT: - break; + break; default: - sif::debug << "PlocMPSoCHandler::handleActionCommandFailure: Did not expect this action ID " - << std::endl; - return; + sif::debug << "PlocMPSoCHandler::handleActionCommandFailure: Did not expect this action ID " + << std::endl; + return; } - switch(powerState) { - case PowerState::BOOTING: { - sif::warning << "PlocMPSoCHandler::handleActionCommandFailure: Failed to boot MPSoC" - << std::endl; - powerState = PowerState::OFF; - break; - } - case PowerState::SHUTDOWN: { - sif::warning << "PlocMPSoCHandler::handleActionCommandFailure: Failed to shutdown MPSoC" - << std::endl; - powerState = PowerState::ON; - break; - } - default: - break; + switch (powerState) { + case PowerState::BOOTING: { + sif::warning << "PlocMPSoCHandler::handleActionCommandFailure: Failed to boot MPSoC" + << std::endl; + powerState = PowerState::OFF; + break; + } + case PowerState::SHUTDOWN: { + sif::warning << "PlocMPSoCHandler::handleActionCommandFailure: Failed to shutdown MPSoC" + << std::endl; + powerState = PowerState::ON; + break; + } + default: + break; } return; } diff --git a/linux/devices/ploc/PlocSupervisorHandler.cpp b/linux/devices/ploc/PlocSupervisorHandler.cpp index 078475c9..5065c7dd 100644 --- a/linux/devices/ploc/PlocSupervisorHandler.cpp +++ b/linux/devices/ploc/PlocSupervisorHandler.cpp @@ -384,7 +384,7 @@ ReturnValue_t PlocSupervisorHandler::scanForReply(const uint8_t* start, size_t r ReturnValue_t PlocSupervisorHandler::getSwitches(const uint8_t** switches, uint8_t* numberOfSwitches) { if (powerSwitch == power::NO_SWITCH) { - return DeviceHandlerBase::NO_SWITCH; + return DeviceHandlerBase::NO_SWITCH; } *numberOfSwitches = 1; *switches = &powerSwitch; @@ -489,8 +489,8 @@ ReturnValue_t PlocSupervisorHandler::enableReplyInReplyMap(DeviceCommandMap::ite switch (command->first) { case supv::GET_HK_REPORT: { enabledReplies = 3; - result = DeviceHandlerBase::enableReplyInReplyMap(command, enabledReplies, true, - supv::HK_REPORT); + result = + DeviceHandlerBase::enableReplyInReplyMap(command, enabledReplies, true, supv::HK_REPORT); if (result != RETURN_OK) { sif::debug << "PlocSupervisorHandler::enableReplyInReplyMap: Reply with id " << supv::HK_REPORT << " not in replyMap" << std::endl; @@ -589,15 +589,15 @@ ReturnValue_t PlocSupervisorHandler::enableReplyInReplyMap(DeviceCommandMap::ite result = DeviceHandlerBase::enableReplyInReplyMap(command, enabledReplies, true, supv::ACK_REPORT); if (result != RETURN_OK) { - sif::debug << "PlocSupervisorHandler::enableReplyInReplyMap: Reply with id " - << supv::ACK_REPORT << " not in replyMap" << std::endl; + sif::debug << "PlocSupervisorHandler::enableReplyInReplyMap: Reply with id " << supv::ACK_REPORT + << " not in replyMap" << std::endl; } result = DeviceHandlerBase::enableReplyInReplyMap(command, enabledReplies, true, supv::EXE_REPORT); if (result != RETURN_OK) { - sif::debug << "PlocSupervisorHandler::enableReplyInReplyMap: Reply with id " - << supv::EXE_REPORT << " not in replyMap" << std::endl; + sif::debug << "PlocSupervisorHandler::enableReplyInReplyMap: Reply with id " << supv::EXE_REPORT + << " not in replyMap" << std::endl; } return RETURN_OK; @@ -1013,7 +1013,7 @@ void PlocSupervisorHandler::prepareEmptyCmd(uint16_t apid) { void PlocSupervisorHandler::prepareSelBootImageCmd(const uint8_t* commandData) { supv::MPSoCBootSelect packet(*commandData, *(commandData + 1), *(commandData + 2), - *(commandData + 3)); + *(commandData + 3)); packetToOutBuffer(packet.getWholeData(), packet.getFullSize()); } @@ -1459,9 +1459,8 @@ ReturnValue_t PlocSupervisorHandler::handleMramDumpFile(DeviceCommandId_t id) { return MRAM_FILE_NOT_EXISTS; } std::ofstream file(activeMramFile, std::ios_base::app | std::ios_base::out); - file.write( - reinterpret_cast(spacePacketBuffer + supv::SPACE_PACKET_HEADER_LENGTH), - packetLen - 1); + file.write(reinterpret_cast(spacePacketBuffer + supv::SPACE_PACKET_HEADER_LENGTH), + packetLen - 1); file.close(); return RETURN_OK; } diff --git a/linux/devices/ploc/PlocUpdater.cpp b/linux/devices/ploc/PlocUpdater.cpp index 220b1e00..37a553da 100644 --- a/linux/devices/ploc/PlocUpdater.cpp +++ b/linux/devices/ploc/PlocUpdater.cpp @@ -262,12 +262,11 @@ void PlocUpdater::commandUpdateAvailable() { calcImageCrc(); supv::UpdateInfo packet(supv::APID_UPDATE_AVAILABLE, static_cast(image), - static_cast(partition), imageSize, imageCrc, - numOfUpdatePackets); + static_cast(partition), imageSize, imageCrc, numOfUpdatePackets); - result = commandActionHelper.commandAction(objects::PLOC_SUPERVISOR_HANDLER, - supv::UPDATE_AVAILABLE, packet.getWholeData(), - packet.getFullSize()); + result = + commandActionHelper.commandAction(objects::PLOC_SUPERVISOR_HANDLER, supv::UPDATE_AVAILABLE, + packet.getWholeData(), packet.getFullSize()); if (result != RETURN_OK) { sif::warning << "PlocUpdater::commandUpdateAvailable: Failed to send update available" << " packet to supervisor handler" << std::endl; @@ -311,9 +310,9 @@ void PlocUpdater::commandUpdatePacket() { } packet.makeCrc(); - result = commandActionHelper.commandAction(objects::PLOC_SUPERVISOR_HANDLER, - supv::UPDATE_IMAGE_DATA, packet.getWholeData(), - packet.getFullSize()); + result = + commandActionHelper.commandAction(objects::PLOC_SUPERVISOR_HANDLER, supv::UPDATE_IMAGE_DATA, + packet.getWholeData(), packet.getFullSize()); if (result != RETURN_OK) { sif::warning << "PlocUpdater::commandUpdateAvailable: Failed to send update" @@ -335,12 +334,10 @@ void PlocUpdater::commandUpdateVerify() { ReturnValue_t result = RETURN_OK; supv::UpdateInfo packet(supv::APID_UPDATE_VERIFY, static_cast(image), - static_cast(partition), imageSize, imageCrc, - numOfUpdatePackets); + static_cast(partition), imageSize, imageCrc, numOfUpdatePackets); - result = - commandActionHelper.commandAction(objects::PLOC_SUPERVISOR_HANDLER, supv::UPDATE_VERIFY, - packet.getWholeData(), packet.getFullSize()); + result = commandActionHelper.commandAction(objects::PLOC_SUPERVISOR_HANDLER, supv::UPDATE_VERIFY, + packet.getWholeData(), packet.getFullSize()); if (result != RETURN_OK) { sif::warning << "PlocUpdater::commandUpdateAvailable: Failed to send update available" << " packet to supervisor handler" << std::endl; diff --git a/linux/devices/startracker/StarTrackerHandler.h b/linux/devices/startracker/StarTrackerHandler.h index 2667db31..90a30966 100644 --- a/linux/devices/startracker/StarTrackerHandler.h +++ b/linux/devices/startracker/StarTrackerHandler.h @@ -7,12 +7,12 @@ #include "ArcsecJsonParamBase.h" #include "OBSWConfig.h" #include "StrHelper.h" +#include "devices/powerSwitcherList.h" #include "fsfw/devicehandlers/DeviceHandlerBase.h" #include "fsfw/src/fsfw/serialize/SerializeAdapter.h" #include "fsfw/timemanager/Countdown.h" #include "linux/devices/devicedefinitions/StarTrackerDefinitions.h" #include "thirdparty/arcsec_star_tracker/common/SLIP.h" -#include "devices/powerSwitcherList.h" /** * @brief This is the device handler for the star tracker from arcsec. diff --git a/mission/devices/P60DockHandler.cpp b/mission/devices/P60DockHandler.cpp index b506a92b..ed209b86 100644 --- a/mission/devices/P60DockHandler.cpp +++ b/mission/devices/P60DockHandler.cpp @@ -441,6 +441,9 @@ ReturnValue_t P60DockHandler::initializeLocalDataPool(localpool::DataPool &local localDataPoolMap.emplace(P60System::P60DOCK_ANT6_DEPL, new PoolEntry({0})); localDataPoolMap.emplace(P60System::P60DOCK_AR6_DEPL, new PoolEntry({0})); +#if OBSW_ENABLE_PERIODIC_HK == 1 + poolManager.subscribeForPeriodicPacket(p60dockHkTableDataset.getSid(), false, 0.8, true); +#endif return HasReturnvaluesIF::RETURN_OK; } diff --git a/mission/devices/PayloadPcduHandler.cpp b/mission/devices/PayloadPcduHandler.cpp index 7a1924c1..67cf8c10 100644 --- a/mission/devices/PayloadPcduHandler.cpp +++ b/mission/devices/PayloadPcduHandler.cpp @@ -66,7 +66,7 @@ void PayloadPcduHandler::doTransition(Mode_t modeFrom, Submode_t subModeFrom) { ReturnValue_t PayloadPcduHandler::stateMachineToNormal(Mode_t modeFrom, Submode_t subModeFrom) { using namespace plpcdu; - if (submode == NormalSubmodes::SOLID_STATE_RELAYS_ADC_ON) { + if (((submode >> SOLID_STATE_RELAYS_ADC_ON) & 0b1) == 1) { if (state == States::PL_PCDU_OFF) { sif::error << "PayloadPcduHandler::stateMachineToNormal: Unexpected state PL_PCDU_OFF" << "detected" << std::endl; @@ -116,7 +116,7 @@ ReturnValue_t PayloadPcduHandler::stateMachineToNormal(Mode_t modeFrom, Submode_ } } - if (submode == NormalSubmodes::DRO_ON) { + if (((submode >> DRO_ON) & 1) == 1) { #if OBSW_VERBOSE_LEVEL >= 1 sif::info << "Enabling PL PCDU DRO module" << std::endl; #endif @@ -127,7 +127,7 @@ ReturnValue_t PayloadPcduHandler::stateMachineToNormal(Mode_t modeFrom, Submode_ setMode(MODE_NORMAL, submode); } - if (submode == NormalSubmodes::X8_ON) { + if (((submode >> X8_ON) & 1) == 1) { #if OBSW_VERBOSE_LEVEL >= 1 sif::info << "Enabling PL PCDU X8 module" << std::endl; #endif @@ -138,7 +138,7 @@ ReturnValue_t PayloadPcduHandler::stateMachineToNormal(Mode_t modeFrom, Submode_ setMode(MODE_NORMAL, submode); } - if (submode == NormalSubmodes::TX_ON) { + if (((submode >> TX_ON) & 1) == 1) { #if OBSW_VERBOSE_LEVEL >= 1 sif::info << "Enabling PL PCDU TX module" << std::endl; #endif @@ -149,7 +149,7 @@ ReturnValue_t PayloadPcduHandler::stateMachineToNormal(Mode_t modeFrom, Submode_ setMode(MODE_NORMAL, submode); } - if (submode == NormalSubmodes::MPA_ON) { + if (((submode >> MPA_ON) & 1) == 1) { #if OBSW_VERBOSE_LEVEL >= 1 sif::info << "Enabling PL PCDU MPA module" << std::endl; #endif @@ -160,7 +160,7 @@ ReturnValue_t PayloadPcduHandler::stateMachineToNormal(Mode_t modeFrom, Submode_ setMode(MODE_NORMAL, submode); } - if (submode == NormalSubmodes::HPA_ON) { + if (((submode >> HPA_ON) & 1) == 1) { #if OBSW_VERBOSE_LEVEL >= 1 sif::info << "Enabling PL PCDU HPA module" << std::endl; #endif @@ -549,24 +549,30 @@ ReturnValue_t PayloadPcduHandler::isModeCombinationValid(Mode_t mode, Submode_t using namespace plpcdu; if (mode == MODE_NORMAL) { // Also deals with the case where the mode is MODE_ON, submode should be 0 here - if (submode == NormalSubmodes::SOLID_STATE_RELAYS_ADC_ON and - (this->mode == MODE_NORMAL and this->submode != NormalSubmodes::ALL_OFF)) { + if ((((submode >> SOLID_STATE_RELAYS_ADC_ON) & 0b1) == SOLID_STATE_RELAYS_ADC_ON) and + (this->mode == MODE_NORMAL and this->submode != ALL_OFF_SUBMODE)) { return TRANS_NOT_ALLOWED; } - if ((submode == NormalSubmodes::DRO_ON and - this->submode != NormalSubmodes::SOLID_STATE_RELAYS_ADC_ON)) { + if (((((submode >> DRO_ON) & 1) == 1) and + (this->submode != (1 << SOLID_STATE_RELAYS_ADC_ON)))) { return TRANS_NOT_ALLOWED; } - if ((submode == NormalSubmodes::X8_ON and this->submode != NormalSubmodes::DRO_ON)) { + if ((((submode >> X8_ON) & 1) == 1) and + (this->submode != ((1 << SOLID_STATE_RELAYS_ADC_ON) | (1 << DRO_ON)))) { return TRANS_NOT_ALLOWED; } - if ((submode == NormalSubmodes::TX_ON and this->submode != NormalSubmodes::X8_ON)) { + if (((((submode >> TX_ON) & 1) == 1) and + (this->submode != ((1 << X8_ON) | (1 << DRO_ON) | (1 << SOLID_STATE_RELAYS_ADC_ON))))) { return TRANS_NOT_ALLOWED; } - if ((submode == NormalSubmodes::MPA_ON and this->submode != NormalSubmodes::TX_ON)) { + if ((((submode >> MPA_ON) & 1) == 1 and + (this->submode != + ((1 << TX_ON) | (1 << X8_ON) | (1 << DRO_ON) | (1 << SOLID_STATE_RELAYS_ADC_ON))))) { return TRANS_NOT_ALLOWED; } - if ((submode == NormalSubmodes::HPA_ON and this->submode != NormalSubmodes::MPA_ON)) { + if ((((submode >> HPA_ON) & 1) == 1 and + (this->submode != ((1 << MPA_ON) | (1 << TX_ON) | (1 << X8_ON) | (1 << DRO_ON) | + (1 << SOLID_STATE_RELAYS_ADC_ON))))) { return TRANS_NOT_ALLOWED; } return HasReturnvaluesIF::RETURN_OK; diff --git a/mission/devices/RadiationSensorHandler.cpp b/mission/devices/RadiationSensorHandler.cpp index 179444ca..e91d8427 100644 --- a/mission/devices/RadiationSensorHandler.cpp +++ b/mission/devices/RadiationSensorHandler.cpp @@ -92,15 +92,15 @@ ReturnValue_t RadiationSensorHandler::buildCommandFromCommand(DeviceCommandId_t return RETURN_OK; } case RAD_SENSOR::ENABLE_DEBUG_OUTPUT: { - printPeriodicData = true; - rawPacketLen = 0; - return RETURN_OK; - } - case RAD_SENSOR::DISABLE_DEBUG_OUTPUT: { - rawPacketLen = 0; - printPeriodicData = false; - return RETURN_OK; - } + printPeriodicData = true; + rawPacketLen = 0; + return RETURN_OK; + } + case RAD_SENSOR::DISABLE_DEBUG_OUTPUT: { + rawPacketLen = 0; + printPeriodicData = false; + return RETURN_OK; + } default: return DeviceHandlerIF::COMMAND_NOT_IMPLEMENTED; } @@ -123,7 +123,7 @@ ReturnValue_t RadiationSensorHandler::scanForReply(const uint8_t *start, size_t switch (*foundId) { case RAD_SENSOR::START_CONVERSION: case RAD_SENSOR::WRITE_SETUP: - *foundLen = remainingSize; + *foundLen = remainingSize; return IGNORE_REPLY_DATA; case RAD_SENSOR::READ_CONVERSIONS: { ReturnValue_t result = gpioIF->pullLow(gpioIds::ENABLE_RADFET); @@ -138,8 +138,8 @@ ReturnValue_t RadiationSensorHandler::scanForReply(const uint8_t *start, size_t } case RAD_SENSOR::ENABLE_DEBUG_OUTPUT: case RAD_SENSOR::DISABLE_DEBUG_OUTPUT: - sif::info << "RadiationSensorHandler::scanForReply: " << remainingSize << std::endl; - break; + sif::info << "RadiationSensorHandler::scanForReply: " << remainingSize << std::endl; + break; default: break; } diff --git a/mission/devices/SyrlinksHkHandler.cpp b/mission/devices/SyrlinksHkHandler.cpp index 017bd53c..53a8af23 100644 --- a/mission/devices/SyrlinksHkHandler.cpp +++ b/mission/devices/SyrlinksHkHandler.cpp @@ -139,42 +139,45 @@ ReturnValue_t SyrlinksHkHandler::buildCommandFromCommand(DeviceCommandId_t devic return RETURN_OK; } case (SYRLINKS::READ_TX_AGC_VALUE_HIGH_BYTE): { - readTxAgcValueHighByte.copy(reinterpret_cast(commandBuffer), readTxAgcValueHighByte.size(), 0); + readTxAgcValueHighByte.copy(reinterpret_cast(commandBuffer), + readTxAgcValueHighByte.size(), 0); rawPacketLen = readTxAgcValueHighByte.size(); rememberCommandId = SYRLINKS::READ_TX_AGC_VALUE_HIGH_BYTE; rawPacket = commandBuffer; return RETURN_OK; } case (SYRLINKS::READ_TX_AGC_VALUE_LOW_BYTE): { - readTxAgcValueLowByte.copy(reinterpret_cast(commandBuffer), readTxAgcValueLowByte.size(), 0); + readTxAgcValueLowByte.copy(reinterpret_cast(commandBuffer), + readTxAgcValueLowByte.size(), 0); rawPacketLen = readTxAgcValueLowByte.size(); rememberCommandId = SYRLINKS::READ_TX_AGC_VALUE_LOW_BYTE; rawPacket = commandBuffer; return RETURN_OK; } case (SYRLINKS::TEMP_POWER_AMPLIFIER_HIGH_BYTE): - tempPowerAmpBoardHighByte.copy(reinterpret_cast(commandBuffer), tempPowerAmpBoardHighByte.size(), - 0); + tempPowerAmpBoardHighByte.copy(reinterpret_cast(commandBuffer), + tempPowerAmpBoardHighByte.size(), 0); rawPacketLen = tempPowerAmpBoardHighByte.size(); rememberCommandId = SYRLINKS::TEMP_POWER_AMPLIFIER_HIGH_BYTE; rawPacket = commandBuffer; return RETURN_OK; case (SYRLINKS::TEMP_POWER_AMPLIFIER_LOW_BYTE): - tempPowerAmpBoardLowByte.copy(reinterpret_cast(commandBuffer), tempPowerAmpBoardLowByte.size(), - 0); + tempPowerAmpBoardLowByte.copy(reinterpret_cast(commandBuffer), + tempPowerAmpBoardLowByte.size(), 0); rawPacketLen = tempPowerAmpBoardLowByte.size(); rememberCommandId = SYRLINKS::TEMP_POWER_AMPLIFIER_LOW_BYTE; rawPacket = commandBuffer; return RETURN_OK; case (SYRLINKS::TEMP_BASEBAND_BOARD_HIGH_BYTE): - tempBasebandBoardHighByte.copy(reinterpret_cast(commandBuffer), tempBasebandBoardHighByte.size(), - 0); + tempBasebandBoardHighByte.copy(reinterpret_cast(commandBuffer), + tempBasebandBoardHighByte.size(), 0); rawPacketLen = tempBasebandBoardHighByte.size(); rememberCommandId = SYRLINKS::TEMP_BASEBAND_BOARD_HIGH_BYTE; rawPacket = commandBuffer; return RETURN_OK; case (SYRLINKS::TEMP_BASEBAND_BOARD_LOW_BYTE): - tempBasebandBoardLowByte.copy(reinterpret_cast(commandBuffer), tempBasebandBoardLowByte.size(), 0); + tempBasebandBoardLowByte.copy(reinterpret_cast(commandBuffer), + tempBasebandBoardLowByte.size(), 0); rawPacketLen = tempBasebandBoardLowByte.size(); rememberCommandId = SYRLINKS::TEMP_BASEBAND_BOARD_LOW_BYTE; rawPacket = commandBuffer; @@ -352,8 +355,8 @@ ReturnValue_t SyrlinksHkHandler::interpretDeviceReply(DeviceCommandId_t id, cons rawTempBasebandBoard |= convertHexStringToUint8( reinterpret_cast(packet + SYRLINKS::MESSAGE_HEADER_SIZE)); tempBasebandBoard = calcTempVal(rawTempBasebandBoard); - sif::info << "Syrlinks temperature baseband board: " << tempBasebandBoard << " °C" - << std::endl; + sif::info << "Syrlinks temperature baseband board: " << tempBasebandBoard << " °C" + << std::endl; break; case (SYRLINKS::TEMP_POWER_AMPLIFIER_HIGH_BYTE): result = verifyReply(packet, SYRLINKS::READ_ONE_REGISTER_REPLY_SIE); @@ -364,8 +367,8 @@ ReturnValue_t SyrlinksHkHandler::interpretDeviceReply(DeviceCommandId_t id, cons } rawTempPowerAmplifier = 0; rawTempPowerAmplifier = convertHexStringToUint8(reinterpret_cast( - packet + SYRLINKS::MESSAGE_HEADER_SIZE)) - << 8; + packet + SYRLINKS::MESSAGE_HEADER_SIZE)) + << 8; break; case (SYRLINKS::TEMP_POWER_AMPLIFIER_LOW_BYTE): result = verifyReply(packet, SYRLINKS::READ_ONE_REGISTER_REPLY_SIE); @@ -378,7 +381,7 @@ ReturnValue_t SyrlinksHkHandler::interpretDeviceReply(DeviceCommandId_t id, cons reinterpret_cast(packet + SYRLINKS::MESSAGE_HEADER_SIZE)); tempPowerAmplifier = calcTempVal(rawTempPowerAmplifier); sif::info << "Syrlinks temperature power amplifier board: " << tempPowerAmplifier << " °C" - << std::endl; + << std::endl; break; default: { sif::debug << "SyrlinksHkHandler::interpretDeviceReply: Unknown device reply id" << std::endl; diff --git a/mission/devices/SyrlinksHkHandler.h b/mission/devices/SyrlinksHkHandler.h index 9b9e05c2..a8cb7b8c 100644 --- a/mission/devices/SyrlinksHkHandler.h +++ b/mission/devices/SyrlinksHkHandler.h @@ -1,10 +1,11 @@ #ifndef MISSION_DEVICES_SYRLINKSHKHANDLER_H_ #define MISSION_DEVICES_SYRLINKSHKHANDLER_H_ +#include + #include "devices/powerSwitcherList.h" #include "fsfw/devicehandlers/DeviceHandlerBase.h" #include "mission/devices/devicedefinitions/SyrlinksDefinitions.h" -#include /** * @brief This is the device handler for the syrlinks transceiver. It handles the command diff --git a/mission/devices/devicedefinitions/payloadPcduDefinitions.h b/mission/devices/devicedefinitions/payloadPcduDefinitions.h index 3013cb82..ab387fc7 100644 --- a/mission/devices/devicedefinitions/payloadPcduDefinitions.h +++ b/mission/devices/devicedefinitions/payloadPcduDefinitions.h @@ -91,16 +91,17 @@ static constexpr DeviceCommandId_t SETUP_CMD = 1; static constexpr DeviceCommandId_t READ_TEMP_EXT = 2; static constexpr DeviceCommandId_t READ_WITH_TEMP_EXT = 3; -enum NormalSubmodes { - ALL_OFF = 0, - SOLID_STATE_RELAYS_ADC_ON = 1, - DRO_ON = 2, - X8_ON = 3, - TX_ON = 4, - MPA_ON = 5, - HPA_ON = 6 +enum NormalSubmodeBits { + SOLID_STATE_RELAYS_ADC_ON = 0, + DRO_ON = 1, + X8_ON = 2, + TX_ON = 3, + MPA_ON = 4, + HPA_ON = 5 }; +static constexpr Submode_t ALL_OFF_SUBMODE = 0; + // 12 ADC values * 2 + trailing zero static constexpr size_t ADC_REPLY_SIZE = 25; // Conversion byte + 24 * zero diff --git a/mission/system/AcsBoardAssembly.cpp b/mission/system/AcsBoardAssembly.cpp index e319f32b..0d65d20e 100644 --- a/mission/system/AcsBoardAssembly.cpp +++ b/mission/system/AcsBoardAssembly.cpp @@ -143,13 +143,13 @@ ReturnValue_t AcsBoardAssembly::handleNormalOrOnModeCmd(Mode_t mode, Submode_t s cmdSeq(helper.mgm1Rm3100IdSideA, helper.mgm1SideAMode, ModeTableIdx::MGM_1_A); if (gpsUsable) { gpioHandler(gpioIds::GNSS_0_NRESET, true, - "AcsBoardAssembly::handleNormalOrOnModeCmd: Could not pull nReset pin" - "of GNSS 0 high (used GNSS)"); + "AcsBoardAssembly::handleNormalOrOnModeCmd: Could not pull nReset pin" + "of GNSS 0 high (used GNSS)"); gpioHandler(gpioIds::GNSS_1_NRESET, false, - "AcsBoardAssembly::handleNormalOrOnModeCmd: Could not pull nReset pin" - "of GNSS 1 low (unused GNSS)"); + "AcsBoardAssembly::handleNormalOrOnModeCmd: Could not pull nReset pin" + "of GNSS 1 low (unused GNSS)"); gpioHandler(gpioIds::GNSS_SELECT, false, - "AcsBoardAssembly::handleNormalOrOnModeCmd: Could not pull GNSS select low"); + "AcsBoardAssembly::handleNormalOrOnModeCmd: Could not pull GNSS select low"); } break; } @@ -168,13 +168,13 @@ ReturnValue_t AcsBoardAssembly::handleNormalOrOnModeCmd(Mode_t mode, Submode_t s cmdSeq(helper.mgm3Rm3100IdSideB, helper.mgm3SideBMode, ModeTableIdx::MGM_3_B); if (gpsUsable) { gpioHandler(gpioIds::GNSS_0_NRESET, false, - "AcsBoardAssembly::handleNormalOrOnModeCmd: Could not pull nReset pin" - "of GNSS 0 low (unused GNSS)"); + "AcsBoardAssembly::handleNormalOrOnModeCmd: Could not pull nReset pin" + "of GNSS 0 low (unused GNSS)"); gpioHandler(gpioIds::GNSS_1_NRESET, true, - "AcsBoardAssembly::handleNormalOrOnModeCmd: Could not pull nReset pin" - "of GNSS 1 high (used GNSS)"); + "AcsBoardAssembly::handleNormalOrOnModeCmd: Could not pull nReset pin" + "of GNSS 1 high (used GNSS)"); gpioHandler(gpioIds::GNSS_SELECT, true, - "AcsBoardAssembly::handleNormalOrOnModeCmd: Could not pull GNSS select high"); + "AcsBoardAssembly::handleNormalOrOnModeCmd: Could not pull GNSS select high"); } break; } @@ -191,11 +191,11 @@ ReturnValue_t AcsBoardAssembly::handleNormalOrOnModeCmd(Mode_t mode, Submode_t s ReturnValue_t status = RETURN_OK; if (gpsUsable) { gpioHandler(gpioIds::GNSS_0_NRESET, true, - "AcsBoardAssembly::handleNormalOrOnModeCmd: Could not pull nReset pin" - "of GNSS 0 high (used GNSS)"); + "AcsBoardAssembly::handleNormalOrOnModeCmd: Could not pull nReset pin" + "of GNSS 0 high (used GNSS)"); gpioHandler(gpioIds::GNSS_1_NRESET, true, - "AcsBoardAssembly::handleNormalOrOnModeCmd: Could not pull nReset pin" - "of GNSS 1 high (used GNSS)"); + "AcsBoardAssembly::handleNormalOrOnModeCmd: Could not pull nReset pin" + "of GNSS 1 high (used GNSS)"); if (defaultSubmode == Submodes::A_SIDE) { status = gpioIF->pullLow(gpioIds::GNSS_SELECT); } else { @@ -245,7 +245,7 @@ void AcsBoardAssembly::selectGpsInDualMode(duallane::Submodes side) { void AcsBoardAssembly::gpioHandler(gpioId_t gpio, bool high, std::string error) { ReturnValue_t result = RETURN_OK; - if(high) { + if (high) { result = gpioIF->pullHigh(gpio); } else { result = gpioIF->pullLow(gpio); From d315d6b4589168974b7ec556bfbd353431dc147d Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Mon, 4 Apr 2022 13:53:44 +0200 Subject: [PATCH 02/14] tmtc update --- tmtc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tmtc b/tmtc index a39c7007..8b5554d6 160000 --- a/tmtc +++ b/tmtc @@ -1 +1 @@ -Subproject commit a39c7007c6aef8cac559b38cdf1b9c8815c346ee +Subproject commit 8b5554d6fdfb9e2d982e4a2af4f5e6d6e844794e From 4327fcb92e47d2d5dc52d434cf6f814763377484 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Mon, 4 Apr 2022 13:55:25 +0200 Subject: [PATCH 03/14] set internal state properly --- mission/devices/PayloadPcduHandler.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/mission/devices/PayloadPcduHandler.cpp b/mission/devices/PayloadPcduHandler.cpp index 67cf8c10..b08e73ca 100644 --- a/mission/devices/PayloadPcduHandler.cpp +++ b/mission/devices/PayloadPcduHandler.cpp @@ -51,6 +51,7 @@ void PayloadPcduHandler::doShutDown() { auto opCode = pwrStateMachine.fsm(); if (opCode == power::OpCodes::TO_OFF_DONE or opCode == power::OpCodes::TIMEOUT_OCCURED) { pwrStateMachine.reset(); + state = States::PL_PCDU_OFF; // No need to set mode _MODE_POWER_DOWN, power switching was already handled setMode(MODE_OFF); } From 834e935c64bf6257df1c455cb36667751dbd2e4c Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Thu, 7 Apr 2022 00:14:18 +0200 Subject: [PATCH 04/14] switch handling working now --- mission/devices/PayloadPcduHandler.cpp | 101 +++++++++++-------------- mission/devices/PayloadPcduHandler.h | 3 + 2 files changed, 46 insertions(+), 58 deletions(-) diff --git a/mission/devices/PayloadPcduHandler.cpp b/mission/devices/PayloadPcduHandler.cpp index b08e73ca..621b7d9e 100644 --- a/mission/devices/PayloadPcduHandler.cpp +++ b/mission/devices/PayloadPcduHandler.cpp @@ -67,6 +67,7 @@ void PayloadPcduHandler::doTransition(Mode_t modeFrom, Submode_t subModeFrom) { ReturnValue_t PayloadPcduHandler::stateMachineToNormal(Mode_t modeFrom, Submode_t subModeFrom) { using namespace plpcdu; + bool doFinish = true; if (((submode >> SOLID_STATE_RELAYS_ADC_ON) & 0b1) == 1) { if (state == States::PL_PCDU_OFF) { sif::error << "PayloadPcduHandler::stateMachineToNormal: Unexpected state PL_PCDU_OFF" @@ -83,22 +84,24 @@ ReturnValue_t PayloadPcduHandler::stateMachineToNormal(Mode_t modeFrom, Submode_ gpioIF->pullHigh(gpioIds::PLPCDU_ENB_VBAT1); state = States::ON_TRANS_SSR; transitionOk = true; + doFinish = false; } if (state == States::ON_TRANS_SSR) { // If necessary, check whether a certain amount of time has elapsed if (transitionOk) { transitionOk = false; state = States::ON_TRANS_ADC_CLOSE_ZERO; - adcCountdown.setTimeout(50); adcCountdown.resetTimer(); adcState = AdcStates::BOOT_DELAY; + doFinish = false; // If the values are not close to zero, we should not allow transition monMode = MonitoringMode::CLOSE_TO_ZERO; } } if (state == States::ON_TRANS_ADC_CLOSE_ZERO) { if (adcState == AdcStates::BOOT_DELAY) { + doFinish = false; if (adcCountdown.hasTimedOut()) { adcState = AdcStates::SEND_SETUP; adcCmdExecuted = false; @@ -107,68 +110,38 @@ ReturnValue_t PayloadPcduHandler::stateMachineToNormal(Mode_t modeFrom, Submode_ if (adcState == AdcStates::SEND_SETUP) { if (adcCmdExecuted) { adcState = AdcStates::NORMAL; + doFinish = true; adcCountdown.setTimeout(100); adcCountdown.resetTimer(); adcCmdExecuted = false; - setMode(MODE_NORMAL, submode); - return HasReturnvaluesIF::RETURN_OK; } } } } - if (((submode >> DRO_ON) & 1) == 1) { + auto switchHandler = [&](NormalSubmodeBits bit, gpioId_t id, std::string info) { + if (((diffMask >> bit) & 1) == 1) { + if (((submode >> bit) & 1) == 1) { #if OBSW_VERBOSE_LEVEL >= 1 - sif::info << "Enabling PL PCDU DRO module" << std::endl; + sif::info << "Enabling PL PCDU " << info << " module" << std::endl; #endif - // Switch on DRO and start monitoring for negative voltages - gpioIF->pullHigh(gpioIds::PLPCDU_ENB_DRO); - adcCountdown.setTimeout(100); - adcCountdown.resetTimer(); - setMode(MODE_NORMAL, submode); - } + // Switch on DRO and start monitoring for negative voltages + updateSwitchGpio(id, gpio::Levels::HIGH); + } else { +#if OBSW_VERBOSE_LEVEL >= 1 + sif::info << "Disabling PL PCDU " << info << " module" << std::endl; +#endif + updateSwitchGpio(id, gpio::Levels::LOW); + } + } + }; - if (((submode >> X8_ON) & 1) == 1) { -#if OBSW_VERBOSE_LEVEL >= 1 - sif::info << "Enabling PL PCDU X8 module" << std::endl; -#endif - // Switch on DRO and start monitoring for negative voltages - gpioIF->pullHigh(gpioIds::PLPCDU_ENB_X8); - adcCountdown.setTimeout(100); - adcCountdown.resetTimer(); - setMode(MODE_NORMAL, submode); - } - - if (((submode >> TX_ON) & 1) == 1) { -#if OBSW_VERBOSE_LEVEL >= 1 - sif::info << "Enabling PL PCDU TX module" << std::endl; -#endif - // Switch on DRO and start monitoring for negative voltages - gpioIF->pullHigh(gpioIds::PLPCDU_ENB_TX); - adcCountdown.setTimeout(100); - adcCountdown.resetTimer(); - setMode(MODE_NORMAL, submode); - } - - if (((submode >> MPA_ON) & 1) == 1) { -#if OBSW_VERBOSE_LEVEL >= 1 - sif::info << "Enabling PL PCDU MPA module" << std::endl; -#endif - // Switch on DRO and start monitoring for negative voltages - gpioIF->pullHigh(gpioIds::PLPCDU_ENB_MPA); - adcCountdown.setTimeout(100); - adcCountdown.resetTimer(); - setMode(MODE_NORMAL, submode); - } - - if (((submode >> HPA_ON) & 1) == 1) { -#if OBSW_VERBOSE_LEVEL >= 1 - sif::info << "Enabling PL PCDU HPA module" << std::endl; -#endif - // Switch on DRO and start monitoring for negative voltages - gpioIF->pullHigh(gpioIds::PLPCDU_ENB_HPA); - adcCountdown.setTimeout(100); - adcCountdown.resetTimer(); + switchHandler(DRO_ON, gpioIds::PLPCDU_ENB_DRO, "DRO"); + switchHandler(X8_ON, gpioIds::PLPCDU_ENB_X8, "X8"); + switchHandler(TX_ON, gpioIds::PLPCDU_ENB_TX, "TX"); + switchHandler(MPA_ON, gpioIds::PLPCDU_ENB_MPA, "MPA"); + switchHandler(HPA_ON, gpioIds::PLPCDU_ENB_HPA, "HPA"); + if (doFinish) { setMode(MODE_NORMAL, submode); } return RETURN_OK; @@ -202,6 +175,16 @@ ReturnValue_t PayloadPcduHandler::buildTransitionDeviceCommand(DeviceCommandId_t return NOTHING_TO_SEND; } +void PayloadPcduHandler::updateSwitchGpio(gpioId_t id, gpio::Levels level) { + if (level == gpio::Levels::HIGH) { + gpioIF->pullHigh(id); + } else { + gpioIF->pullLow(id); + } + adcCountdown.setTimeout(100); + adcCountdown.resetTimer(); +} + void PayloadPcduHandler::fillCommandAndReplyMap() { insertInCommandAndReplyMap(plpcdu::READ_CMD, 2, &adcSet); insertInCommandAndReplyMap(plpcdu::READ_TEMP_EXT, 1, &adcSet); @@ -549,31 +532,33 @@ bool PayloadPcduHandler::checkCurrent(float val, float upperBound, Event event) ReturnValue_t PayloadPcduHandler::isModeCombinationValid(Mode_t mode, Submode_t submode) { using namespace plpcdu; if (mode == MODE_NORMAL) { + diffMask = submode ^ this->submode; // Also deals with the case where the mode is MODE_ON, submode should be 0 here if ((((submode >> SOLID_STATE_RELAYS_ADC_ON) & 0b1) == SOLID_STATE_RELAYS_ADC_ON) and (this->mode == MODE_NORMAL and this->submode != ALL_OFF_SUBMODE)) { return TRANS_NOT_ALLOWED; } if (((((submode >> DRO_ON) & 1) == 1) and - (this->submode != (1 << SOLID_STATE_RELAYS_ADC_ON)))) { + ((this->submode & 0b1) != (1 << SOLID_STATE_RELAYS_ADC_ON)))) { return TRANS_NOT_ALLOWED; } if ((((submode >> X8_ON) & 1) == 1) and - (this->submode != ((1 << SOLID_STATE_RELAYS_ADC_ON) | (1 << DRO_ON)))) { + ((this->submode & 0b11) != ((1 << SOLID_STATE_RELAYS_ADC_ON) | (1 << DRO_ON)))) { return TRANS_NOT_ALLOWED; } if (((((submode >> TX_ON) & 1) == 1) and - (this->submode != ((1 << X8_ON) | (1 << DRO_ON) | (1 << SOLID_STATE_RELAYS_ADC_ON))))) { + ((this->submode & 0b111) != + ((1 << X8_ON) | (1 << DRO_ON) | (1 << SOLID_STATE_RELAYS_ADC_ON))))) { return TRANS_NOT_ALLOWED; } if ((((submode >> MPA_ON) & 1) == 1 and - (this->submode != + ((this->submode & 0b1111) != ((1 << TX_ON) | (1 << X8_ON) | (1 << DRO_ON) | (1 << SOLID_STATE_RELAYS_ADC_ON))))) { return TRANS_NOT_ALLOWED; } if ((((submode >> HPA_ON) & 1) == 1 and - (this->submode != ((1 << MPA_ON) | (1 << TX_ON) | (1 << X8_ON) | (1 << DRO_ON) | - (1 << SOLID_STATE_RELAYS_ADC_ON))))) { + ((this->submode & 0b11111) != ((1 << MPA_ON) | (1 << TX_ON) | (1 << X8_ON) | + (1 << DRO_ON) | (1 << SOLID_STATE_RELAYS_ADC_ON))))) { return TRANS_NOT_ALLOWED; } return HasReturnvaluesIF::RETURN_OK; diff --git a/mission/devices/PayloadPcduHandler.h b/mission/devices/PayloadPcduHandler.h index 18311ec8..dba5b4ef 100644 --- a/mission/devices/PayloadPcduHandler.h +++ b/mission/devices/PayloadPcduHandler.h @@ -134,6 +134,7 @@ class PayloadPcduHandler : public DeviceHandlerBase { SdCardMountedIF* sdcMan; plpcdu::PlPcduParameter params; bool quickTransitionAlreadyCalled = true; + uint8_t diffMask = 0; PoolEntry channelValues = PoolEntry({0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}); PoolEntry processedValues = @@ -141,6 +142,8 @@ class PayloadPcduHandler : public DeviceHandlerBase { PoolEntry tempC = PoolEntry({0.0}); DualLanePowerStateMachine pwrStateMachine; + void updateSwitchGpio(gpioId_t id, gpio::Levels level); + void doTransition(Mode_t modeFrom, Submode_t subModeFrom) override; void doStartUp() override; void doShutDown() override; From 06a15ccec18aa8458da45c84060ed7c127189d65 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Thu, 7 Apr 2022 00:16:15 +0200 Subject: [PATCH 05/14] submodule updates --- fsfw | 2 +- tmtc | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/fsfw b/fsfw index 1bc7a918..0677de39 160000 --- a/fsfw +++ b/fsfw @@ -1 +1 @@ -Subproject commit 1bc7a918694030d1f49f1d2998a289d77b132849 +Subproject commit 0677de39aa4c20e8ee1c066909818d2dfffcbc2a diff --git a/tmtc b/tmtc index 8b5554d6..5d9f0083 160000 --- a/tmtc +++ b/tmtc @@ -1 +1 @@ -Subproject commit 8b5554d6fdfb9e2d982e4a2af4f5e6d6e844794e +Subproject commit 5d9f0083204ff7fcb8269241695aad3ef824f32c From c6e16e0866c9c8e5e3f855042a9b64638acbef8a Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Thu, 7 Apr 2022 09:57:19 +0200 Subject: [PATCH 06/14] resolve merge conflict, ran afmt --- mission/devices/SyrlinksHkHandler.cpp | 57 +++++++++++---------------- mission/devices/SyrlinksHkHandler.h | 11 ++---- 2 files changed, 25 insertions(+), 43 deletions(-) diff --git a/mission/devices/SyrlinksHkHandler.cpp b/mission/devices/SyrlinksHkHandler.cpp index 2a847071..9108a6f1 100644 --- a/mission/devices/SyrlinksHkHandler.cpp +++ b/mission/devices/SyrlinksHkHandler.cpp @@ -192,10 +192,10 @@ void SyrlinksHkHandler::fillCommandAndReplyMap() { true, syrlinks::ACK_REPLY); this->insertInCommandAndReplyMap(syrlinks::WRITE_LCL_CONFIG, 1, nullptr, syrlinks::ACK_SIZE, false, true, syrlinks::ACK_REPLY); - this->insertInCommandAndReplyMap(syrlinks::CONFIG_BPSK, 1, nullptr, syrlinks::ACK_SIZE, - false, true, syrlinks::ACK_REPLY); - this->insertInCommandAndReplyMap(syrlinks::CONFIG_OQPSK, 1, nullptr, syrlinks::ACK_SIZE, - false, true, syrlinks::ACK_REPLY); + this->insertInCommandAndReplyMap(syrlinks::CONFIG_BPSK, 1, nullptr, syrlinks::ACK_SIZE, false, + true, syrlinks::ACK_REPLY); + this->insertInCommandAndReplyMap(syrlinks::CONFIG_OQPSK, 1, nullptr, syrlinks::ACK_SIZE, false, + true, syrlinks::ACK_REPLY); this->insertInCommandMap(syrlinks::ENABLE_DEBUG); this->insertInCommandMap(syrlinks::DISABLE_DEBUG); this->insertInCommandAndReplyMap(syrlinks::READ_LCL_CONFIG, 1, nullptr, @@ -361,17 +361,12 @@ ReturnValue_t SyrlinksHkHandler::interpretDeviceReply(DeviceCommandId_t id, cons rawTempBasebandBoard |= convertHexStringToUint8( reinterpret_cast(packet + syrlinks::MESSAGE_HEADER_SIZE)); tempBasebandBoard = calcTempVal(rawTempBasebandBoard); -<<<<<<< HEAD - sif::info << "Syrlinks temperature baseband board: " << tempBasebandBoard << " °C" - << std::endl; -======= temperatureSet.temperatureBasebandBoard = tempBasebandBoard; PoolReadGuard rg(&temperatureSet); if (debug) { sif::info << "Syrlinks temperature baseband board: " << tempBasebandBoard << " °C" << std::endl; } ->>>>>>> origin/develop break; } case (syrlinks::TEMP_POWER_AMPLIFIER_HIGH_BYTE): { @@ -383,11 +378,7 @@ ReturnValue_t SyrlinksHkHandler::interpretDeviceReply(DeviceCommandId_t id, cons } rawTempPowerAmplifier = 0; rawTempPowerAmplifier = convertHexStringToUint8(reinterpret_cast( -<<<<<<< HEAD - packet + SYRLINKS::MESSAGE_HEADER_SIZE)) -======= packet + syrlinks::MESSAGE_HEADER_SIZE)) ->>>>>>> origin/develop << 8; break; } @@ -401,17 +392,12 @@ ReturnValue_t SyrlinksHkHandler::interpretDeviceReply(DeviceCommandId_t id, cons rawTempPowerAmplifier |= convertHexStringToUint8( reinterpret_cast(packet + syrlinks::MESSAGE_HEADER_SIZE)); tempPowerAmplifier = calcTempVal(rawTempPowerAmplifier); -<<<<<<< HEAD - sif::info << "Syrlinks temperature power amplifier board: " << tempPowerAmplifier << " °C" - << std::endl; -======= PoolReadGuard rg(&temperatureSet); temperatureSet.temperaturePowerAmplifier = tempPowerAmplifier; if (debug) { sif::info << "Syrlinks temperature power amplifier board: " << tempPowerAmplifier << " °C" << std::endl; } ->>>>>>> origin/develop break; } default: { @@ -485,7 +471,8 @@ ReturnValue_t SyrlinksHkHandler::parseReplyStatus(const char* status) { case '0': return RETURN_OK; case '1': - sif::debug << "SyrlinksHkHandler::parseReplyStatus: Uart framing or parity error" << std::endl; + sif::debug << "SyrlinksHkHandler::parseReplyStatus: Uart framing or parity error" + << std::endl; return UART_FRAMIN_OR_PARITY_ERROR_ACK; case '2': sif::debug << "SyrlinksHkHandler::parseReplyStatus: Bad character detected" << std::endl; @@ -555,15 +542,15 @@ void SyrlinksHkHandler::parseRxStatusRegistersReply(const uint8_t* packet) { #if OBSW_VERBOSE_LEVEL >= 1 && OBSW_DEBUG_SYRLINKS == 1 if (debug) { - sif::info << "Syrlinks RX Status: 0x" << std::hex << (unsigned int)rxDataset.rxStatus.value - << std::endl; - sif::info << "Syrlinks RX Sensitivity: " << std::dec << rxDataset.rxSensitivity << std::endl; - sif::info << "Syrlinks RX Frequency Shift: " << rxDataset.rxFrequencyShift << std::endl; - sif::info << "Syrlinks RX IQ Power: " << rxDataset.rxIqPower << std::endl; - sif::info << "Syrlinks RX AGC Value: " << rxDataset.rxAgcValue << std::endl; - sif::info << "Syrlinks RX Demod Eb: " << rxDataset.rxDemodEb << std::endl; - sif::info << "Syrlinks RX Demod N0: " << rxDataset.rxDemodN0 << std::endl; - sif::info << "Syrlinks RX Datarate: " << (unsigned int)rxDataset.rxDataRate.value << std::endl; + sif::info << "Syrlinks RX Status: 0x" << std::hex << (unsigned int)rxDataset.rxStatus.value + << std::endl; + sif::info << "Syrlinks RX Sensitivity: " << std::dec << rxDataset.rxSensitivity << std::endl; + sif::info << "Syrlinks RX Frequency Shift: " << rxDataset.rxFrequencyShift << std::endl; + sif::info << "Syrlinks RX IQ Power: " << rxDataset.rxIqPower << std::endl; + sif::info << "Syrlinks RX AGC Value: " << rxDataset.rxAgcValue << std::endl; + sif::info << "Syrlinks RX Demod Eb: " << rxDataset.rxDemodEb << std::endl; + sif::info << "Syrlinks RX Demod N0: " << rxDataset.rxDemodN0 << std::endl; + sif::info << "Syrlinks RX Datarate: " << (unsigned int)rxDataset.rxDataRate.value << std::endl; } #endif } @@ -572,8 +559,8 @@ void SyrlinksHkHandler::parseLclConfigReply(const uint8_t* packet) { uint16_t offset = syrlinks::MESSAGE_HEADER_SIZE; uint8_t lclConfig = convertHexStringToUint8(reinterpret_cast(packet + offset)); if (debug) { - sif::info << "SyrlinksHkHandler::parseRxStatusRegistersReply: Lcl config: " - << static_cast(lclConfig) << std::endl; + sif::info << "SyrlinksHkHandler::parseRxStatusRegistersReply: Lcl config: " + << static_cast(lclConfig) << std::endl; } } @@ -583,8 +570,8 @@ void SyrlinksHkHandler::parseTxStatusReply(const uint8_t* packet) { txDataset.txStatus = convertHexStringToUint8(reinterpret_cast(packet + offset)); #if OBSW_DEBUG_SYRLINKS == 1 if (debug) { - sif::info << "Syrlinks TX Status: 0x" << std::hex << (unsigned int)txDataset.txStatus.value - << std::endl; + sif::info << "Syrlinks TX Status: 0x" << std::hex << (unsigned int)txDataset.txStatus.value + << std::endl; } #endif } @@ -595,8 +582,8 @@ void SyrlinksHkHandler::parseTxWaveformReply(const uint8_t* packet) { txDataset.txWaveform = convertHexStringToUint8(reinterpret_cast(packet + offset)); #if OBSW_DEBUG_SYRLINKS == 1 if (debug) { - sif::info << "Syrlinks TX Waveform: 0x" << std::hex << (unsigned int)txDataset.txWaveform.value - << std::endl; + sif::info << "Syrlinks TX Waveform: 0x" << std::hex << (unsigned int)txDataset.txWaveform.value + << std::endl; } #endif } @@ -608,7 +595,7 @@ void SyrlinksHkHandler::parseAgcLowByte(const uint8_t* packet) { convertHexStringToUint8(reinterpret_cast(packet + offset)); #if OBSW_DEBUG_SYRLINKS == 1 if (debug) { - sif::info << "Syrlinks TX AGC Value: " << txDataset.txAgcValue << std::endl; + sif::info << "Syrlinks TX AGC Value: " << txDataset.txAgcValue << std::endl; } #endif } diff --git a/mission/devices/SyrlinksHkHandler.h b/mission/devices/SyrlinksHkHandler.h index 6d8c6002..78ae6d99 100644 --- a/mission/devices/SyrlinksHkHandler.h +++ b/mission/devices/SyrlinksHkHandler.h @@ -5,10 +5,9 @@ #include "devices/powerSwitcherList.h" #include "fsfw/devicehandlers/DeviceHandlerBase.h" -#include "mission/devices/devicedefinitions/SyrlinksDefinitions.h" -#include "fsfw_hal/linux/gpio/Gpio.h" #include "fsfw/timemanager/Countdown.h" -#include +#include "fsfw_hal/linux/gpio/Gpio.h" +#include "mission/devices/devicedefinitions/SyrlinksDefinitions.h" /** * @brief This is the device handler for the syrlinks transceiver. It handles the command @@ -104,11 +103,7 @@ class SyrlinksHkHandler : public DeviceHandlerBase { uint8_t commandBuffer[syrlinks::MAX_COMMAND_SIZE]; - enum class StartupState { - OFF, - ENABLE_TEMPERATURE_PROTECTION, - DONE - }; + enum class StartupState { OFF, ENABLE_TEMPERATURE_PROTECTION, DONE }; StartupState startupState = StartupState::OFF; From a6d20de0a51b54cadab4549128dbec1e729755d3 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Thu, 7 Apr 2022 10:02:56 +0200 Subject: [PATCH 07/14] GPS linux controller update --- linux/devices/GPSHyperionLinuxController.cpp | 22 +++++++++++++++++++- linux/devices/GPSHyperionLinuxController.h | 2 ++ 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/linux/devices/GPSHyperionLinuxController.cpp b/linux/devices/GPSHyperionLinuxController.cpp index a811fbc5..d696a188 100644 --- a/linux/devices/GPSHyperionLinuxController.cpp +++ b/linux/devices/GPSHyperionLinuxController.cpp @@ -9,13 +9,16 @@ #include #endif #include +#include GPSHyperionLinuxController::GPSHyperionLinuxController(object_id_t objectId, object_id_t parentId, bool debugHyperionGps) : ExtendedControllerBase(objectId, objects::NO_OBJECT), gpsSet(this), myGpsmm(GPSD_SHARED_MEMORY, nullptr), - debugHyperionGps(debugHyperionGps) {} + debugHyperionGps(debugHyperionGps) { + timeUpdateCd.resetTimer(); +} GPSHyperionLinuxController::~GPSHyperionLinuxController() {} @@ -172,6 +175,20 @@ void GPSHyperionLinuxController::readGpsDataFromGpsd() { timeval time = {}; time.tv_sec = gpsSet.unixSeconds.value; time.tv_usec = gps->fix.time.tv_nsec / 1000; + std::time_t t = std::time(nullptr); + if (time.tv_sec == t) { + timeIsConstantCounter++; + } else { + timeIsConstantCounter = 0; + } + // If the received time does not change anymore for whatever reason, do not set it here + // to avoid stale times. Also, don't do it too often often to avoid jumping times + if (timeIsConstantCounter < 20 and timeUpdateCd.hasTimedOut()) { + // Update the system time here for now. NTP seems to be unable to do so for whatever reason + settimeofday(&time, nullptr); + timeUpdateCd.resetTimer(); + } + Clock::TimeOfDay_t timeOfDay = {}; Clock::convertTimevalToTimeOfDay(&time, &timeOfDay); gpsSet.year = timeOfDay.year; @@ -192,6 +209,9 @@ void GPSHyperionLinuxController::readGpsDataFromGpsd() { std::cout << "Longitude: " << gps->fix.longitude << std::endl; std::cout << "Altitude(MSL): " << gps->fix.altMSL << std::endl; std::cout << "Speed(m/s): " << gps->fix.speed << std::endl; + std::time_t t = std::time(nullptr); + std::tm tm = *std::gmtime(&t); + std::cout << "C Time: " << std::put_time(&tm, "%c") << std::endl; } } #endif diff --git a/linux/devices/GPSHyperionLinuxController.h b/linux/devices/GPSHyperionLinuxController.h index f0e4e6e0..46acb5fc 100644 --- a/linux/devices/GPSHyperionLinuxController.h +++ b/linux/devices/GPSHyperionLinuxController.h @@ -51,6 +51,8 @@ class GPSHyperionLinuxController : public ExtendedControllerBase { bool modeCommanded = true; gpsmm myGpsmm; bool debugHyperionGps = false; + uint32_t timeIsConstantCounter = 0; + Countdown timeUpdateCd = Countdown(60); void readGpsDataFromGpsd(); }; From c3aa9fb9083e618c2cb4962f064a5af8c97a5e6a Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Thu, 7 Apr 2022 10:55:29 +0200 Subject: [PATCH 08/14] update for gps - GPSD/NTPD finally seem to work now. Still keep code to set it manually for now --- linux/devices/GPSHyperionLinuxController.cpp | 7 +- mission/utility/compileTime.h | 97 ++++++++++++++++++++ 2 files changed, 102 insertions(+), 2 deletions(-) create mode 100644 mission/utility/compileTime.h diff --git a/linux/devices/GPSHyperionLinuxController.cpp b/linux/devices/GPSHyperionLinuxController.cpp index d696a188..f1de53e9 100644 --- a/linux/devices/GPSHyperionLinuxController.cpp +++ b/linux/devices/GPSHyperionLinuxController.cpp @@ -4,6 +4,8 @@ #include "fsfw/datapool/PoolReadGuard.h" #include "fsfw/timemanager/Clock.h" +#include "mission/utility/compileTime.h" + #if FSFW_DEV_HYPERION_GPS_CREATE_NMEA_CSV == 1 #include #include @@ -184,8 +186,9 @@ void GPSHyperionLinuxController::readGpsDataFromGpsd() { // If the received time does not change anymore for whatever reason, do not set it here // to avoid stale times. Also, don't do it too often often to avoid jumping times if (timeIsConstantCounter < 20 and timeUpdateCd.hasTimedOut()) { - // Update the system time here for now. NTP seems to be unable to do so for whatever reason - settimeofday(&time, nullptr); + // Update the system time here for now. NTP seems to be unable to do so for whatever reason. + // Further tests have shown that the time seems to be set by NTPD after sme time.. + // Clock::setClock(&time); timeUpdateCd.resetTimer(); } diff --git a/mission/utility/compileTime.h b/mission/utility/compileTime.h new file mode 100644 index 00000000..c55673f6 --- /dev/null +++ b/mission/utility/compileTime.h @@ -0,0 +1,97 @@ +/* + * + * Created: 29.03.2018 + * + * Authors: + * + * Assembled from the code released on Stackoverflow by: + * Dennis (instructable.com/member/nqtronix) | https://stackoverflow.com/questions/23032002/c-c-how-to-get-integer-unix-timestamp-of-build-time-not-string + * and + * Alexis Wilke | https://stackoverflow.com/questions/10538444/do-you-know-of-a-c-macro-to-compute-unix-time-and-date + * + * Assembled by Jean Rabault + * + * UNIX_TIMESTAMP gives the UNIX timestamp (unsigned long integer of seconds since 1st Jan 1970) of compilation from macros using the compiler defined __TIME__ macro. + * This should include Gregorian calendar leap days, in particular the 29ths of February, 100 and 400 years modulo leaps. + * + * Careful: __TIME__ is the local time of the computer, NOT the UTC time in general! + * + */ + +#ifndef COMPILE_TIME_H_ +#define COMPILE_TIME_H_ + +// Some definitions for calculation +#define SEC_PER_MIN 60UL +#define SEC_PER_HOUR 3600UL +#define SEC_PER_DAY 86400UL +#define SEC_PER_YEAR (SEC_PER_DAY*365) + +// extracts 1..4 characters from a string and interprets it as a decimal value +#define CONV_STR2DEC_1(str, i) (str[i]>'0'?str[i]-'0':0) +#define CONV_STR2DEC_2(str, i) (CONV_STR2DEC_1(str, i)*10 + str[i+1]-'0') +#define CONV_STR2DEC_3(str, i) (CONV_STR2DEC_2(str, i)*10 + str[i+2]-'0') +#define CONV_STR2DEC_4(str, i) (CONV_STR2DEC_3(str, i)*10 + str[i+3]-'0') + +// Custom "glue logic" to convert the month name to a usable number +#define GET_MONTH(str, i) (str[i]=='J' && str[i+1]=='a' && str[i+2]=='n' ? 1 : \ + str[i]=='F' && str[i+1]=='e' && str[i+2]=='b' ? 2 : \ + str[i]=='M' && str[i+1]=='a' && str[i+2]=='r' ? 3 : \ + str[i]=='A' && str[i+1]=='p' && str[i+2]=='r' ? 4 : \ + str[i]=='M' && str[i+1]=='a' && str[i+2]=='y' ? 5 : \ + str[i]=='J' && str[i+1]=='u' && str[i+2]=='n' ? 6 : \ + str[i]=='J' && str[i+1]=='u' && str[i+2]=='l' ? 7 : \ + str[i]=='A' && str[i+1]=='u' && str[i+2]=='g' ? 8 : \ + str[i]=='S' && str[i+1]=='e' && str[i+2]=='p' ? 9 : \ + str[i]=='O' && str[i+1]=='c' && str[i+2]=='t' ? 10 : \ + str[i]=='N' && str[i+1]=='o' && str[i+2]=='v' ? 11 : \ + str[i]=='D' && str[i+1]=='e' && str[i+2]=='c' ? 12 : 0) + +// extract the information from the time string given by __TIME__ and __DATE__ +#define __TIME_SECONDS__ CONV_STR2DEC_2(__TIME__, 6) +#define __TIME_MINUTES__ CONV_STR2DEC_2(__TIME__, 3) +#define __TIME_HOURS__ CONV_STR2DEC_2(__TIME__, 0) +#define __TIME_DAYS__ CONV_STR2DEC_2(__DATE__, 4) +#define __TIME_MONTH__ GET_MONTH(__DATE__, 0) +#define __TIME_YEARS__ CONV_STR2DEC_4(__DATE__, 7) + +// Days in February +#define _UNIX_TIMESTAMP_FDAY(year) \ + (((year) % 400) == 0UL ? 29UL : \ + (((year) % 100) == 0UL ? 28UL : \ + (((year) % 4) == 0UL ? 29UL : \ + 28UL))) + +// Days in the year +#define _UNIX_TIMESTAMP_YDAY(year, month, day) \ + ( \ + /* January */ day \ + /* February */ + (month >= 2 ? 31UL : 0UL) \ + /* March */ + (month >= 3 ? _UNIX_TIMESTAMP_FDAY(year) : 0UL) \ + /* April */ + (month >= 4 ? 31UL : 0UL) \ + /* May */ + (month >= 5 ? 30UL : 0UL) \ + /* June */ + (month >= 6 ? 31UL : 0UL) \ + /* July */ + (month >= 7 ? 30UL : 0UL) \ + /* August */ + (month >= 8 ? 31UL : 0UL) \ + /* September */+ (month >= 9 ? 31UL : 0UL) \ + /* October */ + (month >= 10 ? 30UL : 0UL) \ + /* November */ + (month >= 11 ? 31UL : 0UL) \ + /* December */ + (month >= 12 ? 30UL : 0UL) \ + ) + +// get the UNIX timestamp from a digits representation +#define _UNIX_TIMESTAMP(year, month, day, hour, minute, second) \ + ( /* time */ second \ + + minute * SEC_PER_MIN \ + + hour * SEC_PER_HOUR \ + + /* year day (month + day) */ (_UNIX_TIMESTAMP_YDAY(year, month, day) - 1) * SEC_PER_DAY \ + + /* year */ (year - 1970UL) * SEC_PER_YEAR \ + + ((year - 1969UL) / 4UL) * SEC_PER_DAY \ + - ((year - 1901UL) / 100UL) * SEC_PER_DAY \ + + ((year - 1601UL) / 400UL) * SEC_PER_DAY \ + ) + +// the UNIX timestamp +#define UNIX_TIMESTAMP (_UNIX_TIMESTAMP(__TIME_YEARS__, __TIME_MONTH__, __TIME_DAYS__, __TIME_HOURS__, __TIME_MINUTES__, __TIME_SECONDS__)) + +#endif From b2933f95d72bc809425b394145471e42aab10988 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Thu, 7 Apr 2022 11:07:51 +0200 Subject: [PATCH 09/14] fsfw update --- fsfw | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fsfw b/fsfw index 43917d98..a11d7455 160000 --- a/fsfw +++ b/fsfw @@ -1 +1 @@ -Subproject commit 43917d98c025b446aa0d79d2166b1f031fb288ae +Subproject commit a11d7455dfaf2e736f73f6c4dda1f8c06b9f1234 From 5c4ae861b16cb1a41254276143cc575373ad92bf Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Thu, 7 Apr 2022 11:11:37 +0200 Subject: [PATCH 10/14] exclude gps changes --- linux/devices/GPSHyperionLinuxController.cpp | 26 ++------------------ linux/devices/GPSHyperionLinuxController.h | 2 -- 2 files changed, 2 insertions(+), 26 deletions(-) diff --git a/linux/devices/GPSHyperionLinuxController.cpp b/linux/devices/GPSHyperionLinuxController.cpp index b892dc70..a811fbc5 100644 --- a/linux/devices/GPSHyperionLinuxController.cpp +++ b/linux/devices/GPSHyperionLinuxController.cpp @@ -9,16 +9,13 @@ #include #endif #include -#include GPSHyperionLinuxController::GPSHyperionLinuxController(object_id_t objectId, object_id_t parentId, bool debugHyperionGps) : ExtendedControllerBase(objectId, objects::NO_OBJECT), gpsSet(this), myGpsmm(GPSD_SHARED_MEMORY, nullptr), - debugHyperionGps(debugHyperionGps) { - timeUpdateCd.resetTimer(); -} + debugHyperionGps(debugHyperionGps) {} GPSHyperionLinuxController::~GPSHyperionLinuxController() {} @@ -79,11 +76,9 @@ ReturnValue_t GPSHyperionLinuxController::initializeLocalDataPool( localDataPoolMap.emplace(GpsHyperion::SATS_IN_USE, new PoolEntry()); localDataPoolMap.emplace(GpsHyperion::SATS_IN_VIEW, new PoolEntry()); localDataPoolMap.emplace(GpsHyperion::FIX_MODE, new PoolEntry()); - bool enablePeriodicHk = false; #if OBSW_ENABLE_PERIODIC_HK == 1 - enablePeriodicHk = true; + poolManager.subscribeForPeriodicPacket(gpsSet.getSid(), true, 2.0, false); #endif - poolManager.subscribeForPeriodicPacket(gpsSet.getSid(), enablePeriodicHk, 2.0, false); return HasReturnvaluesIF::RETURN_OK; } @@ -177,20 +172,6 @@ void GPSHyperionLinuxController::readGpsDataFromGpsd() { timeval time = {}; time.tv_sec = gpsSet.unixSeconds.value; time.tv_usec = gps->fix.time.tv_nsec / 1000; - std::time_t t = std::time(nullptr); - if (time.tv_sec == t) { - timeIsConstantCounter++; - } else { - timeIsConstantCounter = 0; - } - // If the received time does not change anymore for whatever reason, do not set it here - // to avoid stale times. Also, don't do it too often often to avoid jumping times - if (timeIsConstantCounter < 3 and timeUpdateCd.hasTimedOut()) { - // Update the system time here for now. NTP seems to be unable to do so for whatever reason - settimeofday(&time, nullptr); - timeUpdateCd.resetTimer(); - } - Clock::TimeOfDay_t timeOfDay = {}; Clock::convertTimevalToTimeOfDay(&time, &timeOfDay); gpsSet.year = timeOfDay.year; @@ -211,9 +192,6 @@ void GPSHyperionLinuxController::readGpsDataFromGpsd() { std::cout << "Longitude: " << gps->fix.longitude << std::endl; std::cout << "Altitude(MSL): " << gps->fix.altMSL << std::endl; std::cout << "Speed(m/s): " << gps->fix.speed << std::endl; - std::time_t t = std::time(nullptr); - std::tm tm = *std::gmtime(&t); - std::cout << "C Time: " << std::put_time(&tm, "%c") << std::endl; } } #endif diff --git a/linux/devices/GPSHyperionLinuxController.h b/linux/devices/GPSHyperionLinuxController.h index 46acb5fc..f0e4e6e0 100644 --- a/linux/devices/GPSHyperionLinuxController.h +++ b/linux/devices/GPSHyperionLinuxController.h @@ -51,8 +51,6 @@ class GPSHyperionLinuxController : public ExtendedControllerBase { bool modeCommanded = true; gpsmm myGpsmm; bool debugHyperionGps = false; - uint32_t timeIsConstantCounter = 0; - Countdown timeUpdateCd = Countdown(60); void readGpsDataFromGpsd(); }; From 8f4f2713315e6f28dae3459ce85368ffb8e8cd2c Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Thu, 7 Apr 2022 11:15:28 +0200 Subject: [PATCH 11/14] longer HK intervals --- linux/devices/GPSHyperionLinuxController.cpp | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/linux/devices/GPSHyperionLinuxController.cpp b/linux/devices/GPSHyperionLinuxController.cpp index f1de53e9..b608f972 100644 --- a/linux/devices/GPSHyperionLinuxController.cpp +++ b/linux/devices/GPSHyperionLinuxController.cpp @@ -81,9 +81,7 @@ ReturnValue_t GPSHyperionLinuxController::initializeLocalDataPool( localDataPoolMap.emplace(GpsHyperion::SATS_IN_USE, new PoolEntry()); localDataPoolMap.emplace(GpsHyperion::SATS_IN_VIEW, new PoolEntry()); localDataPoolMap.emplace(GpsHyperion::FIX_MODE, new PoolEntry()); -#if OBSW_ENABLE_PERIODIC_HK == 1 - poolManager.subscribeForPeriodicPacket(gpsSet.getSid(), true, 2.0, false); -#endif + poolManager.subscribeForPeriodicPacket(gpsSet.getSid(), false, 10.0, false); return HasReturnvaluesIF::RETURN_OK; } From ca92b858645b02bc36f71bb709ddb17dd0a58a9f Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Thu, 7 Apr 2022 11:22:29 +0200 Subject: [PATCH 12/14] enable periodic HK by default --- linux/devices/GPSHyperionLinuxController.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/linux/devices/GPSHyperionLinuxController.cpp b/linux/devices/GPSHyperionLinuxController.cpp index b608f972..34e02001 100644 --- a/linux/devices/GPSHyperionLinuxController.cpp +++ b/linux/devices/GPSHyperionLinuxController.cpp @@ -81,7 +81,11 @@ ReturnValue_t GPSHyperionLinuxController::initializeLocalDataPool( localDataPoolMap.emplace(GpsHyperion::SATS_IN_USE, new PoolEntry()); localDataPoolMap.emplace(GpsHyperion::SATS_IN_VIEW, new PoolEntry()); localDataPoolMap.emplace(GpsHyperion::FIX_MODE, new PoolEntry()); - poolManager.subscribeForPeriodicPacket(gpsSet.getSid(), false, 10.0, false); + bool enableHk = false; +#if OBSW_ENABLE_PERIODIC_HK == 1 + enableHk = true; +#endif + poolManager.subscribeForPeriodicPacket(gpsSet.getSid(), enableHk, 60.0, false); return HasReturnvaluesIF::RETURN_OK; } From 66627741f9728a708b0d2267518594120bd31afd Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Thu, 7 Apr 2022 11:53:21 +0200 Subject: [PATCH 13/14] periodic HK definitions for all device handlers --- mission/devices/ACUHandler.cpp | 1 + mission/devices/BpxBatteryHandler.cpp | 5 +---- mission/devices/GPSHyperionHandler.cpp | 2 +- mission/devices/GyroADIS1650XHandler.cpp | 1 + mission/devices/IMTQHandler.cpp | 2 ++ mission/devices/Max31865PT1000Handler.cpp | 3 +-- mission/devices/PDU1Handler.cpp | 2 +- mission/devices/PDU2Handler.cpp | 4 +--- mission/devices/PayloadPcduHandler.cpp | 2 +- mission/devices/RadiationSensorHandler.cpp | 1 + mission/devices/RwHandler.cpp | 4 +++- mission/devices/SusHandler.cpp | 1 + mission/devices/SyrlinksHkHandler.cpp | 3 +++ mission/devices/Tmp1075Handler.cpp | 3 ++- mission/devices/devicedefinitions/Tmp1075Definitions.h | 4 ++-- 15 files changed, 22 insertions(+), 16 deletions(-) diff --git a/mission/devices/ACUHandler.cpp b/mission/devices/ACUHandler.cpp index 7c6e048c..133eb237 100644 --- a/mission/devices/ACUHandler.cpp +++ b/mission/devices/ACUHandler.cpp @@ -271,6 +271,7 @@ ReturnValue_t ACUHandler::initializeLocalDataPool(localpool::DataPool &localData localDataPoolMap.emplace(pool::ACU_WDT_CNT_GND, new PoolEntry({0})); localDataPoolMap.emplace(pool::ACU_WDT_GND_LEFT, new PoolEntry({0})); + poolManager.subscribeForPeriodicPacket(acuHkTableDataset.getSid(), false, 30.0, false); return HasReturnvaluesIF::RETURN_OK; } diff --git a/mission/devices/BpxBatteryHandler.cpp b/mission/devices/BpxBatteryHandler.cpp index 2ad20c9d..9da04207 100644 --- a/mission/devices/BpxBatteryHandler.cpp +++ b/mission/devices/BpxBatteryHandler.cpp @@ -270,10 +270,7 @@ ReturnValue_t BpxBatteryHandler::initializeLocalDataPool(localpool::DataPool& lo localDataPoolMap.emplace(BpxBattery::BATTERY_HEATER_MODE, &battheatMode); localDataPoolMap.emplace(BpxBattery::BATTHEAT_LOW_LIMIT, &battheatLow); localDataPoolMap.emplace(BpxBattery::BATTHEAT_HIGH_LIMIT, &battheatHigh); - -#if OBSW_ENABLE_PERIODIC_HK == 1 - poolManager.subscribeForPeriodicPacket(hkSet.getSid(), true, 1.0, false); -#endif + poolManager.subscribeForPeriodicPacket(hkSet.getSid(), false, 30.0, false); return HasReturnvaluesIF::RETURN_OK; } diff --git a/mission/devices/GPSHyperionHandler.cpp b/mission/devices/GPSHyperionHandler.cpp index d6928bb5..ac1f99fa 100644 --- a/mission/devices/GPSHyperionHandler.cpp +++ b/mission/devices/GPSHyperionHandler.cpp @@ -169,7 +169,7 @@ ReturnValue_t GPSHyperionHandler::initializeLocalDataPool(localpool::DataPool &l localDataPoolMap.emplace(GpsHyperion::UNIX_SECONDS, new PoolEntry()); localDataPoolMap.emplace(GpsHyperion::SATS_IN_USE, new PoolEntry()); localDataPoolMap.emplace(GpsHyperion::FIX_MODE, new PoolEntry()); - poolManager.subscribeForPeriodicPacket(gpsSet.getSid(), true, 2.0, false); + poolManager.subscribeForPeriodicPacket(gpsSet.getSid(), false, 30.0, false); return HasReturnvaluesIF::RETURN_OK; } diff --git a/mission/devices/GyroADIS1650XHandler.cpp b/mission/devices/GyroADIS1650XHandler.cpp index b29f71de..3b525287 100644 --- a/mission/devices/GyroADIS1650XHandler.cpp +++ b/mission/devices/GyroADIS1650XHandler.cpp @@ -363,6 +363,7 @@ ReturnValue_t GyroADIS1650XHandler::initializeLocalDataPool(localpool::DataPool localDataPoolMap.emplace(ADIS1650X::FILTER_SETTINGS, new PoolEntry()); localDataPoolMap.emplace(ADIS1650X::MSC_CTRL_REGISTER, new PoolEntry()); localDataPoolMap.emplace(ADIS1650X::DEC_RATE_REGISTER, new PoolEntry()); + poolManager.subscribeForPeriodicPacket(primaryDataset.getSid(), false, 5.0, true); return HasReturnvaluesIF::RETURN_OK; } diff --git a/mission/devices/IMTQHandler.cpp b/mission/devices/IMTQHandler.cpp index 3c3e1a66..99537dcb 100644 --- a/mission/devices/IMTQHandler.cpp +++ b/mission/devices/IMTQHandler.cpp @@ -599,6 +599,8 @@ ReturnValue_t IMTQHandler::initializeLocalDataPool(localpool::DataPool& localDat localDataPoolMap.emplace(IMTQ::FINA_NEG_Z_COIL_Y_TEMPERATURE, new PoolEntry({0})); localDataPoolMap.emplace(IMTQ::FINA_NEG_Z_COIL_Z_TEMPERATURE, new PoolEntry({0})); + poolManager.subscribeForPeriodicPacket(engHkDataset.getSid(), false, 10.0, true); + poolManager.subscribeForPeriodicPacket(calMtmMeasurementSet.getSid(), false, 10.0, true); return HasReturnvaluesIF::RETURN_OK; } diff --git a/mission/devices/Max31865PT1000Handler.cpp b/mission/devices/Max31865PT1000Handler.cpp index 9a4d88ce..3bb3e911 100644 --- a/mission/devices/Max31865PT1000Handler.cpp +++ b/mission/devices/Max31865PT1000Handler.cpp @@ -515,8 +515,7 @@ ReturnValue_t Max31865PT1000Handler::initializeLocalDataPool(localpool::DataPool localDataPoolMap.emplace(Max31865Definitions::PoolIds::TEMPERATURE_C, new PoolEntry({0}, 1, true)); localDataPoolMap.emplace(Max31865Definitions::PoolIds::FAULT_BYTE, new PoolEntry({0})); - // poolManager.subscribeForPeriodicPacket(sensorDatasetSid, - // false, 4.0, false); + poolManager.subscribeForPeriodicPacket(sensorDataset.getSid(), false, 30.0, false); return HasReturnvaluesIF::RETURN_OK; } diff --git a/mission/devices/PDU1Handler.cpp b/mission/devices/PDU1Handler.cpp index e0c369a3..def2acac 100644 --- a/mission/devices/PDU1Handler.cpp +++ b/mission/devices/PDU1Handler.cpp @@ -426,7 +426,7 @@ ReturnValue_t PDU1Handler::initializeLocalDataPool(localpool::DataPool &localDat localDataPoolMap.emplace(P60System::pool::PDU1_WDT_CAN_LEFT, new PoolEntry({0})); localDataPoolMap.emplace(P60System::pool::PDU1_WDT_CSP_LEFT1, new PoolEntry({0})); localDataPoolMap.emplace(P60System::pool::PDU1_WDT_CSP_LEFT2, new PoolEntry({0})); - poolManager.subscribeForPeriodicPacket(pdu1HkTableDataset.getSid(), false, 0.4, true); + poolManager.subscribeForPeriodicPacket(pdu1HkTableDataset.getSid(), false, 10.0, false); return HasReturnvaluesIF::RETURN_OK; } diff --git a/mission/devices/PDU2Handler.cpp b/mission/devices/PDU2Handler.cpp index 48e7f90e..2fca1ebd 100644 --- a/mission/devices/PDU2Handler.cpp +++ b/mission/devices/PDU2Handler.cpp @@ -354,9 +354,7 @@ ReturnValue_t PDU2Handler::initializeLocalDataPool(localpool::DataPool &localDat localDataPoolMap.emplace(pool::PDU2_WDT_CAN_LEFT, new PoolEntry({0})); localDataPoolMap.emplace(pool::PDU2_WDT_CSP_LEFT1, new PoolEntry({0})); localDataPoolMap.emplace(pool::PDU2_WDT_CSP_LEFT2, new PoolEntry({0})); -#if OBSW_ENABLE_PERIODIC_HK == 1 - poolManager.subscribeForPeriodicPacket(pdu2HkTableDataset.getSid(), false, 0.4, true); -#endif + poolManager.subscribeForPeriodicPacket(pdu2HkTableDataset.getSid(), false, 10.0, false); return HasReturnvaluesIF::RETURN_OK; } diff --git a/mission/devices/PayloadPcduHandler.cpp b/mission/devices/PayloadPcduHandler.cpp index 621b7d9e..a13b7ba6 100644 --- a/mission/devices/PayloadPcduHandler.cpp +++ b/mission/devices/PayloadPcduHandler.cpp @@ -293,7 +293,7 @@ ReturnValue_t PayloadPcduHandler::initializeLocalDataPool(localpool::DataPool& l localDataPoolMap.emplace(plpcdu::PlPcduPoolIds::CHANNEL_VEC, &channelValues); localDataPoolMap.emplace(plpcdu::PlPcduPoolIds::PROCESSED_VEC, &processedValues); localDataPoolMap.emplace(plpcdu::PlPcduPoolIds::TEMP, &tempC); - poolManager.subscribeForPeriodicPacket(adcSet.getSid(), false, 0.1, true); + poolManager.subscribeForPeriodicPacket(adcSet.getSid(), false, 5.0, true); return HasReturnvaluesIF::RETURN_OK; } diff --git a/mission/devices/RadiationSensorHandler.cpp b/mission/devices/RadiationSensorHandler.cpp index e91d8427..b3a9954a 100644 --- a/mission/devices/RadiationSensorHandler.cpp +++ b/mission/devices/RadiationSensorHandler.cpp @@ -203,6 +203,7 @@ ReturnValue_t RadiationSensorHandler::initializeLocalDataPool(localpool::DataPoo localDataPoolMap.emplace(RAD_SENSOR::AIN5, new PoolEntry({0})); localDataPoolMap.emplace(RAD_SENSOR::AIN6, new PoolEntry({0})); localDataPoolMap.emplace(RAD_SENSOR::AIN7, new PoolEntry({0})); + poolManager.subscribeForPeriodicPacket(dataset.getSid(), false, 20.0, false); return HasReturnvaluesIF::RETURN_OK; } diff --git a/mission/devices/RwHandler.cpp b/mission/devices/RwHandler.cpp index 941abf29..99cd341c 100644 --- a/mission/devices/RwHandler.cpp +++ b/mission/devices/RwHandler.cpp @@ -279,7 +279,9 @@ ReturnValue_t RwHandler::initializeLocalDataPool(localpool::DataPool& localDataP localDataPoolMap.emplace(RwDefinitions::SPI_BYTES_READ, new PoolEntry({0})); localDataPoolMap.emplace(RwDefinitions::SPI_REG_OVERRUN_ERRORS, new PoolEntry({0})); localDataPoolMap.emplace(RwDefinitions::SPI_TOTAL_ERRORS, new PoolEntry({0})); - + poolManager.subscribeForPeriodicPacket(temperatureSet.getSid(), false, 30.0, false); + poolManager.subscribeForPeriodicPacket(statusSet.getSid(), false, 5.0, true); + poolManager.subscribeForPeriodicPacket(tmDataset.getSid(), false, 30.0, false); return RETURN_OK; } diff --git a/mission/devices/SusHandler.cpp b/mission/devices/SusHandler.cpp index bea5a749..d763b47d 100644 --- a/mission/devices/SusHandler.cpp +++ b/mission/devices/SusHandler.cpp @@ -200,6 +200,7 @@ ReturnValue_t SusHandler::initializeLocalDataPool(localpool::DataPool &localData LocalDataPoolManager &poolManager) { localDataPoolMap.emplace(SUS::TEMPERATURE_C, &tempC); localDataPoolMap.emplace(SUS::CHANNEL_VEC, &channelVec); + poolManager.subscribeForPeriodicPacket(dataset.getSid(), false, 5.0, true); return HasReturnvaluesIF::RETURN_OK; } diff --git a/mission/devices/SyrlinksHkHandler.cpp b/mission/devices/SyrlinksHkHandler.cpp index 9108a6f1..43888724 100644 --- a/mission/devices/SyrlinksHkHandler.cpp +++ b/mission/devices/SyrlinksHkHandler.cpp @@ -627,6 +627,9 @@ ReturnValue_t SyrlinksHkHandler::initializeLocalDataPool(localpool::DataPool& lo localDataPoolMap.emplace(syrlinks::TEMP_BASEBAND_BOARD, new PoolEntry({0})); localDataPoolMap.emplace(syrlinks::TEMP_POWER_AMPLIFIER, new PoolEntry({0})); + poolManager.subscribeForPeriodicPacket(txDataset.getSid(), false, 5.0, true); + poolManager.subscribeForPeriodicPacket(rxDataset.getSid(), false, 5.0, true); + poolManager.subscribeForPeriodicPacket(temperatureSet.getSid(), false, 10.0, false); return HasReturnvaluesIF::RETURN_OK; } diff --git a/mission/devices/Tmp1075Handler.cpp b/mission/devices/Tmp1075Handler.cpp index 59298851..ce434ff0 100644 --- a/mission/devices/Tmp1075Handler.cpp +++ b/mission/devices/Tmp1075Handler.cpp @@ -119,6 +119,7 @@ uint32_t Tmp1075Handler::getTransitionDelayMs(Mode_t modeFrom, Mode_t modeTo) { ReturnValue_t Tmp1075Handler::initializeLocalDataPool(localpool::DataPool &localDataPoolMap, LocalDataPoolManager &poolManager) { - localDataPoolMap.emplace(TMP1075::TEMPERATURE_C_TMP1075_1, new PoolEntry({0.0})); + localDataPoolMap.emplace(TMP1075::TEMPERATURE_C_TMP1075, new PoolEntry({0.0})); + poolManager.subscribeForPeriodicPacket(dataset.getSid(), false, 30.0, false); return HasReturnvaluesIF::RETURN_OK; } diff --git a/mission/devices/devicedefinitions/Tmp1075Definitions.h b/mission/devices/devicedefinitions/Tmp1075Definitions.h index 3f48508c..6799fd42 100644 --- a/mission/devices/devicedefinitions/Tmp1075Definitions.h +++ b/mission/devices/devicedefinitions/Tmp1075Definitions.h @@ -21,7 +21,7 @@ static const uint32_t TMP1075_DATA_SET_ID = GET_TEMP; static const uint8_t MAX_REPLY_LENGTH = GET_TEMP_REPLY_SIZE; -enum Tmp1075PoolIds : lp_id_t { TEMPERATURE_C_TMP1075_1, TEMPERATURE_C_TMP1075_2 }; +enum Tmp1075PoolIds : lp_id_t { TEMPERATURE_C_TMP1075 }; class Tmp1075Dataset : public StaticLocalDataSet { public: @@ -29,7 +29,7 @@ class Tmp1075Dataset : public StaticLocalDataSet { Tmp1075Dataset(object_id_t objectId) : StaticLocalDataSet(sid_t(objectId, TMP1075_DATA_SET_ID)) {} - lp_var_t temperatureCelcius = lp_var_t(sid.objectId, TEMPERATURE_C_TMP1075_1, this); + lp_var_t temperatureCelcius = lp_var_t(sid.objectId, TEMPERATURE_C_TMP1075, this); }; } // namespace TMP1075 From 64dce75e09d7d409dd053fb14a4ff6accc1c297c Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Thu, 7 Apr 2022 11:56:01 +0200 Subject: [PATCH 14/14] hk update for gps --- linux/devices/GPSHyperionLinuxController.cpp | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/linux/devices/GPSHyperionLinuxController.cpp b/linux/devices/GPSHyperionLinuxController.cpp index a811fbc5..29dba910 100644 --- a/linux/devices/GPSHyperionLinuxController.cpp +++ b/linux/devices/GPSHyperionLinuxController.cpp @@ -76,9 +76,7 @@ ReturnValue_t GPSHyperionLinuxController::initializeLocalDataPool( localDataPoolMap.emplace(GpsHyperion::SATS_IN_USE, new PoolEntry()); localDataPoolMap.emplace(GpsHyperion::SATS_IN_VIEW, new PoolEntry()); localDataPoolMap.emplace(GpsHyperion::FIX_MODE, new PoolEntry()); -#if OBSW_ENABLE_PERIODIC_HK == 1 - poolManager.subscribeForPeriodicPacket(gpsSet.getSid(), true, 2.0, false); -#endif + poolManager.subscribeForPeriodicPacket(gpsSet.getSid(), false, 30.0, false); return HasReturnvaluesIF::RETURN_OK; }