From a298fff6024fd7e1be084c837a72b8b67b68b776 Mon Sep 17 00:00:00 2001 From: IRS Cleanroom Laptop Date: Tue, 17 Aug 2021 16:07:33 +0200 Subject: [PATCH 01/19] 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 From 921e82f6d149b12529f0ac46632a6430d2cbd761 Mon Sep 17 00:00:00 2001 From: IRS Cleanroom Laptop Date: Tue, 17 Aug 2021 16:35:41 +0200 Subject: [PATCH 02/19] 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 From aa248b7997450be4438099d37194a6a724260f06 Mon Sep 17 00:00:00 2001 From: IRS Cleanroom Laptop Date: Tue, 17 Aug 2021 17:11:59 +0200 Subject: [PATCH 03/19] 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; From e98b985d66145632c928880b31efad4d18866511 Mon Sep 17 00:00:00 2001 From: IRS Cleanroom Laptop Date: Tue, 17 Aug 2021 17:48:51 +0200 Subject: [PATCH 04/19] 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 } From 2f72b4e42a56880c746462a22a66c2da2b3221fe Mon Sep 17 00:00:00 2001 From: IRS Cleanroom Laptop Date: Tue, 17 Aug 2021 19:50:48 +0200 Subject: [PATCH 05/19] 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 From 2b061a2b1ce8165afd1c01b5c09117eb69b7b36d Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Wed, 18 Aug 2021 11:32:49 +0200 Subject: [PATCH 06/19] 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 From 19d4349c05fbb25dfe07a5e4fc0fbfb9303bb3ad Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Thu, 19 Aug 2021 10:16:55 +0200 Subject: [PATCH 07/19] 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 From 7fc3285272183fa845b60eddb50422e9fcafe303 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Thu, 19 Aug 2021 13:34:44 +0200 Subject: [PATCH 08/19] 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_ */ From c1b22af695838a8a9f3e4a109c2854082f2776f8 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Thu, 19 Aug 2021 14:05:25 +0200 Subject: [PATCH 09/19] 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; } From a6777067da544fccb21ad652242ee1f2ad28b228 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Thu, 19 Aug 2021 14:16:26 +0200 Subject: [PATCH 10/19] 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; } From faee071edcfb7a2ea873694691d142d069b3615b Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Thu, 19 Aug 2021 14:34:24 +0200 Subject: [PATCH 11/19] 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(); From 963e40120f3c6cfd19c6a26f77a63c43fd05d988 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Thu, 19 Aug 2021 14:35:36 +0200 Subject: [PATCH 12/19] 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()); From 8ddd7b02dc32548ebd3da854f90ee0968f8ee687 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Thu, 19 Aug 2021 14:45:25 +0200 Subject: [PATCH 13/19] 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; From 7c828427e936a55a2b94498dea1c5cd6b8cc89f8 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Thu, 19 Aug 2021 17:08:51 +0200 Subject: [PATCH 14/19] 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 From 42d225bb6c4cc924622e4ad7632746c1aed82d29 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Thu, 19 Aug 2021 17:20:40 +0200 Subject: [PATCH 15/19] 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 From 24ecfe84ae30e58087673ee4ad52e7edb713f134 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Thu, 19 Aug 2021 17:27:13 +0200 Subject: [PATCH 16/19] 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) { From d1afdfe578c08f21c7f5d3d9c81100649db41b21 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Thu, 19 Aug 2021 17:31:13 +0200 Subject: [PATCH 17/19] 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) { From e821a9700a1c1062602b459bdcfec1bcc6db7f18 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Thu, 19 Aug 2021 18:10:19 +0200 Subject: [PATCH 18/19] 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_ */ From ef75d9241555d1da43943f3eee533120fac0de9b Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Thu, 19 Aug 2021 18:26:00 +0200 Subject: [PATCH 19/19] 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);