From e2c9bece05883dfa1bd16659f8f89d0d5c5b1cc9 Mon Sep 17 00:00:00 2001 From: Jakob Meier Date: Sun, 27 Mar 2022 14:42:20 +0200 Subject: [PATCH] adding uart isolator switches wip --- bsp_q7s/core/ObjectFactory.cpp | 5 +++-- linux/devices/ploc/PlocMPSoCHandler.cpp | 21 +++++++++++++++----- linux/devices/ploc/PlocMPSoCHandler.h | 12 +++++++---- linux/devices/ploc/PlocSupervisorHandler.cpp | 5 ++++- linux/devices/ploc/PlocSupervisorHandler.h | 14 ++++++++----- 5 files changed, 40 insertions(+), 17 deletions(-) diff --git a/bsp_q7s/core/ObjectFactory.cpp b/bsp_q7s/core/ObjectFactory.cpp index dc0e938c..38244dad 100644 --- a/bsp_q7s/core/ObjectFactory.cpp +++ b/bsp_q7s/core/ObjectFactory.cpp @@ -185,8 +185,9 @@ void ObjectFactory::produce(void* args) { new UartCookie(objects::PLOC_MPSOC_HANDLER, q7s::UART_PLOC_MPSOC_DEV, UartModes::NON_CANONICAL, uart::PLOC_MPSOC_BAUD, mpsoc::MAX_REPLY_SIZE); PlocMPSoCHelper* plocMpsocHelper = new PlocMPSoCHelper(objects::PLOC_MPSOC_HELPER); - PlocMPSoCHandler* plocMPSoCHandler = new PlocMPSoCHandler( - objects::PLOC_MPSOC_HANDLER, objects::UART_COM_IF, plocMpsocCookie, plocMpsocHelper); + PlocMPSoCHandler* plocMPSoCHandler = + new PlocMPSoCHandler(objects::PLOC_MPSOC_HANDLER, objects::UART_COM_IF, plocMpsocCookie, + plocMpsocHelper, gpioComIF); plocMPSoCHandler->setStartUpImmediately(); #endif /* OBSW_ADD_PLOC_MPSOC == 1 */ diff --git a/linux/devices/ploc/PlocMPSoCHandler.cpp b/linux/devices/ploc/PlocMPSoCHandler.cpp index 89dc8a94..c2229c53 100644 --- a/linux/devices/ploc/PlocMPSoCHandler.cpp +++ b/linux/devices/ploc/PlocMPSoCHandler.cpp @@ -5,10 +5,17 @@ #include "fsfw/globalfunctions/CRC.h" PlocMPSoCHandler::PlocMPSoCHandler(object_id_t objectId, object_id_t uartComIFid, - CookieIF* comCookie, PlocMPSoCHelper* plocMPSoCHelper) - : DeviceHandlerBase(objectId, uartComIFid, comCookie), plocMPSoCHelper(plocMPSoCHelper) { - if (comCookie == NULL) { - sif::error << "PlocMPSoCHandler: Invalid com cookie" << std::endl; + CookieIF* comCookie, PlocMPSoCHelper* plocMPSoCHelper, + LinuxLibgpioIF* gpioComIF, gpioId_t uartIsolatorSwitch) + : DeviceHandlerBase(objectId, uartComIFid, comCookie), + plocMPSoCHelper(plocMPSoCHelper), + gpioComIF(gpioComIF), + uartIsolatorSwitch(uartIsolatorSwitch) { + if (comCookie == nullptr) { + sif::error << "PlocMPSoCHandler: Invalid communication cookie" << std::endl; + } + if (gpioComIF == nullptr) { + sif::error << "PlocMPSoCHandler: Invalid gpio communication interface" << std::endl; } eventQueue = QueueFactory::instance()->createMessageQueue(EventMessage::EVENT_MESSAGE_SIZE * 5); } @@ -118,9 +125,13 @@ void PlocMPSoCHandler::doStartUp() { #else setMode(_MODE_TO_ON); #endif + gpioComIF->pullHigh(uartIsolatorSwitch); } -void PlocMPSoCHandler::doShutDown() { setMode(_MODE_POWER_DOWN); } +void PlocMPSoCHandler::doShutDown() { + gpioComIF->pullLow(uartIsolatorSwitch); + setMode(_MODE_POWER_DOWN); +} ReturnValue_t PlocMPSoCHandler::buildNormalDeviceCommand(DeviceCommandId_t* id) { return NOTHING_TO_SEND; diff --git a/linux/devices/ploc/PlocMPSoCHandler.h b/linux/devices/ploc/PlocMPSoCHandler.h index 2d3dcde1..d923cc96 100644 --- a/linux/devices/ploc/PlocMPSoCHandler.h +++ b/linux/devices/ploc/PlocMPSoCHandler.h @@ -8,27 +8,29 @@ #include "fsfw/ipc/QueueFactory.h" #include "fsfw/tmtcservices/SourceSequenceCounter.h" #include "fsfw_hal/linux/uart/UartComIF.h" +#include "fsfw_hal/linux/gpio/LinuxLibgpioIF.h" #include "linux/devices/devicedefinitions/MPSoCReturnValuesIF.h" #include "linux/devices/devicedefinitions/PlocMPSoCDefinitions.h" /** * @brief This is the device handler for the MPSoC of the payload computer. * - * @details The PLOC uses the space packet protocol for communication. On each command the PLOC - * answers with at least one acknowledgment and one execution report. + * @details The PLOC uses the space packet protocol for communication. Each command will be + * answered with at least one acknowledgment and one execution report. * Flight manual: * https://egit.irs.uni-stuttgart.de/redmine/projects/eive-flight-manual/wiki/PLOC_MPSoC ICD: * https://eive-cloud.irs.uni-stuttgart.de/index.php/apps/files/?dir=/EIVE_TAS-ILH-IRS/ICD-PLOC/ILH&fileid=1030263 * * @note The sequence count in the space packets must be incremented with each received and sent - * packet. + * packet otherwise the MPSoC will reply with an acknowledgment failure report. * * @author J. Meier */ class PlocMPSoCHandler : public DeviceHandlerBase { public: PlocMPSoCHandler(object_id_t objectId, object_id_t uartComIFid, CookieIF* comCookie, - PlocMPSoCHelper* plocMPSoCHelper); + PlocMPSoCHelper* plocMPSoCHelper, LinuxLibgpioIF* gpioComIF, + gpioId_t uartIsolatorSwitch); virtual ~PlocMPSoCHandler(); virtual ReturnValue_t initialize() override; ReturnValue_t executeAction(ActionId_t actionId, MessageQueueId_t commandedBy, @@ -97,6 +99,8 @@ class PlocMPSoCHandler : public DeviceHandlerBase { UartComIF* uartComIf = nullptr; PlocMPSoCHelper* plocMPSoCHelper = nullptr; + LinuxLibgpioIF* gpioComIF = nullptr; + gpioId_t uartIsolatorSwitch = gpio::NO_GPIO; // Used to block incoming commands when MPSoC helper class is currently executing a command bool plocMPSoCHelperExecuting = false; diff --git a/linux/devices/ploc/PlocSupervisorHandler.cpp b/linux/devices/ploc/PlocSupervisorHandler.cpp index 63e02eb8..192a0a0c 100644 --- a/linux/devices/ploc/PlocSupervisorHandler.cpp +++ b/linux/devices/ploc/PlocSupervisorHandler.cpp @@ -12,8 +12,11 @@ #include "OBSWConfig.h" PlocSupervisorHandler::PlocSupervisorHandler(object_id_t objectId, object_id_t uartComIFid, - CookieIF* comCookie) + CookieIF* comCookie, LinuxLibgpioIF* gpioComIF, + gpioId_t uartIsolatorSwitch) : DeviceHandlerBase(objectId, uartComIFid, comCookie), + gpioComIF(gpioComIF), + uartIsolatorSwitch(uartIsolatorSwitch), hkset(this), bootStatusReport(this), latchupStatusReport(this) { diff --git a/linux/devices/ploc/PlocSupervisorHandler.h b/linux/devices/ploc/PlocSupervisorHandler.h index 579bd1aa..5f133fef 100644 --- a/linux/devices/ploc/PlocSupervisorHandler.h +++ b/linux/devices/ploc/PlocSupervisorHandler.h @@ -1,10 +1,11 @@ #ifndef MISSION_DEVICES_PLOCSUPERVISORHANDLER_H_ #define MISSION_DEVICES_PLOCSUPERVISORHANDLER_H_ -#include -#include -#include -#include +#include "bsp_q7s/memory/SdCardManager.h" +#include "fsfw/devicehandlers/DeviceHandlerBase.h" +#include "fsfw_hal/linux/uart/UartComIF.h" +#include "fsfw_hal/linux/gpio/LinuxLibgpioIF.h" +#include "inux/devices/devicedefinitions/PlocSupervisorDefinitions.h" #include "OBSWConfig.h" @@ -22,7 +23,8 @@ */ class PlocSupervisorHandler : public DeviceHandlerBase { public: - PlocSupervisorHandler(object_id_t objectId, object_id_t uartComIFid, CookieIF* comCookie); + PlocSupervisorHandler(object_id_t objectId, object_id_t uartComIFid, CookieIF* comCookie, + LinuxLibgpioIF* gpioComIF, gpioId_t uartIsolatorSwitch); virtual ~PlocSupervisorHandler(); virtual ReturnValue_t initialize() override; @@ -112,6 +114,8 @@ class PlocSupervisorHandler : public DeviceHandlerBase { DeviceCommandId_t nextReplyId = PLOC_SPV::NONE; UartComIF* uartComIf = nullptr; + LinuxLibgpioIF* gpioComIF = nullptr; + gpioId_t uartIsolatorSwitch = gpio::NO_GPIO; PLOC_SPV::HkSet hkset; PLOC_SPV::BootStatusReport bootStatusReport;