From 0580784d1697184bbae4fc01f506c7767d869a0c Mon Sep 17 00:00:00 2001 From: "Jakob.Meier" <–meierj@irs.uni-stuttgart.de> Date: Mon, 9 Aug 2021 10:41:28 +0200 Subject: [PATCH 01/43] added mode power down in star tracker --- mission/devices/StarTrackerHandler.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mission/devices/StarTrackerHandler.cpp b/mission/devices/StarTrackerHandler.cpp index 59eab3de..974b3ff3 100644 --- a/mission/devices/StarTrackerHandler.cpp +++ b/mission/devices/StarTrackerHandler.cpp @@ -28,7 +28,7 @@ void StarTrackerHandler::doStartUp() { #else setMode(_MODE_TO_ON); #endif - + setMode(_MODE_POWER_DOWN); } void StarTrackerHandler::doShutDown() { -- 2.43.0 From 8f124de79c44f7959696dd3901a9823f464d231f Mon Sep 17 00:00:00 2001 From: "Jakob.Meier" <–meierj@irs.uni-stuttgart.de> Date: Mon, 9 Aug 2021 14:41:46 +0200 Subject: [PATCH 02/43] set all devices to mode power down in doShutDown --- linux/devices/SusHandler.cpp | 1 + mission/devices/GPSHyperionHandler.cpp | 2 +- mission/devices/GyroADIS16507Handler.cpp | 1 + mission/devices/IMTQHandler.cpp | 2 +- mission/devices/Max31865PT1000Handler.cpp | 2 +- mission/devices/PlocMPSoCHandler.cpp | 2 +- mission/devices/PlocSupervisorHandler.cpp | 2 +- mission/devices/RwHandler.cpp | 1 + mission/devices/StarTrackerHandler.cpp | 2 +- mission/devices/SyrlinksHkHandler.cpp | 2 +- mission/devices/Tmp1075Handler.cpp | 2 +- 11 files changed, 11 insertions(+), 8 deletions(-) diff --git a/linux/devices/SusHandler.cpp b/linux/devices/SusHandler.cpp index c31160c4..dbe58429 100644 --- a/linux/devices/SusHandler.cpp +++ b/linux/devices/SusHandler.cpp @@ -66,6 +66,7 @@ void SusHandler::doStartUp(){ #else setMode(_MODE_TO_ON); #endif + setMode(_MODE_POWER_DOWN); } void SusHandler::doShutDown(){ diff --git a/mission/devices/GPSHyperionHandler.cpp b/mission/devices/GPSHyperionHandler.cpp index 1f68881c..c3b71882 100644 --- a/mission/devices/GPSHyperionHandler.cpp +++ b/mission/devices/GPSHyperionHandler.cpp @@ -32,7 +32,7 @@ void GPSHyperionHandler::doStartUp() { void GPSHyperionHandler::doShutDown() { internalState = InternalStates::NONE; commandExecuted = false; - setMode(MODE_OFF); + setMode(_MODE_POWER_DOWN); } ReturnValue_t GPSHyperionHandler::buildTransitionDeviceCommand(DeviceCommandId_t *id) { diff --git a/mission/devices/GyroADIS16507Handler.cpp b/mission/devices/GyroADIS16507Handler.cpp index ac49a89d..ad20e65b 100644 --- a/mission/devices/GyroADIS16507Handler.cpp +++ b/mission/devices/GyroADIS16507Handler.cpp @@ -57,6 +57,7 @@ void GyroADIS16507Handler::doStartUp() { void GyroADIS16507Handler::doShutDown() { commandExecuted = false; + setMode(_MODE_POWER_DOWN); } ReturnValue_t GyroADIS16507Handler::buildNormalDeviceCommand(DeviceCommandId_t *id) { diff --git a/mission/devices/IMTQHandler.cpp b/mission/devices/IMTQHandler.cpp index bd5ed2d2..c75f7fde 100644 --- a/mission/devices/IMTQHandler.cpp +++ b/mission/devices/IMTQHandler.cpp @@ -27,7 +27,7 @@ void IMTQHandler::doStartUp() { } void IMTQHandler::doShutDown() { - + setMode(_MODE_POWER_DOWN); } ReturnValue_t IMTQHandler::buildNormalDeviceCommand(DeviceCommandId_t * id) { diff --git a/mission/devices/Max31865PT1000Handler.cpp b/mission/devices/Max31865PT1000Handler.cpp index 751d36eb..fad0fc39 100644 --- a/mission/devices/Max31865PT1000Handler.cpp +++ b/mission/devices/Max31865PT1000Handler.cpp @@ -78,7 +78,7 @@ void Max31865PT1000Handler::doStartUp() { void Max31865PT1000Handler::doShutDown() { commandExecuted = false; - setMode(MODE_OFF); + setMode(_MODE_POWER_DOWN); } ReturnValue_t Max31865PT1000Handler::buildNormalDeviceCommand( diff --git a/mission/devices/PlocMPSoCHandler.cpp b/mission/devices/PlocMPSoCHandler.cpp index 0b1fac73..dcc81ef7 100644 --- a/mission/devices/PlocMPSoCHandler.cpp +++ b/mission/devices/PlocMPSoCHandler.cpp @@ -22,7 +22,7 @@ void PlocMPSoCHandler::doStartUp(){ } void PlocMPSoCHandler::doShutDown(){ - + setMode(_MODE_POWER_DOWN); } ReturnValue_t PlocMPSoCHandler::buildNormalDeviceCommand( diff --git a/mission/devices/PlocSupervisorHandler.cpp b/mission/devices/PlocSupervisorHandler.cpp index 778d8925..de50955f 100644 --- a/mission/devices/PlocSupervisorHandler.cpp +++ b/mission/devices/PlocSupervisorHandler.cpp @@ -49,7 +49,7 @@ void PlocSupervisorHandler::doStartUp(){ } void PlocSupervisorHandler::doShutDown(){ - + setMode(_MODE_POWER_DOWN); } ReturnValue_t PlocSupervisorHandler::buildNormalDeviceCommand( diff --git a/mission/devices/RwHandler.cpp b/mission/devices/RwHandler.cpp index 86e09b9e..81bb69ac 100644 --- a/mission/devices/RwHandler.cpp +++ b/mission/devices/RwHandler.cpp @@ -38,6 +38,7 @@ void RwHandler::doShutDown() { if(gpioComIF->pullLow(enableGpio) != RETURN_OK) { sif::debug << "RwHandler::doStartUp: Failed to pull enable gpio to low"; } + setMode(_MODE_POWER_DOWN); } ReturnValue_t RwHandler::buildNormalDeviceCommand(DeviceCommandId_t * id) { diff --git a/mission/devices/StarTrackerHandler.cpp b/mission/devices/StarTrackerHandler.cpp index 974b3ff3..48236cf7 100644 --- a/mission/devices/StarTrackerHandler.cpp +++ b/mission/devices/StarTrackerHandler.cpp @@ -28,10 +28,10 @@ void StarTrackerHandler::doStartUp() { #else setMode(_MODE_TO_ON); #endif - setMode(_MODE_POWER_DOWN); } void StarTrackerHandler::doShutDown() { + setMode(_MODE_POWER_DOWN); } ReturnValue_t StarTrackerHandler::buildNormalDeviceCommand(DeviceCommandId_t * id) { diff --git a/mission/devices/SyrlinksHkHandler.cpp b/mission/devices/SyrlinksHkHandler.cpp index 7900b8e4..e55755e4 100644 --- a/mission/devices/SyrlinksHkHandler.cpp +++ b/mission/devices/SyrlinksHkHandler.cpp @@ -23,7 +23,7 @@ void SyrlinksHkHandler::doStartUp(){ } void SyrlinksHkHandler::doShutDown(){ - + setMode(_MODE_POWER_DOWN); } ReturnValue_t SyrlinksHkHandler::buildNormalDeviceCommand( diff --git a/mission/devices/Tmp1075Handler.cpp b/mission/devices/Tmp1075Handler.cpp index a84f5597..95b8685f 100644 --- a/mission/devices/Tmp1075Handler.cpp +++ b/mission/devices/Tmp1075Handler.cpp @@ -22,7 +22,7 @@ void Tmp1075Handler::doStartUp(){ } void Tmp1075Handler::doShutDown(){ - + setMode(_MODE_POWER_DOWN); } ReturnValue_t Tmp1075Handler::buildNormalDeviceCommand( -- 2.43.0 From 12dbc5569e76f9a1a2444efc68bfdbff9f217f03 Mon Sep 17 00:00:00 2001 From: "Jakob.Meier" <–meierj@irs.uni-stuttgart.de> Date: Mon, 9 Aug 2021 14:44:06 +0200 Subject: [PATCH 03/43] mode power down sus --- linux/devices/SusHandler.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/linux/devices/SusHandler.cpp b/linux/devices/SusHandler.cpp index dbe58429..c31160c4 100644 --- a/linux/devices/SusHandler.cpp +++ b/linux/devices/SusHandler.cpp @@ -66,7 +66,6 @@ void SusHandler::doStartUp(){ #else setMode(_MODE_TO_ON); #endif - setMode(_MODE_POWER_DOWN); } void SusHandler::doShutDown(){ -- 2.43.0 From 4fdcb5d7cd4c2f55ec7a7f8e50fed889be12197e Mon Sep 17 00:00:00 2001 From: "Jakob.Meier" <–meierj@irs.uni-stuttgart.de> Date: Wed, 11 Aug 2021 09:41:29 +0200 Subject: [PATCH 04/43] minor changes to match software to updated fpga design --- bsp_q7s/core/ObjectFactory.cpp | 7 +++---- bsp_q7s/gpio/gpioCallbacks.cpp | 2 +- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/bsp_q7s/core/ObjectFactory.cpp b/bsp_q7s/core/ObjectFactory.cpp index 73e93dc4..07d61593 100644 --- a/bsp_q7s/core/ObjectFactory.cpp +++ b/bsp_q7s/core/ObjectFactory.cpp @@ -161,16 +161,15 @@ void ObjectFactory::produce(void* args){ #endif #if OBSW_ADD_STAR_TRACKER == 1 - UartCookie* starTrackerCookie = new UartCookie(objects::START_TRACKER, std::string("/dev/ttyUL3"), + UartCookie* starTrackerCookie = new UartCookie(objects::START_TRACKER, std::string("/dev/ttyUL8"), UartModes::NON_CANONICAL, 115200, StarTracker::MAX_FRAME_SIZE* 2 + 2); starTrackerCookie->setNoFixedSizeReply(); new StarTrackerHandler(objects::START_TRACKER, objects::UART_COM_IF, starTrackerCookie); #endif #if ADD_PLOC_SUPERVISOR == 1 - /* Configuration for MIO0 on TE0720-03-1CFA */ UartCookie* plocSupervisorCookie = new UartCookie(objects::PLOC_SUPERVISOR_HANDLER, - std::string("/dev/ttyUL3"), UartModes::NON_CANONICAL, 115200, + std::string("/dev/ttyUL4"), UartModes::NON_CANONICAL, 115200, PLOC_SPV::MAX_PACKET_SIZE * 20); plocSupervisorCookie->setNoFixedSizeReply(); PlocSupervisorHandler* plocSupervisor = new PlocSupervisorHandler( @@ -520,7 +519,7 @@ void ObjectFactory::createSolarArrayDeploymentComponents() { void ObjectFactory::createSyrlinksComponents() { UartCookie* syrlinksUartCookie = new UartCookie(objects::SYRLINKS_HK_HANDLER, - std::string("/dev/ttyUL0"), UartModes::NON_CANONICAL, 38400, SYRLINKS::MAX_REPLY_SIZE); + std::string("/dev/ttyUL5"), UartModes::NON_CANONICAL, 38400, SYRLINKS::MAX_REPLY_SIZE); syrlinksUartCookie->setParityEven(); new SyrlinksHkHandler(objects::SYRLINKS_HK_HANDLER, objects::UART_COM_IF, syrlinksUartCookie); diff --git a/bsp_q7s/gpio/gpioCallbacks.cpp b/bsp_q7s/gpio/gpioCallbacks.cpp index 5499517b..34c927ed 100644 --- a/bsp_q7s/gpio/gpioCallbacks.cpp +++ b/bsp_q7s/gpio/gpioCallbacks.cpp @@ -42,7 +42,7 @@ void initSpiCsDecoder(GpioIF* gpioComIF) { GpiodRegular* spiMuxBit5 = new GpiodRegular(std::string("gpiochip7"), 17, std::string("SPI Mux Bit 5"), gpio::OUT, 0); spiMuxGpios->addGpio(gpioIds::SPI_MUX_BIT_5, spiMuxBit5); - GpiodRegular* spiMuxBit6 = new GpiodRegular(std::string("gpiochip7"), 18, + GpiodRegular* spiMuxBit6 = new GpiodRegular(std::string("gpiochip7"), 9, std::string("SPI Mux Bit 6"), gpio::OUT, 0); spiMuxGpios->addGpio(gpioIds::SPI_MUX_BIT_6, spiMuxBit6); GpiodRegular* enRwDecoder = new GpiodRegular(std::string("gpiochip5"), 17, -- 2.43.0 From 0efaa13a9f689931ed9d07b9ddf988a375a5aaa2 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Wed, 11 Aug 2021 15:53:27 +0200 Subject: [PATCH 05/43] tmtc update --- tmtc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tmtc b/tmtc index cc6dbd8e..84656b90 160000 --- a/tmtc +++ b/tmtc @@ -1 +1 @@ -Subproject commit cc6dbd8ef9d5bd028835f37a24a5617224569862 +Subproject commit 84656b90fc44ab72fb95518410fea3373d1fdf18 -- 2.43.0 From 11c2efa733f5f4358326aaef981e5518e87ecc58 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Wed, 11 Aug 2021 16:07:00 +0200 Subject: [PATCH 06/43] bugfix core controller 1. Increaed robustness of CoreController against invalid state struct 2. Bugfix: If PREFSD not set, set SD card 0 properly now --- bsp_q7s/core/CoreController.cpp | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/bsp_q7s/core/CoreController.cpp b/bsp_q7s/core/CoreController.cpp index b7394cb9..eca0940c 100644 --- a/bsp_q7s/core/CoreController.cpp +++ b/bsp_q7s/core/CoreController.cpp @@ -197,6 +197,10 @@ ReturnValue_t CoreController::sdStateMachine() { result = sdcMan->getSdCardActiveStatus(sdInfo.currentState); determinePreferredSdCard(); updateSdInfoOther(); + if(sdInfo.pref != sd::SdCard::SLOT_0 and sdInfo.pref != sd::SdCard::SLOT_1) { + sif::warning << "Preferred SD card invalid. Setting to card 0.." << std:endl; + sdInfo.pref = sd::SdCard::SLOT_0; + } if(result != HasReturnvaluesIF::RETURN_OK) { sif::warning << "Getting SD card activity status failed" << std::endl; } @@ -833,7 +837,8 @@ void CoreController::determinePreferredSdCard() { if(result == scratch::KEY_NOT_FOUND) { sif::warning << "CoreController::sdCardInit: " "Preferred SD card not set. Setting to 0" << std::endl; - sdcMan->setPreferredSdCard(sdInfo.pref); + sdcMan->setPreferredSdCard(sd::SdCard::SLOT_0); + sdInfo.pref = sd::SdCard::SLOT_0; } else { sif::warning << "CoreController::sdCardInit: Could not get preferred SD card" @@ -852,13 +857,16 @@ void CoreController::updateSdInfoOther() { sdInfo.other = sd::SdCard::SLOT_1; } - else { + else if(sdInfo.pref == sd::SdCard::SLOT_1) { sdInfo.prefChar = "1"; sdInfo.otherChar = "0"; sdInfo.otherState = sdInfo.currentState.first; sdInfo.prefState = sdInfo.currentState.second; sdInfo.other = sd::SdCard::SLOT_0; } + else { + sif::warning << "CoreController::updateSdInfoOther: Invalid SD card passed" << std::endl; + } } bool CoreController::sdInitFinished() const { -- 2.43.0 From 24b58e50d1d0182c2e495e0985d9e166037526e9 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Wed, 11 Aug 2021 16:24:41 +0200 Subject: [PATCH 07/43] Merge core controller bugfix --- bsp_q7s/core/CoreController.cpp | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/bsp_q7s/core/CoreController.cpp b/bsp_q7s/core/CoreController.cpp index b7394cb9..eca0940c 100644 --- a/bsp_q7s/core/CoreController.cpp +++ b/bsp_q7s/core/CoreController.cpp @@ -197,6 +197,10 @@ ReturnValue_t CoreController::sdStateMachine() { result = sdcMan->getSdCardActiveStatus(sdInfo.currentState); determinePreferredSdCard(); updateSdInfoOther(); + if(sdInfo.pref != sd::SdCard::SLOT_0 and sdInfo.pref != sd::SdCard::SLOT_1) { + sif::warning << "Preferred SD card invalid. Setting to card 0.." << std:endl; + sdInfo.pref = sd::SdCard::SLOT_0; + } if(result != HasReturnvaluesIF::RETURN_OK) { sif::warning << "Getting SD card activity status failed" << std::endl; } @@ -833,7 +837,8 @@ void CoreController::determinePreferredSdCard() { if(result == scratch::KEY_NOT_FOUND) { sif::warning << "CoreController::sdCardInit: " "Preferred SD card not set. Setting to 0" << std::endl; - sdcMan->setPreferredSdCard(sdInfo.pref); + sdcMan->setPreferredSdCard(sd::SdCard::SLOT_0); + sdInfo.pref = sd::SdCard::SLOT_0; } else { sif::warning << "CoreController::sdCardInit: Could not get preferred SD card" @@ -852,13 +857,16 @@ void CoreController::updateSdInfoOther() { sdInfo.other = sd::SdCard::SLOT_1; } - else { + else if(sdInfo.pref == sd::SdCard::SLOT_1) { sdInfo.prefChar = "1"; sdInfo.otherChar = "0"; sdInfo.otherState = sdInfo.currentState.first; sdInfo.prefState = sdInfo.currentState.second; sdInfo.other = sd::SdCard::SLOT_0; } + else { + sif::warning << "CoreController::updateSdInfoOther: Invalid SD card passed" << std::endl; + } } bool CoreController::sdInitFinished() const { -- 2.43.0 From cf355a0451203945325785141ea784db13ff7966 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Wed, 11 Aug 2021 16:29:11 +0200 Subject: [PATCH 08/43] missing : --- bsp_q7s/core/CoreController.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bsp_q7s/core/CoreController.cpp b/bsp_q7s/core/CoreController.cpp index eca0940c..bf1a1b1a 100644 --- a/bsp_q7s/core/CoreController.cpp +++ b/bsp_q7s/core/CoreController.cpp @@ -198,7 +198,7 @@ ReturnValue_t CoreController::sdStateMachine() { determinePreferredSdCard(); updateSdInfoOther(); if(sdInfo.pref != sd::SdCard::SLOT_0 and sdInfo.pref != sd::SdCard::SLOT_1) { - sif::warning << "Preferred SD card invalid. Setting to card 0.." << std:endl; + sif::warning << "Preferred SD card invalid. Setting to card 0.." << std::endl; sdInfo.pref = sd::SdCard::SLOT_0; } if(result != HasReturnvaluesIF::RETURN_OK) { -- 2.43.0 From 0ae55e07837f461e45ae8edc741fbb89de778008 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Wed, 11 Aug 2021 18:13:43 +0200 Subject: [PATCH 09/43] no ARCSEC lib for Raspberry Pi --- CMakeLists.txt | 16 +++++++++++----- bsp_linux_board/InitMission.cpp | 8 ++++++-- bsp_linux_board/ObjectFactory.cpp | 17 +++++++++++------ bsp_linux_board/main.cpp | 1 + linux/fsfwconfig/OBSWConfig.h.in | 2 +- .../pollingsequence/pollingSequenceFactory.cpp | 7 +++++++ 6 files changed, 37 insertions(+), 14 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index d057de50..9f1c6d05 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -153,8 +153,6 @@ if(ADD_JSON_LIB) add_subdirectory(${LIB_JSON_PATH}) endif() - - if(NOT EIVE_BUILD_WATCHDOG) if(ADD_LINUX_FILES) add_subdirectory(${LINUX_PATH}) @@ -190,8 +188,13 @@ if((NOT BUILD_Q7S_SIMPLE_MODE) AND (NOT EIVE_BUILD_WATCHDOG)) ${LIB_FSFW_NAME} ${LIB_OS_NAME} ${LIB_LWGPS_NAME} - ${LIB_ARCSEC} ) + + if(TGT_BSP MATCHES "arm/q7s") + target_link_libraries(${TARGET_NAME} PRIVATE + ${LIB_ARCSEC} + ) + endif() endif() if(NOT EIVE_BUILD_WATCHDOG) @@ -214,8 +217,6 @@ if(ADD_JSON_LIB) ) endif() - - target_link_libraries(${TARGET_NAME} PRIVATE ${LIB_CXX_FS} ) @@ -228,6 +229,11 @@ target_include_directories(${TARGET_NAME} PRIVATE ${ARCSEC_LIB_PATH} ) +if(TGT_BSP MATCHES "arm/q7s") + target_include_directories(${TARGET_NAME} PRIVATE + ${ARCSEC_LIB_PATH} + ) +endif() if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU") set(WARNING_FLAGS diff --git a/bsp_linux_board/InitMission.cpp b/bsp_linux_board/InitMission.cpp index 68423216..febae2f3 100644 --- a/bsp_linux_board/InitMission.cpp +++ b/bsp_linux_board/InitMission.cpp @@ -134,12 +134,14 @@ void initmission::initTasks() { objects::INTERNAL_ERROR_REPORTER); } + bool startTestPst = true; #if OBSW_ADD_TEST_PST == 1 FixedTimeslotTaskIF* pstTestTask = factory->createFixedTimeslotTask("ACS_PST", 50, PeriodicTaskIF::MINIMUM_STACK_SIZE * 2, 2.0, missedDeadlineFunc); result = pst::pstTest(pstTestTask); if(result != HasReturnvaluesIF::RETURN_OK) { - sif::warning << "initmission::initTasks: ACS PST initialization failed!" << std::endl; + sif::info << "initmission::initTasks: ACS PST empty or invalid" << std::endl; + startTestPst = false; } #endif /* RPI_TEST_ACS_BOARD == 1 */ @@ -186,7 +188,9 @@ void initmission::initTasks() { #endif /* OBSW_ADD_TEST_CODE == 1 */ #if OBSW_ADD_TEST_PST == 1 - pstTestTask->startTask(); + if(startTestPst) { + pstTestTask->startTask(); + } #endif /* RPI_TEST_ACS_BOARD == 1 */ sif::info << "Tasks started.." << std::endl; } diff --git a/bsp_linux_board/ObjectFactory.cpp b/bsp_linux_board/ObjectFactory.cpp index b24b633f..aefe4919 100644 --- a/bsp_linux_board/ObjectFactory.cpp +++ b/bsp_linux_board/ObjectFactory.cpp @@ -65,6 +65,16 @@ void ObjectFactory::produce(void* args){ GpioIF* gpioIF = new LinuxLibgpioIF(objects::GPIO_IF); GpioCookie* gpioCookie = nullptr; static_cast(gpioCookie); + + new SpiComIF(objects::SPI_COM_IF, gpioIF); + + std::string spiDev; + SpiCookie* spiCookie = nullptr; + static_cast(spiCookie); + +#if OBSW_ADD_TEST_CODE == 1 + new TestTask(objects::TEST_TASK); + #if RPI_ADD_SPI_TEST == 1 new SpiTestClass(objects::SPI_TEST, gpioIF); #endif @@ -89,12 +99,6 @@ void ObjectFactory::produce(void* args){ new LibgpiodTest(objects::LIBGPIOD_TEST, objects::GPIO_IF, gpioCookieLoopback); #endif /* RPI_LOOPBACK_TEST_GPIO == 1 */ - new SpiComIF(objects::SPI_COM_IF, gpioIF); - - std::string spiDev; - SpiCookie* spiCookie = nullptr; - static_cast(spiCookie); - #if RPI_TEST_ACS_BOARD == 1 if(gpioCookie == nullptr) { gpioCookie = new GpioCookie(); @@ -162,4 +166,5 @@ void ObjectFactory::produce(void* args){ gpsHandler->setStartUpImmediately(); #endif +#endif /* OBSW_ADD_TEST_CODE == 1 */ } diff --git a/bsp_linux_board/main.cpp b/bsp_linux_board/main.cpp index 2e9ce8a4..a766f2a0 100644 --- a/bsp_linux_board/main.cpp +++ b/bsp_linux_board/main.cpp @@ -1,4 +1,5 @@ #include "InitMission.h" +#include "OBSWConfig.h" #include "OBSWVersion.h" #include "fsfw/FSFWVersion.h" diff --git a/linux/fsfwconfig/OBSWConfig.h.in b/linux/fsfwconfig/OBSWConfig.h.in index 36d1e638..e2693430 100644 --- a/linux/fsfwconfig/OBSWConfig.h.in +++ b/linux/fsfwconfig/OBSWConfig.h.in @@ -6,7 +6,7 @@ #ifndef FSFWCONFIG_OBSWCONFIG_H_ #define FSFWCONFIG_OBSWCONFIG_H_ -#cmakedefine RASPBERRY_Pi +#cmakedefine RASPBERRY_PI #cmakedefine XIPHOS_Q7S #cmakedefine BEAGLEBONEBLACK diff --git a/linux/fsfwconfig/pollingsequence/pollingSequenceFactory.cpp b/linux/fsfwconfig/pollingsequence/pollingSequenceFactory.cpp index a24c5393..7153ac81 100644 --- a/linux/fsfwconfig/pollingsequence/pollingSequenceFactory.cpp +++ b/linux/fsfwconfig/pollingsequence/pollingSequenceFactory.cpp @@ -606,7 +606,9 @@ ReturnValue_t pst::pstGompaceCan(FixedTimeslotTaskIF *thisSequence){ ReturnValue_t pst::pstTest(FixedTimeslotTaskIF* thisSequence) { /* Length of a communication cycle */ uint32_t length = thisSequence->getPeriodMs(); + bool notEmpty = false; #if OBSW_ADD_ACS_BOARD == 1 + notEmpty = true; thisSequence->addSlot(objects::MGM_0_LIS3_HANDLER, length * 0, DeviceHandlerIF::PERFORM_OPERATION); thisSequence->addSlot(objects::MGM_0_LIS3_HANDLER, length * 0.2, @@ -678,6 +680,7 @@ ReturnValue_t pst::pstTest(FixedTimeslotTaskIF* thisSequence) { #endif #if RPI_TEST_ADIS16507 == 1 + notEmpty = true; thisSequence->addSlot(objects::GYRO_0_ADIS_HANDLER, length * 0, DeviceHandlerIF::PERFORM_OPERATION); thisSequence->addSlot(objects::GYRO_0_ADIS_HANDLER, length * 0.2, DeviceHandlerIF::SEND_WRITE); @@ -687,6 +690,7 @@ ReturnValue_t pst::pstTest(FixedTimeslotTaskIF* thisSequence) { #endif #if RPI_TEST_GPS_HANDLER == 1 + notEmpty = true; thisSequence->addSlot(objects::GPS0_HANDLER, length * 0, DeviceHandlerIF::PERFORM_OPERATION); thisSequence->addSlot(objects::GPS0_HANDLER, length * 0, DeviceHandlerIF::SEND_READ); @@ -696,6 +700,9 @@ ReturnValue_t pst::pstTest(FixedTimeslotTaskIF* thisSequence) { thisSequence->addSlot(objects::GPS0_HANDLER, length * 0.5, DeviceHandlerIF::GET_READ); #endif static_cast(length); + if(not notEmpty) { + return HasReturnvaluesIF::RETURN_FAILED; + } if (thisSequence->checkSequence() != HasReturnvaluesIF::RETURN_OK) { sif::error << "Test PST initialization failed" << std::endl; return HasReturnvaluesIF::RETURN_FAILED; -- 2.43.0 From 268cd33677ab646bc4de05d8662bc6b7e88fa3bd Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Wed, 11 Aug 2021 18:52:33 +0200 Subject: [PATCH 10/43] gps handler tweaks --- bsp_linux_board/ObjectFactory.cpp | 2 +- bsp_linux_board/boardconfig/rpiConfig.h.in | 5 +---- mission/devices/GPSHyperionHandler.cpp | 19 ++++++++++--------- mission/devices/GPSHyperionHandler.h | 7 +++---- 4 files changed, 15 insertions(+), 18 deletions(-) diff --git a/bsp_linux_board/ObjectFactory.cpp b/bsp_linux_board/ObjectFactory.cpp index aefe4919..f4a7320c 100644 --- a/bsp_linux_board/ObjectFactory.cpp +++ b/bsp_linux_board/ObjectFactory.cpp @@ -162,7 +162,7 @@ void ObjectFactory::produce(void* args){ uartCookie->setToFlushInput(true); uartCookie->setReadCycles(6); GPSHyperionHandler* gpsHandler = new GPSHyperionHandler(objects::GPS0_HANDLER, - objects::UART_COM_IF, uartCookie); + objects::UART_COM_IF, uartCookie, true); gpsHandler->setStartUpImmediately(); #endif diff --git a/bsp_linux_board/boardconfig/rpiConfig.h.in b/bsp_linux_board/boardconfig/rpiConfig.h.in index 19629465..5198ddb7 100644 --- a/bsp_linux_board/boardconfig/rpiConfig.h.in +++ b/bsp_linux_board/boardconfig/rpiConfig.h.in @@ -15,10 +15,7 @@ #define RPI_TEST_ACS_BOARD 0 #endif -#define RPI_ADD_UART_TEST 1 -#if RPI_ADD_UART_TEST == 1 -#define RPI_TEST_GPS_DEVICE 0 -#endif +#define RPI_ADD_UART_TEST 0 /* Adapt these values accordingly */ namespace gpio { diff --git a/mission/devices/GPSHyperionHandler.cpp b/mission/devices/GPSHyperionHandler.cpp index 1f68881c..3cc95db6 100644 --- a/mission/devices/GPSHyperionHandler.cpp +++ b/mission/devices/GPSHyperionHandler.cpp @@ -7,8 +7,9 @@ #include "lwgps/lwgps.h" GPSHyperionHandler::GPSHyperionHandler(object_id_t objectId, object_id_t deviceCommunication, - CookieIF *comCookie): - DeviceHandlerBase(objectId, deviceCommunication, comCookie), gpsSet(this) { + CookieIF *comCookie, bool debugHyperionGps): + DeviceHandlerBase(objectId, deviceCommunication, comCookie), gpsSet(this), + debugHyperionGps(debugHyperionGps) { lwgps_init(&gpsData); } @@ -100,13 +101,13 @@ ReturnValue_t GPSHyperionHandler::scanForReply(const uint8_t *start, size_t len, gpsSet.hours = gpsData.hours; gpsSet.minutes = gpsData.minutes; gpsSet.seconds = gpsData.seconds; -#if FSFW_HAL_DEBUG_HYPERION_GPS == 1 - sif::info << "GPS Data" << std::endl; - printf("Valid status: %d\n", gpsData.is_valid); - printf("Latitude: %f degrees\n", gpsData.latitude); - printf("Longitude: %f degrees\n", gpsData.longitude); - printf("Altitude: %f meters\n", gpsData.altitude); -#endif + if(debugHyperionGps) { + sif::info << "GPS Data" << std::endl; + printf("Valid status: %d\n", gpsData.is_valid); + printf("Latitude: %f degrees\n", gpsData.latitude); + printf("Longitude: %f degrees\n", gpsData.longitude); + printf("Altitude: %f meters\n", gpsData.altitude); + } } *foundLen = len; } diff --git a/mission/devices/GPSHyperionHandler.h b/mission/devices/GPSHyperionHandler.h index 5685ac86..feb99a6a 100644 --- a/mission/devices/GPSHyperionHandler.h +++ b/mission/devices/GPSHyperionHandler.h @@ -1,13 +1,11 @@ #ifndef MISSION_DEVICES_GPSHYPERIONHANDLER_H_ #define MISSION_DEVICES_GPSHYPERIONHANDLER_H_ +#include "fsfw/FSFW.h" #include "fsfw/devicehandlers/DeviceHandlerBase.h" #include "devicedefinitions/GPSDefinitions.h" #include "lwgps/lwgps.h" -#ifndef FSFW_HAL_DEBUG_HYPERION_GPS -#define FSFW_HAL_DEBUG_HYPERION_GPS 0 -#endif /** * @brief Device handler for the Hyperion HT-GPS200 device @@ -18,7 +16,7 @@ class GPSHyperionHandler: public DeviceHandlerBase { public: GPSHyperionHandler(object_id_t objectId, object_id_t deviceCommunication, - CookieIF* comCookie); + CookieIF* comCookie, bool debugHyperionGps = false); virtual ~GPSHyperionHandler(); protected: @@ -54,6 +52,7 @@ protected: private: lwgps_t gpsData = {}; GpsPrimaryDataset gpsSet; + bool debugHyperionGps = false; }; #endif /* MISSION_DEVICES_GPSHYPERIONHANDLER_H_ */ -- 2.43.0 From cb330bcf2945c7ce8aac72f0a9abd719ce132cba Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Wed, 11 Aug 2021 18:59:40 +0200 Subject: [PATCH 11/43] hyperion handler: HK packet subscription --- mission/devices/GPSHyperionHandler.cpp | 31 +++++++++++++------------- mission/devices/GPSHyperionHandler.h | 1 + 2 files changed, 17 insertions(+), 15 deletions(-) diff --git a/mission/devices/GPSHyperionHandler.cpp b/mission/devices/GPSHyperionHandler.cpp index 3cc95db6..bd34591a 100644 --- a/mission/devices/GPSHyperionHandler.cpp +++ b/mission/devices/GPSHyperionHandler.cpp @@ -7,9 +7,9 @@ #include "lwgps/lwgps.h" GPSHyperionHandler::GPSHyperionHandler(object_id_t objectId, object_id_t deviceCommunication, - CookieIF *comCookie, bool debugHyperionGps): - DeviceHandlerBase(objectId, deviceCommunication, comCookie), gpsSet(this), - debugHyperionGps(debugHyperionGps) { + CookieIF *comCookie, bool debugHyperionGps): + DeviceHandlerBase(objectId, deviceCommunication, comCookie), gpsSet(this), + debugHyperionGps(debugHyperionGps) { lwgps_init(&gpsData); } @@ -37,21 +37,21 @@ void GPSHyperionHandler::doShutDown() { } ReturnValue_t GPSHyperionHandler::buildTransitionDeviceCommand(DeviceCommandId_t *id) { - return HasReturnvaluesIF::RETURN_OK; + return HasReturnvaluesIF::RETURN_OK; } ReturnValue_t GPSHyperionHandler::buildNormalDeviceCommand(DeviceCommandId_t *id) { - return HasReturnvaluesIF::RETURN_OK; + return HasReturnvaluesIF::RETURN_OK; } ReturnValue_t GPSHyperionHandler::buildCommandFromCommand( - DeviceCommandId_t deviceCommand, const uint8_t *commandData, - size_t commandDataLen) { - return HasReturnvaluesIF::RETURN_OK; + DeviceCommandId_t deviceCommand, const uint8_t *commandData, + size_t commandDataLen) { + return HasReturnvaluesIF::RETURN_OK; } ReturnValue_t GPSHyperionHandler::scanForReply(const uint8_t *start, size_t len, - DeviceCommandId_t *foundId, size_t *foundLen) { + DeviceCommandId_t *foundId, size_t *foundLen) { // Pass data to GPS library if(len > 0) { sif::info << "GPSHandler::scanForReply: Received " << len << " bytes" << std::endl; @@ -111,21 +111,21 @@ ReturnValue_t GPSHyperionHandler::scanForReply(const uint8_t *start, size_t len, } *foundLen = len; } - return HasReturnvaluesIF::RETURN_OK; + return HasReturnvaluesIF::RETURN_OK; } ReturnValue_t GPSHyperionHandler::interpretDeviceReply(DeviceCommandId_t id, - const uint8_t *packet) { - return HasReturnvaluesIF::RETURN_OK; + const uint8_t *packet) { + return HasReturnvaluesIF::RETURN_OK; } uint32_t GPSHyperionHandler::getTransitionDelayMs(Mode_t from, Mode_t to) { - return 5000; + return 5000; } ReturnValue_t GPSHyperionHandler::initializeLocalDataPool( - localpool::DataPool &localDataPoolMap, LocalDataPoolManager &poolManager) { + localpool::DataPool &localDataPoolMap, LocalDataPoolManager &poolManager) { localDataPoolMap.emplace(GpsHyperion::ALTITUDE, new PoolEntry({0.0})); localDataPoolMap.emplace(GpsHyperion::LONGITUDE, new PoolEntry({0.0})); localDataPoolMap.emplace(GpsHyperion::LATITUDE, new PoolEntry({0.0})); @@ -138,7 +138,8 @@ ReturnValue_t GPSHyperionHandler::initializeLocalDataPool( localDataPoolMap.emplace(GpsHyperion::UNIX_SECONDS, new PoolEntry()); localDataPoolMap.emplace(GpsHyperion::SATS_IN_USE, new PoolEntry()); localDataPoolMap.emplace(GpsHyperion::FIX_MODE, new PoolEntry()); - return HasReturnvaluesIF::RETURN_OK; + poolManager.subscribeForPeriodicPacket(gpsSet.getSid(), true, 2.0, false); + return HasReturnvaluesIF::RETURN_OK; } void GPSHyperionHandler::fillCommandAndReplyMap() { diff --git a/mission/devices/GPSHyperionHandler.h b/mission/devices/GPSHyperionHandler.h index feb99a6a..49d8f416 100644 --- a/mission/devices/GPSHyperionHandler.h +++ b/mission/devices/GPSHyperionHandler.h @@ -20,6 +20,7 @@ public: virtual ~GPSHyperionHandler(); protected: + enum class InternalStates { NONE, WAIT_FIRST_MESSAGE, -- 2.43.0 From 1962b30e5f4aa412b8af71c2edc2e786c3cc134e Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Wed, 11 Aug 2021 19:27:17 +0200 Subject: [PATCH 12/43] testing HK downlink --- bsp_linux_board/ObjectFactory.cpp | 18 ++++++++++++++---- mission/devices/GPSHyperionHandler.cpp | 2 +- tmtc | 2 +- 3 files changed, 16 insertions(+), 6 deletions(-) diff --git a/bsp_linux_board/ObjectFactory.cpp b/bsp_linux_board/ObjectFactory.cpp index f4a7320c..fa5c35dd 100644 --- a/bsp_linux_board/ObjectFactory.cpp +++ b/bsp_linux_board/ObjectFactory.cpp @@ -1,6 +1,3 @@ -#include -#include -#include #include "ObjectFactory.h" #include "objects/systemObjectList.h" @@ -17,6 +14,7 @@ #include "mission/core/GenericFactory.h" #include "mission/utility/TmFunnel.h" +#include #include "mission/devices/MGMHandlerLIS3MDL.h" #include "mission/devices/MGMHandlerRM3100.h" #include "mission/devices/GyroADIS16507Handler.h" @@ -28,8 +26,13 @@ #include "fsfw/tasks/TaskFactory.h" /* UDP server includes */ +#if OBSW_USE_TMTC_TCP_BRIDGE == 1 +#include +#include +#else #include "fsfw/osal/common/UdpTmTcBridge.h" #include "fsfw/osal/common/UdpTcPollingTask.h" +#endif #include "fsfw_hal/devicehandlers/GyroL3GD20Handler.h" #include "fsfw_hal/linux/gpio/LinuxLibgpioIF.h" @@ -37,6 +40,8 @@ #include "fsfw_hal/common/gpio/GpioCookie.h" #include "fsfw_hal/linux/spi/SpiCookie.h" #include "fsfw_hal/linux/spi/SpiComIF.h" +#include +#include void Factory::setStaticFrameworkObjectIds() { PusServiceBase::packetSource = objects::PUS_PACKET_DISTRIBUTOR; @@ -59,8 +64,13 @@ void ObjectFactory::produce(void* args){ Factory::setStaticFrameworkObjectIds(); ObjectFactory::produceGenericObjects(); +#if OBSW_USE_TMTC_TCP_BRIDGE == 1 + new TcpTmTcBridge(objects::TMTC_BRIDGE, objects::CCSDS_PACKET_DISTRIBUTOR); + new TcpTmTcServer(objects::TMTC_POLLING_TASK, objects::TMTC_BRIDGE); +#else new UdpTmTcBridge(objects::TMTC_BRIDGE, objects::CCSDS_PACKET_DISTRIBUTOR); new UdpTcPollingTask(objects::TMTC_POLLING_TASK, objects::TMTC_BRIDGE); +#endif GpioIF* gpioIF = new LinuxLibgpioIF(objects::GPIO_IF); GpioCookie* gpioCookie = nullptr; @@ -162,7 +172,7 @@ void ObjectFactory::produce(void* args){ uartCookie->setToFlushInput(true); uartCookie->setReadCycles(6); GPSHyperionHandler* gpsHandler = new GPSHyperionHandler(objects::GPS0_HANDLER, - objects::UART_COM_IF, uartCookie, true); + objects::UART_COM_IF, uartCookie, false); gpsHandler->setStartUpImmediately(); #endif diff --git a/mission/devices/GPSHyperionHandler.cpp b/mission/devices/GPSHyperionHandler.cpp index bd34591a..8f8bd229 100644 --- a/mission/devices/GPSHyperionHandler.cpp +++ b/mission/devices/GPSHyperionHandler.cpp @@ -144,7 +144,7 @@ ReturnValue_t GPSHyperionHandler::initializeLocalDataPool( void GPSHyperionHandler::fillCommandAndReplyMap() { // Reply length does not matter, packets should always arrive periodically - insertInReplyMap(GpsHyperion::GPS_REPLY, 4, nullptr, 0, true); + insertInReplyMap(GpsHyperion::GPS_REPLY, 4, &gpsSet, 0, true); } void GPSHyperionHandler::modeChanged() { diff --git a/tmtc b/tmtc index 84656b90..25f8543a 160000 --- a/tmtc +++ b/tmtc @@ -1 +1 @@ -Subproject commit 84656b90fc44ab72fb95518410fea3373d1fdf18 +Subproject commit 25f8543a8d5e578d40f589019ed065cc50f5074b -- 2.43.0 From dc8879b1afb90593265f65b1d94de22a23c2c785 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Wed, 11 Aug 2021 19:33:26 +0200 Subject: [PATCH 13/43] tmtc update --- tmtc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tmtc b/tmtc index 25f8543a..387a076a 160000 --- a/tmtc +++ b/tmtc @@ -1 +1 @@ -Subproject commit 25f8543a8d5e578d40f589019ed065cc50f5074b +Subproject commit 387a076a2180c14da8de086d690a2ebb5ad63649 -- 2.43.0 From 95c06d5a09447b53d21e366043b2f93417cb6bf4 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Sat, 14 Aug 2021 15:19:32 +0200 Subject: [PATCH 14/43] added make size cfg --- cmake/scripts/Q7S/make-size-cfg.sh | 35 ++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100755 cmake/scripts/Q7S/make-size-cfg.sh diff --git a/cmake/scripts/Q7S/make-size-cfg.sh b/cmake/scripts/Q7S/make-size-cfg.sh new file mode 100755 index 00000000..f75edb7f --- /dev/null +++ b/cmake/scripts/Q7S/make-size-cfg.sh @@ -0,0 +1,35 @@ +#!/bin/sh +counter=0 +cfg_script_name="cmake-build-cfg.py" +while [ ${counter} -lt 5 ] +do + cd .. + if [ -f ${cfg_script_name} ];then + break + fi + counter=$((counter=counter + 1)) +done + +if [ "${counter}" -ge 5 ];then + echo "${cfg_script_name} not found in upper directories!" + exit 1 +fi + +os_fsfw="linux" +tgt_bsp="arm/q7s" +build_dir="build-Release-Q7S" +build_generator="" +if [ "${OS}" = "Windows_NT" ]; then + build_generator="MinGW Makefiles" + python="py" +# Could be other OS but this works for now. +else + build_generator="Unix Makefiles" + python="python3" +fi + +echo "Running command (without the leading +):" +set -x # Print command +${python} ${cfg_script_name} -o "${os_fsfw}" -g "${build_generator}" -b "size" -t "${tgt_bsp}" \ + -l"${build_dir}" +# set +x -- 2.43.0 From cfbacd4d80a5bd7ab722c9d06ddb0aeabe3590d1 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Sat, 14 Aug 2021 15:25:30 +0200 Subject: [PATCH 15/43] generating stripped executable now --- cmake/HardwareOsPostConfig.cmake | 18 +++++------------- cmake/Q7SCrossCompileConfig.cmake | 1 + 2 files changed, 6 insertions(+), 13 deletions(-) diff --git a/cmake/HardwareOsPostConfig.cmake b/cmake/HardwareOsPostConfig.cmake index 73a8d8b1..2492b9bb 100644 --- a/cmake/HardwareOsPostConfig.cmake +++ b/cmake/HardwareOsPostConfig.cmake @@ -11,17 +11,6 @@ if(LINK_LWIP) endif() endif() -if(LINK_HAL) - message(STATUS "Linking against ${LIB_HAL_NAME} HAL library") - if(LIB_HAL_NAME) - target_link_libraries(${TARGET_NAME} PUBLIC - ${LIB_HAL_NAME} - ) - else() - message(WARNING "HAL library name not set!") - endif() -endif() - if(LINKER_SCRIPT) target_link_options(${TARGET_NAME} PRIVATE -T${LINKER_SCRIPT} @@ -52,11 +41,14 @@ target_compile_options(${TARGET_NAME} PRIVATE $<$:${ASM_FLAGS}> ) +set(STRIPPED_TARGET_NAME ${TARGET_NAME}-stripped) + add_custom_command( TARGET ${TARGET_NAME} POST_BUILD - COMMAND ${CMAKE_OBJCOPY} -O binary ${TARGET_NAME} ${TARGET_NAME}.bin - COMMENT "Generating binary file ${CMAKE_PROJECT_NAME}.bin.." + COMMAND ${CMAKE_STRIP} --strip-all ${TARGET_NAME} -o ${STRIPPED_TARGET_NAME} + BYPRODUCTS ${STRIPPED_TARGET_NAME} + COMMENT "Generating stripped executable ${STRIPPED_TARGET_NAME}.." ) endfunction() \ No newline at end of file diff --git a/cmake/Q7SCrossCompileConfig.cmake b/cmake/Q7SCrossCompileConfig.cmake index 006b2c96..1d23b16d 100644 --- a/cmake/Q7SCrossCompileConfig.cmake +++ b/cmake/Q7SCrossCompileConfig.cmake @@ -42,6 +42,7 @@ find_program (CMAKE_CXX_COMPILER ${CROSS_COMPILE_CXX} REQUIRED) # Useful utilities, not strictly necessary find_program(CMAKE_SIZE ${CROSS_COMPILE_SIZE}) find_program(CMAKE_OBJCOPY ${CROSS_COMPILE_OBJCOPY}) +find_program(CMAKE_STRIP ${CROSS_COMPILE_STRIP}) set(CMAKE_CROSSCOMPILING TRUE) set(CMAKE_SYSROOT "${SYSROOT_PATH}") -- 2.43.0 From 1722f14a60cb27cebd16ac485b331dd905e749c9 Mon Sep 17 00:00:00 2001 From: "Jakob.Meier" <–meierj@irs.uni-stuttgart.de> Date: Tue, 17 Aug 2021 11:59:32 +0200 Subject: [PATCH 16/43] added debug output for pcdu modules --- bsp_q7s/core/InitMission.cpp | 2 +- bsp_q7s/core/ObjectFactory.cpp | 13 +++---- linux/fsfwconfig/OBSWConfig.h.in | 6 ++-- mission/devices/P60DockHandler.cpp | 9 +++++ mission/devices/PDU1Handler.cpp | 58 +++++++++++++++++++++++++++--- tmtc | 2 +- 6 files changed, 72 insertions(+), 18 deletions(-) diff --git a/bsp_q7s/core/InitMission.cpp b/bsp_q7s/core/InitMission.cpp index f082d3d9..2ee4d374 100644 --- a/bsp_q7s/core/InitMission.cpp +++ b/bsp_q7s/core/InitMission.cpp @@ -203,7 +203,7 @@ void initmission::createPstTasks(TaskFactory& factory, if(result != HasReturnvaluesIF::RETURN_OK) { sif::error << "InitMission::initTasks: GomSpace PST initialization failed!" << std::endl; } - taskVec.push_back(i2cPst); + taskVec.push_back(gomSpacePstTask); #else /* BOARD_TE7020 == 0 */ FixedTimeslotTaskIF * pollingSequenceTaskTE0720 = factory->createFixedTimeslotTask( "PST_TASK_TE0720", 30, PeriodicTaskIF::MINIMUM_STACK_SIZE * 8, 3.0, diff --git a/bsp_q7s/core/ObjectFactory.cpp b/bsp_q7s/core/ObjectFactory.cpp index a8b55646..4e836f2e 100644 --- a/bsp_q7s/core/ObjectFactory.cpp +++ b/bsp_q7s/core/ObjectFactory.cpp @@ -250,15 +250,10 @@ void ObjectFactory::createPcduComponents() { * Setting PCDU devices to mode normal immediately after start up because PCDU is always * running. */ - /** For now this needs to be commented out because there is no PCDU connected to the OBC */ -// p60dockhandler->setModeNormal(); -// pdu1handler->setModeNormal(); -// pdu2handler->setModeNormal(); -// acuhandler->setModeNormal(); - (void) p60dockhandler; - (void) pdu1handler; - (void) pdu2handler; - (void) acuhandler; + p60dockhandler->setModeNormal(); + pdu1handler->setModeNormal(); + pdu2handler->setModeNormal(); + acuhandler->setModeNormal(); } void ObjectFactory::createRadSensorComponent(LinuxLibgpioIF* gpioComIF) { diff --git a/linux/fsfwconfig/OBSWConfig.h.in b/linux/fsfwconfig/OBSWConfig.h.in index e2693430..d14aaa77 100644 --- a/linux/fsfwconfig/OBSWConfig.h.in +++ b/linux/fsfwconfig/OBSWConfig.h.in @@ -44,9 +44,9 @@ debugging. */ #define BOARD_TE0720 0 #define TE0720_HEATER_TEST 0 -#define P60DOCK_DEBUG 0 -#define PDU1_DEBUG 0 -#define PDU2_DEBUG 0 +#define P60DOCK_DEBUG 1 +#define PDU1_DEBUG 1 +#define PDU2_DEBUG 1 #define ACU_DEBUG 0 #define SYRLINKS_DEBUG 0 #define IMQT_DEBUG 0 diff --git a/mission/devices/P60DockHandler.cpp b/mission/devices/P60DockHandler.cpp index e34f96c2..305606d9 100644 --- a/mission/devices/P60DockHandler.cpp +++ b/mission/devices/P60DockHandler.cpp @@ -27,6 +27,15 @@ void P60DockHandler::letChildHandleHkReply(DeviceCommandId_t id, const uint8_t * #if OBSW_VERBOSE_LEVEL >= 1 && P60DOCK_DEBUG == 1 p60dockHkTableDataset.read(); + sif::info << "P60 Dock: ACU VCC switch: " << static_cast(p60dockHkTableDataset.outputEnableStateAcuVcc.value) << std::endl; + sif::info << "P60 Dock: PDU1 VCC switch: " << static_cast(p60dockHkTableDataset.outputEnableStatePdu1Vcc.value) << std::endl; + sif::info << "P60 Dock: PDU2 VCC switch: " << static_cast(p60dockHkTableDataset.outputEnableStatePdu2Vcc.value) << std::endl; + sif::info << "P60 Dock: ACU VBAT switch: " << static_cast(p60dockHkTableDataset.outputEnableStateAcuVbat.value) << std::endl; + sif::info << "P60 Dock: PDU1 VBAT switch: " << static_cast(p60dockHkTableDataset.outputEnableStatePdu1Vbat.value) << std::endl; + sif::info << "P60 Dock: PDU2 VBAT switch: " << static_cast(p60dockHkTableDataset.outputEnableStatePdu2Vbat.value) << std::endl; + sif::info << "P60 Dock: Stack VBAT switch: " << static_cast(p60dockHkTableDataset.outputEnableStateStackVbat.value) << std::endl; + sif::info << "P60 Dock: Stack 3V3 switch: " << static_cast(p60dockHkTableDataset.outputEnableStateStack3V3.value) << std::endl; + sif::info << "P60 Dock: Stack 5V switch: " << static_cast(p60dockHkTableDataset.outputEnableStateStack5V.value) << std::endl; float temperatureC = p60dockHkTableDataset.temperature1.value * 0.1; sif::info << "P60 Dock: Temperature 1: " << temperatureC << " °C" << std::endl; diff --git a/mission/devices/PDU1Handler.cpp b/mission/devices/PDU1Handler.cpp index 5a6d62cb..b18e0f79 100644 --- a/mission/devices/PDU1Handler.cpp +++ b/mission/devices/PDU1Handler.cpp @@ -24,15 +24,65 @@ void PDU1Handler::letChildHandleHkReply(DeviceCommandId_t id, const uint8_t *pac #if OBSW_VERBOSE_LEVEL >= 1 && PDU1_DEBUG == 1 pdu1HkTableDataset.read(); + sif::info << "PDU1 TCS Board voltage: " << pdu1HkTableDataset.voltageOutTCSBoard3V3 + << std::endl; + sif::info << "PDU1 Syrlinks voltage: " << pdu1HkTableDataset.voltageOutSyrlinks << std::endl; + sif::info << "PDU1 star tracker voltage: " << pdu1HkTableDataset.voltageOutStarTracker + << std::endl; + sif::info << "PDU1 MGT voltage: " << pdu1HkTableDataset.voltageOutMGT << std::endl; + sif::info << "PDU1 SUS nominal voltage: " << pdu1HkTableDataset.voltageOutSUSNominal + << std::endl; + sif::info << "PDU1 solar cell experiment voltage: " << pdu1HkTableDataset.voltageOutSolarCellExp + << std::endl; + sif::info << "PDU1 PLOC voltage: " << pdu1HkTableDataset.voltageOutPLOC << std::endl; + sif::info << "PDU1 ACS Side A voltage: " << pdu1HkTableDataset.voltageOutACSBoardSideA + << std::endl; + sif::info << "PDU1 channel 8 voltage: " << pdu1HkTableDataset.voltageOutACSBoardSideA + << std::endl; + + sif::info << "PDU1 TCS Board current: " << pdu1HkTableDataset.currentOutTCSBoard3V3 + << std::endl; + sif::info << "PDU1 Syrlinks current: " << pdu1HkTableDataset.currentOutSyrlinks << std::endl; + sif::info << "PDU1 star tracker current: " << pdu1HkTableDataset.currentOutStarTracker + << std::endl; + sif::info << "PDU1 MGT current: " << pdu1HkTableDataset.currentOutMGT << std::endl; + sif::info << "PDU1 SUS nominal current: " << pdu1HkTableDataset.currentOutSUSNominal + << std::endl; + sif::info << "PDU1 solar cell experiment current: " << pdu1HkTableDataset.currentOutSolarCellExp + << std::endl; + sif::info << "PDU1 PLOC current: " << pdu1HkTableDataset.currentOutPLOC << std::endl; + sif::info << "PDU1 ACS Side A current: " << pdu1HkTableDataset.currentOutACSBoardSideA + << std::endl; + sif::info << "PDU1 channel 8 current: " << pdu1HkTableDataset.currentOutChannel8 + << std::endl; + sif::info << "PDU1 TCS Board switch: " + << static_cast(pdu1HkTableDataset.outEnabledTCSBoard3V3.value) << std::endl; + sif::info << "PDU1 Syrlinks switch: " + << static_cast(pdu1HkTableDataset.outEnabledSyrlinks.value) << std::endl; + sif::info << "PDU1 star tracker switch: " + << static_cast(pdu1HkTableDataset.outEnabledStarTracker.value) << std::endl; + sif::info << "PDU1 MGT switch: " + << static_cast(pdu1HkTableDataset.outEnabledMGT.value) << std::endl; + sif::info << "PDU1 SUS nominal switch: " + << static_cast(pdu1HkTableDataset.outEnabledSUSNominal.value) << std::endl; + sif::info << "PDU1 solar cell experiment switch: " + << static_cast(pdu1HkTableDataset.outEnabledSolarCellExp.value) << std::endl; + sif::info << "PDU1 PLOC switch: " + << static_cast(pdu1HkTableDataset.outEnabledPLOC.value) << std::endl; + sif::info << "PDU1 ACS Side A switch: " + << static_cast(pdu1HkTableDataset.outEnabledAcsBoardSideA.value) << std::endl; + sif::info << "PDU1 channel 8 switch: " + << static_cast(pdu1HkTableDataset.outEnabledChannel8.value) << std::endl; + sif::info << "PDU1 battery mode: " << static_cast(pdu1HkTableDataset.battMode.value) << std::endl; sif::info << "PDU1 VCC: " << pdu1HkTableDataset.vcc << " mV" << std::endl; - float vbat = pdu1HkTableDataset.vbat.value * 0.1; - sif::info << "PDU1 VBAT: " << vbat << std::endl; + float vbat = pdu1HkTableDataset.vbat.value * 0.001; + sif::info << "PDU1 VBAT: " << vbat << "V" << std::endl; float temperatureC = pdu1HkTableDataset.temperature.value * 0.1; sif::info << "PDU1 Temperature: " << temperatureC << " °C" << std::endl; sif::info << "PDU1 csp1 watchdog pings before reboot: " - << unsigned(pdu1HkTableDataset.csp1WatchdogPingsLeft.value) << std::endl; + << static_cast(pdu1HkTableDataset.csp1WatchdogPingsLeft.value) << std::endl; sif::info << "PDU1 csp2 watchdog pings before reboot: " - << unsigned(pdu1HkTableDataset.csp2WatchdogPingsLeft.value) << std::endl; + << static_cast(pdu1HkTableDataset.csp2WatchdogPingsLeft.value) << std::endl; pdu1HkTableDataset.commit(); #endif } diff --git a/tmtc b/tmtc index 387a076a..5b2ff495 160000 --- a/tmtc +++ b/tmtc @@ -1 +1 @@ -Subproject commit 387a076a2180c14da8de086d690a2ebb5ad63649 +Subproject commit 5b2ff49555f0cfee51cd53c7772a147575a825a3 -- 2.43.0 From 5204afca9e2f23e6b9270f968ec0bd6e276d4718 Mon Sep 17 00:00:00 2001 From: "Jakob.Meier" <–meierj@irs.uni-stuttgart.de> Date: Tue, 17 Aug 2021 12:00:58 +0200 Subject: [PATCH 17/43] pcdu debug output disabled now --- linux/fsfwconfig/OBSWConfig.h.in | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/linux/fsfwconfig/OBSWConfig.h.in b/linux/fsfwconfig/OBSWConfig.h.in index d14aaa77..e2693430 100644 --- a/linux/fsfwconfig/OBSWConfig.h.in +++ b/linux/fsfwconfig/OBSWConfig.h.in @@ -44,9 +44,9 @@ debugging. */ #define BOARD_TE0720 0 #define TE0720_HEATER_TEST 0 -#define P60DOCK_DEBUG 1 -#define PDU1_DEBUG 1 -#define PDU2_DEBUG 1 +#define P60DOCK_DEBUG 0 +#define PDU1_DEBUG 0 +#define PDU2_DEBUG 0 #define ACU_DEBUG 0 #define SYRLINKS_DEBUG 0 #define IMQT_DEBUG 0 -- 2.43.0 From a298fff6024fd7e1be084c837a72b8b67b68b776 Mon Sep 17 00:00:00 2001 From: IRS Cleanroom Laptop Date: Tue, 17 Aug 2021 16:07:33 +0200 Subject: [PATCH 18/43] tmtc update --- tmtc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tmtc b/tmtc index 387a076a..5c609146 160000 --- a/tmtc +++ b/tmtc @@ -1 +1 @@ -Subproject commit 387a076a2180c14da8de086d690a2ebb5ad63649 +Subproject commit 5c6091463879488c7bb495a98f506720620d6198 -- 2.43.0 From be6056aadbe08269ca913739a09f204502a0b7e3 Mon Sep 17 00:00:00 2001 From: "Jakob.Meier" <–meierj@irs.uni-stuttgart.de> Date: Tue, 17 Aug 2021 16:14:23 +0200 Subject: [PATCH 19/43] adaptions to build software for Trenz TE0720 --- README.md | 5 ++ bsp_q7s/core/InitMission.cpp | 13 +++-- bsp_q7s/core/ObjectFactory.cpp | 50 ++++++++++--------- bsp_q7s/devices/PlocSupervisorHandler.cpp | 7 +++ bsp_q7s/devices/PlocSupervisorHandler.h | 2 + bsp_q7s/devices/PlocUpdater.cpp | 7 ++- bsp_q7s/devices/PlocUpdater.h | 5 +- linux/fsfwconfig/OBSWConfig.h.in | 2 +- .../pollingSequenceFactory.cpp | 4 +- .../pollingsequence/pollingSequenceFactory.h | 2 +- 10 files changed, 65 insertions(+), 32 deletions(-) diff --git a/README.md b/README.md index def12cf0..d75c535b 100644 --- a/README.md +++ b/README.md @@ -924,6 +924,11 @@ Reading data from CAN: candump can0 ```` +## Dump content of file in hex +```` +cat file.bin | hexdump +```` + ## Preparation of a fresh rootfs and SD card This section summarizes important changes between a fresh rootfs and the current diff --git a/bsp_q7s/core/InitMission.cpp b/bsp_q7s/core/InitMission.cpp index 2ee4d374..051f7f3c 100644 --- a/bsp_q7s/core/InitMission.cpp +++ b/bsp_q7s/core/InitMission.cpp @@ -57,13 +57,14 @@ void initmission::initTasks() { void (*missedDeadlineFunc) (void) = nullptr; #endif +#if BOARD_TE0720 == 0 PeriodicTaskIF* coreController = factory->createPeriodicTask( "CORE_CTRL", 60, PeriodicTaskIF::MINIMUM_STACK_SIZE, 0.4, missedDeadlineFunc); result = coreController->addComponent(objects::CORE_CONTROLLER); if(result != HasReturnvaluesIF::RETURN_OK) { initmission::printAddObjectError("CORE_CTRL", objects::CORE_CONTROLLER); - } +#endif /* TMTC Distribution */ PeriodicTaskIF* tmTcDistributor = factory->createPeriodicTask( @@ -102,7 +103,7 @@ void initmission::initTasks() { initmission::printAddObjectError("PLOC_UPDATER_TASK", objects::PLOC_UPDATER); } - +# if BOARD_TE0720 == 0 // FS task, task interval does not matter because it runs in permanent loop, priority low // because it is a non-essential background task PeriodicTaskIF* fsTask = factory->createPeriodicTask( @@ -111,6 +112,7 @@ void initmission::initTasks() { if(result != HasReturnvaluesIF::RETURN_OK) { initmission::printAddObjectError("FILE_SYSTEM_TASK", objects::FILE_SYSTEM_HANDLER); } +#endif /* BOARD_TE0720 */ #if TEST_CCSDS_BRIDGE == 1 PeriodicTaskIF* ptmeTestTask = factory->createPeriodicTask( @@ -143,7 +145,9 @@ void initmission::initTasks() { tmTcDistributor->startTask(); tmtcBridgeTask->startTask(); tmtcPollingTask->startTask(); +#if BOARD_TE0720 == 0 coreController->startTask(); +#endif plocUpdaterTask->startTask(); taskStarter(pstTasks, "PST task vector"); @@ -155,7 +159,10 @@ void initmission::initTasks() { #if TEST_CCSDS_BRIDGE == 1 ptmeTestTask->startTask(); #endif + +#if BOARD_TE0720 == 0 fsTask->startTask(); +#endif sif::info << "Tasks started.." << std::endl; } @@ -205,7 +212,7 @@ void initmission::createPstTasks(TaskFactory& factory, } taskVec.push_back(gomSpacePstTask); #else /* BOARD_TE7020 == 0 */ - FixedTimeslotTaskIF * pollingSequenceTaskTE0720 = factory->createFixedTimeslotTask( + FixedTimeslotTaskIF * pollingSequenceTaskTE0720 = factory.createFixedTimeslotTask( "PST_TASK_TE0720", 30, PeriodicTaskIF::MINIMUM_STACK_SIZE * 8, 3.0, missedDeadlineFunc); result = pst::pollingSequenceTE0720(pollingSequenceTaskTE0720); diff --git a/bsp_q7s/core/ObjectFactory.cpp b/bsp_q7s/core/ObjectFactory.cpp index 4e836f2e..59399f67 100644 --- a/bsp_q7s/core/ObjectFactory.cpp +++ b/bsp_q7s/core/ObjectFactory.cpp @@ -103,11 +103,11 @@ void Factory::setStaticFrameworkObjectIds() { void ObjectFactory::produce(void* args){ ObjectFactory::setStatics(); ObjectFactory::produceGenericObjects(); - new CoreController(objects::CORE_CONTROLLER); LinuxLibgpioIF* gpioComIF = nullptr; createCommunicationInterfaces(&gpioComIF); createTmpComponents(); #if BOARD_TE0720 == 0 + new CoreController(objects::CORE_CONTROLLER); createPcduComponents(); createRadSensorComponent(gpioComIF); @@ -136,26 +136,6 @@ void ObjectFactory::produce(void* args){ #endif /* ADD_PLOC_MPSOC */ createReactionWheelComponents(gpioComIF); -#endif /* TE7020 != 0 */ - -#if OBSW_USE_TMTC_TCP_BRIDGE == 0 - auto udpBridge = new UdpTmTcBridge(objects::TMTC_BRIDGE, objects::CCSDS_PACKET_DISTRIBUTOR); - new UdpTcPollingTask(objects::TMTC_POLLING_TASK, objects::TMTC_BRIDGE); - sif::info << "Created UDP server for TMTC commanding with listener port " << - udpBridge->getUdpPort() << std::endl; -#else - new TcpTmTcBridge(objects::TMTC_BRIDGE, objects::CCSDS_PACKET_DISTRIBUTOR); - auto tcpServer = new TcpTmTcServer(objects::TMTC_POLLING_TASK, objects::TMTC_BRIDGE); - sif::info << "Created TCP server for TMTC commanding with listener port " << - tcpServer->getTcpPort() << std::endl; -#endif - - /* Test Task */ -#if OBSW_ADD_TEST_CODE == 1 - createTestComponents(); -#endif /* OBSW_ADD_TEST_CODE == 1 */ - - new FileSystemHandler(objects::FILE_SYSTEM_HANDLER); #if ADD_PLOC_MPSOC == 1 UartCookie* plocMpsocCookie = new UartCookie(objects::RW1, std::string("/dev/ttyUL3"), @@ -178,9 +158,29 @@ void ObjectFactory::produce(void* args){ PlocSupervisorHandler* plocSupervisor = new PlocSupervisorHandler( objects::PLOC_SUPERVISOR_HANDLER, objects::UART_COM_IF, plocSupervisorCookie); plocSupervisor->setStartUpImmediately(); - #endif + new FileSystemHandler(objects::FILE_SYSTEM_HANDLER); + +#endif /* TE7020 != 0 */ + +#if OBSW_USE_TMTC_TCP_BRIDGE == 0 + auto udpBridge = new UdpTmTcBridge(objects::TMTC_BRIDGE, objects::CCSDS_PACKET_DISTRIBUTOR); + new UdpTcPollingTask(objects::TMTC_POLLING_TASK, objects::TMTC_BRIDGE); + sif::info << "Created UDP server for TMTC commanding with listener port " << + udpBridge->getUdpPort() << std::endl; +#else + new TcpTmTcBridge(objects::TMTC_BRIDGE, objects::CCSDS_PACKET_DISTRIBUTOR); + auto tcpServer = new TcpTmTcServer(objects::TMTC_POLLING_TASK, objects::TMTC_BRIDGE); + sif::info << "Created TCP server for TMTC commanding with listener port " << + tcpServer->getTcpPort() << std::endl; +#endif + + /* Test Task */ +#if OBSW_ADD_TEST_CODE == 1 + createTestComponents(); +#endif /* OBSW_ADD_TEST_CODE == 1 */ + new PlocUpdater(objects::PLOC_UPDATER); } @@ -222,8 +222,11 @@ void ObjectFactory::createCommunicationInterfaces(LinuxLibgpioIF **gpioComIF) { #if Q7S_ADD_SPI_TEST == 0 new SpiComIF(objects::SPI_COM_IF, *gpioComIF); #endif /* Q7S_ADD_SPI_TEST == 0 */ + +#if BOARD_TE0720 == 0 /* Adding gpios for chip select decoding to the gpioComIf */ gpioCallbacks::initSpiCsDecoder(*gpioComIF); +#endif } void ObjectFactory::createPcduComponents() { @@ -824,7 +827,8 @@ void ObjectFactory::createTestComponents() { /* Configuration for MIO0 on TE0720-03-1CFA */ UartCookie* plocSupervisorCookie = new UartCookie(objects::PLOC_SUPERVISOR_HANDLER, std::string("/dev/ttyPS1"), UartModes::NON_CANONICAL, 115200, - PLOC_SPV::MAX_REPLY_SIZE); + PLOC_SPV::MAX_PACKET_SIZE * 20); + plocSupervisorCookie->setNoFixedSizeReply(); PlocSupervisorHandler* plocSupervisor = new PlocSupervisorHandler( objects::PLOC_SUPERVISOR_HANDLER, objects::UART_COM_IF, plocSupervisorCookie); plocSupervisor->setStartUpImmediately(); diff --git a/bsp_q7s/devices/PlocSupervisorHandler.cpp b/bsp_q7s/devices/PlocSupervisorHandler.cpp index de50955f..5bbcf1ef 100644 --- a/bsp_q7s/devices/PlocSupervisorHandler.cpp +++ b/bsp_q7s/devices/PlocSupervisorHandler.cpp @@ -34,7 +34,9 @@ ReturnValue_t PlocSupervisorHandler::initialize() { return INVALID_UART_COM_IF; } +#if BOARD_TE0720 == 0 sdcMan = SdCardManager::instance(); +#endif /* BOARD_TE0720 == 0 */ return result; } @@ -1462,7 +1464,12 @@ ReturnValue_t PlocSupervisorHandler::createMramDumpFile() { } std::string filename = "mram-dump--" + timeStamp + ".bin"; + +#if BOARD_TE0720 == 0 std::string currentMountPrefix = sdcMan->getCurrentMountPrefix(); +#else + std::string currentMountPrefix("/mnt/sd0"); +#endif /* BOARD_TE0720 == 0 */ // Check if path to PLOC directory exists if (not std::filesystem::exists(std::string(currentMountPrefix + "/" + plocFilePath))) { diff --git a/bsp_q7s/devices/PlocSupervisorHandler.h b/bsp_q7s/devices/PlocSupervisorHandler.h index 176578e4..c0c09eae 100644 --- a/bsp_q7s/devices/PlocSupervisorHandler.h +++ b/bsp_q7s/devices/PlocSupervisorHandler.h @@ -125,7 +125,9 @@ private: /** This buffer is used to concatenate space packets received in two different read steps */ uint8_t spacePacketBuffer[PLOC_SPV::MAX_PACKET_SIZE]; +#if BOARD_TE0720 == 0 SdCardManager* sdcMan = nullptr; +#endif /* BOARD_TE0720 == 0 */ /** Path to PLOC specific files on SD card */ std::string plocFilePath = "ploc"; diff --git a/bsp_q7s/devices/PlocUpdater.cpp b/bsp_q7s/devices/PlocUpdater.cpp index 4a6085a2..0e4ea77d 100644 --- a/bsp_q7s/devices/PlocUpdater.cpp +++ b/bsp_q7s/devices/PlocUpdater.cpp @@ -14,8 +14,9 @@ PlocUpdater::~PlocUpdater() { } ReturnValue_t PlocUpdater::initialize() { +#if BOARD_TE0720 == 0 sdcMan = SdCardManager::instance(); - +#endif ReturnValue_t result = SystemObject::initialize(); if (result != HasReturnvaluesIF::RETURN_OK) { return result; @@ -148,6 +149,7 @@ ReturnValue_t PlocUpdater::getImageLocation(const uint8_t* data, size_t size) { return result; } +#if BOARD_TE0720 == 0 // Check if file is stored on SD card and if associated SD card is mounted if (std::string(reinterpret_cast(data), SD_PREFIX_LENGTH) == std::string(SdCardManager::SD_0_MOUNT_POINT)) { if (!isSdCardMounted(sd::SLOT_0)) { @@ -164,6 +166,7 @@ ReturnValue_t PlocUpdater::getImageLocation(const uint8_t* data, size_t size) { else { //update image not stored on SD card } +#endif /* BOARD_TE0720 == 0 */ updateFile = std::string(reinterpret_cast(data), size); @@ -174,6 +177,7 @@ ReturnValue_t PlocUpdater::getImageLocation(const uint8_t* data, size_t size) { return RETURN_OK; } +#if BOARD_TE0720 == 0 bool PlocUpdater::isSdCardMounted(sd::SdCard sdCard) { SdCardManager::SdStatePair active; ReturnValue_t result = sdcMan->getSdCardActiveStatus(active); @@ -202,6 +206,7 @@ bool PlocUpdater::isSdCardMounted(sd::SdCard sdCard) { } return false; } +#endif /* #if BOARD_TE0720 == 0 */ void PlocUpdater::stepSuccessfulReceived(ActionId_t actionId, uint8_t step) { diff --git a/bsp_q7s/devices/PlocUpdater.h b/bsp_q7s/devices/PlocUpdater.h index fac8b7c2..8d7d9e30 100644 --- a/bsp_q7s/devices/PlocUpdater.h +++ b/bsp_q7s/devices/PlocUpdater.h @@ -94,8 +94,9 @@ private: MessageQueueIF* commandQueue = nullptr; +#if BOARD_TE0720 == 0 SdCardManager* sdcMan = nullptr; - +#endif CommandActionHelper commandActionHelper; ActionHelper actionHelper; @@ -160,10 +161,12 @@ private: */ void commandUpdateVerify(); +#if BOARD_TE0720 == 0 /** * @brief Checks whether the SD card to read from is mounted or not. */ bool isSdCardMounted(sd::SdCard sdCard); +#endif ReturnValue_t makeCrc(); diff --git a/linux/fsfwconfig/OBSWConfig.h.in b/linux/fsfwconfig/OBSWConfig.h.in index e2693430..e848fc6e 100644 --- a/linux/fsfwconfig/OBSWConfig.h.in +++ b/linux/fsfwconfig/OBSWConfig.h.in @@ -41,7 +41,7 @@ debugging. */ #define ADD_PLOC_SUPERVISOR 1 #define ADD_PLOC_MPSOC 0 -#define BOARD_TE0720 0 +#define BOARD_TE0720 1 #define TE0720_HEATER_TEST 0 #define P60DOCK_DEBUG 0 diff --git a/linux/fsfwconfig/pollingsequence/pollingSequenceFactory.cpp b/linux/fsfwconfig/pollingsequence/pollingSequenceFactory.cpp index 7153ac81..8d05181a 100644 --- a/linux/fsfwconfig/pollingsequence/pollingSequenceFactory.cpp +++ b/linux/fsfwconfig/pollingsequence/pollingSequenceFactory.cpp @@ -710,7 +710,7 @@ ReturnValue_t pst::pstTest(FixedTimeslotTaskIF* thisSequence) { return HasReturnvaluesIF::RETURN_OK; } -#if BOARD_TE7020 == 1 +#if BOARD_TE0720 == 1 ReturnValue_t pst::pollingSequenceTE0720(FixedTimeslotTaskIF *thisSequence) { uint32_t length = thisSequence->getPeriodMs(); @@ -767,4 +767,4 @@ ReturnValue_t pst::pollingSequenceTE0720(FixedTimeslotTaskIF *thisSequence) { } return HasReturnvaluesIF::RETURN_OK; } -#endif /* BOARD_TE7020 == 1 */ +#endif /* BOARD_TE0720 == 1 */ diff --git a/linux/fsfwconfig/pollingsequence/pollingSequenceFactory.h b/linux/fsfwconfig/pollingsequence/pollingSequenceFactory.h index 4ce1619c..5bb5ff2a 100644 --- a/linux/fsfwconfig/pollingsequence/pollingSequenceFactory.h +++ b/linux/fsfwconfig/pollingsequence/pollingSequenceFactory.h @@ -55,7 +55,7 @@ ReturnValue_t pstI2c(FixedTimeslotTaskIF* thisSequence); */ ReturnValue_t pstTest(FixedTimeslotTaskIF* thisSequence); -#if TE0720 == 1 +#if BOARD_TE0720 == 1 /** * @brief This polling sequence will be created when the software is compiled for the TE0720. */ -- 2.43.0 From 921e82f6d149b12529f0ac46632a6430d2cbd761 Mon Sep 17 00:00:00 2001 From: IRS Cleanroom Laptop Date: Tue, 17 Aug 2021 16:35:41 +0200 Subject: [PATCH 20/43] acs board tweaks --- fsfw | 2 +- linux/fsfwconfig/FSFWConfig.h.in | 2 +- linux/fsfwconfig/fsfwconfig.mk | 15 ---- .../pollingSequenceFactory.cpp | 78 +++++++++++++++++-- tmtc | 2 +- 5 files changed, 76 insertions(+), 23 deletions(-) delete mode 100644 linux/fsfwconfig/fsfwconfig.mk diff --git a/fsfw b/fsfw index 1ac372cb..406b77ea 160000 --- a/fsfw +++ b/fsfw @@ -1 +1 @@ -Subproject commit 1ac372cb89fabc868aa9cc6ef024f822c744eaed +Subproject commit 406b77ea81816c2113aec9239b3e5d2ed71e7cb5 diff --git a/linux/fsfwconfig/FSFWConfig.h.in b/linux/fsfwconfig/FSFWConfig.h.in index d70bb7b6..a8519cff 100644 --- a/linux/fsfwconfig/FSFWConfig.h.in +++ b/linux/fsfwconfig/FSFWConfig.h.in @@ -72,6 +72,6 @@ static constexpr size_t FSFW_MAX_TM_PACKET_SIZE = 2048; } -#define FSFW_HAL_LINUX_SPI_WIRETAPPING 1 +#define FSFW_HAL_LINUX_SPI_WIRETAPPING 0 #endif /* CONFIG_FSFWCONFIG_H_ */ diff --git a/linux/fsfwconfig/fsfwconfig.mk b/linux/fsfwconfig/fsfwconfig.mk deleted file mode 100644 index 105c3fba..00000000 --- a/linux/fsfwconfig/fsfwconfig.mk +++ /dev/null @@ -1,15 +0,0 @@ -CXXSRC += $(wildcard $(CURRENTPATH)/cdatapool/*.cpp) -CXXSRC += $(wildcard $(CURRENTPATH)/ipc/*.cpp) -CXXSRC += $(wildcard $(CURRENTPATH)/objects/*.cpp) -CXXSRC += $(wildcard $(CURRENTPATH)/pollingsequence/*.cpp) -CXXSRC += $(wildcard $(CURRENTPATH)/events/*.cpp) - -INCLUDES += $(CURRENTPATH) -INCLUDES += $(CURRENTPATH)/objects -INCLUDES += $(CURRENTPATH)/ipc -INCLUDES += $(CURRENTPATH)/pollingsequence -INCLUDES += $(CURRENTPATH)/returnvalues -INCLUDES += $(CURRENTPATH)/tmtc -INCLUDES += $(CURRENTPATH)/events -INCLUDES += $(CURRENTPATH)/devices -INCLUDES += $(CURRENTPATH)/cdatapool \ No newline at end of file diff --git a/linux/fsfwconfig/pollingsequence/pollingSequenceFactory.cpp b/linux/fsfwconfig/pollingsequence/pollingSequenceFactory.cpp index 7153ac81..57702013 100644 --- a/linux/fsfwconfig/pollingsequence/pollingSequenceFactory.cpp +++ b/linux/fsfwconfig/pollingsequence/pollingSequenceFactory.cpp @@ -423,6 +423,74 @@ ReturnValue_t pst::pstSpi(FixedTimeslotTaskIF *thisSequence) { thisSequence->addSlot(objects::RW4, length * 0.6, DeviceHandlerIF::SEND_READ); thisSequence->addSlot(objects::RW4, length * 0.8, DeviceHandlerIF::GET_READ); + thisSequence->addSlot(objects::MGM_0_LIS3_HANDLER, length * 0, + DeviceHandlerIF::PERFORM_OPERATION); + thisSequence->addSlot(objects::MGM_0_LIS3_HANDLER, length * 0.2, + DeviceHandlerIF::SEND_WRITE); + thisSequence->addSlot(objects::MGM_0_LIS3_HANDLER, length * 0.4, + DeviceHandlerIF::GET_WRITE); + thisSequence->addSlot(objects::MGM_0_LIS3_HANDLER, length * 0.6, + DeviceHandlerIF::SEND_READ); + thisSequence->addSlot(objects::MGM_0_LIS3_HANDLER, length * 0.8, + DeviceHandlerIF::GET_READ); + + thisSequence->addSlot(objects::MGM_1_RM3100_HANDLER, length * 0, + DeviceHandlerIF::PERFORM_OPERATION); + thisSequence->addSlot(objects::MGM_1_RM3100_HANDLER, length * 0.2, + DeviceHandlerIF::SEND_WRITE); + thisSequence->addSlot(objects::MGM_1_RM3100_HANDLER, length * 0.4, + DeviceHandlerIF::GET_WRITE); + thisSequence->addSlot(objects::MGM_1_RM3100_HANDLER, length * 0.6, + DeviceHandlerIF::SEND_READ); + thisSequence->addSlot(objects::MGM_1_RM3100_HANDLER, length * 0.8, + DeviceHandlerIF::GET_READ); + + thisSequence->addSlot(objects::MGM_2_LIS3_HANDLER, length * 0, + DeviceHandlerIF::PERFORM_OPERATION); + thisSequence->addSlot(objects::MGM_2_LIS3_HANDLER, length * 0.2, + DeviceHandlerIF::SEND_WRITE); + thisSequence->addSlot(objects::MGM_2_LIS3_HANDLER, length * 0.4, + DeviceHandlerIF::GET_WRITE); + thisSequence->addSlot(objects::MGM_2_LIS3_HANDLER, length * 0.6, + DeviceHandlerIF::SEND_READ); + thisSequence->addSlot(objects::MGM_2_LIS3_HANDLER, length * 0.8, + DeviceHandlerIF::GET_READ); + + + thisSequence->addSlot(objects::GYRO_1_L3G_HANDLER, length * 0, + DeviceHandlerIF::PERFORM_OPERATION); + thisSequence->addSlot(objects::GYRO_1_L3G_HANDLER, length * 0.2, + DeviceHandlerIF::SEND_WRITE); + thisSequence->addSlot(objects::GYRO_1_L3G_HANDLER, length * 0.4, + DeviceHandlerIF::GET_WRITE); + thisSequence->addSlot(objects::GYRO_1_L3G_HANDLER, length * 0.6, + DeviceHandlerIF::SEND_READ); + thisSequence->addSlot(objects::GYRO_1_L3G_HANDLER, length * 0.8, + DeviceHandlerIF::GET_READ); + + + thisSequence->addSlot(objects::GYRO_3_L3G_HANDLER, length * 0, + DeviceHandlerIF::PERFORM_OPERATION); + thisSequence->addSlot(objects::GYRO_3_L3G_HANDLER, length * 0.2, + DeviceHandlerIF::SEND_WRITE); + thisSequence->addSlot(objects::GYRO_3_L3G_HANDLER, length * 0.4, + DeviceHandlerIF::GET_WRITE); + thisSequence->addSlot(objects::GYRO_3_L3G_HANDLER, length * 0.6, + DeviceHandlerIF::SEND_READ); + thisSequence->addSlot(objects::GYRO_3_L3G_HANDLER, length * 0.8, + DeviceHandlerIF::GET_READ); + + + thisSequence->addSlot(objects::MGM_3_RM3100_HANDLER, length * 0, + DeviceHandlerIF::PERFORM_OPERATION); + thisSequence->addSlot(objects::MGM_3_RM3100_HANDLER, length * 0.2, + DeviceHandlerIF::SEND_WRITE); + thisSequence->addSlot(objects::MGM_3_RM3100_HANDLER, length * 0.4, + DeviceHandlerIF::GET_WRITE); + thisSequence->addSlot(objects::MGM_3_RM3100_HANDLER, length * 0.6, + DeviceHandlerIF::SEND_READ); + thisSequence->addSlot(objects::MGM_3_RM3100_HANDLER, length * 0.8, + DeviceHandlerIF::GET_READ); if (thisSequence->checkSequence() != HasReturnvaluesIF::RETURN_OK) { sif::error << "SPI PST initialization failed" << std::endl; return HasReturnvaluesIF::RETURN_FAILED; @@ -655,15 +723,15 @@ ReturnValue_t pst::pstTest(FixedTimeslotTaskIF* thisSequence) { DeviceHandlerIF::GET_READ); - thisSequence->addSlot(objects::GYRO_2_L3G_HANDLER, length * 0, + thisSequence->addSlot(objects::GYRO_3_L3G_HANDLER, length * 0, DeviceHandlerIF::PERFORM_OPERATION); - thisSequence->addSlot(objects::GYRO_2_L3G_HANDLER, length * 0.2, + thisSequence->addSlot(objects::GYRO_3_L3G_HANDLER, length * 0.2, DeviceHandlerIF::SEND_WRITE); - thisSequence->addSlot(objects::GYRO_2_L3G_HANDLER, length * 0.4, + thisSequence->addSlot(objects::GYRO_3_L3G_HANDLER, length * 0.4, DeviceHandlerIF::GET_WRITE); - thisSequence->addSlot(objects::GYRO_2_L3G_HANDLER, length * 0.6, + thisSequence->addSlot(objects::GYRO_3_L3G_HANDLER, length * 0.6, DeviceHandlerIF::SEND_READ); - thisSequence->addSlot(objects::GYRO_2_L3G_HANDLER, length * 0.8, + thisSequence->addSlot(objects::GYRO_3_L3G_HANDLER, length * 0.8, DeviceHandlerIF::GET_READ); diff --git a/tmtc b/tmtc index 5c609146..28e527b8 160000 --- a/tmtc +++ b/tmtc @@ -1 +1 @@ -Subproject commit 5c6091463879488c7bb495a98f506720620d6198 +Subproject commit 28e527b8f9002a8baa03d90f1e5693796cd1e237 -- 2.43.0 From aa248b7997450be4438099d37194a6a724260f06 Mon Sep 17 00:00:00 2001 From: IRS Cleanroom Laptop Date: Tue, 17 Aug 2021 17:11:59 +0200 Subject: [PATCH 21/43] new busConf file, cleaning up --- bsp_linux_board/ObjectFactory.cpp | 3 +- bsp_q7s/boardconfig/busConf.h | 14 +++ bsp_q7s/core/ObjectFactory.cpp | 99 ++++++++++--------- bsp_q7s/core/ObjectFactory.h | 5 +- common/config/{spiConf.h => devConf.h} | 10 +- .../pollingSequenceFactory.cpp | 3 + 6 files changed, 83 insertions(+), 51 deletions(-) create mode 100644 bsp_q7s/boardconfig/busConf.h rename common/config/{spiConf.h => devConf.h} (89%) diff --git a/bsp_linux_board/ObjectFactory.cpp b/bsp_linux_board/ObjectFactory.cpp index fa5c35dd..237a7ead 100644 --- a/bsp_linux_board/ObjectFactory.cpp +++ b/bsp_linux_board/ObjectFactory.cpp @@ -1,3 +1,4 @@ +#include #include "ObjectFactory.h" #include "objects/systemObjectList.h" @@ -6,8 +7,6 @@ #include "OBSWConfig.h" #include "tmtc/apid.h" #include "tmtc/pusIds.h" -#include "spiConf.h" - #include "linux/boardtest/LibgpiodTest.h" #include "linux/boardtest/SpiTestClass.h" #include "linux/boardtest/UartTestClass.h" diff --git a/bsp_q7s/boardconfig/busConf.h b/bsp_q7s/boardconfig/busConf.h new file mode 100644 index 00000000..bdca6ee5 --- /dev/null +++ b/bsp_q7s/boardconfig/busConf.h @@ -0,0 +1,14 @@ +#ifndef BSP_Q7S_BOARDCONFIG_BUSCONF_H_ +#define BSP_Q7S_BOARDCONFIG_BUSCONF_H_ + +namespace q7s { + +static constexpr char SPI_DEFAULT_FILE[] = "dev/spidev2.0"; +static constexpr char SPI_RW_FILE[] = "dev/spidev3.0"; + + +} + + + +#endif /* BSP_Q7S_BOARDCONFIG_BUSCONF_H_ */ diff --git a/bsp_q7s/core/ObjectFactory.cpp b/bsp_q7s/core/ObjectFactory.cpp index 4e836f2e..b48d3bf7 100644 --- a/bsp_q7s/core/ObjectFactory.cpp +++ b/bsp_q7s/core/ObjectFactory.cpp @@ -1,12 +1,12 @@ #include "ObjectFactory.h" #include "OBSWConfig.h" +#include "devConf.h" +#include "busConf.h" #include "tmtc/apid.h" #include "devices/addresses.h" #include "devices/gpioIds.h" #include "tmtc/pusIds.h" #include "devices/powerSwitcherList.h" -#include "spiConf.h" - #include "bsp_q7s/gpio/gpioCallbacks.h" #include "bsp_q7s/core/CoreController.h" #include "bsp_q7s/spiCallbacks/rwSpiCallback.h" @@ -45,6 +45,7 @@ #include "mission/devices/devicedefinitions/Max31865Definitions.h" #include "mission/devices/devicedefinitions/RwDefinitions.h" #include +#include #include "mission/utility/TmFunnel.h" #include "linux/obc/CCSDSIPCoreBridge.h" @@ -105,7 +106,8 @@ void ObjectFactory::produce(void* args){ ObjectFactory::produceGenericObjects(); new CoreController(objects::CORE_CONTROLLER); LinuxLibgpioIF* gpioComIF = nullptr; - createCommunicationInterfaces(&gpioComIF); + UartComIF* uartComIF = nullptr; + createCommunicationInterfaces(&gpioComIF, &uartComIF); createTmpComponents(); #if BOARD_TE0720 == 0 @@ -113,7 +115,7 @@ void ObjectFactory::produce(void* args){ createRadSensorComponent(gpioComIF); createSunSensorComponents(gpioComIF); #if OBSW_ADD_ACS_BOARD == 1 - createAcsBoardComponents(gpioComIF); + createAcsBoardComponents(gpioComIF, uartComIF); #endif /* OBSW_ADD_ACS_BOARD == 1 */ createHeaterComponents(); createSolarArrayDeploymentComponents(); @@ -208,9 +210,10 @@ void ObjectFactory::createTmpComponents() { (void) tmp1075Handler_2; } -void ObjectFactory::createCommunicationInterfaces(LinuxLibgpioIF **gpioComIF) { - if(gpioComIF == nullptr) { - sif::error << "ObjectFactory::createCommunicationInterfaces: Invalid GPIO ComIF" +void ObjectFactory::createCommunicationInterfaces(LinuxLibgpioIF **gpioComIF, + UartComIF** uartComIF) { + if(gpioComIF == nullptr or uartComIF == nullptr) { + sif::error << "ObjectFactory::createCommunicationInterfaces: Invalid passed ComIF pointer" << std::endl; } *gpioComIF = new LinuxLibgpioIF(objects::GPIO_IF); @@ -218,7 +221,7 @@ void ObjectFactory::createCommunicationInterfaces(LinuxLibgpioIF **gpioComIF) { /* Communication interfaces */ new CspComIF(objects::CSP_COM_IF); new I2cComIF(objects::I2C_COM_IF); - new UartComIF(objects::UART_COM_IF); + *uartComIF = new UartComIF(objects::UART_COM_IF); #if Q7S_ADD_SPI_TEST == 0 new SpiComIF(objects::SPI_COM_IF, *gpioComIF); #endif /* Q7S_ADD_SPI_TEST == 0 */ @@ -264,7 +267,7 @@ void ObjectFactory::createRadSensorComponent(LinuxLibgpioIF* gpioComIF) { gpioComIF->addGpios(gpioCookieRadSensor); SpiCookie* spiCookieRadSensor = new SpiCookie(addresses::RAD_SENSOR, gpioIds::CS_RAD_SENSOR, - std::string("/dev/spidev2.0"), RAD_SENSOR::READ_SIZE, spi::DEFAULT_MAX_1227_MODE, + std::string(q7s::SPI_DEFAULT_FILE), RAD_SENSOR::READ_SIZE, spi::DEFAULT_MAX_1227_MODE, spi::DEFAULT_MAX_1227_SPEED); new RadiationSensorHandler(objects::RAD_SENSOR, objects::SPI_COM_IF, spiCookieRadSensor); } @@ -315,43 +318,43 @@ void ObjectFactory::createSunSensorComponents(LinuxLibgpioIF *gpioComIF) { gpioComIF->addGpios(gpioCookieSus); SpiCookie* spiCookieSus1 = new SpiCookie(addresses::SUS_1, gpio::NO_GPIO, - std::string("/dev/spidev2.0"), SUS::MAX_CMD_SIZE, spi::DEFAULT_MAX_1227_MODE, + std::string(q7s::SPI_DEFAULT_FILE), SUS::MAX_CMD_SIZE, spi::DEFAULT_MAX_1227_MODE, SUS::MAX1227_SPI_FREQ); SpiCookie* spiCookieSus2 = new SpiCookie(addresses::SUS_2, gpio::NO_GPIO, - std::string("/dev/spidev2.0"), SUS::MAX_CMD_SIZE, spi::DEFAULT_MAX_1227_MODE, + std::string(q7s::SPI_DEFAULT_FILE), SUS::MAX_CMD_SIZE, spi::DEFAULT_MAX_1227_MODE, SUS::MAX1227_SPI_FREQ); SpiCookie* spiCookieSus3 = new SpiCookie(addresses::SUS_3, gpio::NO_GPIO, - std::string("/dev/spidev2.0"), SUS::MAX_CMD_SIZE, spi::DEFAULT_MAX_1227_MODE, + std::string(q7s::SPI_DEFAULT_FILE), SUS::MAX_CMD_SIZE, spi::DEFAULT_MAX_1227_MODE, SUS::MAX1227_SPI_FREQ); SpiCookie* spiCookieSus4 = new SpiCookie(addresses::SUS_4, gpio::NO_GPIO, - std::string("/dev/spidev2.0"), SUS::MAX_CMD_SIZE, spi::DEFAULT_MAX_1227_MODE, + std::string(q7s::SPI_DEFAULT_FILE), SUS::MAX_CMD_SIZE, spi::DEFAULT_MAX_1227_MODE, SUS::MAX1227_SPI_FREQ); SpiCookie* spiCookieSus5 = new SpiCookie(addresses::SUS_5, gpio::NO_GPIO, - std::string("/dev/spidev2.0"), SUS::MAX_CMD_SIZE, spi::DEFAULT_MAX_1227_MODE, + std::string(q7s::SPI_DEFAULT_FILE), SUS::MAX_CMD_SIZE, spi::DEFAULT_MAX_1227_MODE, SUS::MAX1227_SPI_FREQ); SpiCookie* spiCookieSus6 = new SpiCookie(addresses::SUS_6, gpio::NO_GPIO, - std::string("/dev/spidev2.0"), SUS::MAX_CMD_SIZE, spi::DEFAULT_MAX_1227_MODE, + std::string(q7s::SPI_DEFAULT_FILE), SUS::MAX_CMD_SIZE, spi::DEFAULT_MAX_1227_MODE, SUS::MAX1227_SPI_FREQ); SpiCookie* spiCookieSus7 = new SpiCookie(addresses::SUS_7, gpio::NO_GPIO, - std::string("/dev/spidev2.0"), SUS::MAX_CMD_SIZE, spi::DEFAULT_MAX_1227_MODE, + std::string(q7s::SPI_DEFAULT_FILE), SUS::MAX_CMD_SIZE, spi::DEFAULT_MAX_1227_MODE, SUS::MAX1227_SPI_FREQ); SpiCookie* spiCookieSus8 = new SpiCookie(addresses::SUS_8, gpio::NO_GPIO, - std::string("/dev/spidev2.0"), SUS::MAX_CMD_SIZE, spi::DEFAULT_MAX_1227_MODE, + std::string(q7s::SPI_DEFAULT_FILE), SUS::MAX_CMD_SIZE, spi::DEFAULT_MAX_1227_MODE, SUS::MAX1227_SPI_FREQ); SpiCookie* spiCookieSus9 = new SpiCookie(addresses::SUS_9, gpio::NO_GPIO, - std::string("/dev/spidev2.0"), SUS::MAX_CMD_SIZE, spi::DEFAULT_MAX_1227_MODE, + std::string(q7s::SPI_DEFAULT_FILE), SUS::MAX_CMD_SIZE, spi::DEFAULT_MAX_1227_MODE, SUS::MAX1227_SPI_FREQ); SpiCookie* spiCookieSus10 = new SpiCookie(addresses::SUS_10, gpio::NO_GPIO, - std::string("/dev/spidev2.0"), SUS::MAX_CMD_SIZE, spi::DEFAULT_MAX_1227_MODE, + std::string(q7s::SPI_DEFAULT_FILE), SUS::MAX_CMD_SIZE, spi::DEFAULT_MAX_1227_MODE, SUS::MAX1227_SPI_FREQ); SpiCookie* spiCookieSus11 = new SpiCookie(addresses::SUS_11, gpio::NO_GPIO, - std::string("/dev/spidev2.0"), SUS::MAX_CMD_SIZE, spi::DEFAULT_MAX_1227_MODE, + std::string(q7s::SPI_DEFAULT_FILE), SUS::MAX_CMD_SIZE, spi::DEFAULT_MAX_1227_MODE, SUS::MAX1227_SPI_FREQ); SpiCookie* spiCookieSus12 = new SpiCookie(addresses::SUS_12, gpio::NO_GPIO, - std::string("/dev/spidev2.0"), SUS::MAX_CMD_SIZE, spi::DEFAULT_MAX_1227_MODE, + std::string(q7s::SPI_DEFAULT_FILE), SUS::MAX_CMD_SIZE, spi::DEFAULT_MAX_1227_MODE, SUS::MAX1227_SPI_FREQ); SpiCookie* spiCookieSus13 = new SpiCookie(addresses::SUS_13, gpio::NO_GPIO, - std::string("/dev/spidev2.0"), SUS::MAX_CMD_SIZE, spi::DEFAULT_MAX_1227_MODE, + std::string(q7s::SPI_DEFAULT_FILE), SUS::MAX_CMD_SIZE, spi::DEFAULT_MAX_1227_MODE, SUS::MAX1227_SPI_FREQ); new SusHandler(objects::SUS_1, objects::SPI_COM_IF, spiCookieSus1, gpioComIF, @@ -382,7 +385,7 @@ void ObjectFactory::createSunSensorComponents(LinuxLibgpioIF *gpioComIF) { gpioIds::CS_SUS_13); } -void ObjectFactory::createAcsBoardComponents(LinuxLibgpioIF *gpioComIF) { +void ObjectFactory::createAcsBoardComponents(LinuxLibgpioIF *gpioComIF, UartComIF* uartComIF) { GpioCookie* gpioCookieAcsBoard = new GpioCookie(); GpiodRegular* gpio = nullptr; gpio = new GpiodRegular(std::string("gpiochip5"), 1, std::string("CS_GYRO_0_ADIS"), @@ -413,7 +416,7 @@ void ObjectFactory::createAcsBoardComponents(LinuxLibgpioIF *gpioComIF) { gpioComIF->addGpios(gpioCookieAcsBoard); - std::string spiDev = "/dev/spidev2.0"; + std::string spiDev = q7s::SPI_DEFAULT_FILE; SpiCookie* spiCookie = new SpiCookie(addresses::MGM_0_LIS3, gpioIds::MGM_0_LIS3_CS, spiDev, MGMLIS3MDL::MAX_BUFFER_SIZE, spi::DEFAULT_LIS3_MODE, spi::DEFAULT_LIS3_SPEED); auto mgmLis3Handler = new MGMHandlerLIS3MDL(objects::MGM_0_LIS3_HANDLER, @@ -454,6 +457,14 @@ void ObjectFactory::createAcsBoardComponents(LinuxLibgpioIF *gpioComIF) { // gyroL3gHandler = new GyroHandlerL3GD20H(objects::GYRO_2_L3G_HANDLER, objects::SPI_COM_IF, // spiCookie); // gyroL3gHandler->setStartUpImmediately(); + + // TODO: Add GPS device handlers +// auto uartCookieGps0 = new UartCookie(objects::GPS0_HANDLER, deviceFile, uartMode, baudrate, +// maxReplyLen); +// auto uartCookieGps1 = new UartCookie(objects::GPS0_HANDLER, deviceFile, uartMode, baudrate, +// maxReplyLen); +// new GPSHyperionHandler(objects::GPS0_HANDLER, uartComIF); +// new GPSHyperionHandler(objects::GPS1_HANDLER, uartComIF); } void ObjectFactory::createHeaterComponents() { @@ -578,52 +589,52 @@ void ObjectFactory::createRtdComponents(LinuxLibgpioIF *gpioComIF) { gpioComIF->addGpios(rtdGpioCookie); SpiCookie* spiRtdIc3 = new SpiCookie(addresses::RTD_IC3, gpioIds::RTD_IC3, - std::string("/dev/spidev2.0"), Max31865Definitions::MAX_REPLY_SIZE, + std::string(q7s::SPI_DEFAULT_FILE), Max31865Definitions::MAX_REPLY_SIZE, spi::SpiModes::MODE_3, 2000000); SpiCookie* spiRtdIc4 = new SpiCookie(addresses::RTD_IC4, gpioIds::RTD_IC4, - std::string("/dev/spidev2.0"), Max31865Definitions::MAX_REPLY_SIZE, + std::string(q7s::SPI_DEFAULT_FILE), Max31865Definitions::MAX_REPLY_SIZE, spi::SpiModes::MODE_1, 2000000); SpiCookie* spiRtdIc5 = new SpiCookie(addresses::RTD_IC5, gpioIds::RTD_IC5, - std::string("/dev/spidev2.0"), Max31865Definitions::MAX_REPLY_SIZE, + std::string(q7s::SPI_DEFAULT_FILE), Max31865Definitions::MAX_REPLY_SIZE, spi::SpiModes::MODE_1, 2000000); SpiCookie* spiRtdIc6 = new SpiCookie(addresses::RTD_IC6, gpioIds::RTD_IC6, - std::string("/dev/spidev2.0"), Max31865Definitions::MAX_REPLY_SIZE, + std::string(q7s::SPI_DEFAULT_FILE), Max31865Definitions::MAX_REPLY_SIZE, spi::SpiModes::MODE_1, 2000000); SpiCookie* spiRtdIc7 = new SpiCookie(addresses::RTD_IC7, gpioIds::RTD_IC7, - std::string("/dev/spidev2.0"), Max31865Definitions::MAX_REPLY_SIZE, + std::string(q7s::SPI_DEFAULT_FILE), Max31865Definitions::MAX_REPLY_SIZE, spi::SpiModes::MODE_1, 2000000); SpiCookie* spiRtdIc8 = new SpiCookie(addresses::RTD_IC8, gpioIds::RTD_IC8, - std::string("/dev/spidev2.0"), Max31865Definitions::MAX_REPLY_SIZE, + std::string(q7s::SPI_DEFAULT_FILE), Max31865Definitions::MAX_REPLY_SIZE, spi::SpiModes::MODE_1, 2000000); SpiCookie* spiRtdIc9 = new SpiCookie(addresses::RTD_IC9, gpioIds::RTD_IC9, - std::string("/dev/spidev2.0"), Max31865Definitions::MAX_REPLY_SIZE, + std::string(q7s::SPI_DEFAULT_FILE), Max31865Definitions::MAX_REPLY_SIZE, spi::SpiModes::MODE_1, 2000000); SpiCookie* spiRtdIc10 = new SpiCookie(addresses::RTD_IC10, gpioIds::RTD_IC10, - std::string("/dev/spidev2.0"), Max31865Definitions::MAX_REPLY_SIZE, + std::string(q7s::SPI_DEFAULT_FILE), Max31865Definitions::MAX_REPLY_SIZE, spi::SpiModes::MODE_1, 2000000); SpiCookie* spiRtdIc11 = new SpiCookie(addresses::RTD_IC11, gpioIds::RTD_IC11, - std::string("/dev/spidev2.0"), Max31865Definitions::MAX_REPLY_SIZE, + std::string(q7s::SPI_DEFAULT_FILE), Max31865Definitions::MAX_REPLY_SIZE, spi::SpiModes::MODE_1, 2000000); SpiCookie* spiRtdIc12 = new SpiCookie(addresses::RTD_IC12, gpioIds::RTD_IC12, - std::string("/dev/spidev2.0"), Max31865Definitions::MAX_REPLY_SIZE, + std::string(q7s::SPI_DEFAULT_FILE), Max31865Definitions::MAX_REPLY_SIZE, spi::SpiModes::MODE_1, 2000000); SpiCookie* spiRtdIc13 = new SpiCookie(addresses::RTD_IC13, gpioIds::RTD_IC13, - std::string("/dev/spidev2.0"), Max31865Definitions::MAX_REPLY_SIZE, + std::string(q7s::SPI_DEFAULT_FILE), Max31865Definitions::MAX_REPLY_SIZE, spi::SpiModes::MODE_1, 2000000); SpiCookie* spiRtdIc14 = new SpiCookie(addresses::RTD_IC14, gpioIds::RTD_IC14, - std::string("/dev/spidev2.0"), Max31865Definitions::MAX_REPLY_SIZE, + std::string(q7s::SPI_DEFAULT_FILE), Max31865Definitions::MAX_REPLY_SIZE, spi::SpiModes::MODE_1, 2000000); SpiCookie* spiRtdIc15 = new SpiCookie(addresses::RTD_IC15, gpioIds::RTD_IC15, - std::string("/dev/spidev2.0"), Max31865Definitions::MAX_REPLY_SIZE, + std::string(q7s::SPI_DEFAULT_FILE), Max31865Definitions::MAX_REPLY_SIZE, spi::SpiModes::MODE_1, 3900000); SpiCookie* spiRtdIc16 = new SpiCookie(addresses::RTD_IC16, gpioIds::RTD_IC16, - std::string("/dev/spidev2.0"), Max31865Definitions::MAX_REPLY_SIZE, + std::string(q7s::SPI_DEFAULT_FILE), Max31865Definitions::MAX_REPLY_SIZE, spi::SpiModes::MODE_1, 2000000); SpiCookie* spiRtdIc17 = new SpiCookie(addresses::RTD_IC17, gpioIds::RTD_IC17, - std::string("/dev/spidev2.0"), Max31865Definitions::MAX_REPLY_SIZE, + std::string(q7s::SPI_DEFAULT_FILE), Max31865Definitions::MAX_REPLY_SIZE, spi::SpiModes::MODE_1, 2000000); SpiCookie* spiRtdIc18 = new SpiCookie(addresses::RTD_IC18, gpioIds::RTD_IC18, - std::string("/dev/spidev2.0"), Max31865Definitions::MAX_REPLY_SIZE, + std::string(q7s::SPI_DEFAULT_FILE), Max31865Definitions::MAX_REPLY_SIZE, spi::SpiModes::MODE_1, 2000000); Max31865PT1000Handler* rtdIc3 = new Max31865PT1000Handler(objects::RTD_IC3, @@ -716,16 +727,16 @@ void ObjectFactory::createReactionWheelComponents(LinuxLibgpioIF* gpioComIF) { gpioComIF->addGpios(gpioCookieRw); - auto rw1SpiCookie = new SpiCookie(addresses::RW1, gpioIds::CS_RW1, "/dev/spidev3.0", + auto rw1SpiCookie = new SpiCookie(addresses::RW1, gpioIds::CS_RW1, q7s::SPI_RW_FILE, RwDefinitions::MAX_REPLY_SIZE, spi::RW_MODE, spi::RW_SPEED, &rwSpiCallback::spiCallback, nullptr); - auto rw2SpiCookie = new SpiCookie(addresses::RW2, gpioIds::CS_RW2, "/dev/spidev3.0", + auto rw2SpiCookie = new SpiCookie(addresses::RW2, gpioIds::CS_RW2, q7s::SPI_RW_FILE, RwDefinitions::MAX_REPLY_SIZE, spi::RW_MODE, spi::RW_SPEED, &rwSpiCallback::spiCallback, nullptr); - auto rw3SpiCookie = new SpiCookie(addresses::RW3, gpioIds::CS_RW3, "/dev/spidev3.0", + auto rw3SpiCookie = new SpiCookie(addresses::RW3, gpioIds::CS_RW3, q7s::SPI_RW_FILE, RwDefinitions::MAX_REPLY_SIZE, spi::RW_MODE, spi::RW_SPEED, &rwSpiCallback::spiCallback, nullptr); - auto rw4SpiCookie = new SpiCookie(addresses::RW4, gpioIds::CS_RW4, "/dev/spidev3.0", + auto rw4SpiCookie = new SpiCookie(addresses::RW4, gpioIds::CS_RW4, q7s::SPI_RW_FILE, RwDefinitions::MAX_REPLY_SIZE, spi::RW_MODE, spi::RW_SPEED, &rwSpiCallback::spiCallback, nullptr); diff --git a/bsp_q7s/core/ObjectFactory.h b/bsp_q7s/core/ObjectFactory.h index 411fa230..6cd1b378 100644 --- a/bsp_q7s/core/ObjectFactory.h +++ b/bsp_q7s/core/ObjectFactory.h @@ -2,18 +2,19 @@ #define BSP_Q7S_OBJECTFACTORY_H_ class LinuxLibgpioIF; +class UartComIF; namespace ObjectFactory { void setStatics(); void produce(void* args); -void createCommunicationInterfaces(LinuxLibgpioIF** gpioComIF); +void createCommunicationInterfaces(LinuxLibgpioIF** gpioComIF, UartComIF** uartComIF); void createTmpComponents(); void createPcduComponents(); void createRadSensorComponent(LinuxLibgpioIF* gpioComIF); void createSunSensorComponents(LinuxLibgpioIF* gpioComIF); -void createAcsBoardComponents(LinuxLibgpioIF* gpioComIF); +void createAcsBoardComponents(LinuxLibgpioIF* gpioComIF, UartComIF* uartComIF); void createHeaterComponents(); void createSolarArrayDeploymentComponents(); void createSyrlinksComponents(); diff --git a/common/config/spiConf.h b/common/config/devConf.h similarity index 89% rename from common/config/spiConf.h rename to common/config/devConf.h index 47600eb3..f97567ac 100644 --- a/common/config/spiConf.h +++ b/common/config/devConf.h @@ -1,5 +1,5 @@ -#ifndef COMMON_CONFIG_SPICONF_H_ -#define COMMON_CONFIG_SPICONF_H_ +#ifndef COMMON_CONFIG_DEVCONF_H_ +#define COMMON_CONFIG_DEVCONF_H_ #include #include @@ -31,4 +31,8 @@ static constexpr spi::SpiModes RW_MODE = spi::SpiModes::MODE_0; } -#endif /* COMMON_CONFIG_SPICONF_H_ */ +namespace uart { + +} + +#endif /* COMMON_CONFIG_DEVCONF_H_ */ diff --git a/linux/fsfwconfig/pollingsequence/pollingSequenceFactory.cpp b/linux/fsfwconfig/pollingsequence/pollingSequenceFactory.cpp index 57702013..2e2466f7 100644 --- a/linux/fsfwconfig/pollingsequence/pollingSequenceFactory.cpp +++ b/linux/fsfwconfig/pollingsequence/pollingSequenceFactory.cpp @@ -423,6 +423,7 @@ ReturnValue_t pst::pstSpi(FixedTimeslotTaskIF *thisSequence) { thisSequence->addSlot(objects::RW4, length * 0.6, DeviceHandlerIF::SEND_READ); thisSequence->addSlot(objects::RW4, length * 0.8, DeviceHandlerIF::GET_READ); +#if OBSW_ADD_ACS_BOARD == 1 thisSequence->addSlot(objects::MGM_0_LIS3_HANDLER, length * 0, DeviceHandlerIF::PERFORM_OPERATION); thisSequence->addSlot(objects::MGM_0_LIS3_HANDLER, length * 0.2, @@ -491,6 +492,8 @@ ReturnValue_t pst::pstSpi(FixedTimeslotTaskIF *thisSequence) { DeviceHandlerIF::SEND_READ); thisSequence->addSlot(objects::MGM_3_RM3100_HANDLER, length * 0.8, DeviceHandlerIF::GET_READ); +#endif + if (thisSequence->checkSequence() != HasReturnvaluesIF::RETURN_OK) { sif::error << "SPI PST initialization failed" << std::endl; return HasReturnvaluesIF::RETURN_FAILED; -- 2.43.0 From e98b985d66145632c928880b31efad4d18866511 Mon Sep 17 00:00:00 2001 From: IRS Cleanroom Laptop Date: Tue, 17 Aug 2021 17:48:51 +0200 Subject: [PATCH 22/43] cleaning up preproc defines --- bsp_q7s/boardconfig/busConf.h | 7 +- bsp_q7s/core/InitMission.cpp | 8 +- bsp_q7s/core/ObjectFactory.cpp | 129 +++++++++--------- bsp_q7s/devices/PlocSupervisorHandler.cpp | 6 +- common/config/devConf.h | 2 + linux/devices/SusHandler.cpp | 2 +- linux/fsfwconfig/OBSWConfig.h.in | 97 +++++++------ .../pollingSequenceFactory.cpp | 10 +- linux/obc/CCSDSIPCoreBridge.cpp | 2 +- mission/devices/ACUHandler.cpp | 2 +- mission/devices/GyroADIS16507Handler.cpp | 4 +- mission/devices/GyroADIS16507Handler.h | 2 +- mission/devices/IMTQHandler.cpp | 18 +-- mission/devices/Max31865PT1000Handler.cpp | 4 +- mission/devices/P60DockHandler.cpp | 2 +- mission/devices/PDU1Handler.cpp | 2 +- mission/devices/PDU2Handler.cpp | 2 +- mission/devices/RadiationSensorHandler.cpp | 2 +- mission/devices/RwHandler.cpp | 8 +- mission/devices/StarTrackerHandler.cpp | 2 +- mission/devices/SyrlinksHkHandler.cpp | 8 +- 21 files changed, 166 insertions(+), 153 deletions(-) diff --git a/bsp_q7s/boardconfig/busConf.h b/bsp_q7s/boardconfig/busConf.h index bdca6ee5..27f44b04 100644 --- a/bsp_q7s/boardconfig/busConf.h +++ b/bsp_q7s/boardconfig/busConf.h @@ -3,9 +3,12 @@ namespace q7s { -static constexpr char SPI_DEFAULT_FILE[] = "dev/spidev2.0"; -static constexpr char SPI_RW_FILE[] = "dev/spidev3.0"; +static constexpr char SPI_DEFAULT_DEV[] = "dev/spidev2.0"; +static constexpr char SPI_RW_DEV[] = "dev/spidev3.0"; +static constexpr char I2C_DEFAULT_DEV[] = "/dev/i2c-0"; + +static constexpr char UART_PLOC_MPSOC_DEV[] = "/dev/ttyUL3"; } diff --git a/bsp_q7s/core/InitMission.cpp b/bsp_q7s/core/InitMission.cpp index 2ee4d374..230a80bf 100644 --- a/bsp_q7s/core/InitMission.cpp +++ b/bsp_q7s/core/InitMission.cpp @@ -112,7 +112,7 @@ void initmission::initTasks() { initmission::printAddObjectError("FILE_SYSTEM_TASK", objects::FILE_SYSTEM_HANDLER); } -#if TEST_CCSDS_BRIDGE == 1 +#if OBSW_TEST_CCSDS_BRIDGE == 1 PeriodicTaskIF* ptmeTestTask = factory->createPeriodicTask( "PTME_TEST", 80, PeriodicTaskIF::MINIMUM_STACK_SIZE, 2.0, missedDeadlineFunc); result = ptmeTestTask->addComponent(objects::CCSDS_IP_CORE_BRIDGE); @@ -152,7 +152,7 @@ void initmission::initTasks() { taskStarter(testTasks, "Test task vector"); #endif -#if TEST_CCSDS_BRIDGE == 1 +#if OBSW_TEST_CCSDS_BRIDGE == 1 ptmeTestTask->startTask(); #endif fsTask->startTask(); @@ -301,11 +301,11 @@ void initmission::createTestTasks(TaskFactory& factory, TaskDeadlineMissedFuncti initmission::printAddObjectError("SPI_TEST", objects::SPI_TEST); } #endif -#if BOARD_TE0720 == 1 && TEST_LIBGPIOD == 1 +#if BOARD_TE0720 == 1 && OBSW_TEST_LIBGPIOD == 1 result = testTask->addComponent(objects::LIBGPIOD_TEST); if(result != HasReturnvaluesIF::RETURN_OK) { initmission::printAddObjectError("GPIOD_TEST", objects::LIBGPIOD_TEST); } -#endif /* BOARD_TE0720 == 1 && TEST_LIBGPIOD == 1 */ +#endif /* BOARD_TE0720 == 1 && OBSW_TEST_LIBGPIOD == 1 */ taskVec.push_back(testTask); } diff --git a/bsp_q7s/core/ObjectFactory.cpp b/bsp_q7s/core/ObjectFactory.cpp index b48d3bf7..1f9cccca 100644 --- a/bsp_q7s/core/ObjectFactory.cpp +++ b/bsp_q7s/core/ObjectFactory.cpp @@ -76,7 +76,7 @@ #include "linux/boardtest/SpiTestClass.h" -#if TEST_LIBGPIOD == 1 +#if OBSW_TEST_LIBGPIOD == 1 #include "linux/boardtest/LibgpiodTest.h" #endif @@ -127,15 +127,15 @@ void ObjectFactory::produce(void* args){ createRtdComponents(); #endif /* Q7S_ADD_RTD_DEVICES == 1 */ - I2cCookie* imtqI2cCookie = new I2cCookie(addresses::IMTQ, IMTQ::MAX_REPLY_SIZE, - std::string("/dev/i2c-0")); + I2cCookie* imtqI2cCookie = new I2cCookie(addresses::IMTQ, + IMTQ::MAX_REPLY_SIZE, q7s::I2C_DEFAULT_DEV); new IMTQHandler(objects::IMTQ_HANDLER, objects::I2C_COM_IF, imtqI2cCookie); -#if ADD_PLOC_MPSOC == 1 - UartCookie* mpsocUartCookie = new UartCookie(objects::RW1, std::string("/dev/ttyUL3"), - UartModes::NON_CANONICAL, 115200, PLOC_MPSOC::MAX_REPLY_SIZE); +#if OBSW_ADD_PLOC_MPSOC == 1 + UartCookie* mpsocUartCookie = new UartCookie(objects::RW1, q7s::UART_PLOC_MPSOC_DEV, + UartModes::NON_CANONICAL, uart::PLOC_MPSOC_BAUD, PLOC_MPSOC::MAX_REPLY_SIZE); new PlocMPSoCHandler(objects::PLOC_MPSOC_HANDLER, objects::UART_COM_IF, mpsocUartCookie); -#endif /* ADD_PLOC_MPSOC */ +#endif /* OBSW_ADD_PLOC_MPSOC */ createReactionWheelComponents(gpioComIF); #endif /* TE7020 != 0 */ @@ -159,7 +159,7 @@ void ObjectFactory::produce(void* args){ new FileSystemHandler(objects::FILE_SYSTEM_HANDLER); -#if ADD_PLOC_MPSOC == 1 +#if OBSW_ADD_PLOC_MPSOC == 1 UartCookie* plocMpsocCookie = new UartCookie(objects::RW1, std::string("/dev/ttyUL3"), UartModes::NON_CANONICAL, 115200, PLOC_MPSOC::MAX_REPLY_SIZE); new PlocMPSoCHandler(objects::PLOC_MPSOC_HANDLER, objects::UART_COM_IF, plocMpsocCookie); @@ -172,7 +172,7 @@ void ObjectFactory::produce(void* args){ new StarTrackerHandler(objects::START_TRACKER, objects::UART_COM_IF, starTrackerCookie); #endif -#if ADD_PLOC_SUPERVISOR == 1 +#if OBSW_ADD_PLOC_SUPERVISOR == 1 UartCookie* plocSupervisorCookie = new UartCookie(objects::PLOC_SUPERVISOR_HANDLER, std::string("/dev/ttyUL4"), UartModes::NON_CANONICAL, 115200, PLOC_SPV::MAX_PACKET_SIZE * 20); @@ -267,7 +267,7 @@ void ObjectFactory::createRadSensorComponent(LinuxLibgpioIF* gpioComIF) { gpioComIF->addGpios(gpioCookieRadSensor); SpiCookie* spiCookieRadSensor = new SpiCookie(addresses::RAD_SENSOR, gpioIds::CS_RAD_SENSOR, - std::string(q7s::SPI_DEFAULT_FILE), RAD_SENSOR::READ_SIZE, spi::DEFAULT_MAX_1227_MODE, + std::string(q7s::SPI_DEFAULT_DEV), RAD_SENSOR::READ_SIZE, spi::DEFAULT_MAX_1227_MODE, spi::DEFAULT_MAX_1227_SPEED); new RadiationSensorHandler(objects::RAD_SENSOR, objects::SPI_COM_IF, spiCookieRadSensor); } @@ -318,43 +318,43 @@ void ObjectFactory::createSunSensorComponents(LinuxLibgpioIF *gpioComIF) { gpioComIF->addGpios(gpioCookieSus); SpiCookie* spiCookieSus1 = new SpiCookie(addresses::SUS_1, gpio::NO_GPIO, - std::string(q7s::SPI_DEFAULT_FILE), SUS::MAX_CMD_SIZE, spi::DEFAULT_MAX_1227_MODE, + std::string(q7s::SPI_DEFAULT_DEV), SUS::MAX_CMD_SIZE, spi::DEFAULT_MAX_1227_MODE, SUS::MAX1227_SPI_FREQ); SpiCookie* spiCookieSus2 = new SpiCookie(addresses::SUS_2, gpio::NO_GPIO, - std::string(q7s::SPI_DEFAULT_FILE), SUS::MAX_CMD_SIZE, spi::DEFAULT_MAX_1227_MODE, + std::string(q7s::SPI_DEFAULT_DEV), SUS::MAX_CMD_SIZE, spi::DEFAULT_MAX_1227_MODE, SUS::MAX1227_SPI_FREQ); SpiCookie* spiCookieSus3 = new SpiCookie(addresses::SUS_3, gpio::NO_GPIO, - std::string(q7s::SPI_DEFAULT_FILE), SUS::MAX_CMD_SIZE, spi::DEFAULT_MAX_1227_MODE, + std::string(q7s::SPI_DEFAULT_DEV), SUS::MAX_CMD_SIZE, spi::DEFAULT_MAX_1227_MODE, SUS::MAX1227_SPI_FREQ); SpiCookie* spiCookieSus4 = new SpiCookie(addresses::SUS_4, gpio::NO_GPIO, - std::string(q7s::SPI_DEFAULT_FILE), SUS::MAX_CMD_SIZE, spi::DEFAULT_MAX_1227_MODE, + std::string(q7s::SPI_DEFAULT_DEV), SUS::MAX_CMD_SIZE, spi::DEFAULT_MAX_1227_MODE, SUS::MAX1227_SPI_FREQ); SpiCookie* spiCookieSus5 = new SpiCookie(addresses::SUS_5, gpio::NO_GPIO, - std::string(q7s::SPI_DEFAULT_FILE), SUS::MAX_CMD_SIZE, spi::DEFAULT_MAX_1227_MODE, + std::string(q7s::SPI_DEFAULT_DEV), SUS::MAX_CMD_SIZE, spi::DEFAULT_MAX_1227_MODE, SUS::MAX1227_SPI_FREQ); SpiCookie* spiCookieSus6 = new SpiCookie(addresses::SUS_6, gpio::NO_GPIO, - std::string(q7s::SPI_DEFAULT_FILE), SUS::MAX_CMD_SIZE, spi::DEFAULT_MAX_1227_MODE, + std::string(q7s::SPI_DEFAULT_DEV), SUS::MAX_CMD_SIZE, spi::DEFAULT_MAX_1227_MODE, SUS::MAX1227_SPI_FREQ); SpiCookie* spiCookieSus7 = new SpiCookie(addresses::SUS_7, gpio::NO_GPIO, - std::string(q7s::SPI_DEFAULT_FILE), SUS::MAX_CMD_SIZE, spi::DEFAULT_MAX_1227_MODE, + std::string(q7s::SPI_DEFAULT_DEV), SUS::MAX_CMD_SIZE, spi::DEFAULT_MAX_1227_MODE, SUS::MAX1227_SPI_FREQ); SpiCookie* spiCookieSus8 = new SpiCookie(addresses::SUS_8, gpio::NO_GPIO, - std::string(q7s::SPI_DEFAULT_FILE), SUS::MAX_CMD_SIZE, spi::DEFAULT_MAX_1227_MODE, + std::string(q7s::SPI_DEFAULT_DEV), SUS::MAX_CMD_SIZE, spi::DEFAULT_MAX_1227_MODE, SUS::MAX1227_SPI_FREQ); SpiCookie* spiCookieSus9 = new SpiCookie(addresses::SUS_9, gpio::NO_GPIO, - std::string(q7s::SPI_DEFAULT_FILE), SUS::MAX_CMD_SIZE, spi::DEFAULT_MAX_1227_MODE, + std::string(q7s::SPI_DEFAULT_DEV), SUS::MAX_CMD_SIZE, spi::DEFAULT_MAX_1227_MODE, SUS::MAX1227_SPI_FREQ); SpiCookie* spiCookieSus10 = new SpiCookie(addresses::SUS_10, gpio::NO_GPIO, - std::string(q7s::SPI_DEFAULT_FILE), SUS::MAX_CMD_SIZE, spi::DEFAULT_MAX_1227_MODE, + std::string(q7s::SPI_DEFAULT_DEV), SUS::MAX_CMD_SIZE, spi::DEFAULT_MAX_1227_MODE, SUS::MAX1227_SPI_FREQ); SpiCookie* spiCookieSus11 = new SpiCookie(addresses::SUS_11, gpio::NO_GPIO, - std::string(q7s::SPI_DEFAULT_FILE), SUS::MAX_CMD_SIZE, spi::DEFAULT_MAX_1227_MODE, + std::string(q7s::SPI_DEFAULT_DEV), SUS::MAX_CMD_SIZE, spi::DEFAULT_MAX_1227_MODE, SUS::MAX1227_SPI_FREQ); SpiCookie* spiCookieSus12 = new SpiCookie(addresses::SUS_12, gpio::NO_GPIO, - std::string(q7s::SPI_DEFAULT_FILE), SUS::MAX_CMD_SIZE, spi::DEFAULT_MAX_1227_MODE, + std::string(q7s::SPI_DEFAULT_DEV), SUS::MAX_CMD_SIZE, spi::DEFAULT_MAX_1227_MODE, SUS::MAX1227_SPI_FREQ); SpiCookie* spiCookieSus13 = new SpiCookie(addresses::SUS_13, gpio::NO_GPIO, - std::string(q7s::SPI_DEFAULT_FILE), SUS::MAX_CMD_SIZE, spi::DEFAULT_MAX_1227_MODE, + std::string(q7s::SPI_DEFAULT_DEV), SUS::MAX_CMD_SIZE, spi::DEFAULT_MAX_1227_MODE, SUS::MAX1227_SPI_FREQ); new SusHandler(objects::SUS_1, objects::SPI_COM_IF, spiCookieSus1, gpioComIF, @@ -416,7 +416,7 @@ void ObjectFactory::createAcsBoardComponents(LinuxLibgpioIF *gpioComIF, UartComI gpioComIF->addGpios(gpioCookieAcsBoard); - std::string spiDev = q7s::SPI_DEFAULT_FILE; + std::string spiDev = q7s::SPI_DEFAULT_DEV; SpiCookie* spiCookie = new SpiCookie(addresses::MGM_0_LIS3, gpioIds::MGM_0_LIS3_CS, spiDev, MGMLIS3MDL::MAX_BUFFER_SIZE, spi::DEFAULT_LIS3_MODE, spi::DEFAULT_LIS3_SPEED); auto mgmLis3Handler = new MGMHandlerLIS3MDL(objects::MGM_0_LIS3_HANDLER, @@ -589,52 +589,52 @@ void ObjectFactory::createRtdComponents(LinuxLibgpioIF *gpioComIF) { gpioComIF->addGpios(rtdGpioCookie); SpiCookie* spiRtdIc3 = new SpiCookie(addresses::RTD_IC3, gpioIds::RTD_IC3, - std::string(q7s::SPI_DEFAULT_FILE), Max31865Definitions::MAX_REPLY_SIZE, + std::string(q7s::SPI_DEFAULT_DEV), Max31865Definitions::MAX_REPLY_SIZE, spi::SpiModes::MODE_3, 2000000); SpiCookie* spiRtdIc4 = new SpiCookie(addresses::RTD_IC4, gpioIds::RTD_IC4, - std::string(q7s::SPI_DEFAULT_FILE), Max31865Definitions::MAX_REPLY_SIZE, + std::string(q7s::SPI_DEFAULT_DEV), Max31865Definitions::MAX_REPLY_SIZE, spi::SpiModes::MODE_1, 2000000); SpiCookie* spiRtdIc5 = new SpiCookie(addresses::RTD_IC5, gpioIds::RTD_IC5, - std::string(q7s::SPI_DEFAULT_FILE), Max31865Definitions::MAX_REPLY_SIZE, + std::string(q7s::SPI_DEFAULT_DEV), Max31865Definitions::MAX_REPLY_SIZE, spi::SpiModes::MODE_1, 2000000); SpiCookie* spiRtdIc6 = new SpiCookie(addresses::RTD_IC6, gpioIds::RTD_IC6, - std::string(q7s::SPI_DEFAULT_FILE), Max31865Definitions::MAX_REPLY_SIZE, + std::string(q7s::SPI_DEFAULT_DEV), Max31865Definitions::MAX_REPLY_SIZE, spi::SpiModes::MODE_1, 2000000); SpiCookie* spiRtdIc7 = new SpiCookie(addresses::RTD_IC7, gpioIds::RTD_IC7, - std::string(q7s::SPI_DEFAULT_FILE), Max31865Definitions::MAX_REPLY_SIZE, + std::string(q7s::SPI_DEFAULT_DEV), Max31865Definitions::MAX_REPLY_SIZE, spi::SpiModes::MODE_1, 2000000); SpiCookie* spiRtdIc8 = new SpiCookie(addresses::RTD_IC8, gpioIds::RTD_IC8, - std::string(q7s::SPI_DEFAULT_FILE), Max31865Definitions::MAX_REPLY_SIZE, + std::string(q7s::SPI_DEFAULT_DEV), Max31865Definitions::MAX_REPLY_SIZE, spi::SpiModes::MODE_1, 2000000); SpiCookie* spiRtdIc9 = new SpiCookie(addresses::RTD_IC9, gpioIds::RTD_IC9, - std::string(q7s::SPI_DEFAULT_FILE), Max31865Definitions::MAX_REPLY_SIZE, + std::string(q7s::SPI_DEFAULT_DEV), Max31865Definitions::MAX_REPLY_SIZE, spi::SpiModes::MODE_1, 2000000); SpiCookie* spiRtdIc10 = new SpiCookie(addresses::RTD_IC10, gpioIds::RTD_IC10, - std::string(q7s::SPI_DEFAULT_FILE), Max31865Definitions::MAX_REPLY_SIZE, + std::string(q7s::SPI_DEFAULT_DEV), Max31865Definitions::MAX_REPLY_SIZE, spi::SpiModes::MODE_1, 2000000); SpiCookie* spiRtdIc11 = new SpiCookie(addresses::RTD_IC11, gpioIds::RTD_IC11, - std::string(q7s::SPI_DEFAULT_FILE), Max31865Definitions::MAX_REPLY_SIZE, + std::string(q7s::SPI_DEFAULT_DEV), Max31865Definitions::MAX_REPLY_SIZE, spi::SpiModes::MODE_1, 2000000); SpiCookie* spiRtdIc12 = new SpiCookie(addresses::RTD_IC12, gpioIds::RTD_IC12, - std::string(q7s::SPI_DEFAULT_FILE), Max31865Definitions::MAX_REPLY_SIZE, + std::string(q7s::SPI_DEFAULT_DEV), Max31865Definitions::MAX_REPLY_SIZE, spi::SpiModes::MODE_1, 2000000); SpiCookie* spiRtdIc13 = new SpiCookie(addresses::RTD_IC13, gpioIds::RTD_IC13, - std::string(q7s::SPI_DEFAULT_FILE), Max31865Definitions::MAX_REPLY_SIZE, + std::string(q7s::SPI_DEFAULT_DEV), Max31865Definitions::MAX_REPLY_SIZE, spi::SpiModes::MODE_1, 2000000); SpiCookie* spiRtdIc14 = new SpiCookie(addresses::RTD_IC14, gpioIds::RTD_IC14, - std::string(q7s::SPI_DEFAULT_FILE), Max31865Definitions::MAX_REPLY_SIZE, + std::string(q7s::SPI_DEFAULT_DEV), Max31865Definitions::MAX_REPLY_SIZE, spi::SpiModes::MODE_1, 2000000); SpiCookie* spiRtdIc15 = new SpiCookie(addresses::RTD_IC15, gpioIds::RTD_IC15, - std::string(q7s::SPI_DEFAULT_FILE), Max31865Definitions::MAX_REPLY_SIZE, + std::string(q7s::SPI_DEFAULT_DEV), Max31865Definitions::MAX_REPLY_SIZE, spi::SpiModes::MODE_1, 3900000); SpiCookie* spiRtdIc16 = new SpiCookie(addresses::RTD_IC16, gpioIds::RTD_IC16, - std::string(q7s::SPI_DEFAULT_FILE), Max31865Definitions::MAX_REPLY_SIZE, + std::string(q7s::SPI_DEFAULT_DEV), Max31865Definitions::MAX_REPLY_SIZE, spi::SpiModes::MODE_1, 2000000); SpiCookie* spiRtdIc17 = new SpiCookie(addresses::RTD_IC17, gpioIds::RTD_IC17, - std::string(q7s::SPI_DEFAULT_FILE), Max31865Definitions::MAX_REPLY_SIZE, + std::string(q7s::SPI_DEFAULT_DEV), Max31865Definitions::MAX_REPLY_SIZE, spi::SpiModes::MODE_1, 2000000); SpiCookie* spiRtdIc18 = new SpiCookie(addresses::RTD_IC18, gpioIds::RTD_IC18, - std::string(q7s::SPI_DEFAULT_FILE), Max31865Definitions::MAX_REPLY_SIZE, + std::string(q7s::SPI_DEFAULT_DEV), Max31865Definitions::MAX_REPLY_SIZE, spi::SpiModes::MODE_1, 2000000); Max31865PT1000Handler* rtdIc3 = new Max31865PT1000Handler(objects::RTD_IC3, @@ -690,30 +690,30 @@ void ObjectFactory::createRtdComponents(LinuxLibgpioIF *gpioComIF) { void ObjectFactory::createReactionWheelComponents(LinuxLibgpioIF* gpioComIF) { GpioCookie* gpioCookieRw = new GpioCookie; - GpioCallback* csRw1 = new GpioCallback(std::string("Chip select reaction wheel 1"), gpio::OUT, + GpioCallback* csRw1 = new GpioCallback("Chip select reaction wheel 1", gpio::OUT, 1, &gpioCallbacks::spiCsDecoderCallback, gpioComIF); gpioCookieRw->addGpio(gpioIds::CS_RW1, csRw1); - GpioCallback* csRw2 = new GpioCallback(std::string("Chip select reaction wheel 2"), gpio::OUT, + GpioCallback* csRw2 = new GpioCallback("Chip select reaction wheel 2", gpio::OUT, 1, &gpioCallbacks::spiCsDecoderCallback, gpioComIF); gpioCookieRw->addGpio(gpioIds::CS_RW2, csRw2); - GpioCallback* csRw3 = new GpioCallback(std::string("Chip select reaction wheel 3"), gpio::OUT, + GpioCallback* csRw3 = new GpioCallback("Chip select reaction wheel 3", gpio::OUT, 1, &gpioCallbacks::spiCsDecoderCallback, gpioComIF); gpioCookieRw->addGpio(gpioIds::CS_RW3, csRw3); - GpioCallback* csRw4 = new GpioCallback(std::string("Chip select reaction wheel 4"), gpio::OUT, + GpioCallback* csRw4 = new GpioCallback("Chip select reaction wheel 4", gpio::OUT, 1, &gpioCallbacks::spiCsDecoderCallback, gpioComIF); gpioCookieRw->addGpio(gpioIds::CS_RW4, csRw4); - GpiodRegular* enRw1 = new GpiodRegular(std::string("gpiochip5"), 7, - std::string("Enable reaction wheel 1"), gpio::OUT, 0); + GpiodRegular* enRw1 = new GpiodRegular("gpiochip5", 7, + "Enable reaction wheel 1", gpio::OUT, 0); gpioCookieRw->addGpio(gpioIds::EN_RW1, enRw1); - GpiodRegular* enRw2 = new GpiodRegular(std::string("gpiochip5"), 3, - std::string("Enable reaction wheel 2"), gpio::OUT, 0); + GpiodRegular* enRw2 = new GpiodRegular("gpiochip5", 3, + "Enable reaction wheel 2", gpio::OUT, 0); gpioCookieRw->addGpio(gpioIds::EN_RW2, enRw2); - GpiodRegular* enRw3 = new GpiodRegular(std::string("gpiochip5"), 11, - std::string("Enable reaction wheel 3"), gpio::OUT, 0); + GpiodRegular* enRw3 = new GpiodRegular("gpiochip5", 11, + "Enable reaction wheel 3", gpio::OUT, 0); gpioCookieRw->addGpio(gpioIds::EN_RW3, enRw3); - GpiodRegular* enRw4 = new GpiodRegular(std::string("gpiochip5"), 6, - std::string("Enable reaction wheel 4"), gpio::OUT, 0); + GpiodRegular* enRw4 = new GpiodRegular("gpiochip5", 6, + "Enable reaction wheel 4", gpio::OUT, 0); gpioCookieRw->addGpio(gpioIds::EN_RW4, enRw4); /** @@ -721,22 +721,21 @@ void ObjectFactory::createReactionWheelComponents(LinuxLibgpioIF* gpioComIF) { * the PS SPI peripheral from the SPI interface and route out the SPI lines of the AXI SPI core. * Per default the PS SPI is selected (EMIO = 0). */ - GpiodRegular* spiMux = new GpiodRegular(std::string("gpiochip11"), 54, - std::string("EMIO 0 SPI Mux"), gpio::OUT, 0); + GpiodRegular* spiMux = new GpiodRegular("gpiochip11", 54, "EMIO 0 SPI Mux", gpio::OUT, 0); gpioCookieRw->addGpio(gpioIds::SPI_MUX, spiMux); gpioComIF->addGpios(gpioCookieRw); - auto rw1SpiCookie = new SpiCookie(addresses::RW1, gpioIds::CS_RW1, q7s::SPI_RW_FILE, + auto rw1SpiCookie = new SpiCookie(addresses::RW1, gpioIds::CS_RW1, q7s::SPI_RW_DEV, RwDefinitions::MAX_REPLY_SIZE, spi::RW_MODE, spi::RW_SPEED, &rwSpiCallback::spiCallback, nullptr); - auto rw2SpiCookie = new SpiCookie(addresses::RW2, gpioIds::CS_RW2, q7s::SPI_RW_FILE, + auto rw2SpiCookie = new SpiCookie(addresses::RW2, gpioIds::CS_RW2, q7s::SPI_RW_DEV, RwDefinitions::MAX_REPLY_SIZE, spi::RW_MODE, spi::RW_SPEED, &rwSpiCallback::spiCallback, nullptr); - auto rw3SpiCookie = new SpiCookie(addresses::RW3, gpioIds::CS_RW3, q7s::SPI_RW_FILE, + auto rw3SpiCookie = new SpiCookie(addresses::RW3, gpioIds::CS_RW3, q7s::SPI_RW_DEV, RwDefinitions::MAX_REPLY_SIZE, spi::RW_MODE, spi::RW_SPEED, &rwSpiCallback::spiCallback, nullptr); - auto rw4SpiCookie = new SpiCookie(addresses::RW4, gpioIds::CS_RW4, q7s::SPI_RW_FILE, + auto rw4SpiCookie = new SpiCookie(addresses::RW4, gpioIds::CS_RW4, q7s::SPI_RW_DEV, RwDefinitions::MAX_REPLY_SIZE, spi::RW_MODE, spi::RW_SPEED, &rwSpiCallback::spiCallback, nullptr); @@ -760,7 +759,7 @@ void ObjectFactory::createReactionWheelComponents(LinuxLibgpioIF* gpioComIF) { void ObjectFactory::createTestComponents() { new Q7STestTask(objects::TEST_TASK); -#if BOARD_TE0720 == 1 && TEST_LIBGPIOD == 1 +#if BOARD_TE0720 == 1 && OBSW_TEST_LIBGPIOD == 1 /* Configure MIO0 as input */ GpiodRegular gpioConfigMio0(std::string("gpiochip0"), 0, std::string("MIO0"), gpio::IN, 0); @@ -769,7 +768,7 @@ void ObjectFactory::createTestComponents() { new LibgpiodTest(objects::LIBGPIOD_TEST, objects::GPIO_IF, gpioCookie); #endif -#if BOARD_TE0720 == 1 && TEST_SUS_HANDLER == 1 +#if BOARD_TE0720 == 1 && OBSW_TEST_SUS_HANDLER == 1 GpioCookie* gpioCookieSus = new GpioCookie; GpiodRegular* chipSelectSus = new GpiodRegular(std::string("gpiochip1"), 9, std::string("Chip Select Sus Sensor"), gpio::OUT, 1); @@ -783,7 +782,7 @@ void ObjectFactory::createTestComponents() { gpioIds::CS_SUS_1); #endif -#if BOARD_TE0720 == 1 && TEST_CCSDS_BRIDGE == 1 +#if BOARD_TE0720 == 1 && OBSW_TEST_CCSDS_BRIDGE == 1 GpioCookie* gpioCookieCcsdsIp = new GpioCookie; GpiodRegular* papbBusyN = new GpiodRegular(std::string("gpiochip0"), 0, std::string("PAPBBusy_N")); gpioCookieCcsdsIp->addGpio(gpioIds::PAPB_BUSY_N, papbBusyN); @@ -797,7 +796,7 @@ void ObjectFactory::createTestComponents() { gpioIds::PAPB_BUSY_N, gpioIds::PAPB_EMPTY); #endif -#if BOARD_TE0720 == 1 && TEST_RADIATION_SENSOR_HANDLER == 1 +#if BOARD_TE0720 == 1 && OBSW_TEST_RADIATION_SENSOR_HANDLER == 1 GpioCookie* gpioCookieRadSensor = new GpioCookie; GpiodRegular* chipSelectRadSensor = new GpiodRegular(std::string("gpiochip1"), 0, std::string("Chip select radiation sensor"), gpio::OUT, 1); @@ -813,7 +812,7 @@ void ObjectFactory::createTestComponents() { radSensor->setStartUpImmediately(); #endif -#if BOARD_TE0720 == 1 && ADD_PLOC_MPSOC == 1 +#if BOARD_TE0720 == 1 && OBSW_ADD_PLOC_MPSOC == 1 UartCookie* plocUartCookie = new UartCookie(std::string("/dev/ttyPS1"), 115200, PLOC_MPSOC::MAX_REPLY_SIZE); /* Testing PlocMPSoCHandler on TE0720-03-1CFA */ @@ -822,7 +821,7 @@ void ObjectFactory::createTestComponents() { mpsocPlocHandler->setStartUpImmediately(); #endif -#if BOARD_TE0720 == 1 && TE0720_HEATER_TEST == 1 +#if BOARD_TE0720 == 1 && OBSW_TEST_TE7020_HEATER == 1 /* Configuration for MIO0 on TE0720-03-1CFA */ GpiodRegular* heaterGpio = new GpiodRegular(std::string("gpiochip0"), 0, std::string("MIO0"), gpio::IN, 0); GpioCookie* gpioCookie = new GpioCookie; @@ -831,7 +830,7 @@ void ObjectFactory::createTestComponents() { pcduSwitches::TCS_BOARD_8V_HEATER_IN); #endif -#if BOARD_TE0720 == 1 && ADD_PLOC_SUPERVISOR == 1 +#if BOARD_TE0720 == 1 && OBSW_ADD_PLOC_SUPERVISOR == 1 /* Configuration for MIO0 on TE0720-03-1CFA */ UartCookie* plocSupervisorCookie = new UartCookie(objects::PLOC_SUPERVISOR_HANDLER, std::string("/dev/ttyPS1"), UartModes::NON_CANONICAL, 115200, diff --git a/bsp_q7s/devices/PlocSupervisorHandler.cpp b/bsp_q7s/devices/PlocSupervisorHandler.cpp index de50955f..7d51874d 100644 --- a/bsp_q7s/devices/PlocSupervisorHandler.cpp +++ b/bsp_q7s/devices/PlocSupervisorHandler.cpp @@ -736,7 +736,7 @@ ReturnValue_t PlocSupervisorHandler::handleHkReport(const uint8_t* data) { nextReplyId = PLOC_SPV::EXE_REPORT; -#if OBSW_VERBOSE_LEVEL >= 1 && PLOC_SUPERVISOR_DEBUG == 1 +#if OBSW_VERBOSE_LEVEL >= 1 && OBSW_DEBUG_PLOC_SUPERVISOR == 1 sif::info << "PlocSupervisorHandler::handleHkReport: temp_ps: " << hkset.tempPs << std::endl; sif::info << "PlocSupervisorHandler::handleHkReport: temp_pl: " << hkset.tempPl << std::endl; sif::info << "PlocSupervisorHandler::handleHkReport: temp_sup: " << hkset.tempSup << std::endl; @@ -793,7 +793,7 @@ ReturnValue_t PlocSupervisorHandler::handleBootStatusReport(const uint8_t* data) nextReplyId = PLOC_SPV::EXE_REPORT; -#if OBSW_VERBOSE_LEVEL >= 1 && PLOC_SUPERVISOR_DEBUG == 1 +#if OBSW_VERBOSE_LEVEL >= 1 && OBSW_DEBUG_PLOC_SUPERVISOR == 1 sif::info << "PlocSupervisorHandler::handleBootStatusReport: Boot signal: " << static_cast(bootStatusReport.bootSignal.value) << std::endl; sif::info << "PlocSupervisorHandler::handleBootStatusReport: Reset counter: " @@ -868,7 +868,7 @@ ReturnValue_t PlocSupervisorHandler::handleLatchupStatusReport(const uint8_t* da nextReplyId = PLOC_SPV::EXE_REPORT; -#if OBSW_VERBOSE_LEVEL >= 1 && PLOC_SUPERVISOR_DEBUG == 1 +#if OBSW_VERBOSE_LEVEL >= 1 && OBSW_DEBUG_PLOC_SUPERVISOR == 1 sif::info << "PlocSupervisorHandler::handleLatchupStatusReport: Latchup ID: " << static_cast(latchupStatusReport.id.value) << std::endl; sif::info << "PlocSupervisorHandler::handleLatchupStatusReport: CNT0: " diff --git a/common/config/devConf.h b/common/config/devConf.h index f97567ac..e5201450 100644 --- a/common/config/devConf.h +++ b/common/config/devConf.h @@ -33,6 +33,8 @@ static constexpr spi::SpiModes RW_MODE = spi::SpiModes::MODE_0; namespace uart { +static constexpr uint32_t PLOC_MPSOC_BAUD = 115200; + } #endif /* COMMON_CONFIG_DEVCONF_H_ */ diff --git a/linux/devices/SusHandler.cpp b/linux/devices/SusHandler.cpp index c31160c4..67263756 100644 --- a/linux/devices/SusHandler.cpp +++ b/linux/devices/SusHandler.cpp @@ -173,7 +173,7 @@ ReturnValue_t SusHandler::interpretDeviceReply(DeviceCommandId_t id, dataset.ain3 = (*(packet + 8) << 8 | *(packet + 9)); dataset.ain4 = (*(packet + 10) << 8 | *(packet + 11)); dataset.ain5 = (*(packet + 12) << 8 | *(packet + 13)); -#if OBSW_VERBOSE_LEVEL >= 1 && DEBUG_SUS +#if OBSW_VERBOSE_LEVEL >= 1 && OBSW_DEBUG_SUS sif::info << "SUS object id 0x" << std::hex << this->getObjectId() << ", Temperature: " << dataset.temperatureCelcius << " °C" << std::endl; sif::info << "SUS object id 0x" << std::hex << this->getObjectId() << ", AIN0: " diff --git a/linux/fsfwconfig/OBSWConfig.h.in b/linux/fsfwconfig/OBSWConfig.h.in index e2693430..7d8334d2 100644 --- a/linux/fsfwconfig/OBSWConfig.h.in +++ b/linux/fsfwconfig/OBSWConfig.h.in @@ -1,14 +1,14 @@ /** - * @brief This file can be used to add preprocessor define for conditional - * code inclusion exclusion or various other project constants and - * properties in one place. + * @brief This file can be used to add preprocessor define for conditional + * code inclusion exclusion or various other project constants and + * properties in one place. */ #ifndef FSFWCONFIG_OBSWCONFIG_H_ #define FSFWCONFIG_OBSWCONFIG_H_ -#cmakedefine RASPBERRY_PI -#cmakedefine XIPHOS_Q7S -#cmakedefine BEAGLEBONEBLACK +/* #undef RASPBERRY_PI */ +#define XIPHOS_Q7S +/* #undef BEAGLEBONEBLACK */ #ifdef RASPBERRY_PI #include "rpiConfig.h" @@ -20,55 +20,64 @@ /* These defines should be disabled for mission code but are useful for debugging. */ -#define OBSW_VERBOSE_LEVEL 1 +#define OBSW_VERBOSE_LEVEL 1 + +//! Board defines +#define BOARD_TE0720 0 + +/*******************************************************************/ +/** All of the following flags should be enabled for mission code */ +/*******************************************************************/ //! Timers can mess up the code when debugging -//! TODO: Enable for mission code, disable for debug code -#define OBSW_ENABLE_TIMERS 0 +//! All of this should be enabled for mission code! +#define OBSW_ENABLE_TIMERS 1 +#define OBSW_ADD_GPS 0 +#define OBSW_ADD_STAR_TRACKER 0 +#define OBSW_ADD_PLOC_SUPERVISOR 0 +#define OBSW_ADD_PLOC_MPSOC 0 -#define OBSW_PRINT_MISSED_DEADLINES 1 -#define OBSW_ADD_TEST_CODE 1 -#define OBSW_ADD_TEST_PST 1 -#define OBSW_ADD_GPS 0 -#define OBSW_ADD_STAR_TRACKER 0 +/*******************************************************************/ +/** All of the following flags should be disabled for mission code */ +/*******************************************************************/ -#define TEST_LIBGPIOD 0 -#define TEST_RADIATION_SENSOR_HANDLER 0 -#define TEST_SUS_HANDLER 0 -#define TEST_PLOC_HANDLER 0 -#define TEST_CCSDS_BRIDGE 0 -#define PERFORM_PTME_TEST 0 -#define ADD_PLOC_SUPERVISOR 1 -#define ADD_PLOC_MPSOC 0 +//! /* Can be used to switch device to NORMAL mode immediately */ +#define OBSW_SWITCH_TO_NORMAL_MODE_AFTER_STARTUP 1 +#define OBSW_PRINT_MISSED_DEADLINES 1 +#define OBSW_ADD_TEST_CODE 1 +#define OBSW_ADD_TEST_PST 0 +#define OBSW_TEST_LIBGPIOD 0 +#define OBSW_TEST_RADIATION_SENSOR_HANDLER 0 +#define OBSW_TEST_SUS_HANDLER 0 +#define OBSW_TEST_PLOC_HANDLER 0 +#define OBSW_TEST_CCSDS_BRIDGE 0 +#define OBSW_TEST_CCSDS_PTME 0 +#define OBSW_TEST_TE7020_HEATER 0 -#define BOARD_TE0720 0 -#define TE0720_HEATER_TEST 0 - -#define P60DOCK_DEBUG 0 -#define PDU1_DEBUG 0 -#define PDU2_DEBUG 0 -#define ACU_DEBUG 0 -#define SYRLINKS_DEBUG 0 -#define IMQT_DEBUG 0 -#define ADIS16507_DEBUG 1 -#define L3GD20_GYRO_DEBUG 0 -#define DEBUG_RAD_SENSOR 0 -#define DEBUG_SUS 1 -#define DEBUG_RTD 1 -#define IMTQ_DEBUG 1 -#define RW_DEBUG 0 -#define START_TRACKER_DEBUG 0 -#define PLOC_MPSOC_DEBUG 0 -#define PLOC_SUPERVISOR_DEBUG 1 +#define OBSW_DEBUG_P60DOCK 0 +#define OBSW_DEBUG_PDU1 0 +#define OBSW_DEBUG_PDU2 0 +#define OBSW_DEBUG_ACU 0 +#define OBSW_DEBUG_SYRLINKS 0 +#define OBSW_DEBUG_IMQT 0 +#define OBSW_DEBUG_ADIS16507 0 +#define OBSW_DEBUG_L3GD20_GYRO 0 +#define OBSW_DEBUG_RAD_SENSOR 0 +#define OBSW_DEBUG_SUS 0 +#define OBSW_DEBUG_RTD 0 +#define OBSW_DEBUG_RW 0 +#define OBSW_DEBUG_STARTRACKER 0 +#define OBSW_DEBUG_PLOC_MPSOC 0 +#define OBSW_DEBUG_PLOC_SUPERVISOR 0 +/*******************************************************************/ +/** Hardcoded */ +/*******************************************************************/ // Leave at one as the BSP is linux. Used by the ADIS16507 device handler #define OBSW_ADIS16507_LINUX_COM_IF 1 #include "OBSWVersion.h" -/* Can be used to switch device to NORMAL mode immediately */ -#define OBSW_SWITCH_TO_NORMAL_MODE_AFTER_STARTUP 1 - #ifdef __cplusplus #include "objects/systemObjectList.h" diff --git a/linux/fsfwconfig/pollingsequence/pollingSequenceFactory.cpp b/linux/fsfwconfig/pollingsequence/pollingSequenceFactory.cpp index 2e2466f7..819f40a9 100644 --- a/linux/fsfwconfig/pollingsequence/pollingSequenceFactory.cpp +++ b/linux/fsfwconfig/pollingsequence/pollingSequenceFactory.cpp @@ -520,7 +520,7 @@ ReturnValue_t pst::pstUart(FixedTimeslotTaskIF *thisSequence) { // Length of a communication cycle uint32_t length = thisSequence->getPeriodMs(); -#if ADD_PLOC_MPSOC == 1 +#if OBSW_ADD_PLOC_MPSOC == 1 thisSequence->addSlot(objects::PLOC_MPSOC_HANDLER, length * 0, DeviceHandlerIF::PERFORM_OPERATION); thisSequence->addSlot(objects::PLOC_MPSOC_HANDLER, length * 0.2, @@ -533,7 +533,7 @@ ReturnValue_t pst::pstUart(FixedTimeslotTaskIF *thisSequence) { DeviceHandlerIF::GET_READ); #endif -#if ADD_PLOC_SUPERVISOR == 1 +#if OBSW_ADD_PLOC_SUPERVISOR == 1 thisSequence->addSlot(objects::PLOC_SUPERVISOR_HANDLER, length * 0, DeviceHandlerIF::PERFORM_OPERATION); thisSequence->addSlot(objects::PLOC_SUPERVISOR_HANDLER, length * 0.2, @@ -793,7 +793,7 @@ ReturnValue_t pst::pollingSequenceTE0720(FixedTimeslotTaskIF *thisSequence) { thisSequence->addSlot(objects::PLOC_MPSOC_HANDLER, length * 0.8, DeviceHandlerIF::GET_READ); #endif -#if TEST_RADIATION_SENSOR_HANDLER == 1 +#if OBSW_TEST_RADIATION_SENSOR_HANDLER == 1 thisSequence->addSlot(objects::RAD_SENSOR, length * 0, DeviceHandlerIF::PERFORM_OPERATION); thisSequence->addSlot(objects::RAD_SENSOR, length * 0.2, DeviceHandlerIF::SEND_WRITE); thisSequence->addSlot(objects::RAD_SENSOR, length * 0.4, DeviceHandlerIF::GET_WRITE); @@ -801,7 +801,7 @@ ReturnValue_t pst::pollingSequenceTE0720(FixedTimeslotTaskIF *thisSequence) { thisSequence->addSlot(objects::RAD_SENSOR, length * 0.8, DeviceHandlerIF::GET_READ); #endif -#if TEST_SUS_HANDLER == 1 +#if OBSW_TEST_SUS_HANDLER == 1 /* Write setup */ thisSequence->addSlot(objects::SUS_1, length * 0.901, DeviceHandlerIF::PERFORM_OPERATION); thisSequence->addSlot(objects::SUS_1, length * 0.902, SusHandler::FIRST_WRITE); @@ -824,7 +824,7 @@ ReturnValue_t pst::pollingSequenceTE0720(FixedTimeslotTaskIF *thisSequence) { thisSequence->addSlot(objects::SUS_1, length * 0.915, DeviceHandlerIF::GET_READ); #endif -#if ADD_PLOC_SUPERVISOR == 1 +#if OBSW_ADD_PLOC_SUPERVISOR == 1 thisSequence->addSlot(objects::PLOC_SUPERVISOR_HANDLER, length * 0, DeviceHandlerIF::PERFORM_OPERATION); thisSequence->addSlot(objects::PLOC_SUPERVISOR_HANDLER, length * 0.2, DeviceHandlerIF::SEND_WRITE); thisSequence->addSlot(objects::PLOC_SUPERVISOR_HANDLER, length * 0.4, DeviceHandlerIF::GET_WRITE); diff --git a/linux/obc/CCSDSIPCoreBridge.cpp b/linux/obc/CCSDSIPCoreBridge.cpp index 2678e76f..fe5a7007 100644 --- a/linux/obc/CCSDSIPCoreBridge.cpp +++ b/linux/obc/CCSDSIPCoreBridge.cpp @@ -39,7 +39,7 @@ ReturnValue_t CCSDSIPCoreBridge::initialize() { ReturnValue_t CCSDSIPCoreBridge::handleTm() { -#if PERFORM_PTME_TEST == 1 +#if OBSW_TEST_CCSDS_PTME == 1 return sendTestFrame(); #else return TmTcBridge::handleTm(); diff --git a/mission/devices/ACUHandler.cpp b/mission/devices/ACUHandler.cpp index 3d5d82e8..24bd52fe 100644 --- a/mission/devices/ACUHandler.cpp +++ b/mission/devices/ACUHandler.cpp @@ -21,7 +21,7 @@ void ACUHandler::letChildHandleHkReply(DeviceCommandId_t id, const uint8_t *pack parseHkTableReply(packet); handleDeviceTM(&acuHkTableDataset, id, true); -#if OBSW_ENHANCED_PRINTOUT == 1 && ACU_DEBUG == 1 +#if OBSW_ENHANCED_PRINTOUT == 1 && OBSW_DEBUG_ACU == 1 acuHkTableDataset.read(); float temperatureC_1 = acuHkTableDataset.temperature1.value * 0.1; float temperatureC_2 = acuHkTableDataset.temperature2.value * 0.1; diff --git a/mission/devices/GyroADIS16507Handler.cpp b/mission/devices/GyroADIS16507Handler.cpp index ad20e65b..3065c249 100644 --- a/mission/devices/GyroADIS16507Handler.cpp +++ b/mission/devices/GyroADIS16507Handler.cpp @@ -16,7 +16,7 @@ GyroADIS16507Handler::GyroADIS16507Handler(object_id_t objectId, object_id_t deviceCommunication, CookieIF * comCookie): DeviceHandlerBase(objectId, deviceCommunication, comCookie), primaryDataset(this), configDataset(this), breakCountdown() { -#if ADIS16507_DEBUG == 1 +#if OBSW_DEBUG_ADIS16507 == 1 debugDivider = new PeriodicOperationDivider(5); #endif @@ -284,7 +284,7 @@ ReturnValue_t GyroADIS16507Handler::handleSensorData(const uint8_t *packet) { primaryDataset.setValidity(true, true); } -#if ADIS16507_DEBUG == 1 +#if OBSW_DEBUG_ADIS16507 == 1 if(debugDivider->checkAndIncrement()) { sif::info << "GyroADIS16507Handler: Angular velocities in deg / s" << std::endl; sif::info << "X: " << primaryDataset.angVelocX.value << std::endl; diff --git a/mission/devices/GyroADIS16507Handler.h b/mission/devices/GyroADIS16507Handler.h index faab3e5d..41be5734 100644 --- a/mission/devices/GyroADIS16507Handler.h +++ b/mission/devices/GyroADIS16507Handler.h @@ -69,7 +69,7 @@ private: const uint8_t *sendData, size_t sendLen, void* args); #endif -#if ADIS16507_DEBUG == 1 +#if OBSW_DEBUG_ADIS16507 == 1 PeriodicOperationDivider* debugDivider; #endif Countdown breakCountdown; diff --git a/mission/devices/IMTQHandler.cpp b/mission/devices/IMTQHandler.cpp index c75f7fde..125040d7 100644 --- a/mission/devices/IMTQHandler.cpp +++ b/mission/devices/IMTQHandler.cpp @@ -683,7 +683,7 @@ void IMTQHandler::fillEngHkDataset(const uint8_t* packet) { offset += 2; engHkDataset.mcuTemperature = (*(packet + offset + 1) << 8 | *(packet + offset)); -#if OBSW_VERBOSE_LEVEL >= 1 && IMTQ_DEBUG == 1 +#if OBSW_VERBOSE_LEVEL >= 1 && OBSW_DEBUG_IMTQ == 1 sif::info << "IMTQ digital voltage: " << engHkDataset.digitalVoltageMv << " mV" << std::endl; sif::info << "IMTQ analog voltage: " << engHkDataset.analogVoltageMv << " mV" << std::endl; sif::info << "IMTQ digital current: " << engHkDataset.digitalCurrentmA << " mA" << std::endl; @@ -757,7 +757,7 @@ void IMTQHandler::fillCalibratedMtmDataset(const uint8_t* packet) { offset += 4; calMtmMeasurementSet.coilActuationStatus = (*(packet + offset + 3) << 24) | (*(packet + offset + 2) << 16) | (*(packet + offset + 1) << 8) | (*(packet + offset)); -#if OBSW_VERBOSE_LEVEL >= 1 && IMTQ_DEBUG == 1 +#if OBSW_VERBOSE_LEVEL >= 1 && OBSW_DEBUG_IMTQ == 1 sif::info << "IMTQ calibrated MTM measurement X: " << calMtmMeasurementSet.mtmXnT << " nT" << std::endl; sif::info << "IMTQ calibrated MTM measurement Y: " << calMtmMeasurementSet.mtmYnT << " nT" @@ -783,7 +783,7 @@ void IMTQHandler::fillRawMtmDataset(const uint8_t* packet) { offset += 4; rawMtmMeasurementSet.coilActuationStatus = (*(packet + offset + 3) << 24) | (*(packet + offset + 2) << 16) | (*(packet + offset + 1) << 8) | (*(packet + offset)); -#if OBSW_VERBOSE_LEVEL >= 1 && IMTQ_DEBUG == 1 +#if OBSW_VERBOSE_LEVEL >= 1 && OBSW_DEBUG_IMTQ == 1 sif::info << "IMTQ raw MTM measurement X: " << rawMtmMeasurementSet.mtmXnT << " nT" << std::endl; sif::info << "IMTQ raw MTM measurement Y: " << rawMtmMeasurementSet.mtmYnT << " nT" @@ -946,7 +946,7 @@ void IMTQHandler::handlePositiveXSelfTestReply(const uint8_t* packet) { posXselfTestDataset.finaCoilZTemperature = *(packet + offset + 1) << 8 | *(packet + offset); offset += 4; -#if OBSW_VERBOSE_LEVEL >= 1 && IMTQ_DEBUG == 1 +#if OBSW_VERBOSE_LEVEL >= 1 && OBSW_DEBUG_IMTQ == 1 sif::info << "IMTQ self test (INIT) err: " << static_cast(posXselfTestDataset.initErr.value) << std::endl; sif::info << "IMTQ self test (INIT) raw magnetic field X: " << posXselfTestDataset.initRawMagX @@ -1147,7 +1147,7 @@ void IMTQHandler::handleNegativeXSelfTestReply(const uint8_t* packet) { negXselfTestDataset.finaCoilZTemperature = *(packet + offset + 1) << 8 | *(packet + offset); offset += 4; -#if OBSW_VERBOSE_LEVEL >= 1 && IMTQ_DEBUG == 1 +#if OBSW_VERBOSE_LEVEL >= 1 && OBSW_DEBUG_IMTQ == 1 sif::info << "IMTQ self test (INIT) err: " << static_cast(negXselfTestDataset.initErr.value) << std::endl; sif::info << "IMTQ self test (INIT) raw magnetic field X: " << negXselfTestDataset.initRawMagX @@ -1348,7 +1348,7 @@ void IMTQHandler::handlePositiveYSelfTestReply(const uint8_t* packet) { posYselfTestDataset.finaCoilZTemperature = *(packet + offset + 1) << 8 | *(packet + offset); offset += 4; -#if OBSW_VERBOSE_LEVEL >= 1 && IMTQ_DEBUG == 1 +#if OBSW_VERBOSE_LEVEL >= 1 && OBSW_DEBUG_IMTQ == 1 sif::info << "IMTQ self test (INIT) err: " << static_cast(posYselfTestDataset.initErr.value) << std::endl; sif::info << "IMTQ self test (INIT) raw magnetic field X: " << posYselfTestDataset.initRawMagX @@ -1549,7 +1549,7 @@ void IMTQHandler::handleNegativeYSelfTestReply(const uint8_t* packet) { negYselfTestDataset.finaCoilZTemperature = *(packet + offset + 1) << 8 | *(packet + offset); offset += 4; -#if OBSW_VERBOSE_LEVEL >= 1 && IMTQ_DEBUG == 1 +#if OBSW_VERBOSE_LEVEL >= 1 && OBSW_DEBUG_IMTQ == 1 sif::info << "IMTQ self test (INIT) err: " << static_cast(negYselfTestDataset.initErr.value) << std::endl; sif::info << "IMTQ self test (INIT) raw magnetic field X: " << negYselfTestDataset.initRawMagX @@ -1750,7 +1750,7 @@ void IMTQHandler::handlePositiveZSelfTestReply(const uint8_t* packet) { posZselfTestDataset.finaCoilZTemperature = *(packet + offset + 1) << 8 | *(packet + offset); offset += 4; -#if OBSW_VERBOSE_LEVEL >= 1 && IMTQ_DEBUG == 1 +#if OBSW_VERBOSE_LEVEL >= 1 && OBSW_DEBUG_IMTQ == 1 sif::info << "IMTQ self test (INIT) err: " << static_cast(posZselfTestDataset.initErr.value) << std::endl; sif::info << "IMTQ self test (INIT) raw magnetic field X: " << posZselfTestDataset.initRawMagX @@ -1951,7 +1951,7 @@ void IMTQHandler::handleNegativeZSelfTestReply(const uint8_t* packet) { negZselfTestDataset.finaCoilZTemperature = *(packet + offset + 1) << 8 | *(packet + offset); offset += 4; -#if OBSW_VERBOSE_LEVEL >= 1 && IMTQ_DEBUG == 1 +#if OBSW_VERBOSE_LEVEL >= 1 && OBSW_DEBUG_IMTQ == 1 sif::info << "IMTQ self test (INIT) err: " << static_cast(negZselfTestDataset.initErr.value) << std::endl; sif::info << "IMTQ self test (INIT) raw magnetic field X: " << negZselfTestDataset.initRawMagX diff --git a/mission/devices/Max31865PT1000Handler.cpp b/mission/devices/Max31865PT1000Handler.cpp index fad0fc39..ac33e01d 100644 --- a/mission/devices/Max31865PT1000Handler.cpp +++ b/mission/devices/Max31865PT1000Handler.cpp @@ -325,7 +325,7 @@ ReturnValue_t Max31865PT1000Handler::interpretDeviceReply( case(Max31865Definitions::REQUEST_LOW_THRESHOLD): { uint16_t readLowThreshold = packet[0] << 8 | packet[1]; if(readLowThreshold != LOW_THRESHOLD) { -#if FSFW_CPP_OSTREAM_ENABLED == 1 && DEBUG_RTD == 1 +#if FSFW_CPP_OSTREAM_ENABLED == 1 && OBSW_DEBUG_RTD == 1 sif::error << "Max31865PT1000Handler::interpretDeviceReply: Missmatch between written " << "and readback value of low threshold register" @@ -338,7 +338,7 @@ ReturnValue_t Max31865PT1000Handler::interpretDeviceReply( case(Max31865Definitions::REQUEST_HIGH_THRESHOLD): { uint16_t readHighThreshold = packet[0] << 8 | packet[1]; if(readHighThreshold != HIGH_THRESHOLD) { -#if FSFW_CPP_OSTREAM_ENABLED == 1 && DEBUG_RTD == 1 +#if FSFW_CPP_OSTREAM_ENABLED == 1 && OBSW_DEBUG_RTD == 1 sif::error << "Max31865PT1000Handler::interpretDeviceReply: Missmatch between written " << "and readback value of high threshold register" diff --git a/mission/devices/P60DockHandler.cpp b/mission/devices/P60DockHandler.cpp index 305606d9..357bee30 100644 --- a/mission/devices/P60DockHandler.cpp +++ b/mission/devices/P60DockHandler.cpp @@ -25,7 +25,7 @@ void P60DockHandler::letChildHandleHkReply(DeviceCommandId_t id, const uint8_t * */ handleDeviceTM(&p60dockHkTableDataset, id, true); -#if OBSW_VERBOSE_LEVEL >= 1 && P60DOCK_DEBUG == 1 +#if OBSW_VERBOSE_LEVEL >= 1 && OBSW_DEBUG_P60DOCK == 1 p60dockHkTableDataset.read(); sif::info << "P60 Dock: ACU VCC switch: " << static_cast(p60dockHkTableDataset.outputEnableStateAcuVcc.value) << std::endl; sif::info << "P60 Dock: PDU1 VCC switch: " << static_cast(p60dockHkTableDataset.outputEnableStatePdu1Vcc.value) << std::endl; diff --git a/mission/devices/PDU1Handler.cpp b/mission/devices/PDU1Handler.cpp index b18e0f79..f6bd938a 100644 --- a/mission/devices/PDU1Handler.cpp +++ b/mission/devices/PDU1Handler.cpp @@ -22,7 +22,7 @@ void PDU1Handler::letChildHandleHkReply(DeviceCommandId_t id, const uint8_t *pac parseHkTableReply(packet); handleDeviceTM(&pdu1HkTableDataset, id, true); -#if OBSW_VERBOSE_LEVEL >= 1 && PDU1_DEBUG == 1 +#if OBSW_VERBOSE_LEVEL >= 1 && OBSW_DEBUG_PDU1 == 1 pdu1HkTableDataset.read(); sif::info << "PDU1 TCS Board voltage: " << pdu1HkTableDataset.voltageOutTCSBoard3V3 << std::endl; diff --git a/mission/devices/PDU2Handler.cpp b/mission/devices/PDU2Handler.cpp index 798a6d67..47fab6b6 100644 --- a/mission/devices/PDU2Handler.cpp +++ b/mission/devices/PDU2Handler.cpp @@ -26,7 +26,7 @@ void PDU2Handler::letChildHandleHkReply(DeviceCommandId_t id, const uint8_t *pac */ handleDeviceTM(&pdu2HkTableDataset, id, true); -#if OBSW_VERBOSE_LEVEL >= 1 && PDU2_DEBUG == 1 +#if OBSW_VERBOSE_LEVEL >= 1 && OBSW_DEBUG_PDU2 == 1 pdu2HkTableDataset.read(); sif::info << "PDU2 Q7S current voltage: " << pdu2HkTableDataset.voltageOutQ7S << " mV" << std::endl; sif::info << "PDU2 VCC: " << pdu2HkTableDataset.vcc << " mV" << std::endl; diff --git a/mission/devices/RadiationSensorHandler.cpp b/mission/devices/RadiationSensorHandler.cpp index bb5176ee..95f045d8 100644 --- a/mission/devices/RadiationSensorHandler.cpp +++ b/mission/devices/RadiationSensorHandler.cpp @@ -147,7 +147,7 @@ ReturnValue_t RadiationSensorHandler::interpretDeviceReply(DeviceCommandId_t id, offset += 2; dataset.ain7 = (*(packet + offset) << 8 | *(packet + offset + 1)); -#if OBSW_VERBOSE_LEVEL >= 1 && DEBUG_RAD_SENSOR +#if OBSW_VERBOSE_LEVEL >= 1 && OBSW_DEBUG_RAD_SENSOR sif::info << "Radiation sensor temperature: " << dataset.temperatureCelcius << " °C" << std::endl; sif::info << "Radiation sensor ADC value channel 0: " << dataset.ain0 diff --git a/mission/devices/RwHandler.cpp b/mission/devices/RwHandler.cpp index 81bb69ac..571f7eca 100644 --- a/mission/devices/RwHandler.cpp +++ b/mission/devices/RwHandler.cpp @@ -347,7 +347,7 @@ void RwHandler::handleResetStatusReply(const uint8_t* packet) { lastResetStatusSet.lastResetStatus = resetStatus; } lastResetStatusSet.currentResetStatus = resetStatus; -#if OBSW_VERBOSE_LEVEL >= 1 && RW_DEBUG == 1 +#if OBSW_VERBOSE_LEVEL >= 1 && OBSW_DEBUG_RW == 1 sif::info << "RwHandler::handleResetStatusReply: Last reset status: " << static_cast(lastResetStatusSet.lastResetStatus.value) << std::endl; sif::info << "RwHandler::handleResetStatusReply: Current reset status: " @@ -378,7 +378,7 @@ void RwHandler::handleGetRwStatusReply(const uint8_t* packet) { << std::endl; } -#if OBSW_VERBOSE_LEVEL >= 1 && RW_DEBUG == 1 +#if OBSW_VERBOSE_LEVEL >= 1 && OBSW_DEBUG_RW == 1 sif::info << "RwHandler::handleGetRwStatusReply: Current speed is: " << statusSet.currSpeed << " * 0.1 RPM" << std::endl; sif::info << "RwHandler::handleGetRwStatusReply: Reference speed is: " @@ -395,7 +395,7 @@ void RwHandler::handleTemperatureReply(const uint8_t* packet) { uint8_t offset = 2; temperatureSet.temperatureCelcius = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 | *(packet + offset + 1) << 8 | *(packet + offset); -#if OBSW_VERBOSE_LEVEL >= 1 && RW_DEBUG == 1 +#if OBSW_VERBOSE_LEVEL >= 1 && OBSW_DEBUG_RW == 1 sif::info << "RwHandler::handleTemperatureReply: Temperature: " << temperatureSet.temperatureCelcius << " °C" << std::endl; #endif @@ -472,7 +472,7 @@ void RwHandler::handleGetTelemetryReply(const uint8_t* packet) { offset += 4; tmDataset.spiTotalNumOfErrors = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 | *(packet + offset + 1) << 8 | *(packet + offset); -#if OBSW_VERBOSE_LEVEL >= 1 && RW_DEBUG == 1 +#if OBSW_VERBOSE_LEVEL >= 1 && OBSW_DEBUG_RW == 1 sif::info << "RwHandler::handleTemperatureReply: Last reset status: " << static_cast(tmDataset.lastResetStatus.value) << std::endl; sif::info << "RwHandler::handleTemperatureReply: MCU temperature: " << tmDataset.mcuTemperature diff --git a/mission/devices/StarTrackerHandler.cpp b/mission/devices/StarTrackerHandler.cpp index 48236cf7..a695403f 100644 --- a/mission/devices/StarTrackerHandler.cpp +++ b/mission/devices/StarTrackerHandler.cpp @@ -207,7 +207,7 @@ void StarTrackerHandler::handleTemperatureTm() { temperatureSet.cmosTemperature = *(decodedFrame + offset) << 24 | *(decodedFrame + offset + 1) << 16 | *(decodedFrame + offset + 2) << 8 | *(decodedFrame + offset + 3); -#if OBSW_VERBOSE_LEVEL >= 1 && START_TRACKER_DEBUG == 1 +#if OBSW_VERBOSE_LEVEL >= 1 && OBSW_DEBUG_STARTRACKER == 1 sif::info << "StarTrackerHandler::handleTemperatureTm: MCU Temperature: " << temperatureSet.mcuTemperature << " °C" << std::endl; sif::info << "StarTrackerHandler::handleTemperatureTm: CMOS Temperature: " diff --git a/mission/devices/SyrlinksHkHandler.cpp b/mission/devices/SyrlinksHkHandler.cpp index e55755e4..9f359bd1 100644 --- a/mission/devices/SyrlinksHkHandler.cpp +++ b/mission/devices/SyrlinksHkHandler.cpp @@ -384,7 +384,7 @@ void SyrlinksHkHandler::parseRxStatusRegistersReply(const uint8_t* packet) { offset += 6; rxDataset.rxDataRate = convertHexStringToUint8(reinterpret_cast(packet + offset)); -#if OBSW_VERBOSE_LEVEL >= 1 && SYRLINKS_DEBUG == 1 +#if OBSW_VERBOSE_LEVEL >= 1 && OBSW_DEBUG_SYRLINKS == 1 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; @@ -400,7 +400,7 @@ void SyrlinksHkHandler::parseTxStatusReply(const uint8_t* packet) { PoolReadGuard readHelper(&txDataset); uint16_t offset = SYRLINKS::MESSAGE_HEADER_SIZE; txDataset.txStatus = convertHexStringToUint8(reinterpret_cast(packet + offset)); -#if OBSW_VERBOSE_LEVEL >= 1 && SYRLINKS_DEBUG == 1 +#if OBSW_VERBOSE_LEVEL >= 1 && OBSW_DEBUG_SYRLINKS == 1 sif::info << "Syrlinks TX Status: 0x" << std::hex << (unsigned int) txDataset.txStatus.value << std::endl; #endif @@ -410,7 +410,7 @@ void SyrlinksHkHandler::parseTxWaveformReply(const uint8_t* packet) { PoolReadGuard readHelper(&txDataset); uint16_t offset = SYRLINKS::MESSAGE_HEADER_SIZE; txDataset.txWaveform = convertHexStringToUint8(reinterpret_cast(packet + offset)); -#if OBSW_VERBOSE_LEVEL >= 1 && SYRLINKS_DEBUG == 1 +#if OBSW_VERBOSE_LEVEL >= 1 && OBSW_DEBUG_SYRLINKS == 1 sif::info << "Syrlinks TX Waveform: 0x" << std::hex << (unsigned int) txDataset.txWaveform.value << std::endl; #endif @@ -420,7 +420,7 @@ void SyrlinksHkHandler::parseAgcLowByte(const uint8_t* packet) { PoolReadGuard readHelper(&txDataset); uint16_t offset = SYRLINKS::MESSAGE_HEADER_SIZE; txDataset.txAgcValue = agcValueHighByte << 8 | convertHexStringToUint8(reinterpret_cast(packet + offset)); -#if OBSW_VERBOSE_LEVEL >= 1 && SYRLINKS_DEBUG == 1 +#if OBSW_VERBOSE_LEVEL >= 1 && OBSW_DEBUG_SYRLINKS == 1 sif::info << "Syrlinks TX AGC Value: " << txDataset.txAgcValue << std::endl; #endif } -- 2.43.0 From 2f72b4e42a56880c746462a22a66c2da2b3221fe Mon Sep 17 00:00:00 2001 From: IRS Cleanroom Laptop Date: Tue, 17 Aug 2021 19:50:48 +0200 Subject: [PATCH 23/43] cleaned up --- bsp_q7s/boardconfig/busConf.h | 49 +++++- bsp_q7s/core/ObjectFactory.cpp | 273 ++++++++++++++--------------- bsp_q7s/core/ObjectFactory.h | 6 +- common/config/commonObjects.h | 8 +- common/config/devConf.h | 4 + fsfw | 2 +- linux/boardtest/SpiTestClass.cpp | 4 +- linux/fsfwconfig/devices/gpioIds.h | 139 +++++++-------- tmtc | 2 +- 9 files changed, 266 insertions(+), 221 deletions(-) diff --git a/bsp_q7s/boardconfig/busConf.h b/bsp_q7s/boardconfig/busConf.h index 27f44b04..b70060f5 100644 --- a/bsp_q7s/boardconfig/busConf.h +++ b/bsp_q7s/boardconfig/busConf.h @@ -3,15 +3,54 @@ namespace q7s { -static constexpr char SPI_DEFAULT_DEV[] = "dev/spidev2.0"; -static constexpr char SPI_RW_DEV[] = "dev/spidev3.0"; +static constexpr char SPI_DEFAULT_DEV[] = "/dev/spidev2.0"; +static constexpr char SPI_RW_DEV[] = "/dev/spidev3.0"; -static constexpr char I2C_DEFAULT_DEV[] = "/dev/i2c-0"; +static constexpr char I2C_DEFAULT_DEV[] = "/dev/i2c-1"; static constexpr char UART_PLOC_MPSOC_DEV[] = "/dev/ttyUL3"; +static constexpr char UART_PLOC_SUPERVSIOR_DEV[] = "/dev/ttyUL4"; +static constexpr char UART_STAR_TRACKER_DEV[] = "/dev/ttyUL8"; +static constexpr char GPIO_ACS_BOARD_DEFAULT_CHIP[] = "gpiochip5"; +static constexpr char GPIO_MGM2_LIS3_CHIP[] = "gpiochip6"; + +// TODO: Determine new pins, additional ADIS gyro device +static constexpr uint32_t GPIO_GYRO_0_ADIS_CS = 1; +static constexpr uint32_t GPIO_GYRO_1_L3G_CS = 7; +static constexpr uint32_t GPIO_GYRO_2_ADIS_CS = 3; +static constexpr uint32_t GPIO_GYRO_3_L3G_CS = 3; + +static constexpr uint32_t GPIO_MGM_0_LIS3_CS = 5; +static constexpr uint32_t GPIO_MGM_1_RM3100_CS = 16; +static constexpr uint32_t GPIO_MGM_2_LIS3_CS = 0; +static constexpr uint32_t GPIO_MGM_3_RM3100_CS = 10; + +static constexpr char GPIO_RW_DEFAULT_CHIP[] = "gpiochip5"; +static constexpr uint32_t GPIO_RW_0_CS = 7; +static constexpr uint32_t GPIO_RW_1_CS = 3; +static constexpr uint32_t GPIO_RW_2_CS = 11; +static constexpr uint32_t GPIO_RW_3_CS = 6; + +static constexpr char GPIO_RW_SPI_MUX_CHIP[] = "gpiochip11"; +static constexpr uint32_t GPIO_RW_SPI_MUX_CS = 57; + +static constexpr char GPIO_HEATER_CHIP[] = "gpiochip7"; +static constexpr uint32_t GPIO_HEATER_0_PIN = 6; +static constexpr uint32_t GPIO_HEATER_1_PIN = 12; +static constexpr uint32_t GPIO_HEATER_2_PIN = 7; +static constexpr uint32_t GPIO_HEATER_3_PIN = 5; +static constexpr uint32_t GPIO_HEATER_4_PIN = 3; +static constexpr uint32_t GPIO_HEATER_5_PIN = 0; +static constexpr uint32_t GPIO_HEATER_6_PIN = 1; +static constexpr uint32_t GPIO_HEATER_7_PIN = 11; + +static constexpr char GPIO_SOLAR_ARR_DEPL_CHIP[] = "gpiochip7"; +static constexpr uint32_t GPIO_SOL_DEPL_SA_0_PIN = 4; +static constexpr uint32_t GPIO_SOL_DEPL_SA_1_PIN = 2; + +static constexpr char GPIO_RAD_SENSOR_CHIP[] = "gpiochip5"; +static constexpr uint32_t GPIO_RAD_SENSOR_CS = 19; } - - #endif /* BSP_Q7S_BOARDCONFIG_BUSCONF_H_ */ diff --git a/bsp_q7s/core/ObjectFactory.cpp b/bsp_q7s/core/ObjectFactory.cpp index 1f9cccca..0faa6562 100644 --- a/bsp_q7s/core/ObjectFactory.cpp +++ b/bsp_q7s/core/ObjectFactory.cpp @@ -21,6 +21,7 @@ #include "linux/devices/SusHandler.h" #include "linux/csp/CspCookie.h" #include "linux/csp/CspComIF.h" +#include "linux/obc/CCSDSIPCoreBridge.h" #include "mission/core/GenericFactory.h" #include "mission/devices/PDU1Handler.h" @@ -44,10 +45,9 @@ #include "mission/devices/devicedefinitions/RadSensorDefinitions.h" #include "mission/devices/devicedefinitions/Max31865Definitions.h" #include "mission/devices/devicedefinitions/RwDefinitions.h" -#include -#include +#include "mission/devices/devicedefinitions/StarTrackerDefinitions.h" +#include "mission/devices/GPSHyperionHandler.h" #include "mission/utility/TmFunnel.h" -#include "linux/obc/CCSDSIPCoreBridge.h" #include "fsfw_hal/linux/uart/UartComIF.h" #include "fsfw_hal/linux/uart/UartCookie.h" @@ -107,13 +107,14 @@ void ObjectFactory::produce(void* args){ new CoreController(objects::CORE_CONTROLLER); LinuxLibgpioIF* gpioComIF = nullptr; UartComIF* uartComIF = nullptr; - createCommunicationInterfaces(&gpioComIF, &uartComIF); + SpiComIF* spiComIF = nullptr; + createCommunicationInterfaces(&gpioComIF, &uartComIF, &spiComIF); createTmpComponents(); #if BOARD_TE0720 == 0 createPcduComponents(); createRadSensorComponent(gpioComIF); - createSunSensorComponents(gpioComIF); + createSunSensorComponents(gpioComIF, spiComIF); #if OBSW_ADD_ACS_BOARD == 1 createAcsBoardComponents(gpioComIF, uartComIF); #endif /* OBSW_ADD_ACS_BOARD == 1 */ @@ -130,13 +131,6 @@ void ObjectFactory::produce(void* args){ I2cCookie* imtqI2cCookie = new I2cCookie(addresses::IMTQ, IMTQ::MAX_REPLY_SIZE, q7s::I2C_DEFAULT_DEV); new IMTQHandler(objects::IMTQ_HANDLER, objects::I2C_COM_IF, imtqI2cCookie); - -#if OBSW_ADD_PLOC_MPSOC == 1 - UartCookie* mpsocUartCookie = new UartCookie(objects::RW1, q7s::UART_PLOC_MPSOC_DEV, - UartModes::NON_CANONICAL, uart::PLOC_MPSOC_BAUD, PLOC_MPSOC::MAX_REPLY_SIZE); - new PlocMPSoCHandler(objects::PLOC_MPSOC_HANDLER, objects::UART_COM_IF, mpsocUartCookie); -#endif /* OBSW_ADD_PLOC_MPSOC */ - createReactionWheelComponents(gpioComIF); #endif /* TE7020 != 0 */ @@ -160,27 +154,28 @@ void ObjectFactory::produce(void* args){ new FileSystemHandler(objects::FILE_SYSTEM_HANDLER); #if OBSW_ADD_PLOC_MPSOC == 1 - UartCookie* plocMpsocCookie = new UartCookie(objects::RW1, std::string("/dev/ttyUL3"), - UartModes::NON_CANONICAL, 115200, PLOC_MPSOC::MAX_REPLY_SIZE); + UartCookie* plocMpsocCookie = new UartCookie(objects::PLOC_MPSOC_HANDLER, + q7s::UART_PLOC_MPSOC_DEV, UartModes::NON_CANONICAL, uart::PLOC_MPSOC_BAUD, + PLOC_MPSOC::MAX_REPLY_SIZE); new PlocMPSoCHandler(objects::PLOC_MPSOC_HANDLER, objects::UART_COM_IF, plocMpsocCookie); #endif -#if OBSW_ADD_STAR_TRACKER == 1 - UartCookie* starTrackerCookie = new UartCookie(objects::START_TRACKER, std::string("/dev/ttyUL8"), - UartModes::NON_CANONICAL, 115200, StarTracker::MAX_FRAME_SIZE* 2 + 2); - starTrackerCookie->setNoFixedSizeReply(); - new StarTrackerHandler(objects::START_TRACKER, objects::UART_COM_IF, starTrackerCookie); -#endif - #if OBSW_ADD_PLOC_SUPERVISOR == 1 UartCookie* plocSupervisorCookie = new UartCookie(objects::PLOC_SUPERVISOR_HANDLER, - std::string("/dev/ttyUL4"), UartModes::NON_CANONICAL, 115200, + q7s::UART_PLOC_SUPERVSIOR_DEV, UartModes::NON_CANONICAL, uart::PLOC_SUPERVISOR_BAUD, PLOC_SPV::MAX_PACKET_SIZE * 20); plocSupervisorCookie->setNoFixedSizeReply(); PlocSupervisorHandler* plocSupervisor = new PlocSupervisorHandler( objects::PLOC_SUPERVISOR_HANDLER, objects::UART_COM_IF, plocSupervisorCookie); plocSupervisor->setStartUpImmediately(); +#endif +#if OBSW_ADD_STAR_TRACKER == 1 + UartCookie* starTrackerCookie = new UartCookie(objects::START_TRACKER, + q7s::UART_STAR_TRACKER_DEV, UartModes::NON_CANONICAL, uart::STAR_TRACKER_BAUD, + StarTracker::MAX_FRAME_SIZE* 2 + 2); + starTrackerCookie->setNoFixedSizeReply(); + new StarTrackerHandler(objects::START_TRACKER, objects::UART_COM_IF, starTrackerCookie); #endif new PlocUpdater(objects::PLOC_UPDATER); @@ -194,9 +189,9 @@ void ObjectFactory::createTmpComponents() { TMP1075::MAX_REPLY_LENGTH, std::string("/dev/i2c-0")); #else I2cCookie* i2cCookieTmp1075tcs1 = new I2cCookie(addresses::TMP1075_TCS_1, - TMP1075::MAX_REPLY_LENGTH, std::string("/dev/i2c-1")); + TMP1075::MAX_REPLY_LENGTH, q7s::I2C_DEFAULT_DEV); I2cCookie* i2cCookieTmp1075tcs2 = new I2cCookie(addresses::TMP1075_TCS_2, - TMP1075::MAX_REPLY_LENGTH, std::string("/dev/i2c-1")); + TMP1075::MAX_REPLY_LENGTH, q7s::I2C_DEFAULT_DEV); #endif /* Temperature sensors */ @@ -211,8 +206,8 @@ void ObjectFactory::createTmpComponents() { } void ObjectFactory::createCommunicationInterfaces(LinuxLibgpioIF **gpioComIF, - UartComIF** uartComIF) { - if(gpioComIF == nullptr or uartComIF == nullptr) { + UartComIF** uartComIF, SpiComIF** spiComIF) { + if(gpioComIF == nullptr or uartComIF == nullptr or spiComIF == nullptr) { sif::error << "ObjectFactory::createCommunicationInterfaces: Invalid passed ComIF pointer" << std::endl; } @@ -223,7 +218,7 @@ void ObjectFactory::createCommunicationInterfaces(LinuxLibgpioIF **gpioComIF, new I2cComIF(objects::I2C_COM_IF); *uartComIF = new UartComIF(objects::UART_COM_IF); #if Q7S_ADD_SPI_TEST == 0 - new SpiComIF(objects::SPI_COM_IF, *gpioComIF); + *spiComIF = new SpiComIF(objects::SPI_COM_IF, *gpioComIF); #endif /* Q7S_ADD_SPI_TEST == 0 */ /* Adding gpios for chip select decoding to the gpioComIf */ gpioCallbacks::initSpiCsDecoder(*gpioComIF); @@ -261,8 +256,8 @@ void ObjectFactory::createPcduComponents() { void ObjectFactory::createRadSensorComponent(LinuxLibgpioIF* gpioComIF) { GpioCookie* gpioCookieRadSensor = new GpioCookie; - GpiodRegular* chipSelectRadSensor = new GpiodRegular(std::string("gpiochip5"), 19, - std::string("Chip Select Radiation Sensor"), gpio::OUT, 1); + GpiodRegular* chipSelectRadSensor = new GpiodRegular(q7s::GPIO_RAD_SENSOR_CHIP, + q7s::GPIO_RAD_SENSOR_CS, "Chip Select Radiation Sensor", gpio::OUT, 1); gpioCookieRadSensor->addGpio(gpioIds::CS_RAD_SENSOR, chipSelectRadSensor); gpioComIF->addGpios(gpioCookieRadSensor); @@ -272,46 +267,48 @@ void ObjectFactory::createRadSensorComponent(LinuxLibgpioIF* gpioComIF) { new RadiationSensorHandler(objects::RAD_SENSOR, objects::SPI_COM_IF, spiCookieRadSensor); } -void ObjectFactory::createSunSensorComponents(LinuxLibgpioIF *gpioComIF) { +void ObjectFactory::createSunSensorComponents(LinuxLibgpioIF *gpioComIF, + SpiComIF* spiComIF) { GpioCookie* gpioCookieSus = new GpioCookie(); + GpioCallback* susgpio = nullptr; - GpioCallback* susgpio = new GpioCallback(std::string("Chip select SUS 1"), gpio::OUT, 1, + susgpio = new GpioCallback("Chip select SUS 1", gpio::OUT, 1, &gpioCallbacks::spiCsDecoderCallback, gpioComIF); gpioCookieSus->addGpio(gpioIds::CS_SUS_1, susgpio); - susgpio = new GpioCallback(std::string("Chip select SUS 2"), gpio::OUT, 1, + susgpio = new GpioCallback("Chip select SUS 2", gpio::OUT, 1, &gpioCallbacks::spiCsDecoderCallback, gpioComIF); gpioCookieSus->addGpio(gpioIds::CS_SUS_2, susgpio); - susgpio = new GpioCallback(std::string("Chip select SUS 3"), gpio::OUT, 1, + susgpio = new GpioCallback("Chip select SUS 3", gpio::OUT, 1, &gpioCallbacks::spiCsDecoderCallback, gpioComIF); gpioCookieSus->addGpio(gpioIds::CS_SUS_3, susgpio); - susgpio = new GpioCallback(std::string("Chip select SUS 4"), gpio::OUT, 1, + susgpio = new GpioCallback("Chip select SUS 4", gpio::OUT, 1, &gpioCallbacks::spiCsDecoderCallback, gpioComIF); gpioCookieSus->addGpio(gpioIds::CS_SUS_4, susgpio); - susgpio = new GpioCallback(std::string("Chip select SUS 5"), gpio::OUT, 1, + susgpio = new GpioCallback("Chip select SUS 5", gpio::OUT, 1, &gpioCallbacks::spiCsDecoderCallback, gpioComIF); gpioCookieSus->addGpio(gpioIds::CS_SUS_5, susgpio); - susgpio = new GpioCallback(std::string("Chip select SUS 6"), gpio::OUT, 1, + susgpio = new GpioCallback("Chip select SUS 6", gpio::OUT, 1, &gpioCallbacks::spiCsDecoderCallback, gpioComIF); gpioCookieSus->addGpio(gpioIds::CS_SUS_6, susgpio); - susgpio = new GpioCallback(std::string("Chip select SUS 7"), gpio::OUT, 1, + susgpio = new GpioCallback("Chip select SUS 7", gpio::OUT, 1, &gpioCallbacks::spiCsDecoderCallback, gpioComIF); gpioCookieSus->addGpio(gpioIds::CS_SUS_7, susgpio); - susgpio = new GpioCallback(std::string("Chip select SUS 8"), gpio::OUT, 1, + susgpio = new GpioCallback("Chip select SUS 8", gpio::OUT, 1, &gpioCallbacks::spiCsDecoderCallback, gpioComIF); gpioCookieSus->addGpio(gpioIds::CS_SUS_8, susgpio); - susgpio = new GpioCallback(std::string("Chip select SUS 9"), gpio::OUT, 1, + susgpio = new GpioCallback("Chip select SUS 9", gpio::OUT, 1, &gpioCallbacks::spiCsDecoderCallback, gpioComIF); gpioCookieSus->addGpio(gpioIds::CS_SUS_9, susgpio); - susgpio = new GpioCallback(std::string("Chip select SUS 10"), gpio::OUT, 1, + susgpio = new GpioCallback("Chip select SUS 10", gpio::OUT, 1, &gpioCallbacks::spiCsDecoderCallback, gpioComIF); gpioCookieSus->addGpio(gpioIds::CS_SUS_10, susgpio); - susgpio = new GpioCallback(std::string("Chip select SUS 11"), gpio::OUT, 1, + susgpio = new GpioCallback("Chip select SUS 11", gpio::OUT, 1, &gpioCallbacks::spiCsDecoderCallback, gpioComIF); gpioCookieSus->addGpio(gpioIds::CS_SUS_11, susgpio); - susgpio = new GpioCallback(std::string("Chip select SUS 12"), gpio::OUT, 1, + susgpio = new GpioCallback("Chip select SUS 12", gpio::OUT, 1, &gpioCallbacks::spiCsDecoderCallback, gpioComIF); gpioCookieSus->addGpio(gpioIds::CS_SUS_12, susgpio); - susgpio = new GpioCallback(std::string("Chip select SUS 13"), gpio::OUT, 1, + susgpio = new GpioCallback("Chip select SUS 13", gpio::OUT, 1, &gpioCallbacks::spiCsDecoderCallback, gpioComIF); gpioCookieSus->addGpio(gpioIds::CS_SUS_13, susgpio); @@ -388,30 +385,31 @@ void ObjectFactory::createSunSensorComponents(LinuxLibgpioIF *gpioComIF) { void ObjectFactory::createAcsBoardComponents(LinuxLibgpioIF *gpioComIF, UartComIF* uartComIF) { GpioCookie* gpioCookieAcsBoard = new GpioCookie(); GpiodRegular* gpio = nullptr; - gpio = new GpiodRegular(std::string("gpiochip5"), 1, std::string("CS_GYRO_0_ADIS"), - gpio::OUT, gpio::HIGH); + // TODO: Determine new Gyro GPIO pins + gpio = new GpiodRegular(q7s::GPIO_ACS_BOARD_DEFAULT_CHIP, q7s::GPIO_GYRO_0_ADIS_CS, + "CS_GYRO_0_ADIS", gpio::OUT, gpio::HIGH); gpioCookieAcsBoard->addGpio(gpioIds::GYRO_0_ADIS_CS, gpio); - gpio = new GpiodRegular(std::string("gpiochip5"), 7, std::string("CS_GYRO_1_L3G"), - gpio::OUT, gpio::HIGH); + gpio = new GpiodRegular(q7s::GPIO_ACS_BOARD_DEFAULT_CHIP, q7s::GPIO_GYRO_1_L3G_CS, + "CS_GYRO_1_L3G", gpio::OUT, gpio::HIGH); gpioCookieAcsBoard->addGpio(gpioIds::GYRO_1_L3G_CS, gpio); - gpio = new GpiodRegular(std::string("gpiochip5"), 3, std::string("CS_GYRO_2_L3G"), - gpio::OUT, gpio::HIGH); - gpioCookieAcsBoard->addGpio(gpioIds::GYRO_2_L3G_CS, gpio); + gpio = new GpiodRegular(q7s::GPIO_ACS_BOARD_DEFAULT_CHIP, q7s::GPIO_GYRO_2_ADIS_CS, + "CS_GYRO_2_ADIS", gpio::OUT, gpio::HIGH); + gpioCookieAcsBoard->addGpio(gpioIds::GYRO_2_ADIS_CS, gpio); + gpio = new GpiodRegular(q7s::GPIO_ACS_BOARD_DEFAULT_CHIP, q7s::GPIO_GYRO_3_L3G_CS, + "CS_GYRO_3_L3G", gpio::OUT, gpio::HIGH); + gpioCookieAcsBoard->addGpio(gpioIds::GYRO_3_L3G_CS, gpio); - gpio = new GpiodRegular(std::string("gpiochip5"), 5, std::string("CS_MGM_0_LIS3_A"), - gpio::OUT, gpio::HIGH); + gpio = new GpiodRegular(q7s::GPIO_ACS_BOARD_DEFAULT_CHIP, q7s::GPIO_MGM_0_LIS3_CS, + "CS_MGM_0_LIS3_A", gpio::OUT, gpio::HIGH); gpioCookieAcsBoard->addGpio(gpioIds::MGM_0_LIS3_CS, gpio); - - gpio = new GpiodRegular(std::string("gpiochip5"), 16, std::string("CS_MGM_1_RM3100_A"), - gpio::OUT, gpio::HIGH); + gpio = new GpiodRegular(q7s::GPIO_ACS_BOARD_DEFAULT_CHIP, q7s::GPIO_MGM_1_RM3100_CS, + "CS_MGM_1_RM3100_A", gpio::OUT, gpio::HIGH); gpioCookieAcsBoard->addGpio(gpioIds::MGM_1_RM3100_CS, gpio); - - gpio = new GpiodRegular(std::string("gpiochip6"), 0, std::string("CS_MGM_2_LIS3_B"), - gpio::OUT, gpio::HIGH); + gpio = new GpiodRegular(q7s::GPIO_MGM2_LIS3_CHIP, q7s::GPIO_MGM_2_LIS3_CS, + "CS_MGM_2_LIS3_B", gpio::OUT, gpio::HIGH); gpioCookieAcsBoard->addGpio(gpioIds::MGM_2_LIS3_CS, gpio); - - gpio = new GpiodRegular(std::string("gpiochip5"), 10, std::string("CS_MGM_3_RM3100_B"), - gpio::OUT, gpio::HIGH); + gpio = new GpiodRegular(q7s::GPIO_ACS_BOARD_DEFAULT_CHIP, q7s::GPIO_MGM_3_RM3100_CS, + "CS_MGM_3_RM3100_B", gpio::OUT, gpio::HIGH); gpioCookieAcsBoard->addGpio(gpioIds::MGM_3_RM3100_CS, gpio); gpioComIF->addGpios(gpioCookieAcsBoard); @@ -472,38 +470,38 @@ void ObjectFactory::createHeaterComponents() { GpioCookie* heaterGpiosCookie = new GpioCookie; /* Pin H2-11 on stack connector */ - GpiodRegular* gpioConfigHeater0 = new GpiodRegular(std::string("gpiochip7"), 6, - std::string("Heater0"), gpio::OUT, 0); + GpiodRegular* gpioConfigHeater0 = new GpiodRegular(q7s::GPIO_HEATER_CHIP, + q7s::GPIO_HEATER_0_PIN, "Heater0", gpio::OUT, 0); heaterGpiosCookie->addGpio(gpioIds::HEATER_0, gpioConfigHeater0); /* Pin H2-12 on stack connector */ - GpiodRegular* gpioConfigHeater1 = new GpiodRegular(std::string("gpiochip7"), 12, - std::string("Heater1"), gpio::OUT, 0); + GpiodRegular* gpioConfigHeater1 = new GpiodRegular(q7s::GPIO_HEATER_CHIP, + q7s::GPIO_HEATER_1_PIN, "Heater1", gpio::OUT, 0); heaterGpiosCookie->addGpio(gpioIds::HEATER_1, gpioConfigHeater1); /* Pin H2-13 on stack connector */ - GpiodRegular* gpioConfigHeater2 = new GpiodRegular(std::string("gpiochip7"), 7, - std::string("Heater2"), gpio::OUT, 0); + GpiodRegular* gpioConfigHeater2 = new GpiodRegular(q7s::GPIO_HEATER_CHIP, + q7s::GPIO_HEATER_2_PIN, "Heater2", gpio::OUT, 0); heaterGpiosCookie->addGpio(gpioIds::HEATER_2, gpioConfigHeater2); - GpiodRegular* gpioConfigHeater3 = new GpiodRegular(std::string("gpiochip7"), 5, - std::string("Heater3"), gpio::OUT, 0); + GpiodRegular* gpioConfigHeater3 = new GpiodRegular(q7s::GPIO_HEATER_CHIP, + q7s::GPIO_HEATER_3_PIN, "Heater3", gpio::OUT, 0); heaterGpiosCookie->addGpio(gpioIds::HEATER_3, gpioConfigHeater3); - GpiodRegular* gpioConfigHeater4 = new GpiodRegular(std::string("gpiochip7"), 3, - std::string("Heater4"), gpio::OUT, 0); + GpiodRegular* gpioConfigHeater4 = new GpiodRegular(q7s::GPIO_HEATER_CHIP, + q7s::GPIO_HEATER_4_PIN, "Heater4", gpio::OUT, 0); heaterGpiosCookie->addGpio(gpioIds::HEATER_4, gpioConfigHeater4); - GpiodRegular* gpioConfigHeater5 = new GpiodRegular(std::string("gpiochip7"), 0, - std::string("Heater5"), gpio::OUT, 0); + GpiodRegular* gpioConfigHeater5 = new GpiodRegular(q7s::GPIO_HEATER_CHIP, + q7s::GPIO_HEATER_5_PIN, "Heater5", gpio::OUT, 0); heaterGpiosCookie->addGpio(gpioIds::HEATER_5, gpioConfigHeater5); - GpiodRegular* gpioConfigHeater6 = new GpiodRegular(std::string("gpiochip7"), 1, - std::string("Heater6"), gpio::OUT, 0); + GpiodRegular* gpioConfigHeater6 = new GpiodRegular(q7s::GPIO_HEATER_CHIP, + q7s::GPIO_HEATER_6_PIN, "Heater6", gpio::OUT, 0); heaterGpiosCookie->addGpio(gpioIds::HEATER_6, gpioConfigHeater6); - GpiodRegular* gpioConfigHeater7 = new GpiodRegular(std::string("gpiochip7"), 11, - std::string("Heater7"), gpio::OUT, 0); + GpiodRegular* gpioConfigHeater7 = new GpiodRegular(q7s::GPIO_HEATER_CHIP, + q7s::GPIO_HEATER_7_PIN, "Heater7", gpio::OUT, 0); heaterGpiosCookie->addGpio(gpioIds::HEATER_7, gpioConfigHeater7); new HeaterHandler(objects::HEATER_HANDLER, objects::GPIO_IF, heaterGpiosCookie, @@ -513,11 +511,11 @@ void ObjectFactory::createHeaterComponents() { void ObjectFactory::createSolarArrayDeploymentComponents() { GpioCookie* solarArrayDeplCookie = new GpioCookie; - GpiodRegular* gpioConfigDeplSA0 = new GpiodRegular(std::string("gpiochip7"), 4, - std::string("DeplSA1"), gpio::OUT, 0); + GpiodRegular* gpioConfigDeplSA0 = new GpiodRegular(q7s::GPIO_SOLAR_ARR_DEPL_CHIP, + q7s::GPIO_SOL_DEPL_SA_0_PIN, "DeplSA0", gpio::OUT, 0); solarArrayDeplCookie->addGpio(gpioIds::DEPLSA1, gpioConfigDeplSA0); - GpiodRegular* gpioConfigDeplSA1 = new GpiodRegular(std::string("gpiochip7"), 2, - std::string("DeplSA2"), gpio::OUT, 0); + GpiodRegular* gpioConfigDeplSA1 = new GpiodRegular(q7s::GPIO_SOLAR_ARR_DEPL_CHIP, + q7s::GPIO_SOL_DEPL_SA_1_PIN, "DeplSA1", gpio::OUT, 0); solarArrayDeplCookie->addGpio(gpioIds::DEPLSA2, gpioConfigDeplSA1); //TODO: Find out burn time. For now set to 1000 ms. @@ -537,105 +535,105 @@ void ObjectFactory::createSyrlinksComponents() { void ObjectFactory::createRtdComponents(LinuxLibgpioIF *gpioComIF) { GpioCookie* rtdGpioCookie = new GpioCookie; - GpioCallback* gpioRtdIc3 = new GpioCallback(std::string("Chip select RTD IC3"), gpio::OUT, 1, + GpioCallback* gpioRtdIc3 = new GpioCallback("Chip select RTD IC3", gpio::OUT, gpio::HIGH, &gpioCallbacks::spiCsDecoderCallback, gpioComIF); rtdGpioCookie->addGpio(gpioIds::RTD_IC3, gpioRtdIc3); - GpioCallback* gpioRtdIc4 = new GpioCallback(std::string("Chip select RTD IC4"), gpio::OUT, 1, + GpioCallback* gpioRtdIc4 = new GpioCallback("Chip select RTD IC4", gpio::OUT, gpio::HIGH, &gpioCallbacks::spiCsDecoderCallback, gpioComIF); rtdGpioCookie->addGpio(gpioIds::RTD_IC4, gpioRtdIc4); - GpioCallback* gpioRtdIc5 = new GpioCallback(std::string("Chip select RTD IC5"), gpio::OUT, 1, + GpioCallback* gpioRtdIc5 = new GpioCallback("Chip select RTD IC5", gpio::OUT, gpio::HIGH, &gpioCallbacks::spiCsDecoderCallback, gpioComIF); rtdGpioCookie->addGpio(gpioIds::RTD_IC5, gpioRtdIc5); - GpioCallback* gpioRtdIc6 = new GpioCallback(std::string("Chip select RTD IC6"), gpio::OUT, 1, + GpioCallback* gpioRtdIc6 = new GpioCallback("Chip select RTD IC6", gpio::OUT, gpio::HIGH, &gpioCallbacks::spiCsDecoderCallback, gpioComIF); rtdGpioCookie->addGpio(gpioIds::RTD_IC6, gpioRtdIc6); - GpioCallback* gpioRtdIc7 = new GpioCallback(std::string("Chip select RTD IC7"), gpio::OUT, 1, + GpioCallback* gpioRtdIc7 = new GpioCallback("Chip select RTD IC7", gpio::OUT, gpio::HIGH, &gpioCallbacks::spiCsDecoderCallback, gpioComIF); rtdGpioCookie->addGpio(gpioIds::RTD_IC7, gpioRtdIc7); - GpioCallback* gpioRtdIc8 = new GpioCallback(std::string("Chip select RTD IC8"), gpio::OUT, 1, + GpioCallback* gpioRtdIc8 = new GpioCallback("Chip select RTD IC8", gpio::OUT, gpio::HIGH, &gpioCallbacks::spiCsDecoderCallback, gpioComIF); rtdGpioCookie->addGpio(gpioIds::RTD_IC8, gpioRtdIc8); - GpioCallback* gpioRtdIc9 = new GpioCallback(std::string("Chip select RTD IC9"), gpio::OUT, 1, + GpioCallback* gpioRtdIc9 = new GpioCallback("Chip select RTD IC9", gpio::OUT, gpio::HIGH, &gpioCallbacks::spiCsDecoderCallback, gpioComIF); rtdGpioCookie->addGpio(gpioIds::RTD_IC9, gpioRtdIc9); - GpioCallback* gpioRtdIc10 = new GpioCallback(std::string("Chip select RTD IC10"), gpio::OUT, 1, + GpioCallback* gpioRtdIc10 = new GpioCallback("Chip select RTD IC10", gpio::OUT, gpio::HIGH, &gpioCallbacks::spiCsDecoderCallback, gpioComIF); rtdGpioCookie->addGpio(gpioIds::RTD_IC10, gpioRtdIc10); - GpioCallback* gpioRtdIc11 = new GpioCallback(std::string("Chip select RTD IC11"), gpio::OUT, 1, + GpioCallback* gpioRtdIc11 = new GpioCallback("Chip select RTD IC11", gpio::OUT, gpio::HIGH, &gpioCallbacks::spiCsDecoderCallback, gpioComIF); rtdGpioCookie->addGpio(gpioIds::RTD_IC11, gpioRtdIc11); - GpioCallback* gpioRtdIc12 = new GpioCallback(std::string("Chip select RTD IC12"), gpio::OUT, 1, + GpioCallback* gpioRtdIc12 = new GpioCallback("Chip select RTD IC12", gpio::OUT, gpio::HIGH, &gpioCallbacks::spiCsDecoderCallback, gpioComIF); rtdGpioCookie->addGpio(gpioIds::RTD_IC12, gpioRtdIc12); - GpioCallback* gpioRtdIc13 = new GpioCallback(std::string("Chip select RTD IC13"), gpio::OUT, 1, + GpioCallback* gpioRtdIc13 = new GpioCallback("Chip select RTD IC13", gpio::OUT, gpio::HIGH, &gpioCallbacks::spiCsDecoderCallback, gpioComIF); rtdGpioCookie->addGpio(gpioIds::RTD_IC13, gpioRtdIc13); - GpioCallback* gpioRtdIc14 = new GpioCallback(std::string("Chip select RTD IC14"), gpio::OUT, 1, + GpioCallback* gpioRtdIc14 = new GpioCallback("Chip select RTD IC14", gpio::OUT, gpio::HIGH, &gpioCallbacks::spiCsDecoderCallback, gpioComIF); rtdGpioCookie->addGpio(gpioIds::RTD_IC14, gpioRtdIc14); - GpioCallback* gpioRtdIc15 = new GpioCallback(std::string("Chip select RTD IC15"), gpio::OUT, 1, + GpioCallback* gpioRtdIc15 = new GpioCallback("Chip select RTD IC15", gpio::OUT, gpio::HIGH, &gpioCallbacks::spiCsDecoderCallback, gpioComIF); rtdGpioCookie->addGpio(gpioIds::RTD_IC15, gpioRtdIc15); - GpioCallback* gpioRtdIc16 = new GpioCallback(std::string("Chip select RTD IC16"), gpio::OUT, 1, + GpioCallback* gpioRtdIc16 = new GpioCallback("Chip select RTD IC16", gpio::OUT, gpio::HIGH, &gpioCallbacks::spiCsDecoderCallback, gpioComIF); rtdGpioCookie->addGpio(gpioIds::RTD_IC16, gpioRtdIc16); - GpioCallback* gpioRtdIc17 = new GpioCallback(std::string("Chip select RTD IC17"), gpio::OUT, 1, + GpioCallback* gpioRtdIc17 = new GpioCallback("Chip select RTD IC17", gpio::OUT, gpio::HIGH, &gpioCallbacks::spiCsDecoderCallback, gpioComIF); rtdGpioCookie->addGpio(gpioIds::RTD_IC17, gpioRtdIc17); - GpioCallback* gpioRtdIc18 = new GpioCallback(std::string("Chip select RTD IC18"), gpio::OUT, 1, + GpioCallback* gpioRtdIc18 = new GpioCallback("Chip select RTD IC18", gpio::OUT, gpio::HIGH, &gpioCallbacks::spiCsDecoderCallback, gpioComIF); rtdGpioCookie->addGpio(gpioIds::RTD_IC18, gpioRtdIc18); gpioComIF->addGpios(rtdGpioCookie); SpiCookie* spiRtdIc3 = new SpiCookie(addresses::RTD_IC3, gpioIds::RTD_IC3, - std::string(q7s::SPI_DEFAULT_DEV), Max31865Definitions::MAX_REPLY_SIZE, - spi::SpiModes::MODE_3, 2000000); + q7s::SPI_DEFAULT_DEV, Max31865Definitions::MAX_REPLY_SIZE, + spi::SpiModes::MODE_1, spi::RTD_SPEED); SpiCookie* spiRtdIc4 = new SpiCookie(addresses::RTD_IC4, gpioIds::RTD_IC4, - std::string(q7s::SPI_DEFAULT_DEV), Max31865Definitions::MAX_REPLY_SIZE, - spi::SpiModes::MODE_1, 2000000); + q7s::SPI_DEFAULT_DEV, Max31865Definitions::MAX_REPLY_SIZE, + spi::SpiModes::MODE_1, spi::RTD_SPEED); SpiCookie* spiRtdIc5 = new SpiCookie(addresses::RTD_IC5, gpioIds::RTD_IC5, - std::string(q7s::SPI_DEFAULT_DEV), Max31865Definitions::MAX_REPLY_SIZE, - spi::SpiModes::MODE_1, 2000000); + q7s::SPI_DEFAULT_DEV, Max31865Definitions::MAX_REPLY_SIZE, + spi::SpiModes::MODE_1, spi::RTD_SPEED); SpiCookie* spiRtdIc6 = new SpiCookie(addresses::RTD_IC6, gpioIds::RTD_IC6, - std::string(q7s::SPI_DEFAULT_DEV), Max31865Definitions::MAX_REPLY_SIZE, - spi::SpiModes::MODE_1, 2000000); + q7s::SPI_DEFAULT_DEV, Max31865Definitions::MAX_REPLY_SIZE, + spi::SpiModes::MODE_1, spi::RTD_SPEED); SpiCookie* spiRtdIc7 = new SpiCookie(addresses::RTD_IC7, gpioIds::RTD_IC7, - std::string(q7s::SPI_DEFAULT_DEV), Max31865Definitions::MAX_REPLY_SIZE, - spi::SpiModes::MODE_1, 2000000); + q7s::SPI_DEFAULT_DEV, Max31865Definitions::MAX_REPLY_SIZE, + spi::SpiModes::MODE_1, spi::RTD_SPEED); SpiCookie* spiRtdIc8 = new SpiCookie(addresses::RTD_IC8, gpioIds::RTD_IC8, - std::string(q7s::SPI_DEFAULT_DEV), Max31865Definitions::MAX_REPLY_SIZE, - spi::SpiModes::MODE_1, 2000000); + q7s::SPI_DEFAULT_DEV, Max31865Definitions::MAX_REPLY_SIZE, + spi::SpiModes::MODE_1, spi::RTD_SPEED); SpiCookie* spiRtdIc9 = new SpiCookie(addresses::RTD_IC9, gpioIds::RTD_IC9, - std::string(q7s::SPI_DEFAULT_DEV), Max31865Definitions::MAX_REPLY_SIZE, - spi::SpiModes::MODE_1, 2000000); + q7s::SPI_DEFAULT_DEV, Max31865Definitions::MAX_REPLY_SIZE, + spi::SpiModes::MODE_1, spi::RTD_SPEED); SpiCookie* spiRtdIc10 = new SpiCookie(addresses::RTD_IC10, gpioIds::RTD_IC10, - std::string(q7s::SPI_DEFAULT_DEV), Max31865Definitions::MAX_REPLY_SIZE, - spi::SpiModes::MODE_1, 2000000); + q7s::SPI_DEFAULT_DEV, Max31865Definitions::MAX_REPLY_SIZE, + spi::SpiModes::MODE_1, spi::RTD_SPEED); SpiCookie* spiRtdIc11 = new SpiCookie(addresses::RTD_IC11, gpioIds::RTD_IC11, - std::string(q7s::SPI_DEFAULT_DEV), Max31865Definitions::MAX_REPLY_SIZE, - spi::SpiModes::MODE_1, 2000000); + q7s::SPI_DEFAULT_DEV, Max31865Definitions::MAX_REPLY_SIZE, + spi::SpiModes::MODE_1, spi::RTD_SPEED); SpiCookie* spiRtdIc12 = new SpiCookie(addresses::RTD_IC12, gpioIds::RTD_IC12, - std::string(q7s::SPI_DEFAULT_DEV), Max31865Definitions::MAX_REPLY_SIZE, - spi::SpiModes::MODE_1, 2000000); + q7s::SPI_DEFAULT_DEV, Max31865Definitions::MAX_REPLY_SIZE, + spi::SpiModes::MODE_1, spi::RTD_SPEED); SpiCookie* spiRtdIc13 = new SpiCookie(addresses::RTD_IC13, gpioIds::RTD_IC13, - std::string(q7s::SPI_DEFAULT_DEV), Max31865Definitions::MAX_REPLY_SIZE, - spi::SpiModes::MODE_1, 2000000); + q7s::SPI_DEFAULT_DEV, Max31865Definitions::MAX_REPLY_SIZE, + spi::SpiModes::MODE_1, spi::RTD_SPEED); SpiCookie* spiRtdIc14 = new SpiCookie(addresses::RTD_IC14, gpioIds::RTD_IC14, - std::string(q7s::SPI_DEFAULT_DEV), Max31865Definitions::MAX_REPLY_SIZE, - spi::SpiModes::MODE_1, 2000000); + q7s::SPI_DEFAULT_DEV, Max31865Definitions::MAX_REPLY_SIZE, + spi::SpiModes::MODE_1, spi::RTD_SPEED); SpiCookie* spiRtdIc15 = new SpiCookie(addresses::RTD_IC15, gpioIds::RTD_IC15, - std::string(q7s::SPI_DEFAULT_DEV), Max31865Definitions::MAX_REPLY_SIZE, - spi::SpiModes::MODE_1, 3900000); + q7s::SPI_DEFAULT_DEV, Max31865Definitions::MAX_REPLY_SIZE, + spi::SpiModes::MODE_1, spi::RTD_SPEED); SpiCookie* spiRtdIc16 = new SpiCookie(addresses::RTD_IC16, gpioIds::RTD_IC16, std::string(q7s::SPI_DEFAULT_DEV), Max31865Definitions::MAX_REPLY_SIZE, - spi::SpiModes::MODE_1, 2000000); + spi::SpiModes::MODE_1, spi::RTD_SPEED); SpiCookie* spiRtdIc17 = new SpiCookie(addresses::RTD_IC17, gpioIds::RTD_IC17, - std::string(q7s::SPI_DEFAULT_DEV), Max31865Definitions::MAX_REPLY_SIZE, - spi::SpiModes::MODE_1, 2000000); + q7s::SPI_DEFAULT_DEV, Max31865Definitions::MAX_REPLY_SIZE, + spi::SpiModes::MODE_1, spi::RTD_SPEED); SpiCookie* spiRtdIc18 = new SpiCookie(addresses::RTD_IC18, gpioIds::RTD_IC18, - std::string(q7s::SPI_DEFAULT_DEV), Max31865Definitions::MAX_REPLY_SIZE, - spi::SpiModes::MODE_1, 2000000); + q7s::SPI_DEFAULT_DEV, Max31865Definitions::MAX_REPLY_SIZE, + spi::SpiModes::MODE_1, spi::RTD_SPEED); Max31865PT1000Handler* rtdIc3 = new Max31865PT1000Handler(objects::RTD_IC3, objects::SPI_COM_IF, spiRtdIc3, 0); // 0 is switchId @@ -691,28 +689,28 @@ void ObjectFactory::createRtdComponents(LinuxLibgpioIF *gpioComIF) { void ObjectFactory::createReactionWheelComponents(LinuxLibgpioIF* gpioComIF) { GpioCookie* gpioCookieRw = new GpioCookie; GpioCallback* csRw1 = new GpioCallback("Chip select reaction wheel 1", gpio::OUT, - 1, &gpioCallbacks::spiCsDecoderCallback, gpioComIF); + gpio::HIGH, &gpioCallbacks::spiCsDecoderCallback, gpioComIF); gpioCookieRw->addGpio(gpioIds::CS_RW1, csRw1); GpioCallback* csRw2 = new GpioCallback("Chip select reaction wheel 2", gpio::OUT, - 1, &gpioCallbacks::spiCsDecoderCallback, gpioComIF); + gpio::HIGH, &gpioCallbacks::spiCsDecoderCallback, gpioComIF); gpioCookieRw->addGpio(gpioIds::CS_RW2, csRw2); GpioCallback* csRw3 = new GpioCallback("Chip select reaction wheel 3", gpio::OUT, - 1, &gpioCallbacks::spiCsDecoderCallback, gpioComIF); + gpio::HIGH, &gpioCallbacks::spiCsDecoderCallback, gpioComIF); gpioCookieRw->addGpio(gpioIds::CS_RW3, csRw3); GpioCallback* csRw4 = new GpioCallback("Chip select reaction wheel 4", gpio::OUT, - 1, &gpioCallbacks::spiCsDecoderCallback, gpioComIF); + gpio::HIGH, &gpioCallbacks::spiCsDecoderCallback, gpioComIF); gpioCookieRw->addGpio(gpioIds::CS_RW4, csRw4); - GpiodRegular* enRw1 = new GpiodRegular("gpiochip5", 7, + GpiodRegular* enRw1 = new GpiodRegular(q7s::GPIO_RW_DEFAULT_CHIP, q7s::GPIO_RW_0_CS, "Enable reaction wheel 1", gpio::OUT, 0); gpioCookieRw->addGpio(gpioIds::EN_RW1, enRw1); - GpiodRegular* enRw2 = new GpiodRegular("gpiochip5", 3, + GpiodRegular* enRw2 = new GpiodRegular(q7s::GPIO_RW_DEFAULT_CHIP, q7s::GPIO_RW_1_CS, "Enable reaction wheel 2", gpio::OUT, 0); gpioCookieRw->addGpio(gpioIds::EN_RW2, enRw2); - GpiodRegular* enRw3 = new GpiodRegular("gpiochip5", 11, + GpiodRegular* enRw3 = new GpiodRegular(q7s::GPIO_RW_DEFAULT_CHIP, q7s::GPIO_RW_2_CS, "Enable reaction wheel 3", gpio::OUT, 0); gpioCookieRw->addGpio(gpioIds::EN_RW3, enRw3); - GpiodRegular* enRw4 = new GpiodRegular("gpiochip5", 6, + GpiodRegular* enRw4 = new GpiodRegular(q7s::GPIO_RW_DEFAULT_CHIP, q7s::GPIO_RW_3_CS, "Enable reaction wheel 4", gpio::OUT, 0); gpioCookieRw->addGpio(gpioIds::EN_RW4, enRw4); @@ -721,7 +719,8 @@ void ObjectFactory::createReactionWheelComponents(LinuxLibgpioIF* gpioComIF) { * the PS SPI peripheral from the SPI interface and route out the SPI lines of the AXI SPI core. * Per default the PS SPI is selected (EMIO = 0). */ - GpiodRegular* spiMux = new GpiodRegular("gpiochip11", 54, "EMIO 0 SPI Mux", gpio::OUT, 0); + GpiodRegular* spiMux = new GpiodRegular(q7s::GPIO_RW_SPI_MUX_CHIP, q7s::GPIO_RW_SPI_MUX_CS, + "EMIO 0 SPI Mux", gpio::OUT, 0); gpioCookieRw->addGpio(gpioIds::SPI_MUX, spiMux); gpioComIF->addGpios(gpioCookieRw); diff --git a/bsp_q7s/core/ObjectFactory.h b/bsp_q7s/core/ObjectFactory.h index 6cd1b378..0e7ff9ff 100644 --- a/bsp_q7s/core/ObjectFactory.h +++ b/bsp_q7s/core/ObjectFactory.h @@ -3,17 +3,19 @@ class LinuxLibgpioIF; class UartComIF; +class SpiComIF; namespace ObjectFactory { void setStatics(); void produce(void* args); -void createCommunicationInterfaces(LinuxLibgpioIF** gpioComIF, UartComIF** uartComIF); +void createCommunicationInterfaces(LinuxLibgpioIF** gpioComIF, UartComIF** uartComIF, + SpiComIF** spiComIF); void createTmpComponents(); void createPcduComponents(); void createRadSensorComponent(LinuxLibgpioIF* gpioComIF); -void createSunSensorComponents(LinuxLibgpioIF* gpioComIF); +void createSunSensorComponents(LinuxLibgpioIF* gpioComIF, SpiComIF* spiComIF); void createAcsBoardComponents(LinuxLibgpioIF* gpioComIF, UartComIF* uartComIF); void createHeaterComponents(); void createSolarArrayDeploymentComponents(); diff --git a/common/config/commonObjects.h b/common/config/commonObjects.h index ef61d4b8..6b987a32 100644 --- a/common/config/commonObjects.h +++ b/common/config/commonObjects.h @@ -75,10 +75,10 @@ enum commonObjects: uint32_t { GPS0_HANDLER = 0x44130045, GPS1_HANDLER = 0x44130146, - RW1 = 0x44120001, - RW2 = 0x44120002, - RW3 = 0x44120003, - RW4 = 0x44120004, + RW1 = 0x44120047, + RW2 = 0x44120148, + RW3 = 0x44120249, + RW4 = 0x44120350, START_TRACKER = 0x44130001, diff --git a/common/config/devConf.h b/common/config/devConf.h index e5201450..ce21c8b3 100644 --- a/common/config/devConf.h +++ b/common/config/devConf.h @@ -29,11 +29,15 @@ static constexpr spi::SpiModes DEFAULT_ADIS16507_MODE = spi::SpiModes::MODE_3; static constexpr uint32_t RW_SPEED = 300000; static constexpr spi::SpiModes RW_MODE = spi::SpiModes::MODE_0; +static constexpr uint32_t RTD_SPEED = 2000000; + } namespace uart { static constexpr uint32_t PLOC_MPSOC_BAUD = 115200; +static constexpr uint32_t PLOC_SUPERVISOR_BAUD = 115200; +static constexpr uint32_t STAR_TRACKER_BAUD = 115200; } diff --git a/fsfw b/fsfw index 406b77ea..e3697d6d 160000 --- a/fsfw +++ b/fsfw @@ -1 +1 @@ -Subproject commit 406b77ea81816c2113aec9239b3e5d2ed71e7cb5 +Subproject commit e3697d6d8c38b278ebc34704fa772f671e36eb57 diff --git a/linux/boardtest/SpiTestClass.cpp b/linux/boardtest/SpiTestClass.cpp index 84750f66..290318a2 100644 --- a/linux/boardtest/SpiTestClass.cpp +++ b/linux/boardtest/SpiTestClass.cpp @@ -223,7 +223,7 @@ void SpiTestClass::performL3gTest(uint8_t l3gId) { currentGpioId = gpioIds::GYRO_1_L3G_CS; } else { - currentGpioId = gpioIds::GYRO_2_L3G_CS; + currentGpioId = gpioIds::GYRO_3_L3G_CS; } uint32_t spiSpeed = 3'900'000; spi::SpiModes spiMode = spi::SpiModes::MODE_3; @@ -352,7 +352,7 @@ void SpiTestClass::acsInit() { gpio = new GpiodRegular(q7sGpioName5, gyro2L3gd20ChipSelect, "GYRO_2_L3G", gpio::Direction::OUT, gpio::HIGH); - gpioCookie->addGpio(gpioIds::GYRO_2_L3G_CS, gpio); + gpioCookie->addGpio(gpioIds::GYRO_3_L3G_CS, gpio); gpio = new GpiodRegular(q7sGpioName6, mgm2Lis3mdlChipSelect, "MGM_2_LIS3", gpio::Direction::OUT, gpio::HIGH); diff --git a/linux/fsfwconfig/devices/gpioIds.h b/linux/fsfwconfig/devices/gpioIds.h index aad06629..ae91e905 100644 --- a/linux/fsfwconfig/devices/gpioIds.h +++ b/linux/fsfwconfig/devices/gpioIds.h @@ -4,86 +4,87 @@ #include namespace gpioIds { - enum gpioId_t { - HEATER_0, - HEATER_1, - HEATER_2, - HEATER_3, - HEATER_4, - HEATER_5, - HEATER_6, - HEATER_7, - DEPLSA1, - DEPLSA2, +enum gpioId_t { + HEATER_0, + HEATER_1, + HEATER_2, + HEATER_3, + HEATER_4, + HEATER_5, + HEATER_6, + HEATER_7, + DEPLSA1, + DEPLSA2, - MGM_0_LIS3_CS, - MGM_1_RM3100_CS, - GYRO_0_ADIS_CS, - GYRO_1_L3G_CS, - GYRO_2_L3G_CS, - MGM_2_LIS3_CS, - MGM_3_RM3100_CS, + MGM_0_LIS3_CS, + MGM_1_RM3100_CS, + GYRO_0_ADIS_CS, + GYRO_1_L3G_CS, + GYRO_2_ADIS_CS, + GYRO_3_L3G_CS, + MGM_2_LIS3_CS, + MGM_3_RM3100_CS, - TEST_ID_0, - TEST_ID_1, + TEST_ID_0, + TEST_ID_1, - RTD_IC3, - RTD_IC4, - RTD_IC5, - RTD_IC6, - RTD_IC7, - RTD_IC8, - RTD_IC9, - RTD_IC10, - RTD_IC11, - RTD_IC12, - RTD_IC13, - RTD_IC14, - RTD_IC15, - RTD_IC16, - RTD_IC17, - RTD_IC18, + RTD_IC3, + RTD_IC4, + RTD_IC5, + RTD_IC6, + RTD_IC7, + RTD_IC8, + RTD_IC9, + RTD_IC10, + RTD_IC11, + RTD_IC12, + RTD_IC13, + RTD_IC14, + RTD_IC15, + RTD_IC16, + RTD_IC17, + RTD_IC18, - CS_SUS_1, - CS_SUS_2, - CS_SUS_3, - CS_SUS_4, - CS_SUS_5, - CS_SUS_6, - CS_SUS_7, - CS_SUS_8, - CS_SUS_9, - CS_SUS_10, - CS_SUS_11, - CS_SUS_12, - CS_SUS_13, + CS_SUS_1, + CS_SUS_2, + CS_SUS_3, + CS_SUS_4, + CS_SUS_5, + CS_SUS_6, + CS_SUS_7, + CS_SUS_8, + CS_SUS_9, + CS_SUS_10, + CS_SUS_11, + CS_SUS_12, + CS_SUS_13, - SPI_MUX_BIT_1, - SPI_MUX_BIT_2, - SPI_MUX_BIT_3, - SPI_MUX_BIT_4, - SPI_MUX_BIT_5, - SPI_MUX_BIT_6, + SPI_MUX_BIT_1, + SPI_MUX_BIT_2, + SPI_MUX_BIT_3, + SPI_MUX_BIT_4, + SPI_MUX_BIT_5, + SPI_MUX_BIT_6, - CS_RAD_SENSOR, + CS_RAD_SENSOR, - PAPB_BUSY_N, - PAPB_EMPTY, + PAPB_BUSY_N, + PAPB_EMPTY, - EN_RW1, - EN_RW2, - EN_RW3, - EN_RW4, + EN_RW1, + EN_RW2, + EN_RW3, + EN_RW4, - CS_RW1, - CS_RW2, - CS_RW3, - CS_RW4, + CS_RW1, + CS_RW2, + CS_RW3, + CS_RW4, - EN_RW_CS, + EN_RW_CS, - SPI_MUX - }; + SPI_MUX +}; } diff --git a/tmtc b/tmtc index 28e527b8..261eef44 160000 --- a/tmtc +++ b/tmtc @@ -1 +1 @@ -Subproject commit 28e527b8f9002a8baa03d90f1e5693796cd1e237 +Subproject commit 261eef449e309549644d8566c8d1034c5696335d -- 2.43.0 From 124abf02137ff4588f65259c64d2c719b81ae2e7 Mon Sep 17 00:00:00 2001 From: "Jakob.Meier" <–meierj@irs.uni-stuttgart.de> Date: Wed, 18 Aug 2021 08:26:31 +0200 Subject: [PATCH 24/43] crc for ploc update --- README.md | 2 +- bsp_q7s/devices/PlocUpdater.cpp | 28 +++++++++++++++---- bsp_q7s/devices/PlocUpdater.h | 7 ++++- .../PlocSupervisorDefinitions.h | 2 +- 4 files changed, 31 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index d75c535b..cb2f9f53 100644 --- a/README.md +++ b/README.md @@ -926,7 +926,7 @@ candump can0 ## Dump content of file in hex ```` -cat file.bin | hexdump +cat file.bin | hexdump -C ```` ## Preparation of a fresh rootfs and SD card diff --git a/bsp_q7s/devices/PlocUpdater.cpp b/bsp_q7s/devices/PlocUpdater.cpp index 0e4ea77d..c37855a4 100644 --- a/bsp_q7s/devices/PlocUpdater.cpp +++ b/bsp_q7s/devices/PlocUpdater.cpp @@ -292,7 +292,7 @@ void PlocUpdater::commandUpdateAvailable() { remainingPackets = numOfUpdatePackets; packetsSent = 0; - uint32_t imageCrc = makeCrc(); + calcImageCrc(); PLOC_SPV::UpdateInfo packet(PLOC_SPV::APID_UPDATE_AVAILABLE, static_cast(updateMemory), static_cast(updatePartition), imageSize, imageCrc, numOfUpdatePackets); @@ -338,7 +338,7 @@ void PlocUpdater::commandUpdatePacket() { file.close(); // sequence count of first packet is 1 packet.setPacketSequenceCount((packetsSent + 1) & PLOC_SPV::SEQUENCE_COUNT_MASK); - if (numOfUpdatePackets > 0) { + if (numOfUpdatePackets > 1) { adjustSequenceFlags(packet); } packet.makeCrc(); @@ -383,9 +383,27 @@ void PlocUpdater::commandUpdateVerify() { return; } -ReturnValue_t PlocUpdater::makeCrc() { - //TODO: Waiting on input from TAS about the CRC to use - return 0; +void PlocUpdater::calcImageCrc() { + std::ifstream file(updateFile, std::ifstream::binary); + file.seekg(0, file.end); + uint32_t count; + uint32_t bit; + uint32_t remainder = INITIAL_REMAINDER_32; + char input; + for (count = 0; count < imageSize; count++) { + file.seekg(count, file.beg); + file.read(&input, 1); + remainder ^= (input << 16); + for (bit = 8; bit > 0; --bit) { + if (remainder & TOPBIT_32) { + remainder = (remainder << 1) ^ POLYNOMIAL_32; + } else { + remainder = (remainder << 1); + } + } + } + file.close(); + imageCrc = (remainder ^ FINAL_XOR_VALUE_32); } void PlocUpdater::adjustSequenceFlags(PLOC_SPV::UpdatePacket& packet) { diff --git a/bsp_q7s/devices/PlocUpdater.h b/bsp_q7s/devices/PlocUpdater.h index 8d7d9e30..c8a2b67b 100644 --- a/bsp_q7s/devices/PlocUpdater.h +++ b/bsp_q7s/devices/PlocUpdater.h @@ -92,6 +92,11 @@ private: // Maximum size of update payload data per space packet (max size of space packet is 1024 bytes) static const size_t MAX_SP_DATA = 1016; + static const uint32_t TOPBIT_32 = (1 << 31); + static const uint32_t POLYNOMIAL_32 = 0x04C11DB7; + static const uint32_t INITIAL_REMAINDER_32 = 0xFFFFFFFF; + static const uint32_t FINAL_XOR_VALUE_32 = 0xFFFFFFFF; + MessageQueueIF* commandQueue = nullptr; #if BOARD_TE0720 == 0 @@ -168,7 +173,7 @@ private: bool isSdCardMounted(sd::SdCard sdCard); #endif - ReturnValue_t makeCrc(); + void calcImageCrc(); void adjustSequenceFlags(PLOC_SPV::UpdatePacket& packet); }; diff --git a/bsp_q7s/devices/devicedefinitions/PlocSupervisorDefinitions.h b/bsp_q7s/devices/devicedefinitions/PlocSupervisorDefinitions.h index 909379df..26d44272 100644 --- a/bsp_q7s/devices/devicedefinitions/PlocSupervisorDefinitions.h +++ b/bsp_q7s/devices/devicedefinitions/PlocSupervisorDefinitions.h @@ -1453,7 +1453,7 @@ public: UpdateInfo(uint16_t apid, uint8_t memory, uint8_t partition, uint32_t imageSize, uint32_t imageCrc, uint32_t numPackets) : SupvTcSpacePacket(PAYLOAD_LENGTH, apid), memory(memory), partition(partition), imageSize( - imageSize), numPackets(numPackets) { + imageSize), imageCrc(imageCrc), numPackets(numPackets) { initPacket(); makeCrc(); } -- 2.43.0 From 2b061a2b1ce8165afd1c01b5c09117eb69b7b36d Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Wed, 18 Aug 2021 11:32:49 +0200 Subject: [PATCH 25/43] fsfw update --- fsfw | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fsfw b/fsfw index e3697d6d..1183e573 160000 --- a/fsfw +++ b/fsfw @@ -1 +1 @@ -Subproject commit e3697d6d8c38b278ebc34704fa772f671e36eb57 +Subproject commit 1183e5739d73da42978e0ab3218b3ca53fff4489 -- 2.43.0 From 19d4349c05fbb25dfe07a5e4fc0fbfb9303bb3ad Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Thu, 19 Aug 2021 10:16:55 +0200 Subject: [PATCH 26/43] submodule update --- fsfw | 2 +- tmtc | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/fsfw b/fsfw index 1183e573..04a1fe7f 160000 --- a/fsfw +++ b/fsfw @@ -1 +1 @@ -Subproject commit 1183e5739d73da42978e0ab3218b3ca53fff4489 +Subproject commit 04a1fe7f1085ed7cbb243c06b3303f4cf0c3035b diff --git a/tmtc b/tmtc index 261eef44..28c2d201 160000 --- a/tmtc +++ b/tmtc @@ -1 +1 @@ -Subproject commit 261eef449e309549644d8566c8d1034c5696335d +Subproject commit 28c2d2015c30bff91f63a7acac8db0a517c76f3a -- 2.43.0 From 7fc3285272183fa845b60eddb50422e9fcafe303 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Thu, 19 Aug 2021 13:34:44 +0200 Subject: [PATCH 27/43] added functions to handle writeprotection --- bsp_q7s/core/CoreController.cpp | 250 ++++++++++++++++++++++++++++++-- bsp_q7s/core/CoreController.h | 88 +++++++---- 2 files changed, 300 insertions(+), 38 deletions(-) diff --git a/bsp_q7s/core/CoreController.cpp b/bsp_q7s/core/CoreController.cpp index bf1a1b1a..b5e1fce3 100644 --- a/bsp_q7s/core/CoreController.cpp +++ b/bsp_q7s/core/CoreController.cpp @@ -21,12 +21,11 @@ #include -CoreController::Chip CoreController::currentChip = Chip::NO_CHIP; -CoreController::Copy CoreController::currentCopy = Copy::NO_COPY; +CoreController::Chip CoreController::CURRENT_CHIP = Chip::NO_CHIP; +CoreController::Copy CoreController::CURRENT_COPY = Copy::NO_COPY; CoreController::CoreController(object_id_t objectId): - ExtendedControllerBase(objectId, objects::NO_OBJECT, 5), - opDivider(5) { + ExtendedControllerBase(objectId, objects::NO_OBJECT, 5), opDivider(5) { ReturnValue_t result = HasReturnvaluesIF::RETURN_OK; try { result = initWatchdogFifo(); @@ -552,6 +551,12 @@ ReturnValue_t CoreController::initializeAfterTaskCreation() { if(result != HasReturnvaluesIF::RETURN_OK) { sif::warning << "CoreController::initialize: Version initialization failed" << std::endl; } + // Add script folder to path + char* currentEnvPath = getenv("PATH"); + sif::info << currentEnvPath << std::endl; + std::string updatedEnvPath = std::string(currentEnvPath) + ":/home/root/scripts"; + setenv("PATH", updatedEnvPath.c_str(), true); + updateProtInfo(); initPrint(); return result; } @@ -614,7 +619,7 @@ ReturnValue_t CoreController::initVersionFile() { std::to_string(FSFW_SUBVERSION) + "." + std::to_string(FSFW_REVISION); std::string systemString = "System: " + unameLine; std::string mountPrefix = SdCardManager::instance()->getCurrentMountPrefix(); - std::string versionFilePath = mountPrefix + "/conf/version.txt"; + std::string versionFilePath = mountPrefix + VERSION_FILE; std::fstream versionFile; if(not std::filesystem::exists(versionFilePath)) { @@ -731,32 +736,31 @@ ReturnValue_t CoreController::actionListDirectoryIntoFile(ActionId_t actionId, } ReturnValue_t CoreController::initBootCopy() { - std::string fileName = "/tmp/curr_copy.txt"; - if(not std::filesystem::exists(fileName)) { + if(not std::filesystem::exists(CURR_COPY_FILE)) { // Thils file is created by the systemd service eive-early-config so this should // not happen normally - std::string cmd = "xsc_boot_copy > " + fileName; + std::string cmd = "xsc_boot_copy > " + std::string(CURR_COPY_FILE); int result = std::system(cmd.c_str()); if(result != 0) { utility::handleSystemError(result, "CoreController::initBootCopy"); } } - std::ifstream file(fileName); + std::ifstream file(CURR_COPY_FILE); std::string line; std::getline(file, line); std::istringstream iss(line); int value = 0; iss >> value; - currentChip = static_cast(value); + CURRENT_CHIP = static_cast(value); iss >> value; - currentCopy = static_cast(value); + CURRENT_COPY = static_cast(value); return HasReturnvaluesIF::RETURN_OK; } void CoreController::getCurrentBootCopy(Chip &chip, Copy ©) { // Not really thread-safe but it does not need to be - chip = currentChip; - copy = currentCopy; + chip = CURRENT_CHIP; + copy = CURRENT_COPY; } ReturnValue_t CoreController::initWatchdogFifo() { @@ -795,6 +799,7 @@ ReturnValue_t CoreController::actionPerformReboot(const uint8_t *data, size_t si return HasActionsIF::INVALID_PARAMETERS; } bool rebootSameBootCopy = data[0]; + bool protOpPerformed; if(rebootSameBootCopy) { #if OBSW_VERBOSE_LEVEL >= 1 sif::info << "CoreController::actionPerformReboot: Rebooting on current image" << std::endl; @@ -802,6 +807,12 @@ ReturnValue_t CoreController::actionPerformReboot(const uint8_t *data, size_t si // Attempt graceful shutdown by unmounting and switching off SD cards SdCardManager::instance()->switchOffSdCard(sd::SdCard::SLOT_0); SdCardManager::instance()->switchOffSdCard(sd::SdCard::SLOT_1); + // If any boot copies are unprotected + ReturnValue_t retval = checkAndSetBootCopyProtection(Chip::SELF_CHIP, Copy::SELF_COPY, + true, protOpPerformed, false); + if(retval == HasReturnvaluesIF::RETURN_OK and protOpPerformed) { + sif::info << "Running slot was writeprotected before reboot" << std::endl; + } int result = std::system("xsc_boot_copy -r"); if(result != 0) { utility::handleSystemError(result, "CoreController::executeAction"); @@ -816,6 +827,16 @@ ReturnValue_t CoreController::actionPerformReboot(const uint8_t *data, size_t si sif::info << "CoreController::actionPerformReboot: Rebooting on " << static_cast(data[1]) << " " << static_cast(data[2]) << std::endl; #endif + + // Check that the target chip and copy is writeprotected first + generateChipStateFile(); + // If any boot copies are unprotected, protect them here + ReturnValue_t retval = checkAndSetBootCopyProtection(static_cast(data[1]), + static_cast(data[2]), true, protOpPerformed, false); + if(retval == HasReturnvaluesIF::RETURN_OK and protOpPerformed) { + sif::info << "Target slot was writeprotected before reboot" << std::endl; + } + // The second byte in data is the target chip, the third byte is the target copy std::string cmdString = "xsc_boot_copy " + std::to_string(data[1]) + " " + std::to_string(data[2]); @@ -873,6 +894,209 @@ bool CoreController::sdInitFinished() const { return sdInfo.initFinished; } +ReturnValue_t CoreController::generateChipStateFile() { + int result = std::system(CHIP_PROT_SCRIPT); + if(result != 0) { + utility::handleSystemError(result, "CoreController::generateChipStateFile"); + return HasReturnvaluesIF::RETURN_FAILED; + } + return HasReturnvaluesIF::RETURN_OK; +} + +ReturnValue_t CoreController::checkAndSetBootCopyProtection(Chip targetChip, Copy targetCopy, + bool protect, bool& protOperationPerformed, bool updateProtFile) { + bool allChips = false; + bool allCopies = false; + bool selfChip = false; + bool selfCopy = false; + switch(targetChip) { + case(Chip::ALL_CHIP): { + allChips = true; + break; + } + case(Chip::NO_CHIP): { + return HasReturnvaluesIF::RETURN_OK; + } + case(Chip::SELF_CHIP): { + selfChip = true; + break; + } + default: { + break; + } + } + switch(targetCopy) { + case(Copy::ALL_COPY): { + allCopies = true; + break; + } + case(Copy::NO_COPY): { + return HasReturnvaluesIF::RETURN_OK; + } + case(Copy::SELF_COPY): { + selfCopy = true; + break; + } + default: { + break; + } + } + + for(uint8_t arrIdx = 0; arrIdx < 4; arrIdx++) { + bool currentProt = protArray[arrIdx]; + std::ostringstream oss; + if(protect == currentProt) { + continue; + } + Chip currentChip; + Copy currentCopy; + oss << "writeprotect "; + if(arrIdx == 0 or arrIdx == 1) { + oss << "0 "; + currentChip = Chip::CHIP_0; + } + else { + oss << "1 "; + currentChip = Chip::CHIP_1; + } + if(arrIdx == 0 or arrIdx == 2) { + oss << "0 "; + currentCopy = Copy::COPY_0; + } + else { + oss << "1 "; + currentCopy = Copy::COPY_1; + } + if(protect) { + oss << "1"; + } + else { + oss << "0"; + } + + int result = 0; + if(allChips and allCopies) { + protOperationPerformed = true; + result = std::system(oss.str().c_str()); + } + else if(allChips) { + if((selfCopy and CURRENT_COPY == targetCopy) or + (currentCopy == targetCopy)) { + protOperationPerformed = true; + result = std::system(oss.str().c_str()); + } + } + else if(allCopies) { + if((selfChip and CURRENT_COPY == targetCopy) or + (currentChip == targetChip)) { + protOperationPerformed = true; + result = std::system(oss.str().c_str()); + } + } + else if(selfChip and (CURRENT_CHIP == targetChip)) { + protOperationPerformed = true; + result = std::system(oss.str().c_str()); + } + else if(selfCopy and (CURRENT_COPY == targetCopy)) { + protOperationPerformed = true; + result = std::system(oss.str().c_str()); + } + if(result != 0) { + utility::handleSystemError(result, "CoreController::checkAndSetBootCopyProtection"); + } + } + if(protOperationPerformed and updateProtFile) { + updateProtInfo(); + } + return HasReturnvaluesIF::RETURN_OK; +} + +ReturnValue_t CoreController::updateProtInfo(bool regenerateChipStateFile) { + using namespace std; + ReturnValue_t result = HasReturnvaluesIF::RETURN_OK; + if(regenerateChipStateFile) { + result = generateChipStateFile(); + if(result != HasReturnvaluesIF::RETURN_OK) { + sif::warning << "CoreController::updateProtInfo: Generating chip state file failed" << + std::endl; + return result; + } + } + if(not filesystem::exists(CHIP_STATE_FILE)) { + return HasReturnvaluesIF::RETURN_FAILED; + } + ifstream chipStateFile(CHIP_STATE_FILE); + if(not chipStateFile.good()) { + return HasReturnvaluesIF::RETURN_FAILED; + } + string nextLine; + uint8_t lineCounter = 0; + string word; + while(getline(chipStateFile, nextLine)) { + ReturnValue_t result = handleProtInfoUpdateLine(nextLine); + if(result != HasReturnvaluesIF::RETURN_OK) { + sif::warning << "CoreController::updateProtInfo: Protection info update failed!" << + std::endl; + return result; + } + ++lineCounter; + if(lineCounter > 4) { + sif::warning << "CoreController::checkAndProtectBootCopy: " + "Line counter larger than 4" << std::endl; + } + } + return HasReturnvaluesIF::RETURN_OK; +} + +ReturnValue_t CoreController::handleProtInfoUpdateLine(std::string nextLine) { + using namespace std; + string word; + uint8_t wordIdx = 0; + istringstream iss(nextLine); + Chip currentChip; + Copy currentCopy; + while(iss >> word) { + if(wordIdx == 1) { + currentChip = static_cast(stoi(word)); + } + if(wordIdx == 3) { + currentCopy = static_cast(stoi(word)); + } + + uint8_t arrayIdx = 0; + if(currentChip == Chip::CHIP_0) { + if(currentCopy == Copy::COPY_1) { + arrayIdx = 1; + } + else if(currentCopy != Copy::COPY_0) { + return HasReturnvaluesIF::RETURN_FAILED; + } + } + + else if(currentChip == Chip::CHIP_1) { + if(currentCopy == Copy::COPY_0) { + arrayIdx = 2; + } + else if(currentCopy == Copy::COPY_1) { + arrayIdx = 3; + } + else { + return HasReturnvaluesIF::RETURN_FAILED; + } + } + + if(wordIdx == 5) { + if(word == "unlocked.") { + protArray[arrayIdx] = false; + } + else { + protArray[arrayIdx] = true; + } + } + } + return HasReturnvaluesIF::RETURN_OK; +} + void CoreController::performWatchdogControlOperation() { // Only perform each fifth iteration if(watchdogFifoFd != 0 and opDivider.checkAndIncrement()) { diff --git a/bsp_q7s/core/CoreController.h b/bsp_q7s/core/CoreController.h index b26c99c5..10cda0df 100644 --- a/bsp_q7s/core/CoreController.h +++ b/bsp_q7s/core/CoreController.h @@ -16,17 +16,28 @@ public: enum Chip: uint8_t { CHIP_0, CHIP_1, - NO_CHIP + NO_CHIP, + SELF_CHIP, + ALL_CHIP }; enum Copy: uint8_t { COPY_0, COPY_1, - NO_COPY + NO_COPY, + SELF_COPY, + ALL_COPY }; + static constexpr char CHIP_PROT_SCRIPT[] = "/home/root/scripts/get-chip-prot-status.sh"; + static constexpr char CHIP_STATE_FILE[] = "/tmp/chip_prot_status.txt"; + static constexpr char CURR_COPY_FILE[] = "/tmp/curr_copy.txt"; + static constexpr char VERSION_FILE[] = "/conf/sd_status"; + static constexpr ActionId_t LIST_DIRECTORY_INTO_FILE = 0; static constexpr ActionId_t REBOOT_OBC = 32; + static constexpr ActionId_t MOUNT_OTHER_COPY = 33; + static constexpr uint8_t SUBSYSTEM_ID = SUBSYSTEM_ID::CORE; @@ -46,19 +57,39 @@ public: ReturnValue_t handleCommandMessage(CommandMessage *message) override; void performControlOperation() override; + /** + * Generate a file containing the chip lock/unlock states inside /tmp/chip_status.txt + * @return + */ + static ReturnValue_t generateChipStateFile(); static ReturnValue_t incrementAllocationFailureCount(); static void getCurrentBootCopy(Chip& chip, Copy& copy); + + ReturnValue_t updateProtInfo(bool regenerateChipStateFile = true); + + /** + * Checks whether the target chip and copy are writeprotected and protect them if they are + * not + * @param targetChip + * @param targetCopy + * @param protect + * @param protOperationPerformed [out] Can be used to determine whether any operation + * was performed + * @param updateProtFile Specify whether the protection info file is updated + * @return + */ + ReturnValue_t checkAndSetBootCopyProtection(Chip targetChip, Copy targetCopy, + bool protect, bool& protOperationPerformed, bool updateProtFile = true); + bool sdInitFinished() const; private: - static Chip currentChip; - static Copy currentCopy; + static Chip CURRENT_CHIP; + static Copy CURRENT_COPY; - ReturnValue_t initializeLocalDataPool(localpool::DataPool& localDataPoolMap, - LocalDataPoolManager& poolManager) override; - LocalPoolDataSetBase* getDataSetHandle(sid_t sid) override; - ReturnValue_t checkModeCommand(Mode_t mode, Submode_t submode, - uint32_t *msToReachTheMode); + // Designated value for rechecking FIFO open + static constexpr int RETRY_FIFO_OPEN = -2; + int watchdogFifoFd = 0; // States for SD state machine, which is used in non-blocking mode enum class SdStates { @@ -85,9 +116,6 @@ private: SdCardManager* sdcMan = nullptr; - ReturnValue_t initSdCardBlocking(); - ReturnValue_t sdStateMachine(); - struct SdInfo { sd::SdCard pref = sd::SdCard::NONE; sd::SdState prefState = sd::SdState::OFF; @@ -108,9 +136,29 @@ private: sd::SdCard commandedCard = sd::SdCard::NONE; sd::SdState commandedState = sd::SdState::OFF; }; - SdInfo sdInfo; + /** + * Index 0: Chip 0 Copy 0 + * Index 1: Chip 0 Copy 1 + * Index 2: Chip 1 Copy 0 + * Index 3: Chip 1 Copy 1 + */ + std::array protArray; + + ReturnValue_t initializeLocalDataPool(localpool::DataPool& localDataPoolMap, + LocalDataPoolManager& poolManager) override; + LocalPoolDataSetBase* getDataSetHandle(sid_t sid) override; + ReturnValue_t checkModeCommand(Mode_t mode, Submode_t submode, + uint32_t *msToReachTheMode); + + ReturnValue_t initVersionFile(); + ReturnValue_t initBootCopy(); + ReturnValue_t initWatchdogFifo(); + ReturnValue_t initSdCardBlocking(); + void initPrint(); + + ReturnValue_t sdStateMachine(); void updateSdInfoOther(); ReturnValue_t sdCardSetup(sd::SdCard sdCard, sd::SdState targetState, std::string sdChar, bool printOutput = true); @@ -120,24 +168,14 @@ private: void executeNextExternalSdCommand(); void checkExternalSdCommandStatus(); - ReturnValue_t initVersionFile(); - ReturnValue_t initBootCopy(); - ReturnValue_t initWatchdogFifo(); - ReturnValue_t actionListDirectoryIntoFile(ActionId_t actionId, MessageQueueId_t commandedBy, const uint8_t *data, size_t size); ReturnValue_t actionPerformReboot(const uint8_t *data, size_t size); - void initPrint(); - - // Designated value for rechecking FIFO open - static constexpr int RETRY_FIFO_OPEN = -2; - int watchdogFifoFd = 0; - PeriodicOperationDivider opDivider; void performWatchdogControlOperation(); + + ReturnValue_t handleProtInfoUpdateLine(std::string nextLine); }; - - #endif /* BSP_Q7S_CORE_CORECONTROLLER_H_ */ -- 2.43.0 From c1b22af695838a8a9f3e4a109c2854082f2776f8 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Thu, 19 Aug 2021 14:05:25 +0200 Subject: [PATCH 28/43] several bugfixes for prot handler --- bsp_q7s/core/CoreController.cpp | 95 ++++++++++++++++++--------------- 1 file changed, 52 insertions(+), 43 deletions(-) diff --git a/bsp_q7s/core/CoreController.cpp b/bsp_q7s/core/CoreController.cpp index b5e1fce3..976cfffb 100644 --- a/bsp_q7s/core/CoreController.cpp +++ b/bsp_q7s/core/CoreController.cpp @@ -85,6 +85,28 @@ ReturnValue_t CoreController::initialize() { return ExtendedControllerBase::initialize(); } +ReturnValue_t CoreController::initializeAfterTaskCreation() { + ReturnValue_t result = HasReturnvaluesIF::RETURN_OK; + if(BLOCKING_SD_INIT) { + ReturnValue_t result = initSdCardBlocking(); + if(result != HasReturnvaluesIF::RETURN_OK and result != SdCardManager::ALREADY_MOUNTED) { + sif::warning << "CoreController::CoreController: SD card init failed" << std::endl; + } + } + sdStateMachine(); + result = initVersionFile(); + if(result != HasReturnvaluesIF::RETURN_OK) { + sif::warning << "CoreController::initialize: Version initialization failed" << std::endl; + } + // Add script folder to path + char* currentEnvPath = getenv("PATH"); + std::string updatedEnvPath = std::string(currentEnvPath) + ":/home/root/scripts"; + setenv("PATH", updatedEnvPath.c_str(), true); + updateProtInfo(); + initPrint(); + return result; +} + ReturnValue_t CoreController::checkModeCommand(Mode_t mode, Submode_t submode, uint32_t *msToReachTheMode) { return HasReturnvaluesIF::RETURN_OK; @@ -538,29 +560,6 @@ ReturnValue_t CoreController::executeAction(ActionId_t actionId, MessageQueueId_ } } -ReturnValue_t CoreController::initializeAfterTaskCreation() { - ReturnValue_t result = HasReturnvaluesIF::RETURN_OK; - if(BLOCKING_SD_INIT) { - ReturnValue_t result = initSdCardBlocking(); - if(result != HasReturnvaluesIF::RETURN_OK and result != SdCardManager::ALREADY_MOUNTED) { - sif::warning << "CoreController::CoreController: SD card init failed" << std::endl; - } - } - sdStateMachine(); - result = initVersionFile(); - if(result != HasReturnvaluesIF::RETURN_OK) { - sif::warning << "CoreController::initialize: Version initialization failed" << std::endl; - } - // Add script folder to path - char* currentEnvPath = getenv("PATH"); - sif::info << currentEnvPath << std::endl; - std::string updatedEnvPath = std::string(currentEnvPath) + ":/home/root/scripts"; - setenv("PATH", updatedEnvPath.c_str(), true); - updateProtInfo(); - initPrint(); - return result; -} - ReturnValue_t CoreController::sdColdRedundantBlockingInit() { ReturnValue_t result = HasReturnvaluesIF::RETURN_OK; @@ -919,6 +918,7 @@ ReturnValue_t CoreController::checkAndSetBootCopyProtection(Chip targetChip, Cop } case(Chip::SELF_CHIP): { selfChip = true; + targetChip = CURRENT_CHIP; break; } default: { @@ -935,6 +935,7 @@ ReturnValue_t CoreController::checkAndSetBootCopyProtection(Chip targetChip, Cop } case(Copy::SELF_COPY): { selfCopy = true; + targetCopy = CURRENT_COPY; break; } default: { @@ -942,12 +943,18 @@ ReturnValue_t CoreController::checkAndSetBootCopyProtection(Chip targetChip, Cop } } - for(uint8_t arrIdx = 0; arrIdx < 4; arrIdx++) { + for(uint8_t arrIdx = 0; arrIdx < protArray.size(); arrIdx++) { bool currentProt = protArray[arrIdx]; std::ostringstream oss; if(protect == currentProt) { continue; } + if(protOperationPerformed) { + if((selfChip and selfCopy) or (not allCopies and not allChips)) { + // No need to continue, only one operation was requested + break; + } + } Chip currentChip; Copy currentCopy; oss << "writeprotect "; @@ -1045,6 +1052,9 @@ ReturnValue_t CoreController::updateProtInfo(bool regenerateChipStateFile) { "Line counter larger than 4" << std::endl; } } + for(uint8_t idx = 0; idx < 4; idx ++) { + sif::debug << (int) protArray[idx] << std::endl; + } return HasReturnvaluesIF::RETURN_OK; } @@ -1052,6 +1062,7 @@ ReturnValue_t CoreController::handleProtInfoUpdateLine(std::string nextLine) { using namespace std; string word; uint8_t wordIdx = 0; + uint8_t arrayIdx = 0; istringstream iss(nextLine); Chip currentChip; Copy currentCopy; @@ -1063,28 +1074,25 @@ ReturnValue_t CoreController::handleProtInfoUpdateLine(std::string nextLine) { currentCopy = static_cast(stoi(word)); } - uint8_t arrayIdx = 0; - if(currentChip == Chip::CHIP_0) { - if(currentCopy == Copy::COPY_1) { - arrayIdx = 1; + if(wordIdx == 3) { + if(currentChip == Chip::CHIP_0) { + if(currentCopy == Copy::COPY_0) { + arrayIdx = 0; + } + else if(currentCopy == Copy::COPY_1) { + arrayIdx = 1; + } } - else if(currentCopy != Copy::COPY_0) { - return HasReturnvaluesIF::RETURN_FAILED; - } - } - else if(currentChip == Chip::CHIP_1) { - if(currentCopy == Copy::COPY_0) { - arrayIdx = 2; - } - else if(currentCopy == Copy::COPY_1) { - arrayIdx = 3; - } - else { - return HasReturnvaluesIF::RETURN_FAILED; - } + else if(currentChip == Chip::CHIP_1) { + if(currentCopy == Copy::COPY_0) { + arrayIdx = 2; + } + else if(currentCopy == Copy::COPY_1) { + arrayIdx = 3; + } + } } - if(wordIdx == 5) { if(word == "unlocked.") { protArray[arrayIdx] = false; @@ -1093,6 +1101,7 @@ ReturnValue_t CoreController::handleProtInfoUpdateLine(std::string nextLine) { protArray[arrayIdx] = true; } } + wordIdx++; } return HasReturnvaluesIF::RETURN_OK; } -- 2.43.0 From a6777067da544fccb21ad652242ee1f2ad28b228 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Thu, 19 Aug 2021 14:16:26 +0200 Subject: [PATCH 29/43] moved test --- bsp_q7s/boardtest/Q7STestTask.cpp | 42 +++++++++++++++++++++++++++++++ bsp_q7s/boardtest/Q7STestTask.h | 4 +++ bsp_q7s/core/CoreController.cpp | 3 --- 3 files changed, 46 insertions(+), 3 deletions(-) diff --git a/bsp_q7s/boardtest/Q7STestTask.cpp b/bsp_q7s/boardtest/Q7STestTask.cpp index f9439fc1..c254e138 100644 --- a/bsp_q7s/boardtest/Q7STestTask.cpp +++ b/bsp_q7s/boardtest/Q7STestTask.cpp @@ -1,3 +1,4 @@ +#include #include #include #include "Q7STestTask.h" @@ -24,6 +25,7 @@ ReturnValue_t Q7STestTask::performOneShotAction() { //testScratchApi(); //testJsonLibDirect(); //testDummyParams(); + testProtHandler(); //FsOpCodes opCode = FsOpCodes::ATTEMPT_DIR_REMOVAL_NON_EMPTY; //testFileSystemHandlerDirect(opCode); return TestTask::performOneShotAction(); @@ -131,6 +133,46 @@ void Q7STestTask::testDummyParams() { sif::info << "Test value 2 (\"blirb\" expected): " << test2 << std::endl; } +ReturnValue_t Q7STestTask::initialize() { + coreController = ObjectManager::instance()->get(objects::CORE_CONTROLLER); + if(coreController == nullptr) { + sif::warning << "Q7STestTask::initialize: Could not retrieve CORE_CONTROLLER object" << + std::endl; + } + return TestTask::initialize(); +} + +void Q7STestTask::testProtHandler() { + bool opPerformed = false; + ReturnValue_t result = coreController->checkAndSetBootCopyProtection( + CoreController::Chip::SELF_CHIP, CoreController::Copy::SELF_COPY, false, + opPerformed, true); + if(result != HasReturnvaluesIF::RETURN_OK) { + sif::warning << "Q7STestTask::testProtHandler: Op failed" << std::endl; + } + if(not opPerformed) { + sif::warning << "Q7STestTask::testProtHandler: No op performed" << std::endl; + } + int retval = std::system("print-chip-prot-status.sh"); + if(retval != 0) { + utility::handleSystemError(retval, "Q7STestTask::testProtHandler"); + } + + result = coreController->checkAndSetBootCopyProtection( + CoreController::Chip::SELF_CHIP, CoreController::Copy::SELF_COPY, true, + opPerformed, true); + if(result != HasReturnvaluesIF::RETURN_OK) { + sif::warning << "Q7STestTask::testProtHandler: Op failed" << std::endl; + } + if(not opPerformed) { + sif::warning << "Q7STestTask::testProtHandler: No op performed" << std::endl; + } + retval = std::system("print-chip-prot-status.sh"); + if(retval != 0) { + utility::handleSystemError(retval, "Q7STestTask::testProtHandler"); + } +} + void Q7STestTask::testFileSystemHandlerDirect(FsOpCodes opCode) { auto fsHandler = ObjectManager::instance()-> get(objects::FILE_SYSTEM_HANDLER); diff --git a/bsp_q7s/boardtest/Q7STestTask.h b/bsp_q7s/boardtest/Q7STestTask.h index a14d8428..b0153ce9 100644 --- a/bsp_q7s/boardtest/Q7STestTask.h +++ b/bsp_q7s/boardtest/Q7STestTask.h @@ -6,7 +6,10 @@ class Q7STestTask: public TestTask { public: Q7STestTask(object_id_t objectId); + + ReturnValue_t initialize() override; private: + CoreController* coreController = nullptr; ReturnValue_t performOneShotAction() override; void testSdCard(); @@ -15,6 +18,7 @@ private: void testScratchApi(); void testJsonLibDirect(); void testDummyParams(); + void testProtHandler(); enum FsOpCodes { CREATE_EMPTY_FILE_IN_TMP, diff --git a/bsp_q7s/core/CoreController.cpp b/bsp_q7s/core/CoreController.cpp index 976cfffb..89f9d450 100644 --- a/bsp_q7s/core/CoreController.cpp +++ b/bsp_q7s/core/CoreController.cpp @@ -1052,9 +1052,6 @@ ReturnValue_t CoreController::updateProtInfo(bool regenerateChipStateFile) { "Line counter larger than 4" << std::endl; } } - for(uint8_t idx = 0; idx < 4; idx ++) { - sif::debug << (int) protArray[idx] << std::endl; - } return HasReturnvaluesIF::RETURN_OK; } -- 2.43.0 From faee071edcfb7a2ea873694691d142d069b3615b Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Thu, 19 Aug 2021 14:34:24 +0200 Subject: [PATCH 30/43] bugfixes, more tests --- bsp_q7s/boardtest/Q7STestTask.cpp | 13 ++++++++++++- bsp_q7s/core/CoreController.cpp | 23 +++++++++++++---------- 2 files changed, 25 insertions(+), 11 deletions(-) diff --git a/bsp_q7s/boardtest/Q7STestTask.cpp b/bsp_q7s/boardtest/Q7STestTask.cpp index c254e138..7b2d1748 100644 --- a/bsp_q7s/boardtest/Q7STestTask.cpp +++ b/bsp_q7s/boardtest/Q7STestTask.cpp @@ -144,7 +144,17 @@ ReturnValue_t Q7STestTask::initialize() { void Q7STestTask::testProtHandler() { bool opPerformed = false; - ReturnValue_t result = coreController->checkAndSetBootCopyProtection( + ReturnValue_t result = HasReturnvaluesIF::RETURN_OK; + // If any chips are unlocked, lock them here + result = coreController->checkAndSetBootCopyProtection( + CoreController::Chip::ALL_CHIP, CoreController::Copy::ALL_COPY, true, + opPerformed, true); + if(result != HasReturnvaluesIF::RETURN_OK) { + sif::warning << "Q7STestTask::testProtHandler: Op failed" << std::endl; + } + + // unlock own copy + result = coreController->checkAndSetBootCopyProtection( CoreController::Chip::SELF_CHIP, CoreController::Copy::SELF_COPY, false, opPerformed, true); if(result != HasReturnvaluesIF::RETURN_OK) { @@ -158,6 +168,7 @@ void Q7STestTask::testProtHandler() { utility::handleSystemError(retval, "Q7STestTask::testProtHandler"); } + // lock own copy result = coreController->checkAndSetBootCopyProtection( CoreController::Chip::SELF_CHIP, CoreController::Copy::SELF_COPY, true, opPerformed, true); diff --git a/bsp_q7s/core/CoreController.cpp b/bsp_q7s/core/CoreController.cpp index 89f9d450..3d1adb3b 100644 --- a/bsp_q7s/core/CoreController.cpp +++ b/bsp_q7s/core/CoreController.cpp @@ -908,6 +908,8 @@ ReturnValue_t CoreController::checkAndSetBootCopyProtection(Chip targetChip, Cop bool allCopies = false; bool selfChip = false; bool selfCopy = false; + protOperationPerformed = false; + switch(targetChip) { case(Chip::ALL_CHIP): { allChips = true; @@ -946,6 +948,7 @@ ReturnValue_t CoreController::checkAndSetBootCopyProtection(Chip targetChip, Cop for(uint8_t arrIdx = 0; arrIdx < protArray.size(); arrIdx++) { bool currentProt = protArray[arrIdx]; std::ostringstream oss; + bool performOp = false; if(protect == currentProt) { continue; } @@ -983,34 +986,34 @@ ReturnValue_t CoreController::checkAndSetBootCopyProtection(Chip targetChip, Cop int result = 0; if(allChips and allCopies) { - protOperationPerformed = true; - result = std::system(oss.str().c_str()); + performOp = true; } else if(allChips) { if((selfCopy and CURRENT_COPY == targetCopy) or (currentCopy == targetCopy)) { - protOperationPerformed = true; - result = std::system(oss.str().c_str()); + performOp = true; } } else if(allCopies) { if((selfChip and CURRENT_COPY == targetCopy) or (currentChip == targetChip)) { - protOperationPerformed = true; - result = std::system(oss.str().c_str()); + performOp = true; } } else if(selfChip and (CURRENT_CHIP == targetChip)) { - protOperationPerformed = true; - result = std::system(oss.str().c_str()); + performOp = true; } else if(selfCopy and (CURRENT_COPY == targetCopy)) { - protOperationPerformed = true; - result = std::system(oss.str().c_str()); + performOp = true; } if(result != 0) { utility::handleSystemError(result, "CoreController::checkAndSetBootCopyProtection"); } + if(performOp) { + protOperationPerformed = true; + sif::info << "Executing command: " << oss.str() << std::endl; + result = std::system(oss.str().c_str()); + } } if(protOperationPerformed and updateProtFile) { updateProtInfo(); -- 2.43.0 From 963e40120f3c6cfd19c6a26f77a63c43fd05d988 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Thu, 19 Aug 2021 14:35:36 +0200 Subject: [PATCH 31/43] added TODO --- bsp_q7s/core/CoreController.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/bsp_q7s/core/CoreController.cpp b/bsp_q7s/core/CoreController.cpp index 3d1adb3b..3a883eac 100644 --- a/bsp_q7s/core/CoreController.cpp +++ b/bsp_q7s/core/CoreController.cpp @@ -1010,6 +1010,7 @@ ReturnValue_t CoreController::checkAndSetBootCopyProtection(Chip targetChip, Cop utility::handleSystemError(result, "CoreController::checkAndSetBootCopyProtection"); } if(performOp) { + // TODO: Lock operation take a long time. Use command executor? protOperationPerformed = true; sif::info << "Executing command: " << oss.str() << std::endl; result = std::system(oss.str().c_str()); -- 2.43.0 From 8ddd7b02dc32548ebd3da854f90ee0968f8ee687 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Thu, 19 Aug 2021 14:45:25 +0200 Subject: [PATCH 32/43] renamed function and bugfix --- bsp_q7s/boardtest/Q7STestTask.cpp | 36 ++++++++++++++++++++++++++++--- bsp_q7s/core/CoreController.cpp | 9 +++++--- bsp_q7s/core/CoreController.h | 2 +- 3 files changed, 40 insertions(+), 7 deletions(-) diff --git a/bsp_q7s/boardtest/Q7STestTask.cpp b/bsp_q7s/boardtest/Q7STestTask.cpp index 7b2d1748..85fdccaa 100644 --- a/bsp_q7s/boardtest/Q7STestTask.cpp +++ b/bsp_q7s/boardtest/Q7STestTask.cpp @@ -146,7 +146,7 @@ void Q7STestTask::testProtHandler() { bool opPerformed = false; ReturnValue_t result = HasReturnvaluesIF::RETURN_OK; // If any chips are unlocked, lock them here - result = coreController->checkAndSetBootCopyProtection( + result = coreController->setBootCopyProtection( CoreController::Chip::ALL_CHIP, CoreController::Copy::ALL_COPY, true, opPerformed, true); if(result != HasReturnvaluesIF::RETURN_OK) { @@ -154,7 +154,7 @@ void Q7STestTask::testProtHandler() { } // unlock own copy - result = coreController->checkAndSetBootCopyProtection( + result = coreController->setBootCopyProtection( CoreController::Chip::SELF_CHIP, CoreController::Copy::SELF_COPY, false, opPerformed, true); if(result != HasReturnvaluesIF::RETURN_OK) { @@ -169,7 +169,7 @@ void Q7STestTask::testProtHandler() { } // lock own copy - result = coreController->checkAndSetBootCopyProtection( + result = coreController->setBootCopyProtection( CoreController::Chip::SELF_CHIP, CoreController::Copy::SELF_COPY, true, opPerformed, true); if(result != HasReturnvaluesIF::RETURN_OK) { @@ -182,6 +182,36 @@ void Q7STestTask::testProtHandler() { if(retval != 0) { utility::handleSystemError(retval, "Q7STestTask::testProtHandler"); } + + // unlock specific copy + result = coreController->setBootCopyProtection( + CoreController::Chip::CHIP_1, CoreController::Copy::COPY_1, false, + opPerformed, true); + if(result != HasReturnvaluesIF::RETURN_OK) { + sif::warning << "Q7STestTask::testProtHandler: Op failed" << std::endl; + } + if(not opPerformed) { + sif::warning << "Q7STestTask::testProtHandler: No op performed" << std::endl; + } + retval = std::system("print-chip-prot-status.sh"); + if(retval != 0) { + utility::handleSystemError(retval, "Q7STestTask::testProtHandler"); + } + + // lock specific copy + result = coreController->setBootCopyProtection( + CoreController::Chip::CHIP_1, CoreController::Copy::COPY_1, true, + opPerformed, true); + if(result != HasReturnvaluesIF::RETURN_OK) { + sif::warning << "Q7STestTask::testProtHandler: Op failed" << std::endl; + } + if(not opPerformed) { + sif::warning << "Q7STestTask::testProtHandler: No op performed" << std::endl; + } + retval = std::system("print-chip-prot-status.sh"); + if(retval != 0) { + utility::handleSystemError(retval, "Q7STestTask::testProtHandler"); + } } void Q7STestTask::testFileSystemHandlerDirect(FsOpCodes opCode) { diff --git a/bsp_q7s/core/CoreController.cpp b/bsp_q7s/core/CoreController.cpp index 3a883eac..5ed5148d 100644 --- a/bsp_q7s/core/CoreController.cpp +++ b/bsp_q7s/core/CoreController.cpp @@ -807,7 +807,7 @@ ReturnValue_t CoreController::actionPerformReboot(const uint8_t *data, size_t si SdCardManager::instance()->switchOffSdCard(sd::SdCard::SLOT_0); SdCardManager::instance()->switchOffSdCard(sd::SdCard::SLOT_1); // If any boot copies are unprotected - ReturnValue_t retval = checkAndSetBootCopyProtection(Chip::SELF_CHIP, Copy::SELF_COPY, + ReturnValue_t retval = setBootCopyProtection(Chip::SELF_CHIP, Copy::SELF_COPY, true, protOpPerformed, false); if(retval == HasReturnvaluesIF::RETURN_OK and protOpPerformed) { sif::info << "Running slot was writeprotected before reboot" << std::endl; @@ -830,7 +830,7 @@ ReturnValue_t CoreController::actionPerformReboot(const uint8_t *data, size_t si // Check that the target chip and copy is writeprotected first generateChipStateFile(); // If any boot copies are unprotected, protect them here - ReturnValue_t retval = checkAndSetBootCopyProtection(static_cast(data[1]), + ReturnValue_t retval = setBootCopyProtection(static_cast(data[1]), static_cast(data[2]), true, protOpPerformed, false); if(retval == HasReturnvaluesIF::RETURN_OK and protOpPerformed) { sif::info << "Target slot was writeprotected before reboot" << std::endl; @@ -902,7 +902,7 @@ ReturnValue_t CoreController::generateChipStateFile() { return HasReturnvaluesIF::RETURN_OK; } -ReturnValue_t CoreController::checkAndSetBootCopyProtection(Chip targetChip, Copy targetCopy, +ReturnValue_t CoreController::setBootCopyProtection(Chip targetChip, Copy targetCopy, bool protect, bool& protOperationPerformed, bool updateProtFile) { bool allChips = false; bool allCopies = false; @@ -1006,6 +1006,9 @@ ReturnValue_t CoreController::checkAndSetBootCopyProtection(Chip targetChip, Cop else if(selfCopy and (CURRENT_COPY == targetCopy)) { performOp = true; } + else if((targetChip == currentChip) and (targetCopy == currentCopy)) { + performOp = true; + } if(result != 0) { utility::handleSystemError(result, "CoreController::checkAndSetBootCopyProtection"); } diff --git a/bsp_q7s/core/CoreController.h b/bsp_q7s/core/CoreController.h index 10cda0df..f527ade7 100644 --- a/bsp_q7s/core/CoreController.h +++ b/bsp_q7s/core/CoreController.h @@ -78,7 +78,7 @@ public: * @param updateProtFile Specify whether the protection info file is updated * @return */ - ReturnValue_t checkAndSetBootCopyProtection(Chip targetChip, Copy targetCopy, + ReturnValue_t setBootCopyProtection(Chip targetChip, Copy targetCopy, bool protect, bool& protOperationPerformed, bool updateProtFile = true); bool sdInitFinished() const; -- 2.43.0 From 7c828427e936a55a2b94498dea1c5cd6b8cc89f8 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Thu, 19 Aug 2021 17:08:51 +0200 Subject: [PATCH 33/43] unix file guard diagnostic prefix adaption --- bsp_q7s/spiCallbacks/rwSpiCallback.cpp | 2 +- fsfw | 2 +- linux/boardtest/SpiTestClass.cpp | 6 +++--- mission/devices/GyroADIS16507Handler.cpp | 2 +- tmtc | 2 +- 5 files changed, 7 insertions(+), 7 deletions(-) diff --git a/bsp_q7s/spiCallbacks/rwSpiCallback.cpp b/bsp_q7s/spiCallbacks/rwSpiCallback.cpp index f05fbbdf..dce79c42 100644 --- a/bsp_q7s/spiCallbacks/rwSpiCallback.cpp +++ b/bsp_q7s/spiCallbacks/rwSpiCallback.cpp @@ -24,7 +24,7 @@ ReturnValue_t spiCallback(SpiComIF* comIf, SpiCookie *cookie, const uint8_t *sen int fileDescriptor = 0; std::string device = cookie->getSpiDevice(); - UnixFileGuard fileHelper(device, &fileDescriptor, O_RDWR, "rwSpiCallback::spiCallback: "); + UnixFileGuard fileHelper(device, &fileDescriptor, O_RDWR, "rwSpiCallback::spiCallback"); if(fileHelper.getOpenResult() != HasReturnvaluesIF::RETURN_OK) { sif::error << "rwSpiCallback::spiCallback: Failed to open device file" << std::endl; return SpiComIF::OPENING_FILE_FAILED; diff --git a/fsfw b/fsfw index 04a1fe7f..b6aebb30 160000 --- a/fsfw +++ b/fsfw @@ -1 +1 @@ -Subproject commit 04a1fe7f1085ed7cbb243c06b3303f4cf0c3035b +Subproject commit b6aebb3061a8417ffe09111eced07b8f17dddd3d diff --git a/linux/boardtest/SpiTestClass.cpp b/linux/boardtest/SpiTestClass.cpp index 290318a2..f3ba3279 100644 --- a/linux/boardtest/SpiTestClass.cpp +++ b/linux/boardtest/SpiTestClass.cpp @@ -85,7 +85,7 @@ void SpiTestClass::performRm3100Test(uint8_t mgmId) { UnixFileGuard fileHelper(deviceName, &fileDescriptor, O_RDWR, - "SpiComIF::initializeInterface: "); + "SpiComIF::initializeInterface"); if(fileHelper.getOpenResult()) { sif::error << "SpiTestClass::performRm3100Test: File descriptor could not be opened!" << std::endl; @@ -184,7 +184,7 @@ void SpiTestClass::performLis3MdlTest(uint8_t lis3Id) { int fileDescriptor = 0; UnixFileGuard fileHelper(deviceName, &fileDescriptor, O_RDWR, - "SpiComIF::initializeInterface: "); + "SpiComIF::initializeInterface"); if(fileHelper.getOpenResult()) { sif::error << "SpiTestClass::performLis3Mdl3100Test: File descriptor could not be opened!" << std::endl; @@ -235,7 +235,7 @@ void SpiTestClass::performL3gTest(uint8_t l3gId) { int fileDescriptor = 0; UnixFileGuard fileHelper(deviceName, &fileDescriptor, O_RDWR, - "SpiComIF::initializeInterface: "); + "SpiComIF::initializeInterface"); if(fileHelper.getOpenResult()) { sif::error << "SpiTestClass::performLis3Mdl3100Test: File descriptor could not be opened!" << std::endl; diff --git a/mission/devices/GyroADIS16507Handler.cpp b/mission/devices/GyroADIS16507Handler.cpp index 3065c249..2034d6a2 100644 --- a/mission/devices/GyroADIS16507Handler.cpp +++ b/mission/devices/GyroADIS16507Handler.cpp @@ -393,7 +393,7 @@ ReturnValue_t GyroADIS16507Handler::spiSendCallback(SpiComIF *comIf, SpiCookie * // Prepare transfer int fileDescriptor = 0; std::string device = cookie->getSpiDevice(); - UnixFileGuard fileHelper(device, &fileDescriptor, O_RDWR, "SpiComIF::sendMessage: "); + UnixFileGuard fileHelper(device, &fileDescriptor, O_RDWR, "SpiComIF::sendMessage"); if(fileHelper.getOpenResult() != HasReturnvaluesIF::RETURN_OK) { return SpiComIF::OPENING_FILE_FAILED; } diff --git a/tmtc b/tmtc index 28c2d201..a7f1ed90 160000 --- a/tmtc +++ b/tmtc @@ -1 +1 @@ -Subproject commit 28c2d2015c30bff91f63a7acac8db0a517c76f3a +Subproject commit a7f1ed904c460005c6d22f17ab496694ae150046 -- 2.43.0 From 42d225bb6c4cc924622e4ad7632746c1aed82d29 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Thu, 19 Aug 2021 17:20:40 +0200 Subject: [PATCH 34/43] fsfw update --- fsfw | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fsfw b/fsfw index b6aebb30..882da68a 160000 --- a/fsfw +++ b/fsfw @@ -1 +1 @@ -Subproject commit b6aebb3061a8417ffe09111eced07b8f17dddd3d +Subproject commit 882da68a2f0c1301d433d517c449c9c31f3cb35e -- 2.43.0 From 24ecfe84ae30e58087673ee4ad52e7edb713f134 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Thu, 19 Aug 2021 17:27:13 +0200 Subject: [PATCH 35/43] minor fix --- bsp_q7s/core/CoreController.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bsp_q7s/core/CoreController.cpp b/bsp_q7s/core/CoreController.cpp index 5ed5148d..4dfe1f91 100644 --- a/bsp_q7s/core/CoreController.cpp +++ b/bsp_q7s/core/CoreController.cpp @@ -1006,7 +1006,7 @@ ReturnValue_t CoreController::setBootCopyProtection(Chip targetChip, Copy target else if(selfCopy and (CURRENT_COPY == targetCopy)) { performOp = true; } - else if((targetChip == currentChip) and (targetCopy == currentCopy)) { + else if(not selfCopy and (targetChip == currentChip) and (targetCopy == currentCopy)) { performOp = true; } if(result != 0) { -- 2.43.0 From d1afdfe578c08f21c7f5d3d9c81100649db41b21 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Thu, 19 Aug 2021 17:31:13 +0200 Subject: [PATCH 36/43] bugfix core controller --- bsp_q7s/core/CoreController.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/bsp_q7s/core/CoreController.cpp b/bsp_q7s/core/CoreController.cpp index 4dfe1f91..f81f1ff0 100644 --- a/bsp_q7s/core/CoreController.cpp +++ b/bsp_q7s/core/CoreController.cpp @@ -1000,13 +1000,13 @@ ReturnValue_t CoreController::setBootCopyProtection(Chip targetChip, Copy target performOp = true; } } - else if(selfChip and (CURRENT_CHIP == targetChip)) { + else if(selfChip and (currentChip == targetChip)) { performOp = true; } - else if(selfCopy and (CURRENT_COPY == targetCopy)) { + else if(selfCopy and (currentCopy == targetCopy)) { performOp = true; } - else if(not selfCopy and (targetChip == currentChip) and (targetCopy == currentCopy)) { + else if((targetChip == currentChip) and (targetCopy == currentCopy)) { performOp = true; } if(result != 0) { -- 2.43.0 From e821a9700a1c1062602b459bdcfec1bcc6db7f18 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Thu, 19 Aug 2021 18:10:19 +0200 Subject: [PATCH 37/43] refactoring and bugfix --- bsp_q7s/boardtest/Q7STestTask.cpp | 2 +- bsp_q7s/core/CoreController.cpp | 167 +++++++++++++++++------------- bsp_q7s/core/CoreController.h | 3 + 3 files changed, 101 insertions(+), 71 deletions(-) diff --git a/bsp_q7s/boardtest/Q7STestTask.cpp b/bsp_q7s/boardtest/Q7STestTask.cpp index 85fdccaa..18baf124 100644 --- a/bsp_q7s/boardtest/Q7STestTask.cpp +++ b/bsp_q7s/boardtest/Q7STestTask.cpp @@ -25,7 +25,7 @@ ReturnValue_t Q7STestTask::performOneShotAction() { //testScratchApi(); //testJsonLibDirect(); //testDummyParams(); - testProtHandler(); + //testProtHandler(); //FsOpCodes opCode = FsOpCodes::ATTEMPT_DIR_REMOVAL_NON_EMPTY; //testFileSystemHandlerDirect(opCode); return TestTask::performOneShotAction(); diff --git a/bsp_q7s/core/CoreController.cpp b/bsp_q7s/core/CoreController.cpp index f81f1ff0..b899e60f 100644 --- a/bsp_q7s/core/CoreController.cpp +++ b/bsp_q7s/core/CoreController.cpp @@ -946,77 +946,10 @@ ReturnValue_t CoreController::setBootCopyProtection(Chip targetChip, Copy target } for(uint8_t arrIdx = 0; arrIdx < protArray.size(); arrIdx++) { - bool currentProt = protArray[arrIdx]; - std::ostringstream oss; - bool performOp = false; - if(protect == currentProt) { - continue; - } - if(protOperationPerformed) { - if((selfChip and selfCopy) or (not allCopies and not allChips)) { - // No need to continue, only one operation was requested - break; - } - } - Chip currentChip; - Copy currentCopy; - oss << "writeprotect "; - if(arrIdx == 0 or arrIdx == 1) { - oss << "0 "; - currentChip = Chip::CHIP_0; - } - else { - oss << "1 "; - currentChip = Chip::CHIP_1; - } - if(arrIdx == 0 or arrIdx == 2) { - oss << "0 "; - currentCopy = Copy::COPY_0; - } - else { - oss << "1 "; - currentCopy = Copy::COPY_1; - } - if(protect) { - oss << "1"; - } - else { - oss << "0"; - } - - int result = 0; - if(allChips and allCopies) { - performOp = true; - } - else if(allChips) { - if((selfCopy and CURRENT_COPY == targetCopy) or - (currentCopy == targetCopy)) { - performOp = true; - } - } - else if(allCopies) { - if((selfChip and CURRENT_COPY == targetCopy) or - (currentChip == targetChip)) { - performOp = true; - } - } - else if(selfChip and (currentChip == targetChip)) { - performOp = true; - } - else if(selfCopy and (currentCopy == targetCopy)) { - performOp = true; - } - else if((targetChip == currentChip) and (targetCopy == currentCopy)) { - performOp = true; - } + int result = handleBootCopyProtAtIndex(targetChip, targetCopy, protect, + protOperationPerformed, selfChip, selfCopy, allChips, allCopies, arrIdx); if(result != 0) { - utility::handleSystemError(result, "CoreController::checkAndSetBootCopyProtection"); - } - if(performOp) { - // TODO: Lock operation take a long time. Use command executor? - protOperationPerformed = true; - sif::info << "Executing command: " << oss.str() << std::endl; - result = std::system(oss.str().c_str()); + break; } } if(protOperationPerformed and updateProtFile) { @@ -1025,6 +958,100 @@ ReturnValue_t CoreController::setBootCopyProtection(Chip targetChip, Copy target return HasReturnvaluesIF::RETURN_OK; } +int CoreController::handleBootCopyProtAtIndex(Chip targetChip, Copy targetCopy, bool protect, + bool &protOperationPerformed, bool selfChip, bool selfCopy, bool allChips, + bool allCopies, uint8_t arrIdx) { + bool currentProt = protArray[arrIdx]; + std::ostringstream oss; + bool performOp = false; + if(protect == currentProt) { + return 0; + } + if(protOperationPerformed) { + if((selfChip and selfCopy) or (not allCopies and not allChips)) { + // No need to continue, only one operation was requested + return 1; + } + } + Chip currentChip; + Copy currentCopy; + oss << "writeprotect "; + if(arrIdx == 0 or arrIdx == 1) { + oss << "0 "; + currentChip = Chip::CHIP_0; + } + else { + oss << "1 "; + currentChip = Chip::CHIP_1; + } + if(arrIdx == 0 or arrIdx == 2) { + oss << "0 "; + currentCopy = Copy::COPY_0; + } + else { + oss << "1 "; + currentCopy = Copy::COPY_1; + } + if(protect) { + oss << "1"; + } + else { + oss << "0"; + } + + int result = 0; + if(allChips and allCopies) { + performOp = true; + } + else if(allChips) { + if((selfCopy and CURRENT_COPY == targetCopy) or + (currentCopy == targetCopy)) { + performOp = true; + } + } + else if(allCopies) { + if((selfChip and CURRENT_COPY == targetCopy) or + (currentChip == targetChip)) { + performOp = true; + } + } + else if(selfChip and (currentChip == targetChip)) { + if(selfCopy) { + if(currentCopy == targetCopy) { + performOp = true; + } + } + else { + performOp = true; + } + + } + else if(selfCopy and (currentCopy == targetCopy)) { + if(selfChip) { + if(currentChip == targetChip) { + performOp = true; + } + } + else { + performOp = true; + } + } + else if((targetChip == currentChip) and (targetCopy == currentCopy)) { + performOp = true; + } + if(result != 0) { + utility::handleSystemError(result, "CoreController::checkAndSetBootCopyProtection"); + } + if(performOp) { + // TODO: Lock operation take a long time. Use command executor? That would require a + // new state machine.. + protOperationPerformed = true; + sif::info << "Executing command: " << oss.str() << std::endl; + result = std::system(oss.str().c_str()); + } + return 0; +} + ReturnValue_t CoreController::updateProtInfo(bool regenerateChipStateFile) { using namespace std; ReturnValue_t result = HasReturnvaluesIF::RETURN_OK; diff --git a/bsp_q7s/core/CoreController.h b/bsp_q7s/core/CoreController.h index f527ade7..862162a0 100644 --- a/bsp_q7s/core/CoreController.h +++ b/bsp_q7s/core/CoreController.h @@ -176,6 +176,9 @@ private: void performWatchdogControlOperation(); ReturnValue_t handleProtInfoUpdateLine(std::string nextLine); + int handleBootCopyProtAtIndex(Chip targetChip, Copy targetCopy, bool protect, + bool &protOperationPerformed, bool selfChip, bool selfCopy, bool allChips, + bool allCopies, uint8_t arrIdx); }; #endif /* BSP_Q7S_CORE_CORECONTROLLER_H_ */ -- 2.43.0 From ef75d9241555d1da43943f3eee533120fac0de9b Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Thu, 19 Aug 2021 18:26:00 +0200 Subject: [PATCH 38/43] smaller tweaks --- bsp_q7s/core/CoreController.h | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/bsp_q7s/core/CoreController.h b/bsp_q7s/core/CoreController.h index 862162a0..74702441 100644 --- a/bsp_q7s/core/CoreController.h +++ b/bsp_q7s/core/CoreController.h @@ -58,7 +58,7 @@ public: void performControlOperation() override; /** - * Generate a file containing the chip lock/unlock states inside /tmp/chip_status.txt + * Generate a file containing the chip lock/unlock states inside /tmp/chip_prot_status.txt * @return */ static ReturnValue_t generateChipStateFile(); @@ -68,11 +68,11 @@ public: ReturnValue_t updateProtInfo(bool regenerateChipStateFile = true); /** - * Checks whether the target chip and copy are writeprotected and protect them if they are - * not + * Checks whether the target chip and copy are write protected and protect set them to a target + * state where applicable. * @param targetChip * @param targetCopy - * @param protect + * @param protect Target state * @param protOperationPerformed [out] Can be used to determine whether any operation * was performed * @param updateProtFile Specify whether the protection info file is updated @@ -145,6 +145,7 @@ private: * Index 3: Chip 1 Copy 1 */ std::array protArray; + PeriodicOperationDivider opDivider; ReturnValue_t initializeLocalDataPool(localpool::DataPool& localDataPoolMap, LocalDataPoolManager& poolManager) override; @@ -172,7 +173,6 @@ private: const uint8_t *data, size_t size); ReturnValue_t actionPerformReboot(const uint8_t *data, size_t size); - PeriodicOperationDivider opDivider; void performWatchdogControlOperation(); ReturnValue_t handleProtInfoUpdateLine(std::string nextLine); -- 2.43.0 From 3acb61959a9ef558aa6bf0e23941dade46944769 Mon Sep 17 00:00:00 2001 From: "Jakob.Meier" <–meierj@irs.uni-stuttgart.de> Date: Fri, 20 Aug 2021 06:56:29 +0200 Subject: [PATCH 39/43] mram dump standalone packet --- README.md | 4 ++ bsp_q7s/devices/PlocSupervisorHandler.cpp | 13 ++++- bsp_q7s/devices/PlocUpdater.cpp | 48 ++++++++++++------- bsp_q7s/devices/PlocUpdater.h | 34 ++++++++----- .../PlocSupervisorDefinitions.h | 21 ++++---- tmtc | 2 +- 6 files changed, 81 insertions(+), 41 deletions(-) diff --git a/README.md b/README.md index cb2f9f53..d690a3a1 100644 --- a/README.md +++ b/README.md @@ -928,6 +928,10 @@ candump can0 ```` cat file.bin | hexdump -C ```` +All content will be printed with +```` +cat file.bin | hexdump -v +```` ## Preparation of a fresh rootfs and SD card diff --git a/bsp_q7s/devices/PlocSupervisorHandler.cpp b/bsp_q7s/devices/PlocSupervisorHandler.cpp index 5bbcf1ef..3a0eb141 100644 --- a/bsp_q7s/devices/PlocSupervisorHandler.cpp +++ b/bsp_q7s/devices/PlocSupervisorHandler.cpp @@ -467,6 +467,7 @@ ReturnValue_t PlocSupervisorHandler::initializeLocalDataPool(localpool::DataPool localDataPoolMap.emplace(PLOC_SPV::LATCHUP_RPT_TIME_MON, new PoolEntry( { 0 })); localDataPoolMap.emplace(PLOC_SPV::LATCHUP_RPT_TIME_YEAR, new PoolEntry( { 0 })); localDataPoolMap.emplace(PLOC_SPV::LATCHUP_RPT_TIME_MSEC, new PoolEntry( { 0 })); + localDataPoolMap.emplace(PLOC_SPV::LATCHUP_RPT_TIME_IS_SET, new PoolEntry( { 0 })); return HasReturnvaluesIF::RETURN_OK; } @@ -557,6 +558,7 @@ ReturnValue_t PlocSupervisorHandler::enableReplyInReplyMap(DeviceCommandMap::ite case PLOC_SPV::FACTORY_RESET_CLEAR_MIRROR: case PLOC_SPV::FACTORY_RESET_CLEAR_CIRCULAR: case PLOC_SPV::REQUEST_LOGGING_DATA: + case PLOC_SPV::DISABLE_PERIOIC_HK_TRANSMISSION: enabledReplies = 2; break; default: @@ -867,6 +869,9 @@ ReturnValue_t PlocSupervisorHandler::handleLatchupStatusReport(const uint8_t* da latchupStatusReport.timeMsec = *(data + offset) << 24 | *(data + offset + 1) << 16 | *(data + offset + 2) << 8 | *(data + offset + 3); offset += 4; + latchupStatusReport.isSet = *(data + offset) << 24 | *(data + offset + 1) << 16 | + *(data + offset + 2) << 8 | *(data + offset + 3); + offset += 4; nextReplyId = PLOC_SPV::EXE_REPORT; @@ -901,6 +906,8 @@ ReturnValue_t PlocSupervisorHandler::handleLatchupStatusReport(const uint8_t* da << latchupStatusReport.timeYear << std::endl; sif::info << "PlocSupervisorHandler::handleLatchupStatusReport: Msec: " << latchupStatusReport.timeMsec << std::endl; + sif::info << "PlocSupervisorHandler::handleLatchupStatusReport: isSet: 0x" + << std::hex << latchupStatusReport.timeMsec << std::dec << std::endl; #endif return result; @@ -1400,7 +1407,8 @@ void PlocSupervisorHandler::increaseExpectedMramReplies() { return; } uint8_t sequenceFlags = spacePacketBuffer[2] >> 6; - if (sequenceFlags != static_cast(PLOC_SPV::SequenceFlags::LAST_PKT)) { + if (sequenceFlags != static_cast(PLOC_SPV::SequenceFlags::LAST_PKT) + && (sequenceFlags != static_cast(PLOC_SPV::SequenceFlags::STANDALONE_PKT))) { // Command expects at least one MRAM packet more and the execution report info->expectedReplies = 2; // Wait maximum of 2 cycles for next MRAM packet @@ -1428,7 +1436,8 @@ ReturnValue_t PlocSupervisorHandler::handleMramDumpFile() { ReturnValue_t result = RETURN_OK; uint16_t packetLen = readSpacePacketLength(spacePacketBuffer); uint8_t sequenceFlags = readSequenceFlags(spacePacketBuffer); - if (sequenceFlags == static_cast(PLOC_SPV::SequenceFlags::FIRST_PKT)) { + if (sequenceFlags == static_cast(PLOC_SPV::SequenceFlags::FIRST_PKT) + || (sequenceFlags == static_cast(PLOC_SPV::SequenceFlags::STANDALONE_PKT))) { result = createMramDumpFile(); if (result != RETURN_OK) { return result; diff --git a/bsp_q7s/devices/PlocUpdater.cpp b/bsp_q7s/devices/PlocUpdater.cpp index c37855a4..5a94495b 100644 --- a/bsp_q7s/devices/PlocUpdater.cpp +++ b/bsp_q7s/devices/PlocUpdater.cpp @@ -52,21 +52,37 @@ ReturnValue_t PlocUpdater::executeAction(ActionId_t actionId, } switch (actionId) { - case UPDATE_NVM0_A: - updatePartition = Partition::A; - updateMemory = Memory::NVM0; + case UPDATE_A_UBOOT: + image = Image::A; + partition = Partition::UBOOT; break; - case UPDATE_NVM0_B: - updatePartition = Partition::B; - updateMemory = Memory::NVM0; + case UPDATE_A_BITSTREAM: + image = Image::A; + partition = Partition::BITSTREAM; break; - case UPDATE_NVM1_A: - updatePartition = Partition::A; - updateMemory = Memory::NVM1; + case UPDATE_A_LINUX: + image = Image::A; + partition = Partition::LINUX_OS; break; - case UPDATE_NVM1_B: - updatePartition = Partition::B; - updateMemory = Memory::NVM1; + case UPDATE_A_APP_SW: + image = Image::A; + partition = Partition::APP_SW; + break; + case UPDATE_B_UBOOT: + image = Image::B; + partition = Partition::UBOOT; + break; + case UPDATE_B_BITSTREAM: + image = Image::B; + partition = Partition::BITSTREAM; + break; + case UPDATE_B_LINUX: + image = Image::B; + partition = Partition::LINUX_OS; + break; + case UPDATE_B_APP_SW: + image = Image::B; + partition = Partition::APP_SW; break; default: return INVALID_ACTION_ID; @@ -294,8 +310,8 @@ void PlocUpdater::commandUpdateAvailable() { calcImageCrc(); - PLOC_SPV::UpdateInfo packet(PLOC_SPV::APID_UPDATE_AVAILABLE, static_cast(updateMemory), - static_cast(updatePartition), imageSize, imageCrc, numOfUpdatePackets); + PLOC_SPV::UpdateInfo packet(PLOC_SPV::APID_UPDATE_AVAILABLE, static_cast(image), + static_cast(partition), imageSize, imageCrc, numOfUpdatePackets); result = commandActionHelper.commandAction(objects::PLOC_SUPERVISOR_HANDLER, PLOC_SPV::UPDATE_AVAILABLE, packet.getWholeData(), packet.getFullSize()); @@ -365,8 +381,8 @@ void PlocUpdater::commandUpdatePacket() { void PlocUpdater::commandUpdateVerify() { ReturnValue_t result = RETURN_OK; - PLOC_SPV::UpdateInfo packet(PLOC_SPV::APID_UPDATE_VERIFY, static_cast(updateMemory), - static_cast(updatePartition), imageSize, imageCrc, numOfUpdatePackets); + PLOC_SPV::UpdateInfo packet(PLOC_SPV::APID_UPDATE_VERIFY, static_cast(image), + static_cast(partition), imageSize, imageCrc, numOfUpdatePackets); result = commandActionHelper.commandAction(objects::PLOC_SUPERVISOR_HANDLER, PLOC_SPV::UPDATE_VERIFY, packet.getWholeData(), packet.getFullSize()); diff --git a/bsp_q7s/devices/PlocUpdater.h b/bsp_q7s/devices/PlocUpdater.h index c8a2b67b..50404d14 100644 --- a/bsp_q7s/devices/PlocUpdater.h +++ b/bsp_q7s/devices/PlocUpdater.h @@ -33,10 +33,14 @@ class PlocUpdater : public SystemObject, public CommandsActionsIF { public: - static const ActionId_t UPDATE_NVM0_A = 0; - static const ActionId_t UPDATE_NVM0_B = 1; - static const ActionId_t UPDATE_NVM1_A = 2; - static const ActionId_t UPDATE_NVM1_B = 3; + static const ActionId_t UPDATE_A_UBOOT = 0; + static const ActionId_t UPDATE_A_BITSTREAM = 1; + static const ActionId_t UPDATE_A_LINUX = 2; + static const ActionId_t UPDATE_A_APP_SW = 3; + static const ActionId_t UPDATE_B_UBOOT = 4; + static const ActionId_t UPDATE_B_BITSTREAM = 5; + static const ActionId_t UPDATE_B_LINUX = 6; + static const ActionId_t UPDATE_B_APP_SW = 7; PlocUpdater(object_id_t objectId); virtual ~PlocUpdater(); @@ -118,19 +122,23 @@ private: ActionId_t pendingCommand = PLOC_SPV::NONE; - enum class Memory: uint8_t { - NVM0, - NVM1 - }; - - Memory updateMemory = Memory::NVM0; - - enum class Partition: uint8_t { + enum class Image: uint8_t { + NONE, A, B }; - Partition updatePartition = Partition::A; + Image image = Image::NONE; + + enum class Partition: uint8_t { + NONE, + UBOOT, + BITSTREAM, + LINUX_OS, + APP_SW + }; + + Partition partition = Partition::NONE; uint32_t packetsSent = 0; uint32_t remainingPackets = 0; diff --git a/bsp_q7s/devices/devicedefinitions/PlocSupervisorDefinitions.h b/bsp_q7s/devices/devicedefinitions/PlocSupervisorDefinitions.h index 26d44272..a28418e7 100644 --- a/bsp_q7s/devices/devicedefinitions/PlocSupervisorDefinitions.h +++ b/bsp_q7s/devices/devicedefinitions/PlocSupervisorDefinitions.h @@ -67,7 +67,7 @@ static const uint16_t SIZE_ACK_REPORT = 14; static const uint16_t SIZE_EXE_REPORT = 14; static const uint16_t SIZE_HK_REPORT = 48; static const uint16_t SIZE_BOOT_STATUS_REPORT = 22; -static const uint16_t SIZE_LATCHUP_STATUS_REPORT = 51; +static const uint16_t SIZE_LATCHUP_STATUS_REPORT = 55; /** * SpacePacket apids of telemetry packets @@ -196,11 +196,12 @@ enum PoolIds LATCHUP_RPT_TIME_YEAR, LATCHUP_RPT_TIME_MSEC, LATCHUP_RPT_TIME_USEC, + LATCHUP_RPT_TIME_IS_SET, }; static const uint8_t HK_SET_ENTRIES = 13; static const uint8_t BOOT_REPORT_SET_ENTRIES = 8; -static const uint8_t LATCHUP_RPT_SET_ENTRIES = 15; +static const uint8_t LATCHUP_RPT_SET_ENTRIES = 16; static const uint32_t HK_SET_ID = HK_REPORT; static const uint32_t BOOT_REPORT_SET_ID = BOOT_STATUS_REPORT; @@ -1445,14 +1446,15 @@ public: * * @param apid Packet can be used to generate the update available and the update verify * packet. Thus the APID must be specified here. - * @param memory The memory to apply the update (NVM0 - 0, NVM1 - 1) - * @param partition The partition to update (A - 0, B - 1) + * @param image The image to update on a NVM (A - 0, B - 1) + * @param partition The partition to update. uboot - 1, bitstream - 2, linux - 3, + * application - 4 * @param imageSize The size of the update image * param numPackets The number of space packets required to transfer all data. */ - UpdateInfo(uint16_t apid, uint8_t memory, uint8_t partition, uint32_t imageSize, + UpdateInfo(uint16_t apid, uint8_t image, uint8_t partition, uint32_t imageSize, uint32_t imageCrc, uint32_t numPackets) : - SupvTcSpacePacket(PAYLOAD_LENGTH, apid), memory(memory), partition(partition), imageSize( + SupvTcSpacePacket(PAYLOAD_LENGTH, apid), image(image), partition(partition), imageSize( imageSize), imageCrc(imageCrc), numPackets(numPackets) { initPacket(); makeCrc(); @@ -1462,7 +1464,7 @@ private: static const uint16_t PAYLOAD_LENGTH = 14; // length without CRC field - uint8_t memory = 0; + uint8_t image = 0; uint8_t partition = 0; uint32_t imageSize = 0; uint32_t imageCrc = 0; @@ -1471,8 +1473,8 @@ private: void initPacket() { size_t serializedSize = 0; uint8_t* data_field_ptr = this->localData.fields.buffer; - SerializeAdapter::serialize(&memory, &data_field_ptr, &serializedSize, - sizeof(memory), SerializeIF::Endianness::BIG); + SerializeAdapter::serialize(&image, &data_field_ptr, &serializedSize, + sizeof(image), SerializeIF::Endianness::BIG); serializedSize = 0; SerializeAdapter::serialize(&partition, &data_field_ptr, &serializedSize, sizeof(partition), SerializeIF::Endianness::BIG); @@ -1599,6 +1601,7 @@ public: lp_var_t timeMon = lp_var_t(sid.objectId, PoolIds::LATCHUP_RPT_TIME_MON, this); lp_var_t timeYear = lp_var_t(sid.objectId, PoolIds::LATCHUP_RPT_TIME_YEAR, this); lp_var_t timeMsec = lp_var_t(sid.objectId, PoolIds::LATCHUP_RPT_TIME_MSEC, this); + lp_var_t isSet = lp_var_t(sid.objectId, PoolIds::LATCHUP_RPT_TIME_IS_SET, this); }; } diff --git a/tmtc b/tmtc index 5b2ff495..c125a626 160000 --- a/tmtc +++ b/tmtc @@ -1 +1 @@ -Subproject commit 5b2ff49555f0cfee51cd53c7772a147575a825a3 +Subproject commit c125a6261201930c25ebdcdeb0ef69a53ab588b0 -- 2.43.0 From 5789e2a3b5229f9a66b6102a9dfb53f089d9848d Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Fri, 20 Aug 2021 10:01:37 +0200 Subject: [PATCH 40/43] added LICENSE and NOTICE file --- LICENSE | 202 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ NOTICE | 13 ++++ 2 files changed, 215 insertions(+) create mode 100644 LICENSE create mode 100644 NOTICE diff --git a/LICENSE b/LICENSE new file mode 100644 index 00000000..d6456956 --- /dev/null +++ b/LICENSE @@ -0,0 +1,202 @@ + + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. diff --git a/NOTICE b/NOTICE new file mode 100644 index 00000000..86a797ad --- /dev/null +++ b/NOTICE @@ -0,0 +1,13 @@ +Copyright 2021 Institute of Space Systems (IRS), University of Stuttgart + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. \ No newline at end of file -- 2.43.0 From 95b49ca49dbd3e2ce7a1dec49b0f1c28ce592c22 Mon Sep 17 00:00:00 2001 From: "Jakob.Meier" <–meierj@irs.uni-stuttgart.de> Date: Fri, 20 Aug 2021 13:56:43 +0200 Subject: [PATCH 41/43] update tmtc and arcsec submodule --- README.md | 4 ++++ linux/fsfwconfig/OBSWConfig.h.in | 2 +- thirdparty/arcsec_star_tracker | 2 +- tmtc | 2 +- 4 files changed, 7 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index d690a3a1..77263fd2 100644 --- a/README.md +++ b/README.md @@ -932,6 +932,10 @@ All content will be printed with ```` cat file.bin | hexdump -v ```` +To print only the first X bytes of a file +```` +cat file.bin | hexdump -v -n X +```` ## Preparation of a fresh rootfs and SD card diff --git a/linux/fsfwconfig/OBSWConfig.h.in b/linux/fsfwconfig/OBSWConfig.h.in index e848fc6e..e2693430 100644 --- a/linux/fsfwconfig/OBSWConfig.h.in +++ b/linux/fsfwconfig/OBSWConfig.h.in @@ -41,7 +41,7 @@ debugging. */ #define ADD_PLOC_SUPERVISOR 1 #define ADD_PLOC_MPSOC 0 -#define BOARD_TE0720 1 +#define BOARD_TE0720 0 #define TE0720_HEATER_TEST 0 #define P60DOCK_DEBUG 0 diff --git a/thirdparty/arcsec_star_tracker b/thirdparty/arcsec_star_tracker index c468400a..657c06e4 160000 --- a/thirdparty/arcsec_star_tracker +++ b/thirdparty/arcsec_star_tracker @@ -1 +1 @@ -Subproject commit c468400aaf8470a31e393f53c858d2bf2c361273 +Subproject commit 657c06e4a6e4c460e897c4a5b4eaefe7c6d1085e diff --git a/tmtc b/tmtc index c125a626..ce5596f5 160000 --- a/tmtc +++ b/tmtc @@ -1 +1 @@ -Subproject commit c125a6261201930c25ebdcdeb0ef69a53ab588b0 +Subproject commit ce5596f5669b8df44df418da6adff123941a395d -- 2.43.0 From 89b68940bede3cecdb3958dec149211fb454fd47 Mon Sep 17 00:00:00 2001 From: "Jakob.Meier" <–meierj@irs.uni-stuttgart.de> Date: Sun, 29 Aug 2021 07:31:34 +0200 Subject: [PATCH 42/43] ploc memory dumper wip --- bsp_q7s/devices/PlocMemoryDumper.cpp | 203 ++++++++++++++++++ bsp_q7s/devices/PlocMemoryDumper.h | 113 ++++++++++ .../PlocMemDumpDefinitions.h | 31 +++ .../PlocSupervisorDefinitions.h | 3 +- common/config/commonClassIds.h | 1 + common/config/commonSubsystemIds.h | 1 + 6 files changed, 351 insertions(+), 1 deletion(-) create mode 100644 bsp_q7s/devices/PlocMemoryDumper.cpp create mode 100644 bsp_q7s/devices/PlocMemoryDumper.h create mode 100644 bsp_q7s/devices/devicedefinitions/PlocMemDumpDefinitions.h diff --git a/bsp_q7s/devices/PlocMemoryDumper.cpp b/bsp_q7s/devices/PlocMemoryDumper.cpp new file mode 100644 index 00000000..34d94186 --- /dev/null +++ b/bsp_q7s/devices/PlocMemoryDumper.cpp @@ -0,0 +1,203 @@ +#include "fsfw/ipc/QueueFactory.h" +#include "PlocMemoryDumper.h" + +#include +#include +#include + +PlocMemoryDumper::PlocMemoryDumper(object_id_t objectId) : + SystemObject(objectId), commandActionHelper(this), actionHelper(this, nullptr) { + commandQueue = QueueFactory::instance()->createMessageQueue(QUEUE_SIZE); +} + +PlocMemoryDumper::~PlocMemoryDumper() { +} + +ReturnValue_t PlocMemoryDumper::initialize() { + + ReturnValue_t result = SystemObject::initialize(); + if (result != HasReturnvaluesIF::RETURN_OK) { + return result; + } + result = commandActionHelper.initialize(); + if (result != HasReturnvaluesIF::RETURN_OK) { + return result; + } + result = actionHelper.initialize(commandQueue); + if (result != HasReturnvaluesIF::RETURN_OK) { + return result; + } + + return HasReturnvaluesIF::RETURN_OK; +} + +ReturnValue_t PlocMemoryDumper::performOperation(uint8_t operationCode) { + readCommandQueue(); + doStateMachine(); + return HasReturnvaluesIF::RETURN_OK; +} + +ReturnValue_t PlocMemoryDumper::executeAction(ActionId_t actionId, + MessageQueueId_t commandedBy, const uint8_t* data, size_t size) { + ReturnValue_t result = RETURN_FAILED; + + if (state != State::IDLE) { + return IS_BUSY; + } + + switch (actionId) { + case DUMP_MRAM: + SerializeAdapter::deSerialize(&mram.startAddress, &data, sizeof(mramStartAdress), + SerializeIF::Endianness::BIG); + SerializeAdapter::deSerialize(&mram.endAddress, &data, sizeof(mramStartAdress), + SerializeIF::Endianness::BIG); + if (mram.endAddress > MAX_MRAM_ADDRESS) { + return MRAM_ADDRESS_TOO_HIGH; + } + if (mram.endAddress <= mram.startAddress) { + return MRAM_INVALID_ADDRESS_COMBINATION; + } + state = State::COMMAND_FIRST_MRAM_DUMP; + break; + default: + sif::warning << "PlocMemoryDumper::executeAction: Received command with invalid action id" + << std::endl; + return INVALID_ACTION_ID; + } + + return RETURN_OK; +} + +MessageQueueId_t PlocMemoryDumper::getCommandQueue() const { + return commandQueue->getId(); +} + +MessageQueueIF* PlocMemoryDumper::getCommandQueuePtr() { + return commandQueue; +} + +void PlocMemoryDumper::readCommandQueue() { + CommandMessage message; + ReturnValue_t result; + + for (result = commandQueue->receiveMessage(&message); result == HasReturnvaluesIF::RETURN_OK; + result = commandQueue->receiveMessage(&message)) { + if (result != RETURN_OK) { + continue; + } + result = actionHelper.handleActionMessage(&message); + if (result == HasReturnvaluesIF::RETURN_OK) { + continue; + } + + result = commandActionHelper.handleReply(&message); + if (result == HasReturnvaluesIF::RETURN_OK) { + continue; + } + + sif::debug << "PlocMemoryDumper::readCommandQueue: Received message with invalid format" + << std::endl; + } +} + +void PlocMemoryDumper::doStateMachine() { + switch (state) { + case State::IDLE: + break; + case State::COMMAND_FIRST_MRAM_DUMP: + commandNextMramDump(PLOC_SPV::FIRST_MRAM_DUMP); + break; + case State::COMMAND_CONSECUTIVE_MRAM_DUMP: + commandNextMramDump(PLOC_SPV::CONSECUTIVE_MRAM_DUMP); + break; + case State::EXECUTING_MRAM_DUMP: + break; + default: + sif::debug << "PlocMemoryDumper::doStateMachine: Invalid state" << std::endl; + break; + } +} + +void PlocMemoryDumper::stepSuccessfulReceived(ActionId_t actionId, + uint8_t step) { +} + +void PlocMemoryDumper::stepFailedReceived(ActionId_t actionId, uint8_t step, + ReturnValue_t returnCode) { +} + +void PlocMemoryDumper::dataReceived(ActionId_t actionId, const uint8_t* data, uint32_t size) { + +} + +void PlocMemoryDumper::completionSuccessfulReceived(ActionId_t actionId) { + switch (pendingCommand) { + case (PLOC_SPV::FIRST_MRAM_DUMP): + case (PLOC_SPV::CONSECUTIVE_MRAM_DUMP): + if (mram.endAddress == mram.startAddress) { + triggerEvent(MRAM_DUMP_FINISHED); + state = State::IDLE; + } + else { + state = State::COMMAND_MRAM_DUMP; + } + break; + default: + sif::debug << "PlocMemoryDumper::completionSuccessfulReceived: Invalid pending command" + << std::endl; + state = State::IDLE; + break; + } +} + +void PlocMemoryDumper::completionFailedReceived(ActionId_t actionId, + ReturnValue_t returnCode) { + switch(pendingCommand) { + case(PLOC_SPV::FIRST_MRAM_DUMP): + case(PLOC_SPV::CONSECUTIVE_MRAM_DUMP): + triggerEvent(MRAM_DUMP_FAILED, mram.lastStartAddress); + break; + default: + sif::debug << "PlocMemoryDumper::completionFailedReceived: Invalid pending command " + << std::endl; + break; + } + state = State::IDLE; +} + +void PlocMemoryDumper::commandNextMramDump(ActionId_t dumpCommand) { + ReturnValue_t result = RETURN_OK; + + uint32_t tempStartAddress = 0; + uint32_t tempEndAddress = 0; + + if (mram.endAddress - mram.startAddress > MAX_MRAM_DUMP_SIZE) { + tempStartAddress = mram.startAddress; + tempEndAddress = mram.startAddress + MAX_MRAM_DUMP_SIZE; + mram.startAddress += MAX_MRAM_DUMP_SIZE; + mram.lastStartAddress = tempStartAddress; + } + else { + tempStartAddress = mram.startAddress; + tempEndAddress = mram.endAddress; + mram.startAddress = mram.endAddress; + } + + MemoryParams params(tempStartAddress, tempEndAddress); + + result = commandActionHelper.commandAction(objects::PLOC_SUPERVISOR_HANDLER, + dumpCommand, ¶ms); + if (result != RETURN_OK) { + sif::warning << "PlocMemoryDumper::commandNextMramDump: Failed to send mram dump command " + << "with start address " << tempStartAddress << " and end address " + << tempEndAddress << std::endl; + triggerEvent(SEND_MRAM_DUMP_FAILED, result, tempStartAddress); + state = State::IDLE; + pendingCommand = NONE; + return; + } + state = State::EXECUTING_MRAM_DUMP; + pendingCommand = dumpCommand; + return; +} + diff --git a/bsp_q7s/devices/PlocMemoryDumper.h b/bsp_q7s/devices/PlocMemoryDumper.h new file mode 100644 index 00000000..ef3a9212 --- /dev/null +++ b/bsp_q7s/devices/PlocMemoryDumper.h @@ -0,0 +1,113 @@ +#ifndef MISSION_DEVICES_PLOCMEMORYDUMPER_H_ +#define MISSION_DEVICES_PLOCMEMORYDUMPER_H_ + +#include +#include +#include "OBSWConfig.h" +#include "fsfw/action/CommandActionHelper.h" +#include "fsfw/action/ActionHelper.h" +#include "fsfw/action/HasActionsIF.h" +#include "fsfw/action/CommandsActionsIF.h" +#include "fsfw/returnvalues/HasReturnvaluesIF.h" +#include "fsfw/tasks/ExecutableObjectIF.h" +#include "fsfw/objectmanager/SystemObject.h" +#include "bsp_q7s/memory/SdCardManager.h" +#include "linux/fsfwconfig/objects/systemObjectList.h" +#include "fsfw/tmtcpacket/SpacePacket.h" + + +/** + * @brief Because the buffer of the linux tty driver is limited to 2 x 65535 bytes, this class is + * created to perform large dumps of PLOC memories. + * + * @details Currently the PLOC supervisor only implements the functionality to dump the MRAM. + * + * @author J. Meier + */ +class PlocMemoryDumper : public SystemObject, + public HasActionsIF, + public ExecutableObjectIF, + public HasReturnvaluesIF, + public CommandsActionsIF { +public: + + static const ActionId_t NONE = 0; + static const ActionId_t DUMP_MRAM = 1; + + PlocMemoryDumper(object_id_t objectId); + virtual ~PlocMemoryDumper(); + + ReturnValue_t performOperation(uint8_t operationCode = 0) override; + ReturnValue_t executeAction(ActionId_t actionId, MessageQueueId_t commandedBy, + const uint8_t* data, size_t size); + MessageQueueId_t getCommandQueue() const; + ReturnValue_t initialize() override; + MessageQueueIF* getCommandQueuePtr() override; + void stepSuccessfulReceived(ActionId_t actionId, uint8_t step) override; + void stepFailedReceived(ActionId_t actionId, uint8_t step, ReturnValue_t returnCode) override; + void dataReceived(ActionId_t actionId, const uint8_t* data, uint32_t size) override; + void completionSuccessfulReceived(ActionId_t actionId) override; + void completionFailedReceived(ActionId_t actionId, ReturnValue_t returnCode) override; + +private: + + static const uint8_t INTERFACE_ID = CLASS_ID::PLOC_MEMORY_DUMPER; + + //! [EXPORT] : [COMMENT] The capacity of the MRAM amounts to 512 kB. Thus the maximum address must not be higher than 0x7d000. + static const ReturnValue_t MRAM_ADDRESS_TOO_HIGH = MAKE_RETURN_CODE(0xA0); + //! [EXPORT] : [COMMENT] The specified end address is lower than the start address + static const ReturnValue_t MRAM_INVALID_ADDRESS_COMBINATION = MAKE_RETURN_CODE(0xA1); + + static const uint8_t SUBSYSTEM_ID = SUBSYSTEM_ID::PLOC_MEMORY_DUMPER; + + //! [EXPORT] : [COMMENT] Failed to send mram dump command to supervisor handler + //! P1: Return value of commandAction function + //! P2: Start address of MRAM to dump with this command + static const Event SEND_MRAM_DUMP_FAILED = MAKE_EVENT(0, severity::LOW); + //! [EXPORT] : [COMMENT] Received completion failure report form PLOC supervisor handler + //! P1: MRAM start address of failing dump command + static const Event MRAM_DUMP_FAILED = MAKE_EVENT(1, severity::LOW); + //! [EXPORT] : [COMMENT] MRAM dump finished successfully + static const Event MRAM_DUMP_FINISHED = MAKE_EVENT(2, severity::LOW); + + // Maximum size of mram dump which can be retrieved with one command + static const uint32_t MAX_MRAM_DUMP_SIZE = 100000; + static const uint32_t MAX_MRAM_ADDRESS = 0x7d000; + + MessageQueueIF* commandQueue = nullptr; + + CommandActionHelper commandActionHelper; + + ActionHelper actionHelper; + + enum class State: uint8_t { + IDLE, + COMMAND_FIRST_MRAM_DUMP, + COMMAND_CONSECUTIVE_MRAM_DUMP, + EXECUTING_MRAM_DUMP + }; + + State state = State::IDLE; + + ActionId_t pendingCommand = NONE; + + typedef struct MemoryRange { + // Stores the start address of the next memory range to dump + uint32_t startAddress; + uint32_t endAddress; + // Stores the start address of the last sent dump command + uint32_t lastStartAddress; + } MemoryRange_t; + + MemoryRange_t mram = {0, 0, 0}; + + void readCommandQueue(); + void doStateMachine(); + + /** + * @brief Sends the next mram dump command to the PLOC supervisor handler. + */ + void commandNextMramDump(); +}; + +#endif /* MISSION_DEVICES_PLOCMEMORYDUMPER_H_ */ diff --git a/bsp_q7s/devices/devicedefinitions/PlocMemDumpDefinitions.h b/bsp_q7s/devices/devicedefinitions/PlocMemDumpDefinitions.h new file mode 100644 index 00000000..e221ac1e --- /dev/null +++ b/bsp_q7s/devices/devicedefinitions/PlocMemDumpDefinitions.h @@ -0,0 +1,31 @@ +#ifndef BSP_Q7S_DEVICES_DEVICEDEFINITIONS_PLOCMEMDUMPDEFINITIONS_H_ +#define BSP_Q7S_DEVICES_DEVICEDEFINITIONS_PLOCMEMDUMPDEFINITIONS_H_ + +class MemoryParams: public SerialLinkedListAdapter { +public: + + /** + * @brief Constructor + * @param startAddress Start of address range to dump + * @param endAddress End of address range to dump + */ + MemoryParams(uint32_t startAddress, uint32_t endAddress) : + startAddress(startAddress), endAddress(endAddress) { + setLinks(); + } +private: + + void setLinks() { + setStart(&startAddress); + startAddress.setNext(&endAddress); + } + + SerializeElement startAddress; + SerializeElement endAddress; + +}; + + + + +#endif /* BSP_Q7S_DEVICES_DEVICEDEFINITIONS_PLOCMEMDUMPDEFINITIONS_H_ */ diff --git a/bsp_q7s/devices/devicedefinitions/PlocSupervisorDefinitions.h b/bsp_q7s/devices/devicedefinitions/PlocSupervisorDefinitions.h index a28418e7..87cf0cb2 100644 --- a/bsp_q7s/devices/devicedefinitions/PlocSupervisorDefinitions.h +++ b/bsp_q7s/devices/devicedefinitions/PlocSupervisorDefinitions.h @@ -42,7 +42,7 @@ static const DeviceCommandId_t ENABLE_NVMS = 26; static const DeviceCommandId_t SELECT_NVM = 27; static const DeviceCommandId_t RUN_AUTO_EM_TESTS = 28; static const DeviceCommandId_t WIPE_MRAM = 29; -static const DeviceCommandId_t DUMP_MRAM = 30; +static const DeviceCommandId_t FIRST_MRAM_DUMP = 30; static const DeviceCommandId_t SET_DBG_VERBOSITY = 31; static const DeviceCommandId_t CAN_LOOPBACK_TEST = 32; static const DeviceCommandId_t PRINT_CPU_STATS = 33; @@ -55,6 +55,7 @@ static const DeviceCommandId_t UPDATE_IMAGE_DATA = 39; static const DeviceCommandId_t FACTORY_RESET_CLEAR_MIRROR = 40; static const DeviceCommandId_t FACTORY_RESET_CLEAR_CIRCULAR = 41; static const DeviceCommandId_t UPDATE_VERIFY = 42; +static const DeviceCommandId_t CONSECUTIVE_MRAM_DUMP = 41; /** Reply IDs */ static const DeviceCommandId_t ACK_REPORT = 50; diff --git a/common/config/commonClassIds.h b/common/config/commonClassIds.h index 8f751df1..793cb1ba 100644 --- a/common/config/commonClassIds.h +++ b/common/config/commonClassIds.h @@ -21,6 +21,7 @@ enum commonClassIds: uint8_t { CCSDS_IP_CORE_BRIDGE, //IPCI PLOC_UPDATER, //PLUD GOM_SPACE_HANDLER, //GOMS + PLOC_MEMORY_DUMPER, //PLMEMDUMP COMMON_CLASS_ID_END // [EXPORT] : [END] }; diff --git a/common/config/commonSubsystemIds.h b/common/config/commonSubsystemIds.h index ab87d119..58ebac66 100644 --- a/common/config/commonSubsystemIds.h +++ b/common/config/commonSubsystemIds.h @@ -18,6 +18,7 @@ enum: uint8_t { PLOC_SUPERVISOR_HANDLER = 115, FILE_SYSTEM = 116, PLOC_UPDATER = 117, + PLOC_MEMORY_DUMPER = 118, COMMON_SUBSYSTEM_ID_END }; } -- 2.43.0 From 0f7986444600d67e15b91abe2f9b154dd81d8d18 Mon Sep 17 00:00:00 2001 From: "Jakob.Meier" <–meierj@irs.uni-stuttgart.de> Date: Tue, 31 Aug 2021 11:20:21 +0200 Subject: [PATCH 43/43] ploc memory dumper complete --- bsp_q7s/core/InitMission.cpp | 8 -- bsp_q7s/core/ObjectFactory.cpp | 2 + bsp_q7s/devices/CMakeLists.txt | 1 + bsp_q7s/devices/PlocMemoryDumper.cpp | 17 +++-- bsp_q7s/devices/PlocMemoryDumper.h | 10 ++- bsp_q7s/devices/PlocSupervisorHandler.cpp | 73 ++++++++++++------- bsp_q7s/devices/PlocSupervisorHandler.h | 6 +- .../PlocMemDumpDefinitions.h | 2 + .../PlocSupervisorDefinitions.h | 2 +- common/config/commonObjects.h | 3 +- generators/bsp_q7s_events.csv | 24 +++--- generators/bsp_q7s_objects.csv | 9 ++- generators/events/event_parser.py | 2 +- generators/events/translateEvents.cpp | 16 +++- generators/objects/translateObjects.cpp | 31 ++++---- linux/fsfwconfig/events/translateEvents.cpp | 16 +++- linux/fsfwconfig/objects/translateObjects.cpp | 31 ++++---- .../pollingSequenceFactory.cpp | 7 ++ tmtc | 2 +- 19 files changed, 164 insertions(+), 98 deletions(-) diff --git a/bsp_q7s/core/InitMission.cpp b/bsp_q7s/core/InitMission.cpp index 0f4bc038..1b5f10fd 100644 --- a/bsp_q7s/core/InitMission.cpp +++ b/bsp_q7s/core/InitMission.cpp @@ -96,13 +96,6 @@ void initmission::initTasks() { initmission::printAddObjectError("UDP_POLLING", objects::TMTC_POLLING_TASK); } - PeriodicTaskIF* plocUpdaterTask = factory->createPeriodicTask( - "PLOC_UPDATER_TASK", 30, PeriodicTaskIF::MINIMUM_STACK_SIZE, 0.5, missedDeadlineFunc); - result = plocUpdaterTask->addComponent(objects::PLOC_UPDATER); - if(result != HasReturnvaluesIF::RETURN_OK) { - initmission::printAddObjectError("PLOC_UPDATER_TASK", objects::PLOC_UPDATER); - } - # if BOARD_TE0720 == 0 // FS task, task interval does not matter because it runs in permanent loop, priority low // because it is a non-essential background task @@ -151,7 +144,6 @@ void initmission::initTasks() { #if BOARD_TE0720 == 0 coreController->startTask(); #endif - plocUpdaterTask->startTask(); taskStarter(pstTasks, "PST task vector"); taskStarter(pusTasks, "PUS task vector"); diff --git a/bsp_q7s/core/ObjectFactory.cpp b/bsp_q7s/core/ObjectFactory.cpp index 60206e8f..9f6f6cd4 100644 --- a/bsp_q7s/core/ObjectFactory.cpp +++ b/bsp_q7s/core/ObjectFactory.cpp @@ -14,6 +14,7 @@ #include "bsp_q7s/memory/FileSystemHandler.h" #include "bsp_q7s/devices/PlocSupervisorHandler.h" #include "bsp_q7s/devices/PlocUpdater.h" +#include "bsp_q7s/devices/PlocMemoryDumper.h" #include "linux/devices/HeaterHandler.h" #include "linux/devices/SolarArrayDeploymentHandler.h" @@ -180,6 +181,7 @@ void ObjectFactory::produce(void* args){ #endif /* OBSW_ADD_TEST_CODE == 1 */ new PlocUpdater(objects::PLOC_UPDATER); + new PlocMemoryDumper(objects::PLOC_MEMORY_DUMPER); } void ObjectFactory::createTmpComponents() { diff --git a/bsp_q7s/devices/CMakeLists.txt b/bsp_q7s/devices/CMakeLists.txt index 80e1b1e5..6347b5f8 100644 --- a/bsp_q7s/devices/CMakeLists.txt +++ b/bsp_q7s/devices/CMakeLists.txt @@ -1,4 +1,5 @@ target_sources(${TARGET_NAME} PRIVATE PlocSupervisorHandler.cpp PlocUpdater.cpp + PlocMemoryDumper.cpp ) \ No newline at end of file diff --git a/bsp_q7s/devices/PlocMemoryDumper.cpp b/bsp_q7s/devices/PlocMemoryDumper.cpp index 34d94186..cc4361bb 100644 --- a/bsp_q7s/devices/PlocMemoryDumper.cpp +++ b/bsp_q7s/devices/PlocMemoryDumper.cpp @@ -1,3 +1,4 @@ +#include #include "fsfw/ipc/QueueFactory.h" #include "PlocMemoryDumper.h" @@ -39,17 +40,17 @@ ReturnValue_t PlocMemoryDumper::performOperation(uint8_t operationCode) { ReturnValue_t PlocMemoryDumper::executeAction(ActionId_t actionId, MessageQueueId_t commandedBy, const uint8_t* data, size_t size) { - ReturnValue_t result = RETURN_FAILED; if (state != State::IDLE) { return IS_BUSY; } switch (actionId) { - case DUMP_MRAM: - SerializeAdapter::deSerialize(&mram.startAddress, &data, sizeof(mramStartAdress), + case DUMP_MRAM: { + size_t deserializeSize = sizeof(mram.startAddress) + sizeof(mram.endAddress); + SerializeAdapter::deSerialize(&mram.startAddress, &data, &deserializeSize, SerializeIF::Endianness::BIG); - SerializeAdapter::deSerialize(&mram.endAddress, &data, sizeof(mramStartAdress), + SerializeAdapter::deSerialize(&mram.endAddress, &data, &deserializeSize, SerializeIF::Endianness::BIG); if (mram.endAddress > MAX_MRAM_ADDRESS) { return MRAM_ADDRESS_TOO_HIGH; @@ -59,13 +60,15 @@ ReturnValue_t PlocMemoryDumper::executeAction(ActionId_t actionId, } state = State::COMMAND_FIRST_MRAM_DUMP; break; - default: + } + default: { sif::warning << "PlocMemoryDumper::executeAction: Received command with invalid action id" << std::endl; return INVALID_ACTION_ID; } + } - return RETURN_OK; + return EXECUTION_FINISHED; } MessageQueueId_t PlocMemoryDumper::getCommandQueue() const { @@ -139,7 +142,7 @@ void PlocMemoryDumper::completionSuccessfulReceived(ActionId_t actionId) { state = State::IDLE; } else { - state = State::COMMAND_MRAM_DUMP; + state = State::COMMAND_CONSECUTIVE_MRAM_DUMP; } break; default: diff --git a/bsp_q7s/devices/PlocMemoryDumper.h b/bsp_q7s/devices/PlocMemoryDumper.h index ef3a9212..72b031ae 100644 --- a/bsp_q7s/devices/PlocMemoryDumper.h +++ b/bsp_q7s/devices/PlocMemoryDumper.h @@ -51,6 +51,8 @@ public: private: + static const uint32_t QUEUE_SIZE = 10; + static const uint8_t INTERFACE_ID = CLASS_ID::PLOC_MEMORY_DUMPER; //! [EXPORT] : [COMMENT] The capacity of the MRAM amounts to 512 kB. Thus the maximum address must not be higher than 0x7d000. @@ -91,15 +93,15 @@ private: ActionId_t pendingCommand = NONE; - typedef struct MemoryRange { + typedef struct MemoryInfo { // Stores the start address of the next memory range to dump uint32_t startAddress; uint32_t endAddress; // Stores the start address of the last sent dump command uint32_t lastStartAddress; - } MemoryRange_t; + } MemoryInfo_t; - MemoryRange_t mram = {0, 0, 0}; + MemoryInfo_t mram = {0, 0, 0}; void readCommandQueue(); void doStateMachine(); @@ -107,7 +109,7 @@ private: /** * @brief Sends the next mram dump command to the PLOC supervisor handler. */ - void commandNextMramDump(); + void commandNextMramDump(ActionId_t dumpCommand); }; #endif /* MISSION_DEVICES_PLOCMEMORYDUMPER_H_ */ diff --git a/bsp_q7s/devices/PlocSupervisorHandler.cpp b/bsp_q7s/devices/PlocSupervisorHandler.cpp index f8566244..30ea9572 100644 --- a/bsp_q7s/devices/PlocSupervisorHandler.cpp +++ b/bsp_q7s/devices/PlocSupervisorHandler.cpp @@ -199,10 +199,10 @@ ReturnValue_t PlocSupervisorHandler::buildCommandFromCommand( result = prepareWipeMramCmd(commandData); break; } - case(PLOC_SPV::DUMP_MRAM): { + case(PLOC_SPV::FIRST_MRAM_DUMP): + case(PLOC_SPV::CONSECUTIVE_MRAM_DUMP): result = prepareDumpMramCmd(commandData); break; - } case(PLOC_SPV::PRINT_CPU_STATS): { preparePrintCpuStatsCmd(commandData); result = RETURN_OK; @@ -319,7 +319,8 @@ void PlocSupervisorHandler::fillCommandAndReplyMap() { this->insertInCommandMap(PLOC_SPV::FACTORY_RESET_CLEAR_MIRROR); this->insertInCommandMap(PLOC_SPV::FACTORY_RESET_CLEAR_CIRCULAR); this->insertInCommandMap(PLOC_SPV::CAN_LOOPBACK_TEST); - this->insertInCommandAndReplyMap(PLOC_SPV::DUMP_MRAM, 3); + this->insertInCommandAndReplyMap(PLOC_SPV::FIRST_MRAM_DUMP, 3); + this->insertInCommandAndReplyMap(PLOC_SPV::CONSECUTIVE_MRAM_DUMP, 3); this->insertInReplyMap(PLOC_SPV::ACK_REPORT, 3, nullptr, PLOC_SPV::SIZE_ACK_REPORT); this->insertInReplyMap(PLOC_SPV::EXE_REPORT, 3, nullptr, PLOC_SPV::SIZE_EXE_REPORT); this->insertInReplyMap(PLOC_SPV::HK_REPORT, 3, &hkset, PLOC_SPV::SIZE_HK_REPORT); @@ -332,8 +333,12 @@ void PlocSupervisorHandler::fillCommandAndReplyMap() { ReturnValue_t PlocSupervisorHandler::scanForReply(const uint8_t *start, size_t remainingSize, DeviceCommandId_t *foundId, size_t *foundLen) { - if (nextReplyId == PLOC_SPV::DUMP_MRAM) { - *foundId = PLOC_SPV::DUMP_MRAM; + if (nextReplyId == PLOC_SPV::FIRST_MRAM_DUMP) { + *foundId = PLOC_SPV::FIRST_MRAM_DUMP; + return parseMramPackets(start, remainingSize, foundLen); + } + else if (nextReplyId == PLOC_SPV::CONSECUTIVE_MRAM_DUMP) { + *foundId = PLOC_SPV::CONSECUTIVE_MRAM_DUMP; return parseMramPackets(start, remainingSize, foundLen); } @@ -402,10 +407,10 @@ ReturnValue_t PlocSupervisorHandler::interpretDeviceReply(DeviceCommandId_t id, result = handleLatchupStatusReport(packet); break; } - case (PLOC_SPV::DUMP_MRAM): { - result = handleMramDumpPacket(); + case (PLOC_SPV::FIRST_MRAM_DUMP): + case (PLOC_SPV::CONSECUTIVE_MRAM_DUMP): + result = handleMramDumpPacket(id); break; - } case (PLOC_SPV::EXE_REPORT): { result = handleExecutionReport(packet); break; @@ -511,13 +516,23 @@ ReturnValue_t PlocSupervisorHandler::enableReplyInReplyMap(DeviceCommandMap::ite } break; } - case PLOC_SPV::DUMP_MRAM: { + case PLOC_SPV::FIRST_MRAM_DUMP: { enabledReplies = 2; // expected replies will be increased in handleMramDumpPacket result = DeviceHandlerBase::enableReplyInReplyMap(command, enabledReplies, true, - PLOC_SPV::DUMP_MRAM); + PLOC_SPV::FIRST_MRAM_DUMP); if (result != RETURN_OK) { sif::debug << "PlocSupervisorHandler::enableReplyInReplyMap: Reply with id " - << PLOC_SPV::LATCHUP_REPORT << " not in replyMap" << std::endl; + << PLOC_SPV::FIRST_MRAM_DUMP << " not in replyMap" << std::endl; + } + break; + } + case PLOC_SPV::CONSECUTIVE_MRAM_DUMP: { + enabledReplies = 2; // expected replies will be increased in handleMramDumpPacket + result = DeviceHandlerBase::enableReplyInReplyMap(command, enabledReplies, true, + PLOC_SPV::CONSECUTIVE_MRAM_DUMP); + if (result != RETURN_OK) { + sif::debug << "PlocSupervisorHandler::enableReplyInReplyMap: Reply with id " + << PLOC_SPV::CONSECUTIVE_MRAM_DUMP << " not in replyMap" << std::endl; } break; } @@ -924,8 +939,11 @@ void PlocSupervisorHandler::setNextReplyId() { case PLOC_SPV::GET_LATCHUP_STATUS_REPORT: nextReplyId = PLOC_SPV::LATCHUP_REPORT; break; - case PLOC_SPV::DUMP_MRAM: - nextReplyId = PLOC_SPV::DUMP_MRAM; + case PLOC_SPV::FIRST_MRAM_DUMP: + nextReplyId = PLOC_SPV::FIRST_MRAM_DUMP; + break; + case PLOC_SPV::CONSECUTIVE_MRAM_DUMP: + nextReplyId = PLOC_SPV::CONSECUTIVE_MRAM_DUMP; break; default: /* If no telemetry is expected the next reply is always the execution report */ @@ -942,7 +960,8 @@ size_t PlocSupervisorHandler::getNextReplyLength(DeviceCommandId_t commandId){ return replyLen; } - if (nextReplyId == PLOC_SPV::DUMP_MRAM) { + if (nextReplyId == PLOC_SPV::FIRST_MRAM_DUMP + || nextReplyId == PLOC_SPV::CONSECUTIVE_MRAM_DUMP) { /** * Try to read 20 MRAM packets. If reply is larger, the packets will be read with the * next doSendRead call. The command will be as long active as the packet with the sequence @@ -1347,7 +1366,7 @@ ReturnValue_t PlocSupervisorHandler::parseMramPackets(const uint8_t *packet, siz return result; } -ReturnValue_t PlocSupervisorHandler::handleMramDumpPacket() { +ReturnValue_t PlocSupervisorHandler::handleMramDumpPacket(DeviceCommandId_t id) { ReturnValue_t result = RETURN_FAILED; @@ -1359,24 +1378,24 @@ ReturnValue_t PlocSupervisorHandler::handleMramDumpPacket() { sif::warning << "PlocSupervisorHandler::handleMramDumpPacket: CRC failure" << std::endl; return result; } - handleMramDumpFile(); + handleMramDumpFile(id); if (downlinkMramDump == true) { handleDeviceTM(spacePacketBuffer + PLOC_SPV::SPACE_PACKET_HEADER_LENGTH, packetLen - 1, - PLOC_SPV::DUMP_MRAM); + id); } packetInBuffer = false; receivedMramDumpPackets++; if (expectedMramDumpPackets == receivedMramDumpPackets) { nextReplyId = PLOC_SPV::EXE_REPORT; } - increaseExpectedMramReplies(); + increaseExpectedMramReplies(id); return RETURN_OK; } return result; } -void PlocSupervisorHandler::increaseExpectedMramReplies() { - DeviceReplyMap::iterator mramDumpIter = deviceReplyMap.find(PLOC_SPV::DUMP_MRAM); +void PlocSupervisorHandler::increaseExpectedMramReplies(DeviceCommandId_t id) { + DeviceReplyMap::iterator mramDumpIter = deviceReplyMap.find(id); DeviceReplyMap::iterator exeReportIter = deviceReplyMap.find(PLOC_SPV::EXE_REPORT); if (mramDumpIter == deviceReplyMap.end()) { sif::debug << "PlocSupervisorHandler::increaseExpectedMramReplies: Dump MRAM reply not " @@ -1432,15 +1451,17 @@ ReturnValue_t PlocSupervisorHandler::checkMramPacketApid() { return APERIODIC_REPLY; } -ReturnValue_t PlocSupervisorHandler::handleMramDumpFile() { +ReturnValue_t PlocSupervisorHandler::handleMramDumpFile(DeviceCommandId_t id) { ReturnValue_t result = RETURN_OK; uint16_t packetLen = readSpacePacketLength(spacePacketBuffer); uint8_t sequenceFlags = readSequenceFlags(spacePacketBuffer); - if (sequenceFlags == static_cast(PLOC_SPV::SequenceFlags::FIRST_PKT) - || (sequenceFlags == static_cast(PLOC_SPV::SequenceFlags::STANDALONE_PKT))) { - result = createMramDumpFile(); - if (result != RETURN_OK) { - return result; + if (id == PLOC_SPV::FIRST_MRAM_DUMP) { + if (sequenceFlags == static_cast(PLOC_SPV::SequenceFlags::FIRST_PKT) + || (sequenceFlags == static_cast(PLOC_SPV::SequenceFlags::STANDALONE_PKT))) { + result = createMramDumpFile(); + if (result != RETURN_OK) { + return result; + } } } if (not std::filesystem::exists(activeMramFile)) { diff --git a/bsp_q7s/devices/PlocSupervisorHandler.h b/bsp_q7s/devices/PlocSupervisorHandler.h index c0c09eae..f22c86b1 100644 --- a/bsp_q7s/devices/PlocSupervisorHandler.h +++ b/bsp_q7s/devices/PlocSupervisorHandler.h @@ -295,14 +295,14 @@ private: /** * @brief This function generates the Service 8 packets for the MRAM dump data. */ - ReturnValue_t handleMramDumpPacket(); + ReturnValue_t handleMramDumpPacket(DeviceCommandId_t id); /** * @brief With this function the number of expected replies following an MRAM dump command * will be increased. This is necessary to release the command in case not all replies * have been received. */ - void increaseExpectedMramReplies(); + void increaseExpectedMramReplies(DeviceCommandId_t id); /** * @brief Function checks if the packet written to the space packet buffer is really a @@ -314,7 +314,7 @@ private: * @brief Writes the data of the MRAM dump to a file. The file will be created when receiving * the first packet. */ - ReturnValue_t handleMramDumpFile(); + ReturnValue_t handleMramDumpFile(DeviceCommandId_t id); /** * @brief Extracts the length field of a spacePacket referenced by the spacePacket pointer. diff --git a/bsp_q7s/devices/devicedefinitions/PlocMemDumpDefinitions.h b/bsp_q7s/devices/devicedefinitions/PlocMemDumpDefinitions.h index e221ac1e..6e44cf35 100644 --- a/bsp_q7s/devices/devicedefinitions/PlocMemDumpDefinitions.h +++ b/bsp_q7s/devices/devicedefinitions/PlocMemDumpDefinitions.h @@ -1,6 +1,8 @@ #ifndef BSP_Q7S_DEVICES_DEVICEDEFINITIONS_PLOCMEMDUMPDEFINITIONS_H_ #define BSP_Q7S_DEVICES_DEVICEDEFINITIONS_PLOCMEMDUMPDEFINITIONS_H_ +#include + class MemoryParams: public SerialLinkedListAdapter { public: diff --git a/bsp_q7s/devices/devicedefinitions/PlocSupervisorDefinitions.h b/bsp_q7s/devices/devicedefinitions/PlocSupervisorDefinitions.h index 87cf0cb2..0235d281 100644 --- a/bsp_q7s/devices/devicedefinitions/PlocSupervisorDefinitions.h +++ b/bsp_q7s/devices/devicedefinitions/PlocSupervisorDefinitions.h @@ -55,7 +55,7 @@ static const DeviceCommandId_t UPDATE_IMAGE_DATA = 39; static const DeviceCommandId_t FACTORY_RESET_CLEAR_MIRROR = 40; static const DeviceCommandId_t FACTORY_RESET_CLEAR_CIRCULAR = 41; static const DeviceCommandId_t UPDATE_VERIFY = 42; -static const DeviceCommandId_t CONSECUTIVE_MRAM_DUMP = 41; +static const DeviceCommandId_t CONSECUTIVE_MRAM_DUMP = 43; /** Reply IDs */ static const DeviceCommandId_t ACK_REPORT = 50; diff --git a/common/config/commonObjects.h b/common/config/commonObjects.h index 6b987a32..e44e0a1a 100644 --- a/common/config/commonObjects.h +++ b/common/config/commonObjects.h @@ -82,7 +82,8 @@ enum commonObjects: uint32_t { START_TRACKER = 0x44130001, - PLOC_UPDATER = 0x44330000 + PLOC_UPDATER = 0x44330000, + PLOC_MEMORY_DUMPER = 0x44330001 }; } diff --git a/generators/bsp_q7s_events.csv b/generators/bsp_q7s_events.csv index 0174a9ee..a5bbcde4 100644 --- a/generators/bsp_q7s_events.csv +++ b/generators/bsp_q7s_events.csv @@ -90,13 +90,17 @@ 11207;SELF_TEST_COIL_CURRENT_FAILURE;LOW;Get self test result returns failure indicating that the coil current was outside of the expected range P1: Indicates on which axis the failure occurred. 0 -> INIT, 1 -> +X, 2 -> -X, 3 -> +Y, 4 -> -Y, 5 -> +Z, 6 -> -Z, 7 -> FINA;C:\Users\jakob\Work\EIVE\Q7S\Software\eive_obsw/mission/devices/IMTQHandler.h 11208;INVALID_ERROR_BYTE;LOW;Received invalid error byte. This indicates an error of the communication link between IMTQ and OBC.;C:\Users\jakob\Work\EIVE\Q7S\Software\eive_obsw/mission/devices/IMTQHandler.h 11301;ERROR_STATE;HIGH;Reaction wheel signals an error state;C:\Users\jakob\Work\EIVE\Q7S\Software\eive_obsw/mission/devices/RwHandler.h -11501;SUPV_MEMORY_READ_RPT_CRC_FAILURE;LOW;PLOC supervisor crc failure in telemetry packet;C:\Users\jakob\Work\EIVE\Q7S\Software\eive_obsw/mission/devices/PlocSupervisorHandler.h -11502;SUPV_ACK_FAILURE;LOW;PLOC supervisor received acknowledgment failure report;C:\Users\jakob\Work\EIVE\Q7S\Software\eive_obsw/mission/devices/PlocSupervisorHandler.h -11503;SUPV_EXE_FAILURE;LOW;PLOC received execution failure report;C:\Users\jakob\Work\EIVE\Q7S\Software\eive_obsw/mission/devices/PlocSupervisorHandler.h -11504;SUPV_CRC_FAILURE_EVENT;LOW;PLOC supervisor reply has invalid crc;C:\Users\jakob\Work\EIVE\Q7S\Software\eive_obsw/mission/devices/PlocSupervisorHandler.h -11700;UPDATE_FILE_NOT_EXISTS;LOW;;C:\Users\jakob\Work\EIVE\Q7S\Software\eive_obsw/mission/devices/PlocUpdater.h -11701;ACTION_COMMANDING_FAILED;LOW;;C:\Users\jakob\Work\EIVE\Q7S\Software\eive_obsw/mission/devices/PlocUpdater.h -11702;UPDATE_AVAILABLE_FAILED;LOW;Supervisor handler replied action message indicating a command execution failure of the update available command;C:\Users\jakob\Work\EIVE\Q7S\Software\eive_obsw/mission/devices/PlocUpdater.h -11703;UPDATE_TRANSFER_FAILED;LOW;Supervisor handler failed to transfer an update space packet. P1: Parameter holds the number of update packets already sent.;C:\Users\jakob\Work\EIVE\Q7S\Software\eive_obsw/mission/devices/PlocUpdater.h -11704;UPDATE_VERIFY_FAILED;LOW;Supervisor failed to execute the update verify command.;C:\Users\jakob\Work\EIVE\Q7S\Software\eive_obsw/mission/devices/PlocUpdater.h -11705;UPDATE_FINISHED;INFO;MPSoC update successful completed;C:\Users\jakob\Work\EIVE\Q7S\Software\eive_obsw/mission/devices/PlocUpdater.h +11501;SUPV_MEMORY_READ_RPT_CRC_FAILURE;LOW;PLOC supervisor crc failure in telemetry packet;C:\Users\jakob\Work\EIVE\Q7S\Software\eive_obsw/bsp_q7s/devices/PlocSupervisorHandler.h +11502;SUPV_ACK_FAILURE;LOW;PLOC supervisor received acknowledgment failure report;C:\Users\jakob\Work\EIVE\Q7S\Software\eive_obsw/bsp_q7s/devices/PlocSupervisorHandler.h +11503;SUPV_EXE_FAILURE;LOW;PLOC received execution failure report;C:\Users\jakob\Work\EIVE\Q7S\Software\eive_obsw/bsp_q7s/devices/PlocSupervisorHandler.h +11504;SUPV_CRC_FAILURE_EVENT;LOW;PLOC supervisor reply has invalid crc;C:\Users\jakob\Work\EIVE\Q7S\Software\eive_obsw/bsp_q7s/devices/PlocSupervisorHandler.h +11600;SANITIZATION_FAILED;LOW;;C:\Users\jakob\Work\EIVE\Q7S\Software\eive_obsw/bsp_q7s/memory/SdCardManager.h +11700;UPDATE_FILE_NOT_EXISTS;LOW;;C:\Users\jakob\Work\EIVE\Q7S\Software\eive_obsw/bsp_q7s/devices/PlocUpdater.h +11701;ACTION_COMMANDING_FAILED;LOW;;C:\Users\jakob\Work\EIVE\Q7S\Software\eive_obsw/bsp_q7s/devices/PlocUpdater.h +11702;UPDATE_AVAILABLE_FAILED;LOW;Supervisor handler replied action message indicating a command execution failure of the update available command;C:\Users\jakob\Work\EIVE\Q7S\Software\eive_obsw/bsp_q7s/devices/PlocUpdater.h +11703;UPDATE_TRANSFER_FAILED;LOW;Supervisor handler failed to transfer an update space packet. P1: Parameter holds the number of update packets already sent (inclusive the failed packet);C:\Users\jakob\Work\EIVE\Q7S\Software\eive_obsw/bsp_q7s/devices/PlocUpdater.h +11704;UPDATE_VERIFY_FAILED;LOW;Supervisor failed to execute the update verify command.;C:\Users\jakob\Work\EIVE\Q7S\Software\eive_obsw/bsp_q7s/devices/PlocUpdater.h +11705;UPDATE_FINISHED;INFO;MPSoC update successful completed;C:\Users\jakob\Work\EIVE\Q7S\Software\eive_obsw/bsp_q7s/devices/PlocUpdater.h +11800;SEND_MRAM_DUMP_FAILED;LOW;;C:\Users\jakob\Work\EIVE\Q7S\Software\eive_obsw/bsp_q7s/devices/PlocMemoryDumper.h +11801;MRAM_DUMP_FAILED;LOW;Received completion failure report form PLOC supervisor handler P1: MRAM start address of failing dump command;C:\Users\jakob\Work\EIVE\Q7S\Software\eive_obsw/bsp_q7s/devices/PlocMemoryDumper.h +11802;MRAM_DUMP_FINISHED;LOW;MRAM dump finished successfully;C:\Users\jakob\Work\EIVE\Q7S\Software\eive_obsw/bsp_q7s/devices/PlocMemoryDumper.h diff --git a/generators/bsp_q7s_objects.csv b/generators/bsp_q7s_objects.csv index 84d3db3a..4930f7a0 100644 --- a/generators/bsp_q7s_objects.csv +++ b/generators/bsp_q7s_objects.csv @@ -2,10 +2,6 @@ 0x43000003;CORE_CONTROLLER 0x43100002;ACS_CONTROLLER 0x43400001;THERMAL_CONTROLLER -0x44120001;RW1 -0x44120002;RW2 -0x44120003;RW3 -0x44120004;RW4 0x44120006;MGM_0_LIS3_HANDLER 0x44120010;GYRO_0_ADIS_HANDLER 0x44120032;SUS_1 @@ -21,12 +17,16 @@ 0x44120042;SUS_11 0x44120043;SUS_12 0x44120044;SUS_13 +0x44120047;RW1 0x44120107;MGM_1_RM3100_HANDLER 0x44120111;GYRO_1_L3G_HANDLER +0x44120148;RW2 0x44120208;MGM_2_LIS3_HANDLER 0x44120212;GYRO_2_ADIS_HANDLER +0x44120249;RW3 0x44120309;MGM_3_RM3100_HANDLER 0x44120313;GYRO_3_L3G_HANDLER +0x44120350;RW4 0x44130001;START_TRACKER 0x44130045;GPS0_HANDLER 0x44130146;GPS1_HANDLER @@ -38,6 +38,7 @@ 0x44250003;ACU_HANDLER 0x443200A5;RAD_SENSOR 0x44330000;PLOC_UPDATER +0x44330001;PLOC_MEMORY_DUMPER 0x44330015;PLOC_MPSOC_HANDLER 0x44330016;PLOC_SUPERVISOR_HANDLER 0x444100A2;SOLAR_ARRAY_DEPL_HANDLER diff --git a/generators/events/event_parser.py b/generators/events/event_parser.py index 56cc076f..62b26af4 100644 --- a/generators/events/event_parser.py +++ b/generators/events/event_parser.py @@ -51,7 +51,7 @@ SUBSYSTEM_DEFINITION_DESTINATIONS = [ ] HEADER_DEFINITION_DESTINATIONS = [ f"{OBSW_ROOT_DIR}/mission/", f"{OBSW_ROOT_DIR}/fsfw/", f"{FSFW_CONFIG_ROOT}", - f"{OBSW_ROOT_DIR}/test/" + f"{OBSW_ROOT_DIR}/test/", f"{OBSW_ROOT_DIR}/bsp_q7s" ] diff --git a/generators/events/translateEvents.cpp b/generators/events/translateEvents.cpp index 1df1d949..9d817651 100644 --- a/generators/events/translateEvents.cpp +++ b/generators/events/translateEvents.cpp @@ -1,7 +1,7 @@ /** - * @brief Auto-generated event translation file. Contains 102 translations. + * @brief Auto-generated event translation file. Contains 106 translations. * @details - * Generated on: 2021-08-07 18:11:16 + * Generated on: 2021-08-31 10:50:10 */ #include "translateEvents.h" @@ -101,12 +101,16 @@ const char *SUPV_MEMORY_READ_RPT_CRC_FAILURE_STRING = "SUPV_MEMORY_READ_RPT_CRC_ const char *SUPV_ACK_FAILURE_STRING = "SUPV_ACK_FAILURE"; const char *SUPV_EXE_FAILURE_STRING = "SUPV_EXE_FAILURE"; const char *SUPV_CRC_FAILURE_EVENT_STRING = "SUPV_CRC_FAILURE_EVENT"; +const char *SANITIZATION_FAILED_STRING = "SANITIZATION_FAILED"; const char *UPDATE_FILE_NOT_EXISTS_STRING = "UPDATE_FILE_NOT_EXISTS"; const char *ACTION_COMMANDING_FAILED_STRING = "ACTION_COMMANDING_FAILED"; const char *UPDATE_AVAILABLE_FAILED_STRING = "UPDATE_AVAILABLE_FAILED"; const char *UPDATE_TRANSFER_FAILED_STRING = "UPDATE_TRANSFER_FAILED"; const char *UPDATE_VERIFY_FAILED_STRING = "UPDATE_VERIFY_FAILED"; const char *UPDATE_FINISHED_STRING = "UPDATE_FINISHED"; +const char *SEND_MRAM_DUMP_FAILED_STRING = "SEND_MRAM_DUMP_FAILED"; +const char *MRAM_DUMP_FAILED_STRING = "MRAM_DUMP_FAILED"; +const char *MRAM_DUMP_FINISHED_STRING = "MRAM_DUMP_FINISHED"; const char * translateEvents(Event event) { switch( (event & 0xffff) ) { @@ -302,6 +306,8 @@ const char * translateEvents(Event event) { return SUPV_EXE_FAILURE_STRING; case(11504): return SUPV_CRC_FAILURE_EVENT_STRING; + case(11600): + return SANITIZATION_FAILED_STRING; case(11700): return UPDATE_FILE_NOT_EXISTS_STRING; case(11701): @@ -314,6 +320,12 @@ const char * translateEvents(Event event) { return UPDATE_VERIFY_FAILED_STRING; case(11705): return UPDATE_FINISHED_STRING; + case(11800): + return SEND_MRAM_DUMP_FAILED_STRING; + case(11801): + return MRAM_DUMP_FAILED_STRING; + case(11802): + return MRAM_DUMP_FINISHED_STRING; default: return "UNKNOWN_EVENT"; } diff --git a/generators/objects/translateObjects.cpp b/generators/objects/translateObjects.cpp index e5cc5b67..23a232c8 100644 --- a/generators/objects/translateObjects.cpp +++ b/generators/objects/translateObjects.cpp @@ -1,8 +1,8 @@ /** * @brief Auto-generated object translation file. * @details - * Contains 104 translations. - * Generated on: 2021-08-07 18:08:35 + * Contains 105 translations. + * Generated on: 2021-08-31 10:31:24 */ #include "translateObjects.h" @@ -10,10 +10,6 @@ const char *P60DOCK_TEST_TASK_STRING = "P60DOCK_TEST_TASK"; const char *CORE_CONTROLLER_STRING = "CORE_CONTROLLER"; const char *ACS_CONTROLLER_STRING = "ACS_CONTROLLER"; const char *THERMAL_CONTROLLER_STRING = "THERMAL_CONTROLLER"; -const char *RW1_STRING = "RW1"; -const char *RW2_STRING = "RW2"; -const char *RW3_STRING = "RW3"; -const char *RW4_STRING = "RW4"; const char *MGM_0_LIS3_HANDLER_STRING = "MGM_0_LIS3_HANDLER"; const char *GYRO_0_ADIS_HANDLER_STRING = "GYRO_0_ADIS_HANDLER"; const char *SUS_1_STRING = "SUS_1"; @@ -29,12 +25,16 @@ const char *SUS_10_STRING = "SUS_10"; const char *SUS_11_STRING = "SUS_11"; const char *SUS_12_STRING = "SUS_12"; const char *SUS_13_STRING = "SUS_13"; +const char *RW1_STRING = "RW1"; const char *MGM_1_RM3100_HANDLER_STRING = "MGM_1_RM3100_HANDLER"; const char *GYRO_1_L3G_HANDLER_STRING = "GYRO_1_L3G_HANDLER"; +const char *RW2_STRING = "RW2"; const char *MGM_2_LIS3_HANDLER_STRING = "MGM_2_LIS3_HANDLER"; const char *GYRO_2_ADIS_HANDLER_STRING = "GYRO_2_ADIS_HANDLER"; +const char *RW3_STRING = "RW3"; const char *MGM_3_RM3100_HANDLER_STRING = "MGM_3_RM3100_HANDLER"; const char *GYRO_3_L3G_HANDLER_STRING = "GYRO_3_L3G_HANDLER"; +const char *RW4_STRING = "RW4"; const char *START_TRACKER_STRING = "START_TRACKER"; const char *GPS0_HANDLER_STRING = "GPS0_HANDLER"; const char *GPS1_HANDLER_STRING = "GPS1_HANDLER"; @@ -46,6 +46,7 @@ const char *PDU2_HANDLER_STRING = "PDU2_HANDLER"; const char *ACU_HANDLER_STRING = "ACU_HANDLER"; const char *RAD_SENSOR_STRING = "RAD_SENSOR"; const char *PLOC_UPDATER_STRING = "PLOC_UPDATER"; +const char *PLOC_MEMORY_DUMPER_STRING = "PLOC_MEMORY_DUMPER"; const char *PLOC_MPSOC_HANDLER_STRING = "PLOC_MPSOC_HANDLER"; const char *PLOC_SUPERVISOR_HANDLER_STRING = "PLOC_SUPERVISOR_HANDLER"; const char *SOLAR_ARRAY_DEPL_HANDLER_STRING = "SOLAR_ARRAY_DEPL_HANDLER"; @@ -121,14 +122,6 @@ const char* translateObject(object_id_t object) { return ACS_CONTROLLER_STRING; case 0x43400001: return THERMAL_CONTROLLER_STRING; - case 0x44120001: - return RW1_STRING; - case 0x44120002: - return RW2_STRING; - case 0x44120003: - return RW3_STRING; - case 0x44120004: - return RW4_STRING; case 0x44120006: return MGM_0_LIS3_HANDLER_STRING; case 0x44120010: @@ -159,18 +152,26 @@ const char* translateObject(object_id_t object) { return SUS_12_STRING; case 0x44120044: return SUS_13_STRING; + case 0x44120047: + return RW1_STRING; case 0x44120107: return MGM_1_RM3100_HANDLER_STRING; case 0x44120111: return GYRO_1_L3G_HANDLER_STRING; + case 0x44120148: + return RW2_STRING; case 0x44120208: return MGM_2_LIS3_HANDLER_STRING; case 0x44120212: return GYRO_2_ADIS_HANDLER_STRING; + case 0x44120249: + return RW3_STRING; case 0x44120309: return MGM_3_RM3100_HANDLER_STRING; case 0x44120313: return GYRO_3_L3G_HANDLER_STRING; + case 0x44120350: + return RW4_STRING; case 0x44130001: return START_TRACKER_STRING; case 0x44130045: @@ -193,6 +194,8 @@ const char* translateObject(object_id_t object) { return RAD_SENSOR_STRING; case 0x44330000: return PLOC_UPDATER_STRING; + case 0x44330001: + return PLOC_MEMORY_DUMPER_STRING; case 0x44330015: return PLOC_MPSOC_HANDLER_STRING; case 0x44330016: diff --git a/linux/fsfwconfig/events/translateEvents.cpp b/linux/fsfwconfig/events/translateEvents.cpp index 1df1d949..9d817651 100644 --- a/linux/fsfwconfig/events/translateEvents.cpp +++ b/linux/fsfwconfig/events/translateEvents.cpp @@ -1,7 +1,7 @@ /** - * @brief Auto-generated event translation file. Contains 102 translations. + * @brief Auto-generated event translation file. Contains 106 translations. * @details - * Generated on: 2021-08-07 18:11:16 + * Generated on: 2021-08-31 10:50:10 */ #include "translateEvents.h" @@ -101,12 +101,16 @@ const char *SUPV_MEMORY_READ_RPT_CRC_FAILURE_STRING = "SUPV_MEMORY_READ_RPT_CRC_ const char *SUPV_ACK_FAILURE_STRING = "SUPV_ACK_FAILURE"; const char *SUPV_EXE_FAILURE_STRING = "SUPV_EXE_FAILURE"; const char *SUPV_CRC_FAILURE_EVENT_STRING = "SUPV_CRC_FAILURE_EVENT"; +const char *SANITIZATION_FAILED_STRING = "SANITIZATION_FAILED"; const char *UPDATE_FILE_NOT_EXISTS_STRING = "UPDATE_FILE_NOT_EXISTS"; const char *ACTION_COMMANDING_FAILED_STRING = "ACTION_COMMANDING_FAILED"; const char *UPDATE_AVAILABLE_FAILED_STRING = "UPDATE_AVAILABLE_FAILED"; const char *UPDATE_TRANSFER_FAILED_STRING = "UPDATE_TRANSFER_FAILED"; const char *UPDATE_VERIFY_FAILED_STRING = "UPDATE_VERIFY_FAILED"; const char *UPDATE_FINISHED_STRING = "UPDATE_FINISHED"; +const char *SEND_MRAM_DUMP_FAILED_STRING = "SEND_MRAM_DUMP_FAILED"; +const char *MRAM_DUMP_FAILED_STRING = "MRAM_DUMP_FAILED"; +const char *MRAM_DUMP_FINISHED_STRING = "MRAM_DUMP_FINISHED"; const char * translateEvents(Event event) { switch( (event & 0xffff) ) { @@ -302,6 +306,8 @@ const char * translateEvents(Event event) { return SUPV_EXE_FAILURE_STRING; case(11504): return SUPV_CRC_FAILURE_EVENT_STRING; + case(11600): + return SANITIZATION_FAILED_STRING; case(11700): return UPDATE_FILE_NOT_EXISTS_STRING; case(11701): @@ -314,6 +320,12 @@ const char * translateEvents(Event event) { return UPDATE_VERIFY_FAILED_STRING; case(11705): return UPDATE_FINISHED_STRING; + case(11800): + return SEND_MRAM_DUMP_FAILED_STRING; + case(11801): + return MRAM_DUMP_FAILED_STRING; + case(11802): + return MRAM_DUMP_FINISHED_STRING; default: return "UNKNOWN_EVENT"; } diff --git a/linux/fsfwconfig/objects/translateObjects.cpp b/linux/fsfwconfig/objects/translateObjects.cpp index e5cc5b67..23a232c8 100644 --- a/linux/fsfwconfig/objects/translateObjects.cpp +++ b/linux/fsfwconfig/objects/translateObjects.cpp @@ -1,8 +1,8 @@ /** * @brief Auto-generated object translation file. * @details - * Contains 104 translations. - * Generated on: 2021-08-07 18:08:35 + * Contains 105 translations. + * Generated on: 2021-08-31 10:31:24 */ #include "translateObjects.h" @@ -10,10 +10,6 @@ const char *P60DOCK_TEST_TASK_STRING = "P60DOCK_TEST_TASK"; const char *CORE_CONTROLLER_STRING = "CORE_CONTROLLER"; const char *ACS_CONTROLLER_STRING = "ACS_CONTROLLER"; const char *THERMAL_CONTROLLER_STRING = "THERMAL_CONTROLLER"; -const char *RW1_STRING = "RW1"; -const char *RW2_STRING = "RW2"; -const char *RW3_STRING = "RW3"; -const char *RW4_STRING = "RW4"; const char *MGM_0_LIS3_HANDLER_STRING = "MGM_0_LIS3_HANDLER"; const char *GYRO_0_ADIS_HANDLER_STRING = "GYRO_0_ADIS_HANDLER"; const char *SUS_1_STRING = "SUS_1"; @@ -29,12 +25,16 @@ const char *SUS_10_STRING = "SUS_10"; const char *SUS_11_STRING = "SUS_11"; const char *SUS_12_STRING = "SUS_12"; const char *SUS_13_STRING = "SUS_13"; +const char *RW1_STRING = "RW1"; const char *MGM_1_RM3100_HANDLER_STRING = "MGM_1_RM3100_HANDLER"; const char *GYRO_1_L3G_HANDLER_STRING = "GYRO_1_L3G_HANDLER"; +const char *RW2_STRING = "RW2"; const char *MGM_2_LIS3_HANDLER_STRING = "MGM_2_LIS3_HANDLER"; const char *GYRO_2_ADIS_HANDLER_STRING = "GYRO_2_ADIS_HANDLER"; +const char *RW3_STRING = "RW3"; const char *MGM_3_RM3100_HANDLER_STRING = "MGM_3_RM3100_HANDLER"; const char *GYRO_3_L3G_HANDLER_STRING = "GYRO_3_L3G_HANDLER"; +const char *RW4_STRING = "RW4"; const char *START_TRACKER_STRING = "START_TRACKER"; const char *GPS0_HANDLER_STRING = "GPS0_HANDLER"; const char *GPS1_HANDLER_STRING = "GPS1_HANDLER"; @@ -46,6 +46,7 @@ const char *PDU2_HANDLER_STRING = "PDU2_HANDLER"; const char *ACU_HANDLER_STRING = "ACU_HANDLER"; const char *RAD_SENSOR_STRING = "RAD_SENSOR"; const char *PLOC_UPDATER_STRING = "PLOC_UPDATER"; +const char *PLOC_MEMORY_DUMPER_STRING = "PLOC_MEMORY_DUMPER"; const char *PLOC_MPSOC_HANDLER_STRING = "PLOC_MPSOC_HANDLER"; const char *PLOC_SUPERVISOR_HANDLER_STRING = "PLOC_SUPERVISOR_HANDLER"; const char *SOLAR_ARRAY_DEPL_HANDLER_STRING = "SOLAR_ARRAY_DEPL_HANDLER"; @@ -121,14 +122,6 @@ const char* translateObject(object_id_t object) { return ACS_CONTROLLER_STRING; case 0x43400001: return THERMAL_CONTROLLER_STRING; - case 0x44120001: - return RW1_STRING; - case 0x44120002: - return RW2_STRING; - case 0x44120003: - return RW3_STRING; - case 0x44120004: - return RW4_STRING; case 0x44120006: return MGM_0_LIS3_HANDLER_STRING; case 0x44120010: @@ -159,18 +152,26 @@ const char* translateObject(object_id_t object) { return SUS_12_STRING; case 0x44120044: return SUS_13_STRING; + case 0x44120047: + return RW1_STRING; case 0x44120107: return MGM_1_RM3100_HANDLER_STRING; case 0x44120111: return GYRO_1_L3G_HANDLER_STRING; + case 0x44120148: + return RW2_STRING; case 0x44120208: return MGM_2_LIS3_HANDLER_STRING; case 0x44120212: return GYRO_2_ADIS_HANDLER_STRING; + case 0x44120249: + return RW3_STRING; case 0x44120309: return MGM_3_RM3100_HANDLER_STRING; case 0x44120313: return GYRO_3_L3G_HANDLER_STRING; + case 0x44120350: + return RW4_STRING; case 0x44130001: return START_TRACKER_STRING; case 0x44130045: @@ -193,6 +194,8 @@ const char* translateObject(object_id_t object) { return RAD_SENSOR_STRING; case 0x44330000: return PLOC_UPDATER_STRING; + case 0x44330001: + return PLOC_MEMORY_DUMPER_STRING; case 0x44330015: return PLOC_MPSOC_HANDLER_STRING; case 0x44330016: diff --git a/linux/fsfwconfig/pollingsequence/pollingSequenceFactory.cpp b/linux/fsfwconfig/pollingsequence/pollingSequenceFactory.cpp index 932fc845..6315d245 100644 --- a/linux/fsfwconfig/pollingsequence/pollingSequenceFactory.cpp +++ b/linux/fsfwconfig/pollingsequence/pollingSequenceFactory.cpp @@ -533,6 +533,9 @@ ReturnValue_t pst::pstUart(FixedTimeslotTaskIF *thisSequence) { DeviceHandlerIF::GET_READ); #endif + thisSequence->addSlot(objects::PLOC_UPDATER, length * 0, DeviceHandlerIF::PERFORM_OPERATION); + thisSequence->addSlot(objects::PLOC_MEMORY_DUMPER, length * 0, + DeviceHandlerIF::PERFORM_OPERATION); #if OBSW_ADD_PLOC_SUPERVISOR == 1 thisSequence->addSlot(objects::PLOC_SUPERVISOR_HANDLER, length * 0, DeviceHandlerIF::PERFORM_OPERATION); @@ -832,6 +835,10 @@ ReturnValue_t pst::pollingSequenceTE0720(FixedTimeslotTaskIF *thisSequence) { thisSequence->addSlot(objects::PLOC_SUPERVISOR_HANDLER, length * 0.8, DeviceHandlerIF::GET_READ); #endif + thisSequence->addSlot(objects::PLOC_UPDATER, length * 0, DeviceHandlerIF::PERFORM_OPERATION); + thisSequence->addSlot(objects::PLOC_MEMORY_DUMPER, length * 0, + DeviceHandlerIF::PERFORM_OPERATION); + if (thisSequence->checkSequence() != HasReturnvaluesIF::RETURN_OK) { sif::error << "Initialization of TE0720 PST failed" << std::endl; return HasReturnvaluesIF::RETURN_FAILED; diff --git a/tmtc b/tmtc index ce5596f5..9b176aeb 160000 --- a/tmtc +++ b/tmtc @@ -1 +1 @@ -Subproject commit ce5596f5669b8df44df418da6adff123941a395d +Subproject commit 9b176aebfaba51f4d045881a125d42b123f4eeb3 -- 2.43.0