From 6a1611686ddfedb629edba90ebfcd72d6487274f Mon Sep 17 00:00:00 2001 From: "Jakob.Meier" Date: Thu, 27 May 2021 13:34:28 +0200 Subject: [PATCH 001/111] fixed include names --- bsp_q7s/ObjectFactory.cpp | 35 ++++++++++++++++---------------- bsp_q7s/boardconfig/q7s_config.h | 2 +- fsfw | 2 +- fsfw_hal | 2 +- mission/devices/SusHandler.h | 1 - 5 files changed, 20 insertions(+), 22 deletions(-) diff --git a/bsp_q7s/ObjectFactory.cpp b/bsp_q7s/ObjectFactory.cpp index 297f8167..4aa76df5 100644 --- a/bsp_q7s/ObjectFactory.cpp +++ b/bsp_q7s/ObjectFactory.cpp @@ -400,54 +400,53 @@ void ObjectFactory::produce(){ #if Q7S_ADD_RTD_DEVICES == 1 GpioCookie* rtdGpioCookie = new GpioCookie; - gpioCallbacks::initTcsBoardDecoder(gpioComIF); GpioCallback* gpioRtdIc3 = new GpioCallback(std::string("Chip select RTD IC3"), gpio::OUT, 1, - &gpioCallbacks::tcsBoardDecoderCallback, gpioComIF); + &gpioCallbacks::spiCsDecoderCallback, gpioComIF); rtdGpioCookie->addGpio(gpioIds::RTD_IC3, gpioRtdIc3); GpioCallback* gpioRtdIc4 = new GpioCallback(std::string("Chip select RTD IC4"), gpio::OUT, 1, - &gpioCallbacks::tcsBoardDecoderCallback, gpioComIF); + &gpioCallbacks::spiCsDecoderCallback, gpioComIF); rtdGpioCookie->addGpio(gpioIds::RTD_IC4, gpioRtdIc4); GpioCallback* gpioRtdIc5 = new GpioCallback(std::string("Chip select RTD IC5"), gpio::OUT, 1, - &gpioCallbacks::tcsBoardDecoderCallback, gpioComIF); + &gpioCallbacks::spiCsDecoderCallback, gpioComIF); rtdGpioCookie->addGpio(gpioIds::RTD_IC5, gpioRtdIc5); GpioCallback* gpioRtdIc6 = new GpioCallback(std::string("Chip select RTD IC6"), gpio::OUT, 1, - &gpioCallbacks::tcsBoardDecoderCallback, gpioComIF); + &gpioCallbacks::spiCsDecoderCallback, gpioComIF); rtdGpioCookie->addGpio(gpioIds::RTD_IC6, gpioRtdIc6); GpioCallback* gpioRtdIc7 = new GpioCallback(std::string("Chip select RTD IC7"), gpio::OUT, 1, - &gpioCallbacks::tcsBoardDecoderCallback, gpioComIF); + &gpioCallbacks::spiCsDecoderCallback, gpioComIF); rtdGpioCookie->addGpio(gpioIds::RTD_IC7, gpioRtdIc7); GpioCallback* gpioRtdIc8 = new GpioCallback(std::string("Chip select RTD IC8"), gpio::OUT, 1, - &gpioCallbacks::tcsBoardDecoderCallback, gpioComIF); + &gpioCallbacks::spiCsDecoderCallback, gpioComIF); rtdGpioCookie->addGpio(gpioIds::RTD_IC8, gpioRtdIc8); GpioCallback* gpioRtdIc9 = new GpioCallback(std::string("Chip select RTD IC9"), gpio::OUT, 1, - &gpioCallbacks::tcsBoardDecoderCallback, gpioComIF); + &gpioCallbacks::spiCsDecoderCallback, gpioComIF); rtdGpioCookie->addGpio(gpioIds::RTD_IC9, gpioRtdIc9); GpioCallback* gpioRtdIc10 = new GpioCallback(std::string("Chip select RTD IC10"), gpio::OUT, 1, - &gpioCallbacks::tcsBoardDecoderCallback, gpioComIF); + &gpioCallbacks::spiCsDecoderCallback, gpioComIF); rtdGpioCookie->addGpio(gpioIds::RTD_IC10, gpioRtdIc10); GpioCallback* gpioRtdIc11 = new GpioCallback(std::string("Chip select RTD IC11"), gpio::OUT, 1, - &gpioCallbacks::tcsBoardDecoderCallback, gpioComIF); + &gpioCallbacks::spiCsDecoderCallback, gpioComIF); rtdGpioCookie->addGpio(gpioIds::RTD_IC11, gpioRtdIc11); GpioCallback* gpioRtdIc12 = new GpioCallback(std::string("Chip select RTD IC12"), gpio::OUT, 1, - &gpioCallbacks::tcsBoardDecoderCallback, gpioComIF); + &gpioCallbacks::spiCsDecoderCallback, gpioComIF); rtdGpioCookie->addGpio(gpioIds::RTD_IC12, gpioRtdIc12); GpioCallback* gpioRtdIc13 = new GpioCallback(std::string("Chip select RTD IC13"), gpio::OUT, 1, - &gpioCallbacks::tcsBoardDecoderCallback, gpioComIF); + &gpioCallbacks::spiCsDecoderCallback, gpioComIF); rtdGpioCookie->addGpio(gpioIds::RTD_IC13, gpioRtdIc13); GpioCallback* gpioRtdIc14 = new GpioCallback(std::string("Chip select RTD IC14"), gpio::OUT, 1, - &gpioCallbacks::tcsBoardDecoderCallback, gpioComIF); + &gpioCallbacks::spiCsDecoderCallback, gpioComIF); rtdGpioCookie->addGpio(gpioIds::RTD_IC14, gpioRtdIc14); GpioCallback* gpioRtdIc15 = new GpioCallback(std::string("Chip select RTD IC15"), gpio::OUT, 1, - &gpioCallbacks::tcsBoardDecoderCallback, gpioComIF); + &gpioCallbacks::spiCsDecoderCallback, gpioComIF); rtdGpioCookie->addGpio(gpioIds::RTD_IC15, gpioRtdIc15); GpioCallback* gpioRtdIc16 = new GpioCallback(std::string("Chip select RTD IC16"), gpio::OUT, 1, - &gpioCallbacks::tcsBoardDecoderCallback, gpioComIF); + &gpioCallbacks::spiCsDecoderCallback, gpioComIF); rtdGpioCookie->addGpio(gpioIds::RTD_IC16, gpioRtdIc16); GpioCallback* gpioRtdIc17 = new GpioCallback(std::string("Chip select RTD IC17"), gpio::OUT, 1, - &gpioCallbacks::tcsBoardDecoderCallback, gpioComIF); + &gpioCallbacks::spiCsDecoderCallback, gpioComIF); rtdGpioCookie->addGpio(gpioIds::RTD_IC17, gpioRtdIc17); GpioCallback* gpioRtdIc18 = new GpioCallback(std::string("Chip select RTD IC18"), gpio::OUT, 1, - &gpioCallbacks::tcsBoardDecoderCallback, gpioComIF); + &gpioCallbacks::spiCsDecoderCallback, gpioComIF); rtdGpioCookie->addGpio(gpioIds::RTD_IC18, gpioRtdIc18); gpioComIF->addGpios(rtdGpioCookie); @@ -517,7 +516,7 @@ void ObjectFactory::produce(){ Max31865PT1000Handler* rtdIc16 = new Max31865PT1000Handler(objects::RTD_IC16, objects::SPI_COM_IF, spiRtdIc16, 0); Max31865PT1000Handler* rtdIc17 = new Max31865PT1000Handler(objects::RTD_IC17, objects::SPI_COM_IF, spiRtdIc17, 0); Max31865PT1000Handler* rtdIc18 = new Max31865PT1000Handler(objects::RTD_IC18, objects::SPI_COM_IF, spiRtdIc18, 0); -// rtdIc10->setStartUpImmediately(); + rtdIc3->setStartUpImmediately(); // rtdIc4->setStartUpImmediately(); (void) rtdIc3; diff --git a/bsp_q7s/boardconfig/q7s_config.h b/bsp_q7s/boardconfig/q7s_config.h index 782ecf4f..73cf2225 100644 --- a/bsp_q7s/boardconfig/q7s_config.h +++ b/bsp_q7s/boardconfig/q7s_config.h @@ -1,7 +1,7 @@ #ifndef BSP_Q7S_BOARDCONFIG_Q7S_CONFIG_H_ #define BSP_Q7S_BOARDCONFIG_Q7S_CONFIG_H_ -#define Q7S_ADD_RTD_DEVICES 0 +#define Q7S_ADD_RTD_DEVICES 1 /* Only one of those 2 should be enabled! */ /* Add code for ACS board */ diff --git a/fsfw b/fsfw index e7d24563..32b289cb 160000 --- a/fsfw +++ b/fsfw @@ -1 +1 @@ -Subproject commit e7d245635047439ca4b5a46d05bf58437a5aa33a +Subproject commit 32b289cbec97e66707a416f3696c804c05d84fb0 diff --git a/fsfw_hal b/fsfw_hal index a0f698ff..7724fdc3 160000 --- a/fsfw_hal +++ b/fsfw_hal @@ -1 +1 @@ -Subproject commit a0f698fffa4dd5c9f86337c5d6170f9321cb8de7 +Subproject commit 7724fdc389c48fc3c52ba94c7c7d9fe4530f1996 diff --git a/mission/devices/SusHandler.h b/mission/devices/SusHandler.h index c73cee97..3829f14e 100644 --- a/mission/devices/SusHandler.h +++ b/mission/devices/SusHandler.h @@ -4,7 +4,6 @@ #include #include #include -#include /** * @brief This is the device handler class for the SUS sensor. The sensor is From 33a55d7114ca22d3b89db36bf0706dcb6d29daf8 Mon Sep 17 00:00:00 2001 From: "Jakob.Meier" Date: Mon, 21 Jun 2021 09:50:26 +0200 Subject: [PATCH 002/111] RwHandler first commands --- bsp_q7s/CMakeLists.txt | 1 + bsp_q7s/ObjectFactory.cpp | 14 +- bsp_q7s/spiCallbacks/CMakeLists.txt | 3 + bsp_q7s/spiCallbacks/rwSpiCallback.cpp | 220 +++++++++++++++ bsp_q7s/spiCallbacks/rwSpiCallback.h | 21 ++ common/config/commonClassIds.h | 1 + common/config/commonSubsystemIds.h | 1 + common/config/spiConf.h | 3 + linux/fsfwconfig/devices/addresses.h | 6 +- linux/fsfwconfig/devices/gpioIds.h | 7 +- linux/fsfwconfig/objects/systemObjectList.h | 5 + mission/devices/CMakeLists.txt | 1 + mission/devices/RwHandler.cpp | 259 ++++++++++++++++++ mission/devices/RwHandler.h | 125 +++++++++ .../devicedefinitions/Max31865Definitions.h | 6 +- .../devices/devicedefinitions/RwDefinitions.h | 86 ++++++ 16 files changed, 750 insertions(+), 9 deletions(-) create mode 100644 bsp_q7s/spiCallbacks/CMakeLists.txt create mode 100644 bsp_q7s/spiCallbacks/rwSpiCallback.cpp create mode 100644 bsp_q7s/spiCallbacks/rwSpiCallback.h create mode 100644 mission/devices/RwHandler.cpp create mode 100644 mission/devices/RwHandler.h create mode 100644 mission/devices/devicedefinitions/RwDefinitions.h diff --git a/bsp_q7s/CMakeLists.txt b/bsp_q7s/CMakeLists.txt index ce790656..c0547997 100644 --- a/bsp_q7s/CMakeLists.txt +++ b/bsp_q7s/CMakeLists.txt @@ -9,3 +9,4 @@ add_subdirectory(comIF) add_subdirectory(boardtest) add_subdirectory(gpio) add_subdirectory(core) +add_subdirectory(spiCallbacks) diff --git a/bsp_q7s/ObjectFactory.cpp b/bsp_q7s/ObjectFactory.cpp index a977c91b..8c9dc91a 100644 --- a/bsp_q7s/ObjectFactory.cpp +++ b/bsp_q7s/ObjectFactory.cpp @@ -9,6 +9,7 @@ #include "bsp_q7s/gpio/gpioCallbacks.h" #include "bsp_q7s/core/CoreController.h" +#include "bsp_q7s/spiCallbacks/rwSpiCallback.h" #include #include @@ -31,11 +32,13 @@ #include #include #include +#include #include #include #include #include #include +#include #include #include @@ -545,10 +548,13 @@ void ObjectFactory::produce(void* args){ UartCookie* plocUartCookie = new UartCookie(std::string("/dev/ttyUL3"), 115200, PLOC::MAX_REPLY_SIZE); - PlocHandler* plocHandler = new PlocHandler(objects::PLOC_HANDLER, objects::UART_COM_IF, - plocUartCookie); -// plocHandler->setStartUpImmediately(); - (void) plocHandler; + PlocHandler(objects::PLOC_HANDLER, objects::UART_COM_IF, plocUartCookie); + + auto rw1SpiCookie = new SpiCookie(addresses::RW1, gpioIds::RW1, "/dev/spidev2.0", + RwDefinitions::MAX_REPLY_SIZE, spi::RW_MODE, spi::RW_SPEED, &rwSpiCallback, nullptr); + + auto rwHandler1 = new RwHandler(objects::RW1, objects::SPI_COM_IF, rw1SpiCookie); + rwHandler1->setStartUpImmediately(); #endif /* TE0720 == 0 */ diff --git a/bsp_q7s/spiCallbacks/CMakeLists.txt b/bsp_q7s/spiCallbacks/CMakeLists.txt new file mode 100644 index 00000000..59d507e6 --- /dev/null +++ b/bsp_q7s/spiCallbacks/CMakeLists.txt @@ -0,0 +1,3 @@ +target_sources(${TARGET_NAME} PRIVATE + rwSpiCallback.cpp +) diff --git a/bsp_q7s/spiCallbacks/rwSpiCallback.cpp b/bsp_q7s/spiCallbacks/rwSpiCallback.cpp new file mode 100644 index 00000000..fc9bade1 --- /dev/null +++ b/bsp_q7s/spiCallbacks/rwSpiCallback.cpp @@ -0,0 +1,220 @@ +#include +#include +#include +#include +#include + +ReturnValue_t rwSpiCallback(SpiComIF* comIf, SpiCookie *cookie, const uint8_t *sendData, + size_t sendLen, void* args) { + + ReturnValue_t result = HasReturnvaluesIF::RETURN_OK; + + RwHandler* handler = reinterpret_cast(args); + if(handler == nullptr) { + sif::error << "rwSpiCallback: Pointer to handler is invalid" + << std::endl; + return HasReturnvaluesIF::RETURN_FAILED; + } + + uint8_t writeBuffer[2]; + uint8_t writeSize = 0; + + int fileDescriptor = 0; + std::string device = cookie->getSpiDevice(); + UnixFileGuard fileHelper(device, &fileDescriptor, O_RDWR, "rwSpiCallback: "); + if(fileHelper.getOpenResult() != HasReturnvaluesIF::RETURN_OK) { + sif::error << "rwSpiCallback: Failed to open device file" << std::endl; + return SpiComIF::OPENING_FILE_FAILED; + } + spi::SpiModes spiMode = spi::SpiModes::MODE_0; + uint32_t spiSpeed = 0; + cookie->getSpiParameters(spiMode, spiSpeed, nullptr); + comIf->setSpiSpeedAndMode(fileDescriptor, spiMode, spiSpeed); + + gpioId_t gpioId = cookie->getChipSelectPin(); + GpioIF* gpioIF = comIf->getGpioInterface(); + MutexIF::TimeoutType timeoutType = MutexIF::TimeoutType::WAITING; + uint32_t timeoutMs = 0; + MutexIF* mutex = comIf->getMutex(&timeoutType, &timeoutMs); + if(mutex == nullptr or gpioIF == nullptr) { + sif::debug << "rwSpiCallback: Mutex or GPIO interface invalid" << std::endl; + return HasReturnvaluesIF::RETURN_FAILED; + } + + if(gpioId != gpio::NO_GPIO) { + result = mutex->lockMutex(timeoutType, timeoutMs); + if (result != HasReturnvaluesIF::RETURN_OK) { + sif::debug << "rwSpiCallback: Failed to lock mutex" << std::endl; + return result; + } + } + + /** Sending frame start sign */ + writeBuffer[0] = 0x7E; + writeSize = 1; + + // Pull SPI CS low. For now, no support for active high given + if(gpioId != gpio::NO_GPIO) { + if(gpioIF->pullLow(gpioId) != HasReturnvaluesIF::RETURN_OK) { + sif::error << "rwSpiCallback: Failed to pull chip select low" << std::endl; + } + } + + if (write(fileDescriptor, writeBuffer, writeSize) != static_cast(writeSize)) { + sif::error << "rwSpiCallback: Write failed!" << std::endl; + if(gpioId != gpio::NO_GPIO) { + if (gpioIF->pullHigh(gpioId) != HasReturnvaluesIF::RETURN_OK) { + sif::error << "rwSpiCallback: Failed to pull chip select high" << std::endl; + } + } + if(mutex->unlockMutex() != HasReturnvaluesIF::RETURN_OK) { + sif::error << "rwSpiCallback: Failed to unlock mutex" << std::endl;; + } + return RwHandler::SPI_WRITE_FAILURE; + } + + /** Encoding and sending command */ + size_t idx = 0; + while(idx < sendLen) { + switch(*(sendData + idx)) { + case 0x7E: + writeBuffer[0] = 0x7D; + writeBuffer[1] = 0x5E; + writeSize = 2; + break; + case 0x7D: + writeBuffer[0] = 0x7D; + writeBuffer[1] = 0x5D; + writeSize = 2; + break; + default: + writeBuffer[0] = *(sendData + idx); + writeSize = 1; + } + if (write(fileDescriptor, writeBuffer, writeSize) != static_cast(writeSize)) { + sif::error << "rwSpiCallback: Write failed!" << std::endl; + if(gpioId != gpio::NO_GPIO) { + if (gpioIF->pullHigh(gpioId) != HasReturnvaluesIF::RETURN_OK) { + sif::error << "rwSpiCallback: Failed to pull chip select high" << std::endl; + } + } + if(mutex->unlockMutex() != HasReturnvaluesIF::RETURN_OK) { + sif::error << "rwSpiCallback: Failed to unlock mutex"; + } + return RwHandler::SPI_WRITE_FAILURE; + } + } + + /** Sending frame start sign */ + writeBuffer[0] = 0x7E; + writeSize = 1; + + if (write(fileDescriptor, writeBuffer, writeSize) != static_cast(writeSize)) { + sif::error << "rwSpiCallback: Write failed!" << std::endl; + if(gpioId != gpio::NO_GPIO) { + if (gpioIF->pullHigh(gpioId) != HasReturnvaluesIF::RETURN_OK) { + sif::error << "rwSpiCallback: Failed to pull chip select high" << std::endl; + } + } + if(mutex->unlockMutex() != HasReturnvaluesIF::RETURN_OK) { + sif::error << "rwSpiCallback: Failed to unlock mutex"; + } + return RwHandler::SPI_WRITE_FAILURE; + } + + uint8_t* rxBuf = nullptr; + result = comIf->getReadBuffer(cookie->getSpiAddress(), &rxBuf); + if(result != HasReturnvaluesIF::RETURN_OK) { + return result; + } + + size_t replyBufferSize = cookie->getMaxBufferSize(); + + uint8_t byteRead = 0; + /** Reading the reply frame */ + if(read(fileDescriptor, &byteRead, 1) != 1) { + sif::error << "rwSpiCallback: Failed to read first byte of reply frame" << std::endl; + return RwHandler::SPI_READ_FAILURE; + } + + /** First byte must be the start sign 0x7E */ + if (byteRead != 0x7E) { + sif::error << "rwSpiCallback: First byte of reply is not 0x7E" << std::endl; + return RwHandler::MISSING_START_SIGN; + } + + size_t decodedFrameLen = 0; + for (; decodedFrameLen < replyBufferSize; decodedFrameLen++) { + if(read(fileDescriptor, &byteRead, 1) != 1) { + sif::error << "rwSpiCallback: Read failed" << std::endl; + return RwHandler::SPI_READ_FAILURE; + } + + if (byteRead == 0x7E) { + /** Reached end of frame */ + break; + } + else if (byteRead == 0xD) { + if(read(fileDescriptor, &byteRead, 1) != 1) { + sif::error << "rwSpiCallback: Read failed" << std::endl; + result = RwHandler::SPI_READ_FAILURE; + break; + } + if (byteRead == 0x5E) { + *(rxBuf + decodedFrameLen) = 0x7E; + decodedFrameLen++; + continue; + } + else if (byteRead == 0x5D) { + *(rxBuf + decodedFrameLen) = 0x7D; + decodedFrameLen++; + continue; + } + else { + sif::error << "rwSpiCallback: Invalid substitute" << std::endl; + result = RwHandler::INVALID_SUBSTITUTE; + break; + } + } + else { + *(rxBuf + decodedFrameLen) = byteRead; + decodedFrameLen++; + continue; + } + + /** + * There might be the unlikely case that each byte in a get-telemetry reply has been + * replaced by its substitute. Than the next byte must correspond to the end sign 0x7E. + * Otherwise there might be something wrong. + */ + if (decodedFrameLen == replyBufferSize) { + if(read(fileDescriptor, &byteRead, 1) != 1) { + sif::error << "rwSpiCallback: Failed to read last byte" << std::endl; + result = RwHandler::SPI_READ_FAILURE; + break; + } + if (byteRead != 0x7E) { + sif::error << "rwSpiCallback: Missing end sign 0x7E" << std::endl; + decodedFrameLen--; + result = RwHandler::MISSING_END_SIGN; + break; + } + } + result = HasReturnvaluesIF::RETURN_OK; + } + + cookie->assignTransferSize(decodedFrameLen); + + if(gpioId != gpio::NO_GPIO) { + if (gpioIF->pullHigh(gpioId) != HasReturnvaluesIF::RETURN_OK) { + sif::error << "rwSpiCallback: Failed to pull chip select high" << std::endl; + } + } + + if(gpioId != gpio::NO_GPIO) { + if(mutex->unlockMutex() != HasReturnvaluesIF::RETURN_OK) { + sif::error << "rwSpiCallback: Failed to unlock mutex" << std::endl; + } + } + return result; +} diff --git a/bsp_q7s/spiCallbacks/rwSpiCallback.h b/bsp_q7s/spiCallbacks/rwSpiCallback.h new file mode 100644 index 00000000..d882bee4 --- /dev/null +++ b/bsp_q7s/spiCallbacks/rwSpiCallback.h @@ -0,0 +1,21 @@ +#ifndef BSP_Q7S_RW_SPI_CALLBACK_H_ +#define BSP_Q7S_RW_SPI_CALLBACK_H_ + +#include +#include + +/** + * @brief This is the callback function to send commands to the nano avionics reaction wheels and + * receive the replies. + * + * @details The data to sent are additionally encoded according to the HDLC framing defined in the + * datasheet of the reaction wheels: + * https://eive-cloud.irs.uni-stuttgart.de/index.php/apps/files/?dir=/EIVE_IRS/ + * Arbeitsdaten/08_Used%20Components/Nanoavionics_Reactionwheels&fileid=181622 + * Each command entails exactly one reply which will also be read in and decoded by this + * function. + */ +ReturnValue_t rwSpiCallback(SpiComIF* comIf, SpiCookie *cookie, const uint8_t *sendData, + size_t sendLen, void* args); + +#endif /* BSP_Q7S_RW_SPI_CALLBACK_H_ */ diff --git a/common/config/commonClassIds.h b/common/config/commonClassIds.h index 7a53bdf0..8a4a8121 100644 --- a/common/config/commonClassIds.h +++ b/common/config/commonClassIds.h @@ -13,6 +13,7 @@ enum commonClassIds: uint8_t { HEATER_HANDLER, //HEATER SYRLINKS_HANDLER, //SYRLINKS IMTQ_HANDLER, //IMTQ + RW_HANDLER, //Reaction Wheels PLOC_HANDLER, //PLOC SUS_HANDLER, //SUSS CCSDS_IP_CORE_BRIDGE, // IP Core interface diff --git a/common/config/commonSubsystemIds.h b/common/config/commonSubsystemIds.h index 0bc3e1dd..bc2fe400 100644 --- a/common/config/commonSubsystemIds.h +++ b/common/config/commonSubsystemIds.h @@ -13,6 +13,7 @@ enum: uint8_t { SA_DEPL_HANDLER = 110, PLOC_HANDLER = 111, IMTQ_HANDLER = 112, + RW_HANDLER = 113, COMMON_SUBSYSTEM_ID_END }; } diff --git a/common/config/spiConf.h b/common/config/spiConf.h index 2632924d..d76ac9b8 100644 --- a/common/config/spiConf.h +++ b/common/config/spiConf.h @@ -26,6 +26,9 @@ static constexpr spi::SpiModes DEFAULT_MAX_1227_MODE = spi::SpiModes::MODE_3; static constexpr uint32_t DEFAULT_ADIS16507_SPEED = 976'000; static constexpr spi::SpiModes DEFAULT_ADIS16507_MODE = spi::SpiModes::MODE_3; +static constexpr uint32_t RW_SPEED = 300'000; +static constexpr spi::SpiModes RW_MODE = spi::SpiModes::MODE_0; + } #endif /* COMMON_CONFIG_SPICONF_H_ */ diff --git a/linux/fsfwconfig/devices/addresses.h b/linux/fsfwconfig/devices/addresses.h index 0deb8490..e4dc4979 100644 --- a/linux/fsfwconfig/devices/addresses.h +++ b/linux/fsfwconfig/devices/addresses.h @@ -63,7 +63,11 @@ namespace addresses { RTD_IC15, RTD_IC16, RTD_IC17, - RTD_IC18 + RTD_IC18, + RW1, + RW2, + RW3, + RW4 }; /* Addresses of devices supporting the CSP protocol */ diff --git a/linux/fsfwconfig/devices/gpioIds.h b/linux/fsfwconfig/devices/gpioIds.h index 102b04b9..39d1b8ce 100644 --- a/linux/fsfwconfig/devices/gpioIds.h +++ b/linux/fsfwconfig/devices/gpioIds.h @@ -68,7 +68,12 @@ namespace gpioIds { CS_RAD_SENSOR, PAPB_BUSY_N, - PAPB_EMPTY + PAPB_EMPTY, + + RW1, + RW2, + RW3, + RW4 }; } diff --git a/linux/fsfwconfig/objects/systemObjectList.h b/linux/fsfwconfig/objects/systemObjectList.h index 98d6c448..bda929a5 100644 --- a/linux/fsfwconfig/objects/systemObjectList.h +++ b/linux/fsfwconfig/objects/systemObjectList.h @@ -58,6 +58,11 @@ namespace objects { RAD_SENSOR = 0x54000050, + RW1 = 0x54000051, + RW2 = 0x54000052, + RW3 = 0x54000053, + RW4 = 0x54000054, + /* 0x54 ('T') for test handlers */ TEST_TASK = 0x54694269, LIBGPIOD_TEST = 0x54123456, diff --git a/mission/devices/CMakeLists.txt b/mission/devices/CMakeLists.txt index 735e595b..544bbd14 100644 --- a/mission/devices/CMakeLists.txt +++ b/mission/devices/CMakeLists.txt @@ -16,6 +16,7 @@ target_sources(${TARGET_NAME} PUBLIC PlocHandler.cpp RadiationSensorHandler.cpp GyroADIS16507Handler.cpp + RwHandler.cpp ) diff --git a/mission/devices/RwHandler.cpp b/mission/devices/RwHandler.cpp new file mode 100644 index 00000000..9f6d483b --- /dev/null +++ b/mission/devices/RwHandler.cpp @@ -0,0 +1,259 @@ +#include "RwHandler.h" +#include "OBSWConfig.h" + +#include +#include +#include + +RwHandler::RwHandler(object_id_t objectId, object_id_t comIF, CookieIF * comCookie) : + DeviceHandlerBase(objectId, comIF, comCookie), temperatureSet(this), statusSet(this) { + if (comCookie == NULL) { + sif::error << "RwHandler: Invalid com cookie" << std::endl; + } +} + +RwHandler::~RwHandler() { +} + +void RwHandler::doStartUp() { +#if OBSW_SWITCH_TO_NORMAL_MODE_AFTER_STARTUP == 1 + setMode(MODE_NORMAL); +#else + setMode(_MODE_TO_ON); +#endif +} + +void RwHandler::doShutDown() { + +} + +ReturnValue_t RwHandler::buildNormalDeviceCommand(DeviceCommandId_t * id) { + switch (communicationStep) { + case CommunicationStep::READ_TEMPERATURE: + *id = RwDefinitions::GET_TEMPERATURE; + break; + case CommunicationStep::GET_RW_SATUS: + *id = RwDefinitions::GET_RW_STATUS; + break; + default: + sif::debug << "RwHandler::buildNormalDeviceCommand: Invalid communication step" + << std::endl; + break; + } + return buildCommandFromCommand(*id, NULL, 0); +} + +ReturnValue_t RwHandler::buildTransitionDeviceCommand(DeviceCommandId_t * id) { + return RETURN_OK; +} + +ReturnValue_t RwHandler::buildCommandFromCommand(DeviceCommandId_t deviceCommand, + const uint8_t * commandData, size_t commandDataLen) { + ReturnValue_t result = RETURN_OK; + + switch (deviceCommand) { + case (RwDefinitions::GET_RW_STATUS): { + prepareGetStatusCmd(commandData, commandDataLen); + return RETURN_OK; + } + case (RwDefinitions::SET_SPEED): { + if (commandDataLen != 6) { + sif::error << "RwHandler::buildCommandFromCommand: Received set speed command with" + << " invalid length" << std::endl; + return SET_SPEED_COMMAND_INVALID_LENGTH; + } + result = checkSpeedAndRampTime(commandData, commandDataLen); + if (result != RETURN_OK) { + return result; + } + prepareSetSpeedCmd(commandData, commandDataLen); + return result; + } + case (RwDefinitions::GET_TEMPERATURE): { + prepareGetTemperatureCmd(); + return RETURN_OK; + } + default: + return DeviceHandlerIF::COMMAND_NOT_IMPLEMENTED; + } + return HasReturnvaluesIF::RETURN_FAILED; +} + +void RwHandler::fillCommandAndReplyMap() { + this->insertInCommandAndReplyMap(RwDefinitions::GET_TEMPERATURE, 1, &temperatureSet, + RwDefinitions::SIZE_GET_TEMPERATURE_REPLY); + this->insertInCommandAndReplyMap(RwDefinitions::SET_SPEED, 1, nullptr, + RwDefinitions::SIZE_SET_SPEED_REPLY); +} + +ReturnValue_t RwHandler::scanForReply(const uint8_t *start, size_t remainingSize, + DeviceCommandId_t *foundId, size_t *foundLen) { + + switch (*(start + 1)) { + case (static_cast(RwDefinitions::GET_RW_STATUS)): { + *foundLen = RwDefinitions::SIZE_GET_RW_STATUS; + *foundId = RwDefinitions::GET_RW_STATUS; + break; + } + case (static_cast(RwDefinitions::SET_SPEED)): { + *foundLen = RwDefinitions::SIZE_SET_SPEED_REPLY; + *foundId = RwDefinitions::SET_SPEED; + break; + } + case (static_cast(RwDefinitions::GET_TEMPERATURE)): { + *foundLen = RwDefinitions::SIZE_GET_TEMPERATURE_REPLY; + *foundId = RwDefinitions::GET_TEMPERATURE; + break; + } + default: { + sif::debug << "RwHandler::scanForReply: Reply contains invalid command code" << std::endl; + return RETURN_FAILED; + break; + } + } + + sizeOfReply = *foundLen; + + return RETURN_OK; +} + +ReturnValue_t RwHandler::interpretDeviceReply(DeviceCommandId_t id, const uint8_t *packet) { + + /** Check result code */ + if (*(packet + 1) != 0) { + return EXECUTION_FAILED; + } + + /** Received in little endian byte order */ + uint16_t replyCrc = *(packet + sizeOfReply - 1) << 8 | *(packet + sizeOfReply - 2) ; + + if (CRC::crc16ccitt(packet, sizeOfReply, 0xFFFF) != replyCrc) { + return CRC_ERROR; + } + + switch (id) { + case (RwDefinitions::GET_RW_STATUS): { + handleGetRwStatusReply(packet); + break; + } + case (RwDefinitions::SET_SPEED): + // no reply data expected + break; + case (RwDefinitions::GET_TEMPERATURE): { + handleTemperatureReply(packet); + break; + } + default: { + sif::debug << "RwHandler::interpretDeviceReply: Unknown device reply id" << std::endl; + return DeviceHandlerIF::UNKNOWN_DEVICE_REPLY; + } + } + + return RETURN_OK; +} + +void RwHandler::setNormalDatapoolEntriesInvalid() { + +} + +uint32_t RwHandler::getTransitionDelayMs(Mode_t modeFrom, Mode_t modeTo) { + return 5000; +} + +ReturnValue_t RwHandler::initializeLocalDataPool(localpool::DataPool& localDataPoolMap, + LocalDataPoolManager& poolManager) { + + localDataPoolMap.emplace(RwDefinitions::TEMPERATURE_C, new PoolEntry( { 0 })); + + return RETURN_OK; +} + +void RwHandler::prepareGetStatusCmd(const uint8_t * commandData, size_t commandDataLen) { + commandBuffer[0] = static_cast(RwDefinitions::GET_RW_STATUS); + + uint16_t crc = CRC::crc16ccitt(commandBuffer, 1, 0xFFFF); + commandBuffer[1] = static_cast(crc & 0xFF); + commandBuffer[2] = static_cast(crc >> 8 & 0xFF); + rawPacket = commandBuffer; + rawPacketLen = 3; +} + +ReturnValue_t RwHandler::checkSpeedAndRampTime(const uint8_t* commandData, size_t commandDataLen) { + int32_t speed = *commandData << 24 | *(commandData + 1) << 16 | *(commandData + 2) << 8 + | *(commandData + 3); + + if (speed < -65000 || speed > 65000 || (speed > -1000 && speed < 1000)) { + sif::error << "RwHandler::checkSpeedAndRampTime: Command has invalid speed" << std::endl; + return INVALID_SPEED; + } + + uint16_t rampTime = *commandData << 8 | *(commandData + 1); + + if (rampTime < 10 || rampTime > 10000) { + sif::error << "RwHandler::checkSpeedAndRampTime: Command has invalid ramp time" + << std::endl; + return INVALID_RAMP_TIME; + } + + return RETURN_OK; +} + +void RwHandler::prepareGetTemperatureCmd() { + commandBuffer[0] = static_cast(RwDefinitions::GET_TEMPERATURE); + uint16_t crc = CRC::crc16ccitt(commandBuffer, 1, 0xFFFF); + commandBuffer[1] = static_cast(crc & 0xFF); + commandBuffer[2] = static_cast(crc >> 8 & 0xFF); + rawPacket = commandBuffer; + rawPacketLen = 3; +} + + +void RwHandler::prepareSetSpeedCmd(const uint8_t * commandData, size_t commandDataLen) { + commandBuffer[0] = static_cast(RwDefinitions::SET_SPEED); + + /** Speed (0.1 RPM) */ + commandBuffer[1] = *(commandData + 3); + commandBuffer[2] = *(commandData + 2); + commandBuffer[3] = *(commandData + 1); + commandBuffer[4] = *commandData; + /** Ramp time (ms) */ + commandBuffer[5] = *(commandData + 1); + commandBuffer[6] = *commandData; + + uint16_t crc = CRC::crc16ccitt(commandBuffer, 7, 0xFFFF); + commandBuffer[7] = static_cast(crc & 0xFF); + commandBuffer[8] = static_cast(crc >> 8 & 0xFF); + rawPacket = commandBuffer; + rawPacketLen = 9; +} + +void RwHandler::handleGetRwStatusReply(const uint8_t* packet) { + uint8_t offset = 0; + statusSet.currSpeed = *(packet + 3) << 24 | *(packet + 2) << 16 | *(packet + 1) << 1 | *packet; + offset += 4; + statusSet.referenceSpeed = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 | *(packet + offset + 1) << 1 | *(packet + offset); + offset += 4; + statusSet.state = *(packet + offset); + offset += 1; + statusSet.clcMode = *(packet + offset); + +#if OBSW_VERBOSE_LEVEL >= 1 && RW_DEBUG == 1 + sif::info << "RwHandler::handleGetRwStatusReply: Current speed is: " << statusSet.currSpeed + << " * 0.1 RPM" << std::endl; + sif::info << "RwHandler::handleGetRwStatusReply: Reference speed is: " + << statusSet.referenceSpeed << " * 0.1 RPM" << std::endl; + sif::info << "RwHandler::handleGetRwStatusReply: State is: " << statusSet.state + << " * 0.1 RPM" << std::endl; + sif::info << "RwHandler::handleGetRwStatusReply: clc mode is: " << statusSet.clcMode + << " * 0.1 RPM" << std::endl; +#endif +} + +void RwHandler::handleTemperatureReply(const uint8_t* packet) { + temperatureSet.temperatureCelcius = *(packet + 3) << 24 | *(packet + 2) << 16 + | *(packet + 1) << 1 | *packet; +#if OBSW_VERBOSE_LEVEL >= 1 && RW_DEBUG == 1 + sif::info << "RwHandler::handleTemperatureReply: Temperature: " + << temperatureSet.temperatureCelcius << " °C" << std::endl; +#endif +} diff --git a/mission/devices/RwHandler.h b/mission/devices/RwHandler.h new file mode 100644 index 00000000..8f77527b --- /dev/null +++ b/mission/devices/RwHandler.h @@ -0,0 +1,125 @@ +#ifndef MISSION_DEVICES_RWHANDLER_H_ +#define MISSION_DEVICES_RWHANDLER_H_ + +#include +#include +#include + +/** + * @brief This is the device handler for the reaction wheel from nano avionics. + * + * @details Datasheet: https://eive-cloud.irs.uni-stuttgart.de/index.php/apps/files/?dir=/EIVE_IRS/ + * Arbeitsdaten/08_Used%20Components/Nanoavionics_Reactionwheels&fileid=181622 + * + * @note Values are transferred in little endian format. + * + * @author J. Meier + */ +class RwHandler: public DeviceHandlerBase { +public: + + RwHandler(object_id_t objectId, object_id_t comIF, CookieIF * comCookie); + virtual ~RwHandler(); + + /** + * @brief Sets mode to MODE_NORMAL. Can be used for debugging. + */ + void setModeNormal(); + + static const uint8_t INTERFACE_ID = CLASS_ID::RW_HANDLER; + + static const ReturnValue_t SPI_WRITE_FAILURE = MAKE_RETURN_CODE(0xB0); + //! [EXPORT] : [COMMENT] Used by the spi send function to tell a failing read call + static const ReturnValue_t SPI_READ_FAILURE = MAKE_RETURN_CODE(0xB1); + //! [EXPORT] : [COMMENT] Can be used by the HDLC decoding mechanism to inform about a missing start sign 0x7E + static const ReturnValue_t MISSING_START_SIGN = MAKE_RETURN_CODE(0xB2); + //! [EXPORT] : [COMMENT] Can be used by the HDLC decoding mechanism to inform about an invalid substitution combination + static const ReturnValue_t INVALID_SUBSTITUTE = MAKE_RETURN_CODE(0xB3); + //! [EXPORT] : [COMMENT] HDLC decoding mechanism never receives the end sign 0x7E + static const ReturnValue_t MISSING_END_SIGN = MAKE_RETURN_CODE(0xB4); + +protected: + void doStartUp() override; + void doShutDown() override; + ReturnValue_t buildNormalDeviceCommand(DeviceCommandId_t * id) override; + ReturnValue_t buildTransitionDeviceCommand(DeviceCommandId_t * id) override; + void fillCommandAndReplyMap() override; + ReturnValue_t buildCommandFromCommand(DeviceCommandId_t deviceCommand, + const uint8_t * commandData,size_t commandDataLen) override; + ReturnValue_t scanForReply(const uint8_t *start, size_t remainingSize, + DeviceCommandId_t *foundId, size_t *foundLen) override; + ReturnValue_t interpretDeviceReply(DeviceCommandId_t id, + const uint8_t *packet) override; + void setNormalDatapoolEntriesInvalid() override; + uint32_t getTransitionDelayMs(Mode_t modeFrom, Mode_t modeTo) override; + ReturnValue_t initializeLocalDataPool(localpool::DataPool& localDataPoolMap, + LocalDataPoolManager& poolManager) override; + +private: + + static const uint8_t SUBSYSTEM_ID = SUBSYSTEM_ID::RW_HANDLER; + + //! [EXPORT] : [COMMENT] Action Message with invalid speed was received. Valid speeds must be in the range of [-65000; 1000] or [1000; 65000] + static const ReturnValue_t INVALID_SPEED = MAKE_RETURN_CODE(0xA0); + //! [EXPORT] : [COMMENT] Action Message with invalid ramp time was received. + static const ReturnValue_t INVALID_RAMP_TIME = MAKE_RETURN_CODE(0xA1); + //! [EXPORT] : [COMMENT] Received set speed command has invalid length. Should be 6. + static const ReturnValue_t SET_SPEED_COMMAND_INVALID_LENGTH = MAKE_RETURN_CODE(0xA2); + //! [EXPORT] : [COMMENT] Command execution failed + static const ReturnValue_t EXECUTION_FAILED = MAKE_RETURN_CODE(0xA3); + //! [EXPORT] : [COMMENT] Reaction wheel reply has invalid crc + static const ReturnValue_t CRC_ERROR = MAKE_RETURN_CODE(0xA4); + + RwDefinitions::TemperatureSet temperatureSet; + RwDefinitions::StatusSet statusSet; + + + uint8_t commandBuffer[RwDefinitions::MAX_CMD_SIZE]; + + enum class CommunicationStep { + READ_TEMPERATURE, + GET_RW_SATUS + }; + + CommunicationStep communicationStep = CommunicationStep::READ_TEMPERATURE; + + size_t sizeOfReply = 0; + + /** + * @brief This function prepares the send buffer with the data to request the status of + * the reaction wheel. + */ + void prepareGetStatusCmd(const uint8_t * commandData, size_t commandDataLen); + + /** + * @brief This function checks if the receiced speed and ramp time to set are in a valid + * range. + * @return RETURN_OK if successful, otherwise error code. + */ + ReturnValue_t checkSpeedAndRampTime(const uint8_t * commandData, size_t commandDataLen); + + /** + * @brief This function prepares the set speed command from the commandData received with + * an action message. + */ + void prepareSetSpeedCmd(const uint8_t * commandData, size_t commandDataLen); + + /** + * @brief This function fills the commandBuffer with the data to request the temperature. + */ + void prepareGetTemperatureCmd(); + + /** + * @brief This function handles the reply of the get temperature command. + * + * @param packet Pointer to the reply data + */ + void handleTemperatureReply(const uint8_t* packet); + + /** + * @brief This function fills the status set with the data from the get-status-reply. + */ + void handleGetRwStatusReply(const uint8_t* packet); +}; + +#endif /* MISSION_DEVICES_RWHANDLER_H_ */ diff --git a/mission/devices/devicedefinitions/Max31865Definitions.h b/mission/devices/devicedefinitions/Max31865Definitions.h index 2a789a7b..26c702a3 100644 --- a/mission/devices/devicedefinitions/Max31865Definitions.h +++ b/mission/devices/devicedefinitions/Max31865Definitions.h @@ -1,5 +1,5 @@ -#ifndef MISSION_DEVICES_DEVICEPACKETS_THERMALSENSORPACKET_H_ -#define MISSION_DEVICES_DEVICEPACKETS_THERMALSENSORPACKET_H_ +#ifndef MISSION_DEVICES_DEVICEDEFINITIONS_MAX13865DEFINITIONS_H_ +#define MISSION_DEVICES_DEVICEDEFINITIONS_MAX13865DEFINITIONS_H_ #include #include @@ -54,5 +54,5 @@ public: } -#endif /* MISSION_DEVICES_DEVICEPACKETS_THERMALSENSORPACKET_H_ */ +#endif /* MISSION_DEVICES_DEVICEDEFINITIONS_MAX13865DEFINITIONS_H_ */ diff --git a/mission/devices/devicedefinitions/RwDefinitions.h b/mission/devices/devicedefinitions/RwDefinitions.h new file mode 100644 index 00000000..247b7bc6 --- /dev/null +++ b/mission/devices/devicedefinitions/RwDefinitions.h @@ -0,0 +1,86 @@ +#ifndef MISSION_DEVICES_DEVICEDEFINITIONS_RWDEFINITIONS_H_ +#define MISSION_DEVICES_DEVICEDEFINITIONS_RWDEFINITIONS_H_ + +#include +#include +#include +#include "objects/systemObjectList.h" + +namespace RwDefinitions { + +enum PoolIds: lp_id_t { + TEMPERATURE_C, + CURR_SPEED, + REFERENCE_SPEED, + STATE, + CLC_MODE +}; + +static constexpr DeviceCommandId_t GET_RW_STATUS = 4; +static constexpr DeviceCommandId_t SET_SPEED = 6; +static constexpr DeviceCommandId_t GET_TEMPERATURE = 8; + +static constexpr uint32_t TEMPERATURE_SET_ID = GET_TEMPERATURE; +static constexpr uint32_t STATUS_SET_ID = GET_RW_STATUS; + +static constexpr size_t SIZE_GET_RW_STATUS = 14; +static constexpr size_t SIZE_SET_SPEED_REPLY = 4; +static constexpr size_t SIZE_GET_TEMPERATURE_REPLY = 8; +/** Max size when requesting telemetry */ +static constexpr size_t SIZE_GET_TELEMETRY_REPLY = 83; + +/** Set speed command has maximum size */ +static constexpr size_t MAX_CMD_SIZE = 9; +static constexpr size_t MAX_REPLY_SIZE = SIZE_GET_TELEMETRY_REPLY; + +static constexpr uint8_t TEMPERATURE_SET_ENTRIES = 1; +static constexpr uint8_t STATUS_SET_ENTRIES = 4; + +/** + * @brief This dataset can be used to store the temperature of a reaction wheel. + */ +class TemperatureSet: + public StaticLocalDataSet { +public: + + TemperatureSet(HasLocalDataPoolIF* owner): + StaticLocalDataSet(owner, TEMPERATURE_SET_ID) { + } + + TemperatureSet(object_id_t objectId): + StaticLocalDataSet(sid_t(objectId, TEMPERATURE_SET_ID)) { + } + + lp_var_t temperatureCelcius = lp_var_t(sid.objectId, + PoolIds::TEMPERATURE_C, this); +}; + +/** + * @brief This dataset can be used to store the reaction wheel status. + */ +class StatusSet: + public StaticLocalDataSet { +public: + + StatusSet(HasLocalDataPoolIF* owner): + StaticLocalDataSet(owner, STATUS_SET_ID) { + } + + StatusSet(object_id_t objectId): + StaticLocalDataSet(sid_t(objectId, STATUS_SET_ID)) { + } + + lp_var_t currSpeed = lp_var_t(sid.objectId, + PoolIds::CURR_SPEED, this); + lp_var_t referenceSpeed = lp_var_t(sid.objectId, + PoolIds::REFERENCE_SPEED, this); + lp_var_t state = lp_var_t(sid.objectId, + PoolIds::STATE, this); + lp_var_t clcMode = lp_var_t(sid.objectId, + PoolIds::CLC_MODE, this); +}; + +} + +#endif /* MISSION_DEVICES_DEVICEDEFINITIONS_RWDEFINITIONS_H_ */ + From d704b389e48617b5442534ad7c575246fd5ad49b Mon Sep 17 00:00:00 2001 From: Martin Zietz Date: Mon, 21 Jun 2021 14:46:46 +0200 Subject: [PATCH 003/111] reaction wheels testing --- bsp_q7s/ObjectFactory.cpp | 9 ++++++- bsp_q7s/spiCallbacks/rwSpiCallback.cpp | 25 +++++++++++++++++++ .../pollingSequenceFactory.cpp | 9 ++++++- mission/devices/RwHandler.cpp | 1 - mission/devices/RwHandler.h | 5 ---- tmtc | 2 +- 6 files changed, 42 insertions(+), 9 deletions(-) diff --git a/bsp_q7s/ObjectFactory.cpp b/bsp_q7s/ObjectFactory.cpp index 8c9dc91a..e5b43ee0 100644 --- a/bsp_q7s/ObjectFactory.cpp +++ b/bsp_q7s/ObjectFactory.cpp @@ -548,13 +548,20 @@ void ObjectFactory::produce(void* args){ UartCookie* plocUartCookie = new UartCookie(std::string("/dev/ttyUL3"), 115200, PLOC::MAX_REPLY_SIZE); - PlocHandler(objects::PLOC_HANDLER, objects::UART_COM_IF, plocUartCookie); + new PlocHandler(objects::PLOC_HANDLER, objects::UART_COM_IF, plocUartCookie); + + GpioCookie* gpioCookieRw = new GpioCookie; + GpiodRegular* rw1ChipSelect = new GpiodRegular(std::string("gpiochip5"), 7, + std::string("Chip Select RW 1"), gpio::OUT, 1); + gpioCookieRw->addGpio(gpioIds::RW1, rw1ChipSelect); + gpioComIF->addGpios(gpioCookieRw); auto rw1SpiCookie = new SpiCookie(addresses::RW1, gpioIds::RW1, "/dev/spidev2.0", RwDefinitions::MAX_REPLY_SIZE, spi::RW_MODE, spi::RW_SPEED, &rwSpiCallback, nullptr); auto rwHandler1 = new RwHandler(objects::RW1, objects::SPI_COM_IF, rw1SpiCookie); rwHandler1->setStartUpImmediately(); + rw1SpiCookie->setCallbackArgs(rwHandler1); #endif /* TE0720 == 0 */ diff --git a/bsp_q7s/spiCallbacks/rwSpiCallback.cpp b/bsp_q7s/spiCallbacks/rwSpiCallback.cpp index fc9bade1..d1abf55e 100644 --- a/bsp_q7s/spiCallbacks/rwSpiCallback.cpp +++ b/bsp_q7s/spiCallbacks/rwSpiCallback.cpp @@ -103,6 +103,7 @@ ReturnValue_t rwSpiCallback(SpiComIF* comIf, SpiCookie *cookie, const uint8_t *s } return RwHandler::SPI_WRITE_FAILURE; } + idx++; } /** Sending frame start sign */ @@ -125,6 +126,14 @@ ReturnValue_t rwSpiCallback(SpiComIF* comIf, SpiCookie *cookie, const uint8_t *s uint8_t* rxBuf = nullptr; result = comIf->getReadBuffer(cookie->getSpiAddress(), &rxBuf); if(result != HasReturnvaluesIF::RETURN_OK) { + if(gpioId != gpio::NO_GPIO) { + if (gpioIF->pullHigh(gpioId) != HasReturnvaluesIF::RETURN_OK) { + sif::error << "rwSpiCallback: Failed to pull chip select high" << std::endl; + } + } + if(mutex->unlockMutex() != HasReturnvaluesIF::RETURN_OK) { + sif::error << "rwSpiCallback: Failed to unlock mutex"; + } return result; } @@ -133,6 +142,14 @@ ReturnValue_t rwSpiCallback(SpiComIF* comIf, SpiCookie *cookie, const uint8_t *s uint8_t byteRead = 0; /** Reading the reply frame */ if(read(fileDescriptor, &byteRead, 1) != 1) { + if(gpioId != gpio::NO_GPIO) { + if (gpioIF->pullHigh(gpioId) != HasReturnvaluesIF::RETURN_OK) { + sif::error << "rwSpiCallback: Failed to pull chip select high" << std::endl; + } + } + if(mutex->unlockMutex() != HasReturnvaluesIF::RETURN_OK) { + sif::error << "rwSpiCallback: Failed to unlock mutex"; + } sif::error << "rwSpiCallback: Failed to read first byte of reply frame" << std::endl; return RwHandler::SPI_READ_FAILURE; } @@ -140,6 +157,14 @@ ReturnValue_t rwSpiCallback(SpiComIF* comIf, SpiCookie *cookie, const uint8_t *s /** First byte must be the start sign 0x7E */ if (byteRead != 0x7E) { sif::error << "rwSpiCallback: First byte of reply is not 0x7E" << std::endl; + if(gpioId != gpio::NO_GPIO) { + if (gpioIF->pullHigh(gpioId) != HasReturnvaluesIF::RETURN_OK) { + sif::error << "rwSpiCallback: Failed to pull chip select high" << std::endl; + } + } + if(mutex->unlockMutex() != HasReturnvaluesIF::RETURN_OK) { + sif::error << "rwSpiCallback: Failed to unlock mutex"; + } return RwHandler::MISSING_START_SIGN; } diff --git a/linux/fsfwconfig/pollingsequence/pollingSequenceFactory.cpp b/linux/fsfwconfig/pollingsequence/pollingSequenceFactory.cpp index 39cbae4d..1682e4df 100644 --- a/linux/fsfwconfig/pollingsequence/pollingSequenceFactory.cpp +++ b/linux/fsfwconfig/pollingsequence/pollingSequenceFactory.cpp @@ -412,6 +412,12 @@ ReturnValue_t pst::pollingSequenceInitDefault(FixedTimeslotTaskIF *thisSequence) // thisSequence->addSlot(objects::SUS_13, length * 0.938, DeviceHandlerIF::SEND_READ); // thisSequence->addSlot(objects::SUS_13, length * 0.938, DeviceHandlerIF::GET_READ); + thisSequence->addSlot(objects::RW1, length * 0, DeviceHandlerIF::PERFORM_OPERATION); + thisSequence->addSlot(objects::RW1, length * 0.2, DeviceHandlerIF::SEND_WRITE); + thisSequence->addSlot(objects::RW1, length * 0.4, DeviceHandlerIF::GET_WRITE); + thisSequence->addSlot(objects::RW1, length * 0.6, DeviceHandlerIF::SEND_READ); + thisSequence->addSlot(objects::RW1, length * 0.8, DeviceHandlerIF::GET_READ); + if (thisSequence->checkSequence() == HasReturnvaluesIF::RETURN_OK) { return HasReturnvaluesIF::RETURN_OK; } @@ -480,8 +486,9 @@ ReturnValue_t pst::gomspacePstInit(FixedTimeslotTaskIF *thisSequence){ ReturnValue_t pst::pollingSequenceTest(FixedTimeslotTaskIF* thisSequence) { /* Length of a communication cycle */ - uint32_t length = thisSequence->getPeriodMs(); + #if OBSW_ADD_ACS_BOARD == 1 + uint32_t length = thisSequence->getPeriodMs(); thisSequence->addSlot(objects::MGM_0_LIS3_HANDLER, length * 0, DeviceHandlerIF::PERFORM_OPERATION); thisSequence->addSlot(objects::MGM_0_LIS3_HANDLER, length * 0.2, diff --git a/mission/devices/RwHandler.cpp b/mission/devices/RwHandler.cpp index 9f6d483b..f64c3685 100644 --- a/mission/devices/RwHandler.cpp +++ b/mission/devices/RwHandler.cpp @@ -3,7 +3,6 @@ #include #include -#include RwHandler::RwHandler(object_id_t objectId, object_id_t comIF, CookieIF * comCookie) : DeviceHandlerBase(objectId, comIF, comCookie), temperatureSet(this), statusSet(this) { diff --git a/mission/devices/RwHandler.h b/mission/devices/RwHandler.h index 8f77527b..7a5382d7 100644 --- a/mission/devices/RwHandler.h +++ b/mission/devices/RwHandler.h @@ -21,11 +21,6 @@ public: RwHandler(object_id_t objectId, object_id_t comIF, CookieIF * comCookie); virtual ~RwHandler(); - /** - * @brief Sets mode to MODE_NORMAL. Can be used for debugging. - */ - void setModeNormal(); - static const uint8_t INTERFACE_ID = CLASS_ID::RW_HANDLER; static const ReturnValue_t SPI_WRITE_FAILURE = MAKE_RETURN_CODE(0xB0); diff --git a/tmtc b/tmtc index 805470df..7a4d6ee1 160000 --- a/tmtc +++ b/tmtc @@ -1 +1 @@ -Subproject commit 805470df6d907ba5002fcca1ae71f662a7097b0b +Subproject commit 7a4d6ee13a32119a9a9e815d32680ae7ab302699 From 51dba9f2e9bc082bb29079eb63d872a5c78a1b54 Mon Sep 17 00:00:00 2001 From: "Jakob.Meier" Date: Mon, 21 Jun 2021 17:15:19 +0200 Subject: [PATCH 004/111] rw chip select decoding --- bsp_q7s/ObjectFactory.cpp | 16 +++++++++++--- bsp_q7s/gpio/gpioCallbacks.cpp | 34 ++++++++++++++++++++++++++++-- bsp_q7s/gpio/gpioCallbacks.h | 5 +++++ fsfw | 2 +- fsfw_hal | 2 +- linux/fsfwconfig/devices/gpioIds.h | 9 ++++---- 6 files changed, 57 insertions(+), 11 deletions(-) diff --git a/bsp_q7s/ObjectFactory.cpp b/bsp_q7s/ObjectFactory.cpp index e5b43ee0..68751f5c 100644 --- a/bsp_q7s/ObjectFactory.cpp +++ b/bsp_q7s/ObjectFactory.cpp @@ -551,9 +551,19 @@ void ObjectFactory::produce(void* args){ new PlocHandler(objects::PLOC_HANDLER, objects::UART_COM_IF, plocUartCookie); GpioCookie* gpioCookieRw = new GpioCookie; - GpiodRegular* rw1ChipSelect = new GpiodRegular(std::string("gpiochip5"), 7, - std::string("Chip Select RW 1"), gpio::OUT, 1); - gpioCookieRw->addGpio(gpioIds::RW1, rw1ChipSelect); + GpioCallback* csRw1 = new GpioCallback(std::string("Chip select reaction wheel 1"), gpio::OUT, + 1, &gpioCallbacks::spiCsDecoderCallback, gpioComIF); + gpioCookieRw->addGpio(gpioIds::EN_RW1, csRw1); + GpioCallback* csRw2 = new GpioCallback(std::string("Chip select reaction wheel 2"), gpio::OUT, + 1, &gpioCallbacks::spiCsDecoderCallback, gpioComIF); + gpioCookieRw->addGpio(gpioIds::EN_RW2, csRw2); + GpioCallback* csRw3 = new GpioCallback(std::string("Chip select reaction wheel 3"), gpio::OUT, + 1, &gpioCallbacks::spiCsDecoderCallback, gpioComIF); + gpioCookieRw->addGpio(gpioIds::EN_RW3, csRw3); + GpioCallback* csRw4 = new GpioCallback(std::string("Chip select reaction wheel 4"), gpio::OUT, + 1, &gpioCallbacks::spiCsDecoderCallback, gpioComIF); + gpioCookieRw->addGpio(gpioIds::EN_RW4, csRw4); + gpioComIF->addGpios(gpioCookieRw); auto rw1SpiCookie = new SpiCookie(addresses::RW1, gpioIds::RW1, "/dev/spidev2.0", diff --git a/bsp_q7s/gpio/gpioCallbacks.cpp b/bsp_q7s/gpio/gpioCallbacks.cpp index 2f59cb0e..7ae2c417 100644 --- a/bsp_q7s/gpio/gpioCallbacks.cpp +++ b/bsp_q7s/gpio/gpioCallbacks.cpp @@ -45,11 +45,13 @@ void initSpiCsDecoder(GpioIF* gpioComIF) { GpiodRegular* spiMuxBit6 = new GpiodRegular(std::string("gpiochip7"), 18, std::string("SPI Mux Bit 6"), gpio::OUT, 0); spiMuxGpios->addGpio(gpioIds::SPI_MUX_BIT_6, spiMuxBit6); + GpiodRegular* enRwDecoder = new GpiodRegular(std::string("gpiochip5"), 17, + std::string("EN_RW_CS"), gpio::OUT, 0); + spiMuxGpios->addGpio(gpioIds::EN_RW_CS, enRwDecoder); result = gpioComInterface->addGpios(spiMuxGpios); if (result != HasReturnvaluesIF::RETURN_OK) { - sif::error << "initSpiCsDecoder: Failed to add mux bit gpios to gpioComIF" - << std::endl; + sif::error << "initSpiCsDecoder: Failed to add mux bit gpios to gpioComIF" << std::endl; return; } } @@ -218,6 +220,26 @@ void spiCsDecoderCallback(gpioId_t gpioId, gpio::GpioOperation gpioOp, int value selectY6(); break; } + case(gpioIds::EN_RW1): { + enableRwDecoder(); + selectY0(); + break; + } + case(gpioIds::EN_RW2): { + enableRwDecoder(); + selectY1(); + break; + } + case(gpioIds::EN_RW3): { + enableRwDecoder(); + selectY3(); + break; + } + case(gpioIds::EN_RW4): { + enableRwDecoder(); + selectY4(); + break; + } default: sif::debug << "spiCsDecoderCallback: Invalid gpio id " << gpioId << std::endl; } @@ -251,6 +273,13 @@ void enableDecoderInterfaceBoardIc2() { gpioComInterface->pullHigh(gpioIds::SPI_MUX_BIT_3); } +void enableRwDecoder() { + gpioComInterface->pullLow(gpioIds::SPI_MUX_BIT_1); + gpioComInterface->pullLow(gpioIds::SPI_MUX_BIT_2); + gpioComInterface->pullLow(gpioIds::SPI_MUX_BIT_3); + gpioComInterface->pullHigh(gpioIds::EN_RW_CS); +} + void selectY0() { gpioComInterface->pullLow(gpioIds::SPI_MUX_BIT_4); gpioComInterface->pullLow(gpioIds::SPI_MUX_BIT_5); @@ -303,6 +332,7 @@ void disableAllDecoder() { gpioComInterface->pullLow(gpioIds::SPI_MUX_BIT_1); gpioComInterface->pullLow(gpioIds::SPI_MUX_BIT_2); gpioComInterface->pullLow(gpioIds::SPI_MUX_BIT_3); + gpioComInterface->pullLow(gpioIds::EN_RW_CS); } } diff --git a/bsp_q7s/gpio/gpioCallbacks.h b/bsp_q7s/gpio/gpioCallbacks.h index 4a0c73cb..eaf9a701 100644 --- a/bsp_q7s/gpio/gpioCallbacks.h +++ b/bsp_q7s/gpio/gpioCallbacks.h @@ -43,6 +43,11 @@ namespace gpioCallbacks { */ void enableDecoderInterfaceBoardIc2(); + /** + * @brief Enables the reaction wheel chip select decoder (IC3). + */ + void enableRwDecoder(); + /** * @brief This function disables all decoder. */ diff --git a/fsfw b/fsfw index d700fb55..cae69d54 160000 --- a/fsfw +++ b/fsfw @@ -1 +1 @@ -Subproject commit d700fb551c85393b58a3ada96fbd3f807217d14b +Subproject commit cae69d540097acba46bffa47fd7afc6a8a19bd15 diff --git a/fsfw_hal b/fsfw_hal index ae322d98..8fe5d0af 160000 --- a/fsfw_hal +++ b/fsfw_hal @@ -1 +1 @@ -Subproject commit ae322d981bd1ed8411a058ba6b4dc185f00a12f3 +Subproject commit 8fe5d0afa0857025d9dee3c6f266c2503a22c517 diff --git a/linux/fsfwconfig/devices/gpioIds.h b/linux/fsfwconfig/devices/gpioIds.h index 39d1b8ce..0a541477 100644 --- a/linux/fsfwconfig/devices/gpioIds.h +++ b/linux/fsfwconfig/devices/gpioIds.h @@ -70,10 +70,11 @@ namespace gpioIds { PAPB_BUSY_N, PAPB_EMPTY, - RW1, - RW2, - RW3, - RW4 + EN_RW1, + EN_RW2, + EN_RW3, + EN_RW4, + EN_RW_CS }; } From c46b41c2497720e5e5590a49c1a2bedbd2daec1b Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Mon, 21 Jun 2021 18:11:07 +0200 Subject: [PATCH 005/111] test --- README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index ba18152d..a03d7272 100644 --- a/README.md +++ b/README.md @@ -40,11 +40,11 @@ the TCF plugin and downloading the cross-compiler as specified in the section be * Install settings. In the Devices selection, it is sufficient to pick SoC → Zynq-7000:
-
+
-
+
-
+
* For supported OS refer to https://www.xilinx.com/support/documentation/sw_manuals/xilinx2018_2/ug973-vivado-release-notes-install-license.pdf * Add path of linux cross-compiler to permanent environment variables (`.profile` file in Linux): From 941e34ea0d4b768900a581aaf2e8a21fd61cdc05 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Mon, 21 Jun 2021 18:40:26 +0200 Subject: [PATCH 006/111] tmtc update --- tmtc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tmtc b/tmtc index 20a44b4b..5be05c2a 160000 --- a/tmtc +++ b/tmtc @@ -1 +1 @@ -Subproject commit 20a44b4b67198d42e83a790191ad6740d0aabf7c +Subproject commit 5be05c2a929dfc908b8de61250e4db890b010fa5 From cbdcc50cc9b018d9a9fa24721bd2b8f917ee7675 Mon Sep 17 00:00:00 2001 From: Martin Zietz Date: Tue, 22 Jun 2021 13:48:30 +0200 Subject: [PATCH 007/111] rw enable wip --- bsp_q7s/ObjectFactory.cpp | 16 ++++++++-------- bsp_q7s/gpio/gpioCallbacks.cpp | 2 +- mission/devices/RwHandler.cpp | 14 +++++++++----- mission/devices/RwHandler.h | 13 ++++++++++++- 4 files changed, 30 insertions(+), 15 deletions(-) diff --git a/bsp_q7s/ObjectFactory.cpp b/bsp_q7s/ObjectFactory.cpp index f3ecd173..821d94fd 100644 --- a/bsp_q7s/ObjectFactory.cpp +++ b/bsp_q7s/ObjectFactory.cpp @@ -552,18 +552,18 @@ void ObjectFactory::produce(void* args){ new PlocHandler(objects::PLOC_HANDLER, objects::UART_COM_IF, plocUartCookie); GpioCookie* gpioCookieRw = new GpioCookie; - GpioCallback* csRw1 = new GpioCallback(std::string("Chip select reaction wheel 1"), gpio::OUT, + GpioCallback* enRw1 = new GpioCallback(std::string("Chip select reaction wheel 1"), gpio::OUT, 1, &gpioCallbacks::spiCsDecoderCallback, gpioComIF); - gpioCookieRw->addGpio(gpioIds::EN_RW1, csRw1); - GpioCallback* csRw2 = new GpioCallback(std::string("Chip select reaction wheel 2"), gpio::OUT, + gpioCookieRw->addGpio(gpioIds::EN_RW1, enRw1); + GpioCallback* enRw2 = new GpioCallback(std::string("Chip select reaction wheel 2"), gpio::OUT, 1, &gpioCallbacks::spiCsDecoderCallback, gpioComIF); - gpioCookieRw->addGpio(gpioIds::EN_RW2, csRw2); - GpioCallback* csRw3 = new GpioCallback(std::string("Chip select reaction wheel 3"), gpio::OUT, + gpioCookieRw->addGpio(gpioIds::EN_RW2, enRw2); + GpioCallback* enRw3 = new GpioCallback(std::string("Chip select reaction wheel 3"), gpio::OUT, 1, &gpioCallbacks::spiCsDecoderCallback, gpioComIF); - gpioCookieRw->addGpio(gpioIds::EN_RW3, csRw3); - GpioCallback* csRw4 = new GpioCallback(std::string("Chip select reaction wheel 4"), gpio::OUT, + gpioCookieRw->addGpio(gpioIds::EN_RW3, enRw3); + GpioCallback* enRw4 = new GpioCallback(std::string("Chip select reaction wheel 4"), gpio::OUT, 1, &gpioCallbacks::spiCsDecoderCallback, gpioComIF); - gpioCookieRw->addGpio(gpioIds::EN_RW4, csRw4); + gpioCookieRw->addGpio(gpioIds::EN_RW4, enRw4); gpioComIF->addGpios(gpioCookieRw); diff --git a/bsp_q7s/gpio/gpioCallbacks.cpp b/bsp_q7s/gpio/gpioCallbacks.cpp index 7ae2c417..ede2311a 100644 --- a/bsp_q7s/gpio/gpioCallbacks.cpp +++ b/bsp_q7s/gpio/gpioCallbacks.cpp @@ -46,7 +46,7 @@ void initSpiCsDecoder(GpioIF* gpioComIF) { std::string("SPI Mux Bit 6"), gpio::OUT, 0); spiMuxGpios->addGpio(gpioIds::SPI_MUX_BIT_6, spiMuxBit6); GpiodRegular* enRwDecoder = new GpiodRegular(std::string("gpiochip5"), 17, - std::string("EN_RW_CS"), gpio::OUT, 0); + std::string("EN_RW_CS"), gpio::OUT, 1); spiMuxGpios->addGpio(gpioIds::EN_RW_CS, enRwDecoder); result = gpioComInterface->addGpios(spiMuxGpios); diff --git a/mission/devices/RwHandler.cpp b/mission/devices/RwHandler.cpp index f64c3685..c029372b 100644 --- a/mission/devices/RwHandler.cpp +++ b/mission/devices/RwHandler.cpp @@ -4,11 +4,15 @@ #include #include -RwHandler::RwHandler(object_id_t objectId, object_id_t comIF, CookieIF * comCookie) : - DeviceHandlerBase(objectId, comIF, comCookie), temperatureSet(this), statusSet(this) { - if (comCookie == NULL) { - sif::error << "RwHandler: Invalid com cookie" << std::endl; - } +RwHandler::RwHandler(object_id_t objectId, object_id_t comIF, CookieIF * comCookie, + LinuxLibgpioIF* gpioComIF, gpioId_t enableGpio) : + DeviceHandlerBase(objectId, comIF, comCookie), temperatureSet(this), statusSet(this) { + if (comCookie == NULL) { + sif::error << "RwHandler: Invalid com cookie" << std::endl; + } + if (gpioComIF == NULL) { + sif::error << "RwHandler: Invalid gpio communication interface" << std::endl; + } } RwHandler::~RwHandler() { diff --git a/mission/devices/RwHandler.h b/mission/devices/RwHandler.h index 7a5382d7..f68b57b7 100644 --- a/mission/devices/RwHandler.h +++ b/mission/devices/RwHandler.h @@ -18,7 +18,18 @@ class RwHandler: public DeviceHandlerBase { public: - RwHandler(object_id_t objectId, object_id_t comIF, CookieIF * comCookie); + /** + * @brief Constructor + * + * @param objectId + * @param comIF + * @param comCookie + * @param gpioComIF Pointer to gpio communication interface + * @param enablePin GPIO connected to the enable pin of the reaction wheels. Must be pulled + * to high to enable the device. + */ + RwHandler(object_id_t objectId, object_id_t comIF, CookieIF * comCookie, + LinuxLibgpioIF* gpioComIF, gpioId_t enableGpio); virtual ~RwHandler(); static const uint8_t INTERFACE_ID = CLASS_ID::RW_HANDLER; From 56cabbc117ade28e3216bd5c4bc941a73d45f2e6 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Wed, 23 Jun 2021 15:18:31 +0200 Subject: [PATCH 008/111] split up psts --- bsp_linux_board/InitMission.cpp | 6 +- bsp_q7s/InitMission.cpp | 61 +- bsp_q7s/boardconfig/q7sConfig.h.in | 6 +- common/config/commonObjects.h | 3 + .../pollingSequenceFactory.cpp | 648 ++++++++++-------- .../pollingsequence/pollingSequenceFactory.h | 25 +- mission/devices/GPSHandler.cpp | 10 +- 7 files changed, 426 insertions(+), 333 deletions(-) diff --git a/bsp_linux_board/InitMission.cpp b/bsp_linux_board/InitMission.cpp index 16dab475..9e7abd94 100644 --- a/bsp_linux_board/InitMission.cpp +++ b/bsp_linux_board/InitMission.cpp @@ -135,9 +135,9 @@ void initmission::initTasks() { } #if OBSW_ADD_TEST_PST == 1 - FixedTimeslotTaskIF* pstTestTask = factory->createFixedTimeslotTask( - "ACS_PST", 50, PeriodicTaskIF::MINIMUM_STACK_SIZE * 2, 2.0, missedDeadlineFunc); - result = pst::pollingSequenceTest(pstTestTask); + FixedTimeslotTaskIF* pstTestTask = factory->createFixedTimeslotTask("ACS_PST", 50, + PeriodicTaskIF::MINIMUM_STACK_SIZE * 2, 2.0, missedDeadlineFunc); + result = pst::pstTest(pstTestTask); if(result != HasReturnvaluesIF::RETURN_OK) { sif::warning << "initmission::initTasks: ACS PST initialization failed!" << std::endl; } diff --git a/bsp_q7s/InitMission.cpp b/bsp_q7s/InitMission.cpp index 9a475a11..25cd6abf 100644 --- a/bsp_q7s/InitMission.cpp +++ b/bsp_q7s/InitMission.cpp @@ -85,14 +85,6 @@ void initmission::initTasks() { initmission::printAddObjectError("UDP_POLLING", objects::UDP_POLLING_TASK); } - /* UDP bridge */ - PeriodicTaskIF* errorReporterTestTask = factory->createPeriodicTask( - "ERROR_REPORTER", 50, PeriodicTaskIF::MINIMUM_STACK_SIZE, 0.2, missedDeadlineFunc); - result = udpBridgeTask->addComponent(objects::INTERNAL_ERROR_REPORTER); - if(result != HasReturnvaluesIF::RETURN_OK) { - initmission::printAddObjectError("ERROR_REPORTER", objects::INTERNAL_ERROR_REPORTER); - } - #if TEST_CCSDS_BRIDGE == 1 PeriodicTaskIF* ptmeTestTask = factory->createPeriodicTask( "PTME_TEST", 80, PeriodicTaskIF::MINIMUM_STACK_SIZE, 2.0, missedDeadlineFunc); @@ -153,30 +145,51 @@ void initmission::initTasks() { if(result != HasReturnvaluesIF::RETURN_OK) { initmission::printAddObjectError("PUS_17", objects::PUS_SERVICE_17_TEST); } + result = pusLowPrio->addComponent(objects::INTERNAL_ERROR_REPORTER); + if(result != HasReturnvaluesIF::RETURN_OK) { + initmission::printAddObjectError("ERROR_REPORTER", objects::INTERNAL_ERROR_REPORTER); + } #if TE0720 == 0 - //TODO: Add handling of missed deadlines /* Polling Sequence Table Default */ #if Q7S_ADD_SPI_TEST == 0 - FixedTimeslotTaskIF * pollingSequenceTableTaskDefault = factory->createFixedTimeslotTask( - "PST_TASK_DEFAULT", 50, PeriodicTaskIF::MINIMUM_STACK_SIZE * 4, 3.0, + FixedTimeslotTaskIF* spiPst = factory->createFixedTimeslotTask( + "PST_TASK_DEFAULT", 70, PeriodicTaskIF::MINIMUM_STACK_SIZE * 4, 3.0, missedDeadlineFunc); - result = pst::pollingSequenceInitDefault(pollingSequenceTableTaskDefault); + result = pst::pstSpi(spiPst); if (result != HasReturnvaluesIF::RETURN_OK) { sif::error << "InitMission::initTasks: Creating PST failed!" << std::endl; } #endif - FixedTimeslotTaskIF* gomSpacePstTask = factory-> - createFixedTimeslotTask("GS_PST_TASK", 50, - PeriodicTaskIF::MINIMUM_STACK_SIZE*8, 1.0, missedDeadlineFunc); - result = pst::gomspacePstInit(gomSpacePstTask); + FixedTimeslotTaskIF* uartPst = factory->createFixedTimeslotTask( + "UART_PST", 70, PeriodicTaskIF::MINIMUM_STACK_SIZE * 4, 3.0, missedDeadlineFunc); + result = pst::pstUart(uartPst); + if (result != HasReturnvaluesIF::RETURN_OK) { + sif::error << "InitMission::initTasks: Creating PST failed!" << std::endl; + } + FixedTimeslotTaskIF* gpioPst = factory->createFixedTimeslotTask( + "GPIO_PST", 70, PeriodicTaskIF::MINIMUM_STACK_SIZE * 4, 3.0, missedDeadlineFunc); + result = pst::pstGpio(gpioPst); + if (result != HasReturnvaluesIF::RETURN_OK) { + sif::error << "InitMission::initTasks: Creating PST failed!" << std::endl; + } + FixedTimeslotTaskIF* i2cPst = factory->createFixedTimeslotTask( + "I2C_PST", 70, PeriodicTaskIF::MINIMUM_STACK_SIZE * 4, 3.0, missedDeadlineFunc); + result = pst::pstI2c(i2cPst); + if (result != HasReturnvaluesIF::RETURN_OK) { + sif::error << "InitMission::initTasks: Creating PST failed!" << std::endl; + } + + FixedTimeslotTaskIF* gomSpacePstTask = factory->createFixedTimeslotTask( + "GS_PST_TASK", 70, PeriodicTaskIF::MINIMUM_STACK_SIZE * 4, 1.0, missedDeadlineFunc); + result = pst::pstGompaceCan(gomSpacePstTask); if(result != HasReturnvaluesIF::RETURN_OK) { sif::error << "InitMission::initTasks: GomSpace PST initialization failed!" << std::endl; } -#else +#else /* TE7020 == 0 */ FixedTimeslotTaskIF * pollingSequenceTaskTE0720 = factory->createFixedTimeslotTask( "PST_TASK_TE0720", 30, PeriodicTaskIF::MINIMUM_STACK_SIZE * 8, 3.0, missedDeadlineFunc); @@ -184,7 +197,7 @@ void initmission::initTasks() { if (result != HasReturnvaluesIF::RETURN_OK) { sif::error << "InitMission::initTasks: Creating TE0720 PST failed!" << std::endl; } -#endif +#endif /* TE7020 == 1 */ #if OBSW_ADD_TEST_CODE == 1 PeriodicTaskIF* testTask = factory->createPeriodicTask( @@ -213,9 +226,15 @@ void initmission::initTasks() { udpBridgeTask->startTask(); udpPollingTask->startTask(); -#if TE0720 == 0 && Q7S_ADD_SPI_TEST == 0 +#if TE0720 == 0 + uartPst->startTask(); + gpioPst->startTask(); + i2cPst->startTask(); +#if Q7S_ADD_SPI_TEST == 0 gomSpacePstTask->startTask(); - pollingSequenceTableTaskDefault->startTask(); + spiPst->startTask(); +#endif /* Q7S_ADD_SPI_TEST == 0 */ + #elif TE0720 == 1 && Q7S_ADD_SPI_TEST == 0 pollingSequenceTaskTE0720->startTask(); #endif @@ -226,8 +245,6 @@ void initmission::initTasks() { pusMedPrio->startTask(); pusLowPrio->startTask(); - errorReporterTestTask->startTask(); - #if OBSW_ADD_TEST_CODE == 1 testTask->startTask(); #endif diff --git a/bsp_q7s/boardconfig/q7sConfig.h.in b/bsp_q7s/boardconfig/q7sConfig.h.in index 782ecf4f..81b96a7e 100644 --- a/bsp_q7s/boardconfig/q7sConfig.h.in +++ b/bsp_q7s/boardconfig/q7sConfig.h.in @@ -1,13 +1,13 @@ #ifndef BSP_Q7S_BOARDCONFIG_Q7S_CONFIG_H_ #define BSP_Q7S_BOARDCONFIG_Q7S_CONFIG_H_ -#define Q7S_ADD_RTD_DEVICES 0 +#define Q7S_ADD_RTD_DEVICES 0 /* Only one of those 2 should be enabled! */ /* Add code for ACS board */ #define OBSW_ADD_ACS_BOARD 0 +#if OBSW_ADD_ACS_BOARD == 0 #define Q7S_ADD_SPI_TEST 0 - - +#endif #endif /* BSP_Q7S_BOARDCONFIG_Q7S_CONFIG_H_ */ diff --git a/common/config/commonObjects.h b/common/config/commonObjects.h index 3baf58b0..1651f6a0 100644 --- a/common/config/commonObjects.h +++ b/common/config/commonObjects.h @@ -48,6 +48,9 @@ enum commonObjects: uint32_t { SUS_11 = 0x44000021, SUS_12 = 0x44000022, SUS_13 = 0x44000023, + + GPS0_HANDLER = 0x44001000, + GPS1_HANDLER = 0x44002000 }; } diff --git a/linux/fsfwconfig/pollingsequence/pollingSequenceFactory.cpp b/linux/fsfwconfig/pollingsequence/pollingSequenceFactory.cpp index 60059d3c..0add7a3b 100644 --- a/linux/fsfwconfig/pollingsequence/pollingSequenceFactory.cpp +++ b/linux/fsfwconfig/pollingsequence/pollingSequenceFactory.cpp @@ -9,18 +9,40 @@ #include "objects/systemObjectList.h" -ReturnValue_t pst::pollingSequenceInitDefault(FixedTimeslotTaskIF *thisSequence) +ReturnValue_t pst::pstGpio(FixedTimeslotTaskIF *thisSequence) { - /* Length of a communication cycle */ + // Length of a communication cycle uint32_t length = thisSequence->getPeriodMs(); - thisSequence->addSlot(objects::TMP1075_HANDLER_1, length * 0, - DeviceHandlerIF::PERFORM_OPERATION); - thisSequence->addSlot(objects::TMP1075_HANDLER_2, length * 0, - DeviceHandlerIF::PERFORM_OPERATION); + thisSequence->addSlot(objects::HEATER_HANDLER, length * 0, DeviceHandlerIF::PERFORM_OPERATION); thisSequence->addSlot(objects::SOLAR_ARRAY_DEPL_HANDLER, length * 0, DeviceHandlerIF::PERFORM_OPERATION); + // Radiation sensor +// 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); +// thisSequence->addSlot(objects::RAD_SENSOR, length * 0.6, DeviceHandlerIF::SEND_READ); +// thisSequence->addSlot(objects::RAD_SENSOR, length * 0.8, DeviceHandlerIF::GET_READ); + // if (length != 3000) { + // sif::warning << "pollingSequenceInitDefault: Frequency changed. Make sure timing critical " + // << "SUS sensors still produce correct values" << std::endl; + // } + if (thisSequence->checkSequence() == HasReturnvaluesIF::RETURN_OK) { + return HasReturnvaluesIF::RETURN_OK; + } + + sif::error << "PollingSequence::initialize has errors!" << std::endl; + return HasReturnvaluesIF::RETURN_FAILED; +} + +ReturnValue_t pst::pstSpi(FixedTimeslotTaskIF *thisSequence) { + uint32_t length = thisSequence->getPeriodMs(); + + thisSequence->addSlot(objects::TMP1075_HANDLER_1, length * 0, + DeviceHandlerIF::PERFORM_OPERATION); + thisSequence->addSlot(objects::TMP1075_HANDLER_2, length * 0, + DeviceHandlerIF::PERFORM_OPERATION); #if Q7S_ADD_RTD_DEVICES == 1 thisSequence->addSlot(objects::RTD_IC3, length * 0, DeviceHandlerIF::PERFORM_OPERATION); thisSequence->addSlot(objects::RTD_IC4, length * 0, DeviceHandlerIF::PERFORM_OPERATION); @@ -40,12 +62,8 @@ ReturnValue_t pst::pollingSequenceInitDefault(FixedTimeslotTaskIF *thisSequence) thisSequence->addSlot(objects::RTD_IC18, length * 0, DeviceHandlerIF::PERFORM_OPERATION); #endif /* Q7S_ADD_RTD_DEVICES */ - thisSequence->addSlot(objects::IMTQ_HANDLER, length * 0, DeviceHandlerIF::PERFORM_OPERATION); - thisSequence->addSlot(objects::PLOC_HANDLER, length * 0, DeviceHandlerIF::PERFORM_OPERATION); - thisSequence->addSlot(objects::TMP1075_HANDLER_1, length * 0.2, DeviceHandlerIF::SEND_WRITE); thisSequence->addSlot(objects::TMP1075_HANDLER_2, length * 0.2, DeviceHandlerIF::SEND_WRITE); - #if Q7S_ADD_RTD_DEVICES == 1 thisSequence->addSlot(objects::RTD_IC3, length * 0.2, DeviceHandlerIF::SEND_WRITE); thisSequence->addSlot(objects::RTD_IC4, length * 0.2, DeviceHandlerIF::SEND_WRITE); @@ -65,12 +83,8 @@ ReturnValue_t pst::pollingSequenceInitDefault(FixedTimeslotTaskIF *thisSequence) thisSequence->addSlot(objects::RTD_IC18, length * 0.2, DeviceHandlerIF::SEND_WRITE); #endif /* Q7S_ADD_RTD_DEVICES */ - thisSequence->addSlot(objects::IMTQ_HANDLER, length * 0.2, DeviceHandlerIF::SEND_WRITE); - thisSequence->addSlot(objects::PLOC_HANDLER, length * 0.2, DeviceHandlerIF::SEND_WRITE); - thisSequence->addSlot(objects::TMP1075_HANDLER_1, length * 0.4, DeviceHandlerIF::GET_WRITE); thisSequence->addSlot(objects::TMP1075_HANDLER_2, length * 0.4, DeviceHandlerIF::GET_WRITE); - #if Q7S_ADD_RTD_DEVICES == 1 thisSequence->addSlot(objects::RTD_IC3, length * 0.4, DeviceHandlerIF::GET_WRITE); thisSequence->addSlot(objects::RTD_IC4, length * 0.4, DeviceHandlerIF::GET_WRITE); @@ -90,12 +104,8 @@ ReturnValue_t pst::pollingSequenceInitDefault(FixedTimeslotTaskIF *thisSequence) thisSequence->addSlot(objects::RTD_IC18, length * 0.4, DeviceHandlerIF::GET_WRITE); #endif /* Q7S_ADD_RTD_DEVICES */ - thisSequence->addSlot(objects::IMTQ_HANDLER, length * 0.4, DeviceHandlerIF::GET_WRITE); - thisSequence->addSlot(objects::PLOC_HANDLER, length * 0.4, DeviceHandlerIF::GET_WRITE); - thisSequence->addSlot(objects::TMP1075_HANDLER_1, length * 0.6, DeviceHandlerIF::SEND_READ); thisSequence->addSlot(objects::TMP1075_HANDLER_2, length * 0.6, DeviceHandlerIF::SEND_READ); - #if Q7S_ADD_RTD_DEVICES == 1 thisSequence->addSlot(objects::RTD_IC3, length * 0.6, DeviceHandlerIF::SEND_READ); thisSequence->addSlot(objects::RTD_IC4, length * 0.6, DeviceHandlerIF::SEND_READ); @@ -115,12 +125,8 @@ ReturnValue_t pst::pollingSequenceInitDefault(FixedTimeslotTaskIF *thisSequence) thisSequence->addSlot(objects::RTD_IC18, length * 0.6, DeviceHandlerIF::SEND_READ); #endif /* Q7S_ADD_RTD_DEVICES */ - thisSequence->addSlot(objects::IMTQ_HANDLER, length * 0.6, DeviceHandlerIF::SEND_READ); - thisSequence->addSlot(objects::PLOC_HANDLER, length * 0.6, DeviceHandlerIF::SEND_READ); - thisSequence->addSlot(objects::TMP1075_HANDLER_1, length * 0.8, DeviceHandlerIF::GET_READ); thisSequence->addSlot(objects::TMP1075_HANDLER_2, length * 0.8, DeviceHandlerIF::GET_READ); - #if Q7S_ADD_RTD_DEVICES == 1 thisSequence->addSlot(objects::RTD_IC3, length * 0.8, DeviceHandlerIF::GET_READ); thisSequence->addSlot(objects::RTD_IC4, length * 0.8, DeviceHandlerIF::GET_READ); @@ -139,23 +145,6 @@ ReturnValue_t pst::pollingSequenceInitDefault(FixedTimeslotTaskIF *thisSequence) thisSequence->addSlot(objects::RTD_IC17, length * 0.8, DeviceHandlerIF::GET_READ); thisSequence->addSlot(objects::RTD_IC18, length * 0.8, DeviceHandlerIF::GET_READ); #endif /* Q7S_ADD_RTD_DEVICES */ - - thisSequence->addSlot(objects::IMTQ_HANDLER, length * 0.8, DeviceHandlerIF::GET_READ); - thisSequence->addSlot(objects::PLOC_HANDLER, length * 0.8, DeviceHandlerIF::GET_READ); - - - /* Radiation sensor */ -// 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); -// thisSequence->addSlot(objects::RAD_SENSOR, length * 0.6, DeviceHandlerIF::SEND_READ); -// thisSequence->addSlot(objects::RAD_SENSOR, length * 0.8, DeviceHandlerIF::GET_READ); - - if (length != 3000) { - sif::warning << "pollingSequenceInitDefault: Frequency changed. Make sure timing critical " - << "SUS sensors still produce correct values" << std::endl; - } - /** * The sun sensor will be shutdown as soon as the chip select is pulled high. Thus all * requests to a sun sensor must be performed consecutively. Another reason for calling multiple @@ -166,263 +155,333 @@ ReturnValue_t pst::pollingSequenceInitDefault(FixedTimeslotTaskIF *thisSequence) */ /* Write setup */ -// thisSequence->addSlot(objects::SUS_1, length * 0.9, DeviceHandlerIF::PERFORM_OPERATION); -// thisSequence->addSlot(objects::SUS_1, length * 0.9, SusHandler::FIRST_WRITE); -// thisSequence->addSlot(objects::SUS_1, length * 0.9, DeviceHandlerIF::GET_WRITE); -// thisSequence->addSlot(objects::SUS_1, length * 0.9, DeviceHandlerIF::SEND_READ); -// thisSequence->addSlot(objects::SUS_1, length * 0.9, DeviceHandlerIF::GET_READ); -// /* Write setup */ -// thisSequence->addSlot(objects::SUS_1, length * 0.901, DeviceHandlerIF::PERFORM_OPERATION); -// thisSequence->addSlot(objects::SUS_1, length * 0.901, SusHandler::FIRST_WRITE); -// thisSequence->addSlot(objects::SUS_1, length * 0.901, DeviceHandlerIF::GET_WRITE); -// thisSequence->addSlot(objects::SUS_1, length * 0.901, DeviceHandlerIF::SEND_READ); -// thisSequence->addSlot(objects::SUS_1, length * 0.901, DeviceHandlerIF::GET_READ); -// /* Write setup */ -// thisSequence->addSlot(objects::SUS_1, length * 0.902, DeviceHandlerIF::PERFORM_OPERATION); -// thisSequence->addSlot(objects::SUS_1, length * 0.902, SusHandler::FIRST_WRITE); -// thisSequence->addSlot(objects::SUS_1, length * 0.902, DeviceHandlerIF::GET_WRITE); -// thisSequence->addSlot(objects::SUS_1, length * 0.902, DeviceHandlerIF::SEND_READ); -// thisSequence->addSlot(objects::SUS_1, length * 0.902, DeviceHandlerIF::GET_READ); + // thisSequence->addSlot(objects::SUS_1, length * 0.9, DeviceHandlerIF::PERFORM_OPERATION); + // thisSequence->addSlot(objects::SUS_1, length * 0.9, SusHandler::FIRST_WRITE); + // thisSequence->addSlot(objects::SUS_1, length * 0.9, DeviceHandlerIF::GET_WRITE); + // thisSequence->addSlot(objects::SUS_1, length * 0.9, DeviceHandlerIF::SEND_READ); + // thisSequence->addSlot(objects::SUS_1, length * 0.9, DeviceHandlerIF::GET_READ); + // /* Write setup */ + // thisSequence->addSlot(objects::SUS_1, length * 0.901, DeviceHandlerIF::PERFORM_OPERATION); + // thisSequence->addSlot(objects::SUS_1, length * 0.901, SusHandler::FIRST_WRITE); + // thisSequence->addSlot(objects::SUS_1, length * 0.901, DeviceHandlerIF::GET_WRITE); + // thisSequence->addSlot(objects::SUS_1, length * 0.901, DeviceHandlerIF::SEND_READ); + // thisSequence->addSlot(objects::SUS_1, length * 0.901, DeviceHandlerIF::GET_READ); + // /* Write setup */ + // thisSequence->addSlot(objects::SUS_1, length * 0.902, DeviceHandlerIF::PERFORM_OPERATION); + // thisSequence->addSlot(objects::SUS_1, length * 0.902, SusHandler::FIRST_WRITE); + // thisSequence->addSlot(objects::SUS_1, length * 0.902, DeviceHandlerIF::GET_WRITE); + // thisSequence->addSlot(objects::SUS_1, length * 0.902, DeviceHandlerIF::SEND_READ); + // thisSequence->addSlot(objects::SUS_1, length * 0.902, DeviceHandlerIF::GET_READ); - /* Write setup */ -// thisSequence->addSlot(objects::SUS_2, length * 0.903, DeviceHandlerIF::PERFORM_OPERATION); -// thisSequence->addSlot(objects::SUS_2, length * 0.903, SusHandler::FIRST_WRITE); -// thisSequence->addSlot(objects::SUS_2, length * 0.903, DeviceHandlerIF::GET_WRITE); -// thisSequence->addSlot(objects::SUS_2, length * 0.903, DeviceHandlerIF::SEND_READ); -// thisSequence->addSlot(objects::SUS_2, length * 0.903, DeviceHandlerIF::GET_READ); -// /* Write setup */ -// thisSequence->addSlot(objects::SUS_2, length * 0.904, DeviceHandlerIF::PERFORM_OPERATION); -// thisSequence->addSlot(objects::SUS_2, length * 0.904, SusHandler::SEND_WRITE); -// thisSequence->addSlot(objects::SUS_2, length * 0.904, DeviceHandlerIF::GET_WRITE); -// thisSequence->addSlot(objects::SUS_2, length * 0.904, DeviceHandlerIF::SEND_READ); -// thisSequence->addSlot(objects::SUS_2, length * 0.904, DeviceHandlerIF::GET_READ); -// /* Write setup */ -// thisSequence->addSlot(objects::SUS_2, length * 0.905, DeviceHandlerIF::PERFORM_OPERATION); -// thisSequence->addSlot(objects::SUS_2, length * 0.905, SusHandler::SEND_WRITE); -// thisSequence->addSlot(objects::SUS_2, length * 0.905, DeviceHandlerIF::GET_WRITE); -// thisSequence->addSlot(objects::SUS_2, length * 0.905, DeviceHandlerIF::SEND_READ); -// thisSequence->addSlot(objects::SUS_2, length * 0.905, DeviceHandlerIF::GET_READ); + /* Write setup */ + // thisSequence->addSlot(objects::SUS_2, length * 0.903, DeviceHandlerIF::PERFORM_OPERATION); + // thisSequence->addSlot(objects::SUS_2, length * 0.903, SusHandler::FIRST_WRITE); + // thisSequence->addSlot(objects::SUS_2, length * 0.903, DeviceHandlerIF::GET_WRITE); + // thisSequence->addSlot(objects::SUS_2, length * 0.903, DeviceHandlerIF::SEND_READ); + // thisSequence->addSlot(objects::SUS_2, length * 0.903, DeviceHandlerIF::GET_READ); + // /* Write setup */ + // thisSequence->addSlot(objects::SUS_2, length * 0.904, DeviceHandlerIF::PERFORM_OPERATION); + // thisSequence->addSlot(objects::SUS_2, length * 0.904, SusHandler::SEND_WRITE); + // thisSequence->addSlot(objects::SUS_2, length * 0.904, DeviceHandlerIF::GET_WRITE); + // thisSequence->addSlot(objects::SUS_2, length * 0.904, DeviceHandlerIF::SEND_READ); + // thisSequence->addSlot(objects::SUS_2, length * 0.904, DeviceHandlerIF::GET_READ); + // /* Write setup */ + // thisSequence->addSlot(objects::SUS_2, length * 0.905, DeviceHandlerIF::PERFORM_OPERATION); + // thisSequence->addSlot(objects::SUS_2, length * 0.905, SusHandler::SEND_WRITE); + // thisSequence->addSlot(objects::SUS_2, length * 0.905, DeviceHandlerIF::GET_WRITE); + // thisSequence->addSlot(objects::SUS_2, length * 0.905, DeviceHandlerIF::SEND_READ); + // thisSequence->addSlot(objects::SUS_2, length * 0.905, DeviceHandlerIF::GET_READ); - /* Write setup */ -// thisSequence->addSlot(objects::SUS_3, length * 0.8, DeviceHandlerIF::PERFORM_OPERATION); -// thisSequence->addSlot(objects::SUS_3, length * 0.8, SusHandler::FIRST_WRITE); -// thisSequence->addSlot(objects::SUS_3, length * 0.8, DeviceHandlerIF::GET_WRITE); -// thisSequence->addSlot(objects::SUS_3, length * 0.8, DeviceHandlerIF::SEND_READ); -// thisSequence->addSlot(objects::SUS_3, length * 0.8, DeviceHandlerIF::GET_READ); -// /* Write setup */ -// thisSequence->addSlot(objects::SUS_3, length * 0.91, DeviceHandlerIF::PERFORM_OPERATION); -// thisSequence->addSlot(objects::SUS_3, length * 0.91, SusHandler::SEND_WRITE); -// thisSequence->addSlot(objects::SUS_3, length * 0.91, DeviceHandlerIF::GET_WRITE); -// thisSequence->addSlot(objects::SUS_3, length * 0.91, DeviceHandlerIF::SEND_READ); -// thisSequence->addSlot(objects::SUS_3, length * 0.91, DeviceHandlerIF::GET_READ); -// /* Write setup */ -// thisSequence->addSlot(objects::SUS_3, length * 0.93, DeviceHandlerIF::PERFORM_OPERATION); -// thisSequence->addSlot(objects::SUS_3, length * 0.93, SusHandler::SEND_WRITE); -// thisSequence->addSlot(objects::SUS_3, length * 0.93, DeviceHandlerIF::GET_WRITE); -// thisSequence->addSlot(objects::SUS_3, length * 0.93, DeviceHandlerIF::SEND_READ); -// thisSequence->addSlot(objects::SUS_3, length * 0.93, DeviceHandlerIF::GET_READ); -// -// /* Write setup */ -// thisSequence->addSlot(objects::SUS_4, length * 0.909, DeviceHandlerIF::PERFORM_OPERATION); -// thisSequence->addSlot(objects::SUS_4, length * 0.909, SusHandler::FIRST_WRITE); -// thisSequence->addSlot(objects::SUS_4, length * 0.909, DeviceHandlerIF::GET_WRITE); -// thisSequence->addSlot(objects::SUS_4, length * 0.909, DeviceHandlerIF::SEND_READ); -// thisSequence->addSlot(objects::SUS_4, length * 0.909, DeviceHandlerIF::GET_READ); -// /* Write setup */ -// thisSequence->addSlot(objects::SUS_4, length * 0.91, DeviceHandlerIF::PERFORM_OPERATION); -// thisSequence->addSlot(objects::SUS_4, length * 0.91, SusHandler::FIRST_WRITE); -// thisSequence->addSlot(objects::SUS_4, length * 0.91, DeviceHandlerIF::GET_WRITE); -// thisSequence->addSlot(objects::SUS_4, length * 0.91, DeviceHandlerIF::SEND_READ); -// thisSequence->addSlot(objects::SUS_4, length * 0.91, DeviceHandlerIF::GET_READ); -// /* Write setup */ -// thisSequence->addSlot(objects::SUS_4, length * 0.911, DeviceHandlerIF::PERFORM_OPERATION); -// thisSequence->addSlot(objects::SUS_4, length * 0.911, SusHandler::FIRST_WRITE); -// thisSequence->addSlot(objects::SUS_4, length * 0.911, DeviceHandlerIF::GET_WRITE); -// thisSequence->addSlot(objects::SUS_4, length * 0.911, DeviceHandlerIF::SEND_READ); -// thisSequence->addSlot(objects::SUS_4, length * 0.911, DeviceHandlerIF::GET_READ); -// -// /* Write setup */ -// thisSequence->addSlot(objects::SUS_5, length * 0.912, DeviceHandlerIF::PERFORM_OPERATION); -// thisSequence->addSlot(objects::SUS_5, length * 0.912, SusHandler::FIRST_WRITE); -// thisSequence->addSlot(objects::SUS_5, length * 0.912, DeviceHandlerIF::GET_WRITE); -// thisSequence->addSlot(objects::SUS_5, length * 0.912, DeviceHandlerIF::SEND_READ); -// thisSequence->addSlot(objects::SUS_5, length * 0.912, DeviceHandlerIF::GET_READ); -// /* Write setup */ -// thisSequence->addSlot(objects::SUS_5, length * 0.913, DeviceHandlerIF::PERFORM_OPERATION); -// thisSequence->addSlot(objects::SUS_5, length * 0.913, SusHandler::FIRST_WRITE); -// thisSequence->addSlot(objects::SUS_5, length * 0.913, DeviceHandlerIF::GET_WRITE); -// thisSequence->addSlot(objects::SUS_5, length * 0.913, DeviceHandlerIF::SEND_READ); -// thisSequence->addSlot(objects::SUS_5, length * 0.913, DeviceHandlerIF::GET_READ); -// /* Write setup */ -// thisSequence->addSlot(objects::SUS_5, length * 0.914, DeviceHandlerIF::PERFORM_OPERATION); -// thisSequence->addSlot(objects::SUS_5, length * 0.914, SusHandler::FIRST_WRITE); -// thisSequence->addSlot(objects::SUS_5, length * 0.914, DeviceHandlerIF::GET_WRITE); -// thisSequence->addSlot(objects::SUS_5, length * 0.914, DeviceHandlerIF::SEND_READ); -// thisSequence->addSlot(objects::SUS_5, length * 0.914, DeviceHandlerIF::GET_READ); -// -// /* Write setup */ -// thisSequence->addSlot(objects::SUS_6, length * 0.915, DeviceHandlerIF::PERFORM_OPERATION); -// thisSequence->addSlot(objects::SUS_6, length * 0.915, SusHandler::FIRST_WRITE); -// thisSequence->addSlot(objects::SUS_6, length * 0.915, DeviceHandlerIF::GET_WRITE); -// thisSequence->addSlot(objects::SUS_6, length * 0.915, DeviceHandlerIF::SEND_READ); -// thisSequence->addSlot(objects::SUS_6, length * 0.915, DeviceHandlerIF::GET_READ); -// /* Start ADC conversions */ -// thisSequence->addSlot(objects::SUS_6, length * 0.916, DeviceHandlerIF::PERFORM_OPERATION); -// thisSequence->addSlot(objects::SUS_6, length * 0.916, DeviceHandlerIF::SEND_WRITE); -// thisSequence->addSlot(objects::SUS_6, length * 0.916, DeviceHandlerIF::GET_WRITE); -// thisSequence->addSlot(objects::SUS_6, length * 0.916, DeviceHandlerIF::SEND_READ); -// thisSequence->addSlot(objects::SUS_6, length * 0.916, DeviceHandlerIF::GET_READ); -// /* Read ADC conversions from inernal FIFO */ -// thisSequence->addSlot(objects::SUS_6, length * 0.917, DeviceHandlerIF::PERFORM_OPERATION); -// thisSequence->addSlot(objects::SUS_6, length * 0.917, DeviceHandlerIF::SEND_WRITE); -// thisSequence->addSlot(objects::SUS_6, length * 0.917, DeviceHandlerIF::GET_WRITE); -// thisSequence->addSlot(objects::SUS_6, length * 0.917, DeviceHandlerIF::SEND_READ); -// thisSequence->addSlot(objects::SUS_6, length * 0.917, DeviceHandlerIF::GET_READ); -// -// /* Write setup */ -// thisSequence->addSlot(objects::SUS_7, length * 0.918, DeviceHandlerIF::PERFORM_OPERATION); -// thisSequence->addSlot(objects::SUS_7, length * 0.918, SusHandler::FIRST_WRITE); -// thisSequence->addSlot(objects::SUS_7, length * 0.918, DeviceHandlerIF::GET_WRITE); -// thisSequence->addSlot(objects::SUS_7, length * 0.918, DeviceHandlerIF::SEND_READ); -// thisSequence->addSlot(objects::SUS_7, length * 0.918, DeviceHandlerIF::GET_READ); -// /* Start ADC conversions */ -// thisSequence->addSlot(objects::SUS_7, length * 0.919, DeviceHandlerIF::PERFORM_OPERATION); -// thisSequence->addSlot(objects::SUS_7, length * 0.919, DeviceHandlerIF::SEND_WRITE); -// thisSequence->addSlot(objects::SUS_7, length * 0.919, DeviceHandlerIF::GET_WRITE); -// thisSequence->addSlot(objects::SUS_7, length * 0.919, DeviceHandlerIF::SEND_READ); -// thisSequence->addSlot(objects::SUS_7, length * 0.919, DeviceHandlerIF::GET_READ); -// /* Read ADC conversions from inernal FIFO */ -// thisSequence->addSlot(objects::SUS_7, length * 0.92, DeviceHandlerIF::PERFORM_OPERATION); -// thisSequence->addSlot(objects::SUS_7, length * 0.92, DeviceHandlerIF::SEND_WRITE); -// thisSequence->addSlot(objects::SUS_7, length * 0.92, DeviceHandlerIF::GET_WRITE); -// thisSequence->addSlot(objects::SUS_7, length * 0.92, DeviceHandlerIF::SEND_READ); -// thisSequence->addSlot(objects::SUS_7, length * 0.92, DeviceHandlerIF::GET_READ); -// -// /* Write setup */ -// thisSequence->addSlot(objects::SUS_8, length * 0.921, DeviceHandlerIF::PERFORM_OPERATION); -// thisSequence->addSlot(objects::SUS_8, length * 0.921, SusHandler::FIRST_WRITE); -// thisSequence->addSlot(objects::SUS_8, length * 0.921, DeviceHandlerIF::GET_WRITE); -// thisSequence->addSlot(objects::SUS_8, length * 0.921, DeviceHandlerIF::SEND_READ); -// thisSequence->addSlot(objects::SUS_8, length * 0.921, DeviceHandlerIF::GET_READ); -// /* Start ADC conversions */ -// thisSequence->addSlot(objects::SUS_8, length * 0.922, DeviceHandlerIF::PERFORM_OPERATION); -// thisSequence->addSlot(objects::SUS_8, length * 0.922, DeviceHandlerIF::SEND_WRITE); -// thisSequence->addSlot(objects::SUS_8, length * 0.922, DeviceHandlerIF::GET_WRITE); -// thisSequence->addSlot(objects::SUS_8, length * 0.922, DeviceHandlerIF::SEND_READ); -// thisSequence->addSlot(objects::SUS_8, length * 0.922, DeviceHandlerIF::GET_READ); -// /* Read ADC conversions from inernal FIFO */ -// thisSequence->addSlot(objects::SUS_8, length * 0.923, DeviceHandlerIF::PERFORM_OPERATION); -// thisSequence->addSlot(objects::SUS_8, length * 0.923, DeviceHandlerIF::SEND_WRITE); -// thisSequence->addSlot(objects::SUS_8, length * 0.923, DeviceHandlerIF::GET_WRITE); -// thisSequence->addSlot(objects::SUS_8, length * 0.923, DeviceHandlerIF::SEND_READ); -// thisSequence->addSlot(objects::SUS_8, length * 0.923, DeviceHandlerIF::GET_READ); -// -// /* Write setup */ -// thisSequence->addSlot(objects::SUS_9, length * 0.924, DeviceHandlerIF::PERFORM_OPERATION); -// thisSequence->addSlot(objects::SUS_9, length * 0.924, SusHandler::FIRST_WRITE); -// thisSequence->addSlot(objects::SUS_9, length * 0.924, DeviceHandlerIF::GET_WRITE); -// thisSequence->addSlot(objects::SUS_9, length * 0.924, DeviceHandlerIF::SEND_READ); -// thisSequence->addSlot(objects::SUS_9, length * 0.924, DeviceHandlerIF::GET_READ); -// /* Start ADC conversions */ -// thisSequence->addSlot(objects::SUS_9, length * 0.925, DeviceHandlerIF::PERFORM_OPERATION); -// thisSequence->addSlot(objects::SUS_9, length * 0.925, DeviceHandlerIF::SEND_WRITE); -// thisSequence->addSlot(objects::SUS_9, length * 0.925, DeviceHandlerIF::GET_WRITE); -// thisSequence->addSlot(objects::SUS_9, length * 0.925, DeviceHandlerIF::SEND_READ); -// thisSequence->addSlot(objects::SUS_9, length * 0.925, DeviceHandlerIF::GET_READ); -// /* Read ADC conversions */ -// thisSequence->addSlot(objects::SUS_9, length * 0.926, DeviceHandlerIF::PERFORM_OPERATION); -// thisSequence->addSlot(objects::SUS_9, length * 0.926, DeviceHandlerIF::SEND_WRITE); -// thisSequence->addSlot(objects::SUS_9, length * 0.926, DeviceHandlerIF::GET_WRITE); -// thisSequence->addSlot(objects::SUS_9, length * 0.926, DeviceHandlerIF::SEND_READ); -// thisSequence->addSlot(objects::SUS_9, length * 0.926, DeviceHandlerIF::GET_READ); -// -// /* Write setup */ -// thisSequence->addSlot(objects::SUS_10, length * 0.927, DeviceHandlerIF::PERFORM_OPERATION); -// thisSequence->addSlot(objects::SUS_10, length * 0.927, SusHandler::FIRST_WRITE); -// thisSequence->addSlot(objects::SUS_10, length * 0.927, DeviceHandlerIF::GET_WRITE); -// thisSequence->addSlot(objects::SUS_10, length * 0.927, DeviceHandlerIF::SEND_READ); -// thisSequence->addSlot(objects::SUS_10, length * 0.927, DeviceHandlerIF::GET_READ); -// /* Start ADC conversions */ -// thisSequence->addSlot(objects::SUS_10, length * 0.928, DeviceHandlerIF::PERFORM_OPERATION); -// thisSequence->addSlot(objects::SUS_10, length * 0.928, DeviceHandlerIF::SEND_WRITE); -// thisSequence->addSlot(objects::SUS_10, length * 0.928, DeviceHandlerIF::GET_WRITE); -// thisSequence->addSlot(objects::SUS_10, length * 0.928, DeviceHandlerIF::SEND_READ); -// thisSequence->addSlot(objects::SUS_10, length * 0.928, DeviceHandlerIF::GET_READ); -// /* Read ADC conversions */ -// thisSequence->addSlot(objects::SUS_10, length * 0.929, DeviceHandlerIF::PERFORM_OPERATION); -// thisSequence->addSlot(objects::SUS_10, length * 0.929, DeviceHandlerIF::SEND_WRITE); -// thisSequence->addSlot(objects::SUS_10, length * 0.929, DeviceHandlerIF::GET_WRITE); -// thisSequence->addSlot(objects::SUS_10, length * 0.929, DeviceHandlerIF::SEND_READ); -// thisSequence->addSlot(objects::SUS_10, length * 0.929, DeviceHandlerIF::GET_READ); -// -// /* Write setup */ -// thisSequence->addSlot(objects::SUS_11, length * 0.93, DeviceHandlerIF::PERFORM_OPERATION); -// thisSequence->addSlot(objects::SUS_11, length * 0.93, SusHandler::FIRST_WRITE); -// thisSequence->addSlot(objects::SUS_11, length * 0.93, DeviceHandlerIF::GET_WRITE); -// thisSequence->addSlot(objects::SUS_11, length * 0.93, DeviceHandlerIF::SEND_READ); -// thisSequence->addSlot(objects::SUS_11, length * 0.93, DeviceHandlerIF::GET_READ); -// /* Start ADC conversions */ -// thisSequence->addSlot(objects::SUS_11, length * 0.931, DeviceHandlerIF::PERFORM_OPERATION); -// thisSequence->addSlot(objects::SUS_11, length * 0.931, DeviceHandlerIF::SEND_WRITE); -// thisSequence->addSlot(objects::SUS_11, length * 0.931, DeviceHandlerIF::GET_WRITE); -// thisSequence->addSlot(objects::SUS_11, length * 0.931, DeviceHandlerIF::SEND_READ); -// thisSequence->addSlot(objects::SUS_11, length * 0.931, DeviceHandlerIF::GET_READ); -// /* Read ADC conversions */ -// thisSequence->addSlot(objects::SUS_11, length * 0.932, DeviceHandlerIF::PERFORM_OPERATION); -// thisSequence->addSlot(objects::SUS_11, length * 0.932, DeviceHandlerIF::SEND_WRITE); -// thisSequence->addSlot(objects::SUS_11, length * 0.932, DeviceHandlerIF::GET_WRITE); -// thisSequence->addSlot(objects::SUS_11, length * 0.932, DeviceHandlerIF::SEND_READ); -// thisSequence->addSlot(objects::SUS_11, length * 0.932, DeviceHandlerIF::GET_READ); -// -// /* Write setup */ -// thisSequence->addSlot(objects::SUS_12, length * 0.933, DeviceHandlerIF::PERFORM_OPERATION); -// thisSequence->addSlot(objects::SUS_12, length * 0.933, SusHandler::FIRST_WRITE); -// thisSequence->addSlot(objects::SUS_12, length * 0.933, DeviceHandlerIF::GET_WRITE); -// thisSequence->addSlot(objects::SUS_12, length * 0.933, DeviceHandlerIF::SEND_READ); -// thisSequence->addSlot(objects::SUS_12, length * 0.933, DeviceHandlerIF::GET_READ); -// /* Start ADC conversions */ -// thisSequence->addSlot(objects::SUS_12, length * 0.934, DeviceHandlerIF::PERFORM_OPERATION); -// thisSequence->addSlot(objects::SUS_12, length * 0.934, DeviceHandlerIF::SEND_WRITE); -// thisSequence->addSlot(objects::SUS_12, length * 0.934, DeviceHandlerIF::GET_WRITE); -// thisSequence->addSlot(objects::SUS_12, length * 0.934, DeviceHandlerIF::SEND_READ); -// thisSequence->addSlot(objects::SUS_12, length * 0.934, DeviceHandlerIF::GET_READ); -// /* Read ADC conversions */ -// thisSequence->addSlot(objects::SUS_12, length * 0.935, DeviceHandlerIF::PERFORM_OPERATION); -// thisSequence->addSlot(objects::SUS_12, length * 0.935, DeviceHandlerIF::SEND_WRITE); -// thisSequence->addSlot(objects::SUS_12, length * 0.935, DeviceHandlerIF::GET_WRITE); -// thisSequence->addSlot(objects::SUS_12, length * 0.935, DeviceHandlerIF::SEND_READ); -// thisSequence->addSlot(objects::SUS_12, length * 0.935, DeviceHandlerIF::GET_READ); -// -// /* Write setup */ -// thisSequence->addSlot(objects::SUS_13, length * 0.936, DeviceHandlerIF::PERFORM_OPERATION); -// thisSequence->addSlot(objects::SUS_13, length * 0.936, SusHandler::FIRST_WRITE); -// thisSequence->addSlot(objects::SUS_13, length * 0.936, DeviceHandlerIF::GET_WRITE); -// thisSequence->addSlot(objects::SUS_13, length * 0.936, DeviceHandlerIF::SEND_READ); -// thisSequence->addSlot(objects::SUS_13, length * 0.936, DeviceHandlerIF::GET_READ); -// /* Start ADC conversions */ -// thisSequence->addSlot(objects::SUS_13, length * 0.937, DeviceHandlerIF::PERFORM_OPERATION); -// thisSequence->addSlot(objects::SUS_13, length * 0.937, DeviceHandlerIF::SEND_WRITE); -// thisSequence->addSlot(objects::SUS_13, length * 0.937, DeviceHandlerIF::GET_WRITE); -// thisSequence->addSlot(objects::SUS_13, length * 0.937, DeviceHandlerIF::SEND_READ); -// thisSequence->addSlot(objects::SUS_13, length * 0.937, DeviceHandlerIF::GET_READ); -// /* Read ADC conversions */ -// thisSequence->addSlot(objects::SUS_13, length * 0.938, DeviceHandlerIF::PERFORM_OPERATION); -// thisSequence->addSlot(objects::SUS_13, length * 0.938, DeviceHandlerIF::SEND_WRITE); -// thisSequence->addSlot(objects::SUS_13, length * 0.938, DeviceHandlerIF::GET_WRITE); -// thisSequence->addSlot(objects::SUS_13, length * 0.938, DeviceHandlerIF::SEND_READ); -// thisSequence->addSlot(objects::SUS_13, length * 0.938, DeviceHandlerIF::GET_READ); + /* Write setup */ + // thisSequence->addSlot(objects::SUS_3, length * 0.8, DeviceHandlerIF::PERFORM_OPERATION); + // thisSequence->addSlot(objects::SUS_3, length * 0.8, SusHandler::FIRST_WRITE); + // thisSequence->addSlot(objects::SUS_3, length * 0.8, DeviceHandlerIF::GET_WRITE); + // thisSequence->addSlot(objects::SUS_3, length * 0.8, DeviceHandlerIF::SEND_READ); + // thisSequence->addSlot(objects::SUS_3, length * 0.8, DeviceHandlerIF::GET_READ); + // /* Write setup */ + // thisSequence->addSlot(objects::SUS_3, length * 0.91, DeviceHandlerIF::PERFORM_OPERATION); + // thisSequence->addSlot(objects::SUS_3, length * 0.91, SusHandler::SEND_WRITE); + // thisSequence->addSlot(objects::SUS_3, length * 0.91, DeviceHandlerIF::GET_WRITE); + // thisSequence->addSlot(objects::SUS_3, length * 0.91, DeviceHandlerIF::SEND_READ); + // thisSequence->addSlot(objects::SUS_3, length * 0.91, DeviceHandlerIF::GET_READ); + // /* Write setup */ + // thisSequence->addSlot(objects::SUS_3, length * 0.93, DeviceHandlerIF::PERFORM_OPERATION); + // thisSequence->addSlot(objects::SUS_3, length * 0.93, SusHandler::SEND_WRITE); + // thisSequence->addSlot(objects::SUS_3, length * 0.93, DeviceHandlerIF::GET_WRITE); + // thisSequence->addSlot(objects::SUS_3, length * 0.93, DeviceHandlerIF::SEND_READ); + // thisSequence->addSlot(objects::SUS_3, length * 0.93, DeviceHandlerIF::GET_READ); + // + // /* Write setup */ + // thisSequence->addSlot(objects::SUS_4, length * 0.909, DeviceHandlerIF::PERFORM_OPERATION); + // thisSequence->addSlot(objects::SUS_4, length * 0.909, SusHandler::FIRST_WRITE); + // thisSequence->addSlot(objects::SUS_4, length * 0.909, DeviceHandlerIF::GET_WRITE); + // thisSequence->addSlot(objects::SUS_4, length * 0.909, DeviceHandlerIF::SEND_READ); + // thisSequence->addSlot(objects::SUS_4, length * 0.909, DeviceHandlerIF::GET_READ); + // /* Write setup */ + // thisSequence->addSlot(objects::SUS_4, length * 0.91, DeviceHandlerIF::PERFORM_OPERATION); + // thisSequence->addSlot(objects::SUS_4, length * 0.91, SusHandler::FIRST_WRITE); + // thisSequence->addSlot(objects::SUS_4, length * 0.91, DeviceHandlerIF::GET_WRITE); + // thisSequence->addSlot(objects::SUS_4, length * 0.91, DeviceHandlerIF::SEND_READ); + // thisSequence->addSlot(objects::SUS_4, length * 0.91, DeviceHandlerIF::GET_READ); + // /* Write setup */ + // thisSequence->addSlot(objects::SUS_4, length * 0.911, DeviceHandlerIF::PERFORM_OPERATION); + // thisSequence->addSlot(objects::SUS_4, length * 0.911, SusHandler::FIRST_WRITE); + // thisSequence->addSlot(objects::SUS_4, length * 0.911, DeviceHandlerIF::GET_WRITE); + // thisSequence->addSlot(objects::SUS_4, length * 0.911, DeviceHandlerIF::SEND_READ); + // thisSequence->addSlot(objects::SUS_4, length * 0.911, DeviceHandlerIF::GET_READ); + // + // /* Write setup */ + // thisSequence->addSlot(objects::SUS_5, length * 0.912, DeviceHandlerIF::PERFORM_OPERATION); + // thisSequence->addSlot(objects::SUS_5, length * 0.912, SusHandler::FIRST_WRITE); + // thisSequence->addSlot(objects::SUS_5, length * 0.912, DeviceHandlerIF::GET_WRITE); + // thisSequence->addSlot(objects::SUS_5, length * 0.912, DeviceHandlerIF::SEND_READ); + // thisSequence->addSlot(objects::SUS_5, length * 0.912, DeviceHandlerIF::GET_READ); + // /* Write setup */ + // thisSequence->addSlot(objects::SUS_5, length * 0.913, DeviceHandlerIF::PERFORM_OPERATION); + // thisSequence->addSlot(objects::SUS_5, length * 0.913, SusHandler::FIRST_WRITE); + // thisSequence->addSlot(objects::SUS_5, length * 0.913, DeviceHandlerIF::GET_WRITE); + // thisSequence->addSlot(objects::SUS_5, length * 0.913, DeviceHandlerIF::SEND_READ); + // thisSequence->addSlot(objects::SUS_5, length * 0.913, DeviceHandlerIF::GET_READ); + // /* Write setup */ + // thisSequence->addSlot(objects::SUS_5, length * 0.914, DeviceHandlerIF::PERFORM_OPERATION); + // thisSequence->addSlot(objects::SUS_5, length * 0.914, SusHandler::FIRST_WRITE); + // thisSequence->addSlot(objects::SUS_5, length * 0.914, DeviceHandlerIF::GET_WRITE); + // thisSequence->addSlot(objects::SUS_5, length * 0.914, DeviceHandlerIF::SEND_READ); + // thisSequence->addSlot(objects::SUS_5, length * 0.914, DeviceHandlerIF::GET_READ); + // + // /* Write setup */ + // thisSequence->addSlot(objects::SUS_6, length * 0.915, DeviceHandlerIF::PERFORM_OPERATION); + // thisSequence->addSlot(objects::SUS_6, length * 0.915, SusHandler::FIRST_WRITE); + // thisSequence->addSlot(objects::SUS_6, length * 0.915, DeviceHandlerIF::GET_WRITE); + // thisSequence->addSlot(objects::SUS_6, length * 0.915, DeviceHandlerIF::SEND_READ); + // thisSequence->addSlot(objects::SUS_6, length * 0.915, DeviceHandlerIF::GET_READ); + // /* Start ADC conversions */ + // thisSequence->addSlot(objects::SUS_6, length * 0.916, DeviceHandlerIF::PERFORM_OPERATION); + // thisSequence->addSlot(objects::SUS_6, length * 0.916, DeviceHandlerIF::SEND_WRITE); + // thisSequence->addSlot(objects::SUS_6, length * 0.916, DeviceHandlerIF::GET_WRITE); + // thisSequence->addSlot(objects::SUS_6, length * 0.916, DeviceHandlerIF::SEND_READ); + // thisSequence->addSlot(objects::SUS_6, length * 0.916, DeviceHandlerIF::GET_READ); + // /* Read ADC conversions from inernal FIFO */ + // thisSequence->addSlot(objects::SUS_6, length * 0.917, DeviceHandlerIF::PERFORM_OPERATION); + // thisSequence->addSlot(objects::SUS_6, length * 0.917, DeviceHandlerIF::SEND_WRITE); + // thisSequence->addSlot(objects::SUS_6, length * 0.917, DeviceHandlerIF::GET_WRITE); + // thisSequence->addSlot(objects::SUS_6, length * 0.917, DeviceHandlerIF::SEND_READ); + // thisSequence->addSlot(objects::SUS_6, length * 0.917, DeviceHandlerIF::GET_READ); + // + // /* Write setup */ + // thisSequence->addSlot(objects::SUS_7, length * 0.918, DeviceHandlerIF::PERFORM_OPERATION); + // thisSequence->addSlot(objects::SUS_7, length * 0.918, SusHandler::FIRST_WRITE); + // thisSequence->addSlot(objects::SUS_7, length * 0.918, DeviceHandlerIF::GET_WRITE); + // thisSequence->addSlot(objects::SUS_7, length * 0.918, DeviceHandlerIF::SEND_READ); + // thisSequence->addSlot(objects::SUS_7, length * 0.918, DeviceHandlerIF::GET_READ); + // /* Start ADC conversions */ + // thisSequence->addSlot(objects::SUS_7, length * 0.919, DeviceHandlerIF::PERFORM_OPERATION); + // thisSequence->addSlot(objects::SUS_7, length * 0.919, DeviceHandlerIF::SEND_WRITE); + // thisSequence->addSlot(objects::SUS_7, length * 0.919, DeviceHandlerIF::GET_WRITE); + // thisSequence->addSlot(objects::SUS_7, length * 0.919, DeviceHandlerIF::SEND_READ); + // thisSequence->addSlot(objects::SUS_7, length * 0.919, DeviceHandlerIF::GET_READ); + // /* Read ADC conversions from inernal FIFO */ + // thisSequence->addSlot(objects::SUS_7, length * 0.92, DeviceHandlerIF::PERFORM_OPERATION); + // thisSequence->addSlot(objects::SUS_7, length * 0.92, DeviceHandlerIF::SEND_WRITE); + // thisSequence->addSlot(objects::SUS_7, length * 0.92, DeviceHandlerIF::GET_WRITE); + // thisSequence->addSlot(objects::SUS_7, length * 0.92, DeviceHandlerIF::SEND_READ); + // thisSequence->addSlot(objects::SUS_7, length * 0.92, DeviceHandlerIF::GET_READ); + // + // /* Write setup */ + // thisSequence->addSlot(objects::SUS_8, length * 0.921, DeviceHandlerIF::PERFORM_OPERATION); + // thisSequence->addSlot(objects::SUS_8, length * 0.921, SusHandler::FIRST_WRITE); + // thisSequence->addSlot(objects::SUS_8, length * 0.921, DeviceHandlerIF::GET_WRITE); + // thisSequence->addSlot(objects::SUS_8, length * 0.921, DeviceHandlerIF::SEND_READ); + // thisSequence->addSlot(objects::SUS_8, length * 0.921, DeviceHandlerIF::GET_READ); + // /* Start ADC conversions */ + // thisSequence->addSlot(objects::SUS_8, length * 0.922, DeviceHandlerIF::PERFORM_OPERATION); + // thisSequence->addSlot(objects::SUS_8, length * 0.922, DeviceHandlerIF::SEND_WRITE); + // thisSequence->addSlot(objects::SUS_8, length * 0.922, DeviceHandlerIF::GET_WRITE); + // thisSequence->addSlot(objects::SUS_8, length * 0.922, DeviceHandlerIF::SEND_READ); + // thisSequence->addSlot(objects::SUS_8, length * 0.922, DeviceHandlerIF::GET_READ); + // /* Read ADC conversions from inernal FIFO */ + // thisSequence->addSlot(objects::SUS_8, length * 0.923, DeviceHandlerIF::PERFORM_OPERATION); + // thisSequence->addSlot(objects::SUS_8, length * 0.923, DeviceHandlerIF::SEND_WRITE); + // thisSequence->addSlot(objects::SUS_8, length * 0.923, DeviceHandlerIF::GET_WRITE); + // thisSequence->addSlot(objects::SUS_8, length * 0.923, DeviceHandlerIF::SEND_READ); + // thisSequence->addSlot(objects::SUS_8, length * 0.923, DeviceHandlerIF::GET_READ); + // + // /* Write setup */ + // thisSequence->addSlot(objects::SUS_9, length * 0.924, DeviceHandlerIF::PERFORM_OPERATION); + // thisSequence->addSlot(objects::SUS_9, length * 0.924, SusHandler::FIRST_WRITE); + // thisSequence->addSlot(objects::SUS_9, length * 0.924, DeviceHandlerIF::GET_WRITE); + // thisSequence->addSlot(objects::SUS_9, length * 0.924, DeviceHandlerIF::SEND_READ); + // thisSequence->addSlot(objects::SUS_9, length * 0.924, DeviceHandlerIF::GET_READ); + // /* Start ADC conversions */ + // thisSequence->addSlot(objects::SUS_9, length * 0.925, DeviceHandlerIF::PERFORM_OPERATION); + // thisSequence->addSlot(objects::SUS_9, length * 0.925, DeviceHandlerIF::SEND_WRITE); + // thisSequence->addSlot(objects::SUS_9, length * 0.925, DeviceHandlerIF::GET_WRITE); + // thisSequence->addSlot(objects::SUS_9, length * 0.925, DeviceHandlerIF::SEND_READ); + // thisSequence->addSlot(objects::SUS_9, length * 0.925, DeviceHandlerIF::GET_READ); + // /* Read ADC conversions */ + // thisSequence->addSlot(objects::SUS_9, length * 0.926, DeviceHandlerIF::PERFORM_OPERATION); + // thisSequence->addSlot(objects::SUS_9, length * 0.926, DeviceHandlerIF::SEND_WRITE); + // thisSequence->addSlot(objects::SUS_9, length * 0.926, DeviceHandlerIF::GET_WRITE); + // thisSequence->addSlot(objects::SUS_9, length * 0.926, DeviceHandlerIF::SEND_READ); + // thisSequence->addSlot(objects::SUS_9, length * 0.926, DeviceHandlerIF::GET_READ); + // + // /* Write setup */ + // thisSequence->addSlot(objects::SUS_10, length * 0.927, DeviceHandlerIF::PERFORM_OPERATION); + // thisSequence->addSlot(objects::SUS_10, length * 0.927, SusHandler::FIRST_WRITE); + // thisSequence->addSlot(objects::SUS_10, length * 0.927, DeviceHandlerIF::GET_WRITE); + // thisSequence->addSlot(objects::SUS_10, length * 0.927, DeviceHandlerIF::SEND_READ); + // thisSequence->addSlot(objects::SUS_10, length * 0.927, DeviceHandlerIF::GET_READ); + // /* Start ADC conversions */ + // thisSequence->addSlot(objects::SUS_10, length * 0.928, DeviceHandlerIF::PERFORM_OPERATION); + // thisSequence->addSlot(objects::SUS_10, length * 0.928, DeviceHandlerIF::SEND_WRITE); + // thisSequence->addSlot(objects::SUS_10, length * 0.928, DeviceHandlerIF::GET_WRITE); + // thisSequence->addSlot(objects::SUS_10, length * 0.928, DeviceHandlerIF::SEND_READ); + // thisSequence->addSlot(objects::SUS_10, length * 0.928, DeviceHandlerIF::GET_READ); + // /* Read ADC conversions */ + // thisSequence->addSlot(objects::SUS_10, length * 0.929, DeviceHandlerIF::PERFORM_OPERATION); + // thisSequence->addSlot(objects::SUS_10, length * 0.929, DeviceHandlerIF::SEND_WRITE); + // thisSequence->addSlot(objects::SUS_10, length * 0.929, DeviceHandlerIF::GET_WRITE); + // thisSequence->addSlot(objects::SUS_10, length * 0.929, DeviceHandlerIF::SEND_READ); + // thisSequence->addSlot(objects::SUS_10, length * 0.929, DeviceHandlerIF::GET_READ); + // + // /* Write setup */ + // thisSequence->addSlot(objects::SUS_11, length * 0.93, DeviceHandlerIF::PERFORM_OPERATION); + // thisSequence->addSlot(objects::SUS_11, length * 0.93, SusHandler::FIRST_WRITE); + // thisSequence->addSlot(objects::SUS_11, length * 0.93, DeviceHandlerIF::GET_WRITE); + // thisSequence->addSlot(objects::SUS_11, length * 0.93, DeviceHandlerIF::SEND_READ); + // thisSequence->addSlot(objects::SUS_11, length * 0.93, DeviceHandlerIF::GET_READ); + // /* Start ADC conversions */ + // thisSequence->addSlot(objects::SUS_11, length * 0.931, DeviceHandlerIF::PERFORM_OPERATION); + // thisSequence->addSlot(objects::SUS_11, length * 0.931, DeviceHandlerIF::SEND_WRITE); + // thisSequence->addSlot(objects::SUS_11, length * 0.931, DeviceHandlerIF::GET_WRITE); + // thisSequence->addSlot(objects::SUS_11, length * 0.931, DeviceHandlerIF::SEND_READ); + // thisSequence->addSlot(objects::SUS_11, length * 0.931, DeviceHandlerIF::GET_READ); + // /* Read ADC conversions */ + // thisSequence->addSlot(objects::SUS_11, length * 0.932, DeviceHandlerIF::PERFORM_OPERATION); + // thisSequence->addSlot(objects::SUS_11, length * 0.932, DeviceHandlerIF::SEND_WRITE); + // thisSequence->addSlot(objects::SUS_11, length * 0.932, DeviceHandlerIF::GET_WRITE); + // thisSequence->addSlot(objects::SUS_11, length * 0.932, DeviceHandlerIF::SEND_READ); + // thisSequence->addSlot(objects::SUS_11, length * 0.932, DeviceHandlerIF::GET_READ); + // + // /* Write setup */ + // thisSequence->addSlot(objects::SUS_12, length * 0.933, DeviceHandlerIF::PERFORM_OPERATION); + // thisSequence->addSlot(objects::SUS_12, length * 0.933, SusHandler::FIRST_WRITE); + // thisSequence->addSlot(objects::SUS_12, length * 0.933, DeviceHandlerIF::GET_WRITE); + // thisSequence->addSlot(objects::SUS_12, length * 0.933, DeviceHandlerIF::SEND_READ); + // thisSequence->addSlot(objects::SUS_12, length * 0.933, DeviceHandlerIF::GET_READ); + // /* Start ADC conversions */ + // thisSequence->addSlot(objects::SUS_12, length * 0.934, DeviceHandlerIF::PERFORM_OPERATION); + // thisSequence->addSlot(objects::SUS_12, length * 0.934, DeviceHandlerIF::SEND_WRITE); + // thisSequence->addSlot(objects::SUS_12, length * 0.934, DeviceHandlerIF::GET_WRITE); + // thisSequence->addSlot(objects::SUS_12, length * 0.934, DeviceHandlerIF::SEND_READ); + // thisSequence->addSlot(objects::SUS_12, length * 0.934, DeviceHandlerIF::GET_READ); + // /* Read ADC conversions */ + // thisSequence->addSlot(objects::SUS_12, length * 0.935, DeviceHandlerIF::PERFORM_OPERATION); + // thisSequence->addSlot(objects::SUS_12, length * 0.935, DeviceHandlerIF::SEND_WRITE); + // thisSequence->addSlot(objects::SUS_12, length * 0.935, DeviceHandlerIF::GET_WRITE); + // thisSequence->addSlot(objects::SUS_12, length * 0.935, DeviceHandlerIF::SEND_READ); + // thisSequence->addSlot(objects::SUS_12, length * 0.935, DeviceHandlerIF::GET_READ); + // + // /* Write setup */ + // thisSequence->addSlot(objects::SUS_13, length * 0.936, DeviceHandlerIF::PERFORM_OPERATION); + // thisSequence->addSlot(objects::SUS_13, length * 0.936, SusHandler::FIRST_WRITE); + // thisSequence->addSlot(objects::SUS_13, length * 0.936, DeviceHandlerIF::GET_WRITE); + // thisSequence->addSlot(objects::SUS_13, length * 0.936, DeviceHandlerIF::SEND_READ); + // thisSequence->addSlot(objects::SUS_13, length * 0.936, DeviceHandlerIF::GET_READ); + // /* Start ADC conversions */ + // thisSequence->addSlot(objects::SUS_13, length * 0.937, DeviceHandlerIF::PERFORM_OPERATION); + // thisSequence->addSlot(objects::SUS_13, length * 0.937, DeviceHandlerIF::SEND_WRITE); + // thisSequence->addSlot(objects::SUS_13, length * 0.937, DeviceHandlerIF::GET_WRITE); + // thisSequence->addSlot(objects::SUS_13, length * 0.937, DeviceHandlerIF::SEND_READ); + // thisSequence->addSlot(objects::SUS_13, length * 0.937, DeviceHandlerIF::GET_READ); + // /* Read ADC conversions */ + // thisSequence->addSlot(objects::SUS_13, length * 0.938, DeviceHandlerIF::PERFORM_OPERATION); + // thisSequence->addSlot(objects::SUS_13, length * 0.938, DeviceHandlerIF::SEND_WRITE); + // thisSequence->addSlot(objects::SUS_13, length * 0.938, DeviceHandlerIF::GET_WRITE); + // thisSequence->addSlot(objects::SUS_13, length * 0.938, DeviceHandlerIF::SEND_READ); + // thisSequence->addSlot(objects::SUS_13, length * 0.938, DeviceHandlerIF::GET_READ); - if (thisSequence->checkSequence() == HasReturnvaluesIF::RETURN_OK) { - return HasReturnvaluesIF::RETURN_OK; + if (thisSequence->checkSequence() != HasReturnvaluesIF::RETURN_OK) { + sif::error << "SPI PST initialization failed" << std::endl; + return HasReturnvaluesIF::RETURN_FAILED; } - - sif::error << "PollingSequence::initialize has errors!" << std::endl; - return HasReturnvaluesIF::RETURN_FAILED; + return HasReturnvaluesIF::RETURN_OK; } -ReturnValue_t pst::gomspacePstInit(FixedTimeslotTaskIF *thisSequence){ +ReturnValue_t pst::pstI2c(FixedTimeslotTaskIF *thisSequence) { + // Length of a communication cycle + uint32_t length = thisSequence->getPeriodMs(); + thisSequence->addSlot(objects::IMTQ_HANDLER, length * 0, DeviceHandlerIF::PERFORM_OPERATION); + thisSequence->addSlot(objects::IMTQ_HANDLER, length * 0.2, DeviceHandlerIF::SEND_WRITE); + thisSequence->addSlot(objects::IMTQ_HANDLER, length * 0.4, DeviceHandlerIF::GET_WRITE); + thisSequence->addSlot(objects::IMTQ_HANDLER, length * 0.6, DeviceHandlerIF::SEND_READ); + thisSequence->addSlot(objects::IMTQ_HANDLER, length * 0.8, DeviceHandlerIF::GET_READ); + if (thisSequence->checkSequence() != HasReturnvaluesIF::RETURN_OK) { + sif::error << "I2C PST initialization failed" << std::endl; + return HasReturnvaluesIF::RETURN_FAILED; + } + return HasReturnvaluesIF::RETURN_OK; +} + +ReturnValue_t pst::pstUart(FixedTimeslotTaskIF *thisSequence) { + // Length of a communication cycle + uint32_t length = thisSequence->getPeriodMs(); + thisSequence->addSlot(objects::PLOC_HANDLER, length * 0, + DeviceHandlerIF::PERFORM_OPERATION); + thisSequence->addSlot(objects::SYRLINKS_HK_HANDLER, length * 0, + DeviceHandlerIF::PERFORM_OPERATION); + thisSequence->addSlot(objects::GPS0_HANDLER, length * 0, + DeviceHandlerIF::PERFORM_OPERATION); + thisSequence->addSlot(objects::GPS1_HANDLER, length * 0, + DeviceHandlerIF::PERFORM_OPERATION); + + thisSequence->addSlot(objects::PLOC_HANDLER, length * 0.2, + DeviceHandlerIF::SEND_WRITE); + thisSequence->addSlot(objects::SYRLINKS_HK_HANDLER, length * 0.2, + DeviceHandlerIF::SEND_WRITE); + thisSequence->addSlot(objects::GPS0_HANDLER, length * 0.2, + DeviceHandlerIF::SEND_WRITE); + thisSequence->addSlot(objects::GPS1_HANDLER, length * 0.2, + DeviceHandlerIF::SEND_WRITE); + + thisSequence->addSlot(objects::PLOC_HANDLER, length * 0.4, + DeviceHandlerIF::GET_WRITE); + thisSequence->addSlot(objects::SYRLINKS_HK_HANDLER, length * 0.4, + DeviceHandlerIF::GET_WRITE); + thisSequence->addSlot(objects::GPS0_HANDLER, length * 0.4, + DeviceHandlerIF::GET_WRITE); + thisSequence->addSlot(objects::GPS1_HANDLER, length * 0.4, + DeviceHandlerIF::GET_WRITE); + + thisSequence->addSlot(objects::PLOC_HANDLER, length * 0.6, + DeviceHandlerIF::SEND_READ); + thisSequence->addSlot(objects::SYRLINKS_HK_HANDLER, length * 0.6, + DeviceHandlerIF::SEND_READ); + thisSequence->addSlot(objects::GPS0_HANDLER, length * 0.6, + DeviceHandlerIF::SEND_READ); + thisSequence->addSlot(objects::GPS1_HANDLER, length * 0.6, + DeviceHandlerIF::SEND_READ); + + thisSequence->addSlot(objects::PLOC_HANDLER, length * 0.8, + DeviceHandlerIF::GET_READ); + thisSequence->addSlot(objects::SYRLINKS_HK_HANDLER, length * 0.8, + DeviceHandlerIF::GET_READ); + thisSequence->addSlot(objects::GPS0_HANDLER, length * 0.8, + DeviceHandlerIF::GET_READ); + thisSequence->addSlot(objects::GPS1_HANDLER, length * 0.8, + DeviceHandlerIF::GET_READ); + + if (thisSequence->checkSequence() != HasReturnvaluesIF::RETURN_OK) { + sif::error << "UART PST initialization failed" << std::endl; + return HasReturnvaluesIF::RETURN_FAILED; + } + return HasReturnvaluesIF::RETURN_OK; +} + +ReturnValue_t pst::pstGompaceCan(FixedTimeslotTaskIF *thisSequence){ uint32_t length = thisSequence->getPeriodMs(); + // PCDU handlers receives two messages and both must be handled thisSequence->addSlot(objects::PCDU_HANDLER, length * 0, DeviceHandlerIF::PERFORM_OPERATION); thisSequence->addSlot(objects::PCDU_HANDLER, length * 0, DeviceHandlerIF::PERFORM_OPERATION); @@ -472,13 +531,13 @@ ReturnValue_t pst::gomspacePstInit(FixedTimeslotTaskIF *thisSequence){ length * 0.8, DeviceHandlerIF::GET_READ); if (thisSequence->checkSequence() != HasReturnvaluesIF::RETURN_OK) { - sif::error << "Initialization of GomSpace PST failed" << std::endl; + sif::error << "GomSpace PST initialization failed" << std::endl; return HasReturnvaluesIF::RETURN_FAILED; } return HasReturnvaluesIF::RETURN_OK; } -ReturnValue_t pst::pollingSequenceTest(FixedTimeslotTaskIF* thisSequence) { +ReturnValue_t pst::pstTest(FixedTimeslotTaskIF* thisSequence) { /* Length of a communication cycle */ uint32_t length = thisSequence->getPeriodMs(); #if OBSW_ADD_ACS_BOARD == 1 @@ -561,12 +620,11 @@ ReturnValue_t pst::pollingSequenceTest(FixedTimeslotTaskIF* thisSequence) { thisSequence->addSlot(objects::GYRO_0_ADIS_HANDLER, length * 0.8, DeviceHandlerIF::GET_READ); #endif static_cast(length); - if (thisSequence->checkSequence() == HasReturnvaluesIF::RETURN_OK) { - return HasReturnvaluesIF::RETURN_OK; + if (thisSequence->checkSequence() != HasReturnvaluesIF::RETURN_OK) { + sif::error << "Test PST initialization failed" << std::endl; + return HasReturnvaluesIF::RETURN_FAILED; } - - sif::error << "PollingSequence::initialize has errors!" << std::endl; - return HasReturnvaluesIF::RETURN_FAILED; + return HasReturnvaluesIF::RETURN_OK; } ReturnValue_t pst::pollingSequenceTE0720(FixedTimeslotTaskIF *thisSequence) { diff --git a/linux/fsfwconfig/pollingsequence/pollingSequenceFactory.h b/linux/fsfwconfig/pollingsequence/pollingSequenceFactory.h index e05f96aa..32d35169 100644 --- a/linux/fsfwconfig/pollingsequence/pollingSequenceFactory.h +++ b/linux/fsfwconfig/pollingsequence/pollingSequenceFactory.h @@ -25,16 +25,29 @@ class FixedTimeslotTaskIF; namespace pst { /* 0.4 second period init*/ -ReturnValue_t pollingSequenceInitDefault(FixedTimeslotTaskIF *thisSequence); +ReturnValue_t pstGpio(FixedTimeslotTaskIF *thisSequence); /** - * @brief This function creates the PST for all gomspace devices. They are - * scheduled in a separate PST because the gomspace library uses - * blocking calls when requesting data from devices. + * @brief This function creates the PST for all gomspace devices. + * @details + * Scheduled in a separate PST because the gomspace library uses blocking calls when requesting + * data from devices. */ -ReturnValue_t gomspacePstInit(FixedTimeslotTaskIF *thisSequence); +ReturnValue_t pstGompaceCan(FixedTimeslotTaskIF *thisSequence); + +ReturnValue_t pstUart(FixedTimeslotTaskIF* thisSequence); + +ReturnValue_t pstSpi(FixedTimeslotTaskIF* thisSequence); + +ReturnValue_t pstI2c(FixedTimeslotTaskIF* thisSequence); + +/** + * Generic test PST + * @param thisSequence + * @return + */ +ReturnValue_t pstTest(FixedTimeslotTaskIF* thisSequence); -ReturnValue_t pollingSequenceTest(FixedTimeslotTaskIF* thisSequence); /** * @brief This polling sequence will be created when the software is compiled for the TE0720. diff --git a/mission/devices/GPSHandler.cpp b/mission/devices/GPSHandler.cpp index 86733794..be227f9c 100644 --- a/mission/devices/GPSHandler.cpp +++ b/mission/devices/GPSHandler.cpp @@ -49,10 +49,12 @@ ReturnValue_t GPSHandler::buildCommandFromCommand( ReturnValue_t GPSHandler::scanForReply(const uint8_t *start, size_t len, DeviceCommandId_t *foundId, size_t *foundLen) { // Pass data to GPS library - int result = lwgps_process(&gpsData, start, len); - if(result != 0) { - sif::warning << "GPSHandler::scanForReply: Issue processing GPS data with lwgps" - << std::endl; + if(len > 0) { + int result = lwgps_process(&gpsData, start, len); + if(result != 0) { + sif::warning << "GPSHandler::scanForReply: Issue processing GPS data with lwgps" + << std::endl; + } } return HasReturnvaluesIF::RETURN_OK; From 2331637350fdde889b170d2e674d7db4075c5231 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Thu, 24 Jun 2021 08:50:46 +0200 Subject: [PATCH 009/111] split up PSTs and add contd GPS handler --- bsp_linux_board/ObjectFactory.cpp | 16 +++++ bsp_linux_board/boardconfig/rpiConfig.h.in | 1 + fsfw_hal | 2 +- .../pollingSequenceFactory.cpp | 69 +++++++++++-------- .../pollingsequence/pollingSequenceFactory.h | 13 +++- mission/devices/GPSHandler.cpp | 16 ++++- 6 files changed, 84 insertions(+), 33 deletions(-) diff --git a/bsp_linux_board/ObjectFactory.cpp b/bsp_linux_board/ObjectFactory.cpp index d6dfd623..f4ae00bf 100644 --- a/bsp_linux_board/ObjectFactory.cpp +++ b/bsp_linux_board/ObjectFactory.cpp @@ -1,3 +1,6 @@ +#include +#include +#include #include "ObjectFactory.h" #include "objects/systemObjectList.h" @@ -68,6 +71,8 @@ void ObjectFactory::produce(void* args){ #if RPI_ADD_UART_TEST == 1 new UartTestClass(objects::UART_TEST); +#else + new UartComIF(objects::UART_COM_IF); #endif #if RPI_LOOPBACK_TEST_GPIO == 1 @@ -146,4 +151,15 @@ void ObjectFactory::produce(void* args){ auto adisGyroHandler = new GyroADIS16507Handler(objects::GYRO_0_ADIS_HANDLER, objects::SPI_COM_IF, spiCookie); adisGyroHandler->setStartUpImmediately(); #endif /* RPI_TEST_ADIS16507 == 1 */ + +#if RPI_TEST_GPS_HANDLER == 1 + UartCookie* uartCookie = new UartCookie(objects::GPS0_HANDLER, "/dev/serial0", + UartModes::CANONICAL, 9600, 1024); + uartCookie->setToFlushInput(true); + uartCookie->setReadCycles(6); + GPSHandler* gpsHandler = new GPSHandler(objects::GPS0_HANDLER, + objects::UART_COM_IF, uartCookie); + gpsHandler->setStartUpImmediately(); +#endif + } diff --git a/bsp_linux_board/boardconfig/rpiConfig.h.in b/bsp_linux_board/boardconfig/rpiConfig.h.in index 0094903c..19629465 100644 --- a/bsp_linux_board/boardconfig/rpiConfig.h.in +++ b/bsp_linux_board/boardconfig/rpiConfig.h.in @@ -7,6 +7,7 @@ #define RPI_LOOPBACK_TEST_GPIO 0 #define RPI_TEST_ADIS16507 0 +#define RPI_TEST_GPS_HANDLER 0 // Only one of those 2 should be enabled! #define RPI_ADD_SPI_TEST 0 diff --git a/fsfw_hal b/fsfw_hal index fce40ebf..2533af3b 160000 --- a/fsfw_hal +++ b/fsfw_hal @@ -1 +1 @@ -Subproject commit fce40ebf9a4a45bafedaee2fc87e5aa10e49fdcc +Subproject commit 2533af3b53804bc68436236370911e013a2b8f64 diff --git a/linux/fsfwconfig/pollingsequence/pollingSequenceFactory.cpp b/linux/fsfwconfig/pollingsequence/pollingSequenceFactory.cpp index 0add7a3b..3b64724a 100644 --- a/linux/fsfwconfig/pollingsequence/pollingSequenceFactory.cpp +++ b/linux/fsfwconfig/pollingsequence/pollingSequenceFactory.cpp @@ -19,11 +19,11 @@ ReturnValue_t pst::pstGpio(FixedTimeslotTaskIF *thisSequence) DeviceHandlerIF::PERFORM_OPERATION); // Radiation sensor -// 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); -// thisSequence->addSlot(objects::RAD_SENSOR, length * 0.6, DeviceHandlerIF::SEND_READ); -// thisSequence->addSlot(objects::RAD_SENSOR, length * 0.8, DeviceHandlerIF::GET_READ); + // 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); + // thisSequence->addSlot(objects::RAD_SENSOR, length * 0.6, DeviceHandlerIF::SEND_READ); + // thisSequence->addSlot(objects::RAD_SENSOR, length * 0.8, DeviceHandlerIF::GET_READ); // if (length != 3000) { // sif::warning << "pollingSequenceInitDefault: Frequency changed. Make sure timing critical " // << "SUS sensors still produce correct values" << std::endl; @@ -173,7 +173,7 @@ ReturnValue_t pst::pstSpi(FixedTimeslotTaskIF *thisSequence) { // thisSequence->addSlot(objects::SUS_1, length * 0.902, DeviceHandlerIF::SEND_READ); // thisSequence->addSlot(objects::SUS_1, length * 0.902, DeviceHandlerIF::GET_READ); - /* Write setup */ + /* Write setup */ // thisSequence->addSlot(objects::SUS_2, length * 0.903, DeviceHandlerIF::PERFORM_OPERATION); // thisSequence->addSlot(objects::SUS_2, length * 0.903, SusHandler::FIRST_WRITE); // thisSequence->addSlot(objects::SUS_2, length * 0.903, DeviceHandlerIF::GET_WRITE); @@ -192,7 +192,7 @@ ReturnValue_t pst::pstSpi(FixedTimeslotTaskIF *thisSequence) { // thisSequence->addSlot(objects::SUS_2, length * 0.905, DeviceHandlerIF::SEND_READ); // thisSequence->addSlot(objects::SUS_2, length * 0.905, DeviceHandlerIF::GET_READ); - /* Write setup */ + /* Write setup */ // thisSequence->addSlot(objects::SUS_3, length * 0.8, DeviceHandlerIF::PERFORM_OPERATION); // thisSequence->addSlot(objects::SUS_3, length * 0.8, SusHandler::FIRST_WRITE); // thisSequence->addSlot(objects::SUS_3, length * 0.8, DeviceHandlerIF::GET_WRITE); @@ -542,7 +542,7 @@ ReturnValue_t pst::pstTest(FixedTimeslotTaskIF* thisSequence) { uint32_t length = thisSequence->getPeriodMs(); #if OBSW_ADD_ACS_BOARD == 1 thisSequence->addSlot(objects::MGM_0_LIS3_HANDLER, length * 0, - DeviceHandlerIF::PERFORM_OPERATION); + 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, @@ -563,28 +563,28 @@ ReturnValue_t pst::pstTest(FixedTimeslotTaskIF* thisSequence) { 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::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_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_2_L3G_HANDLER, length * 0, @@ -619,6 +619,16 @@ ReturnValue_t pst::pstTest(FixedTimeslotTaskIF* thisSequence) { thisSequence->addSlot(objects::GYRO_0_ADIS_HANDLER, length * 0.6, DeviceHandlerIF::SEND_READ); thisSequence->addSlot(objects::GYRO_0_ADIS_HANDLER, length * 0.8, DeviceHandlerIF::GET_READ); #endif + +#if RPI_TEST_GPS_HANDLER == 1 + thisSequence->addSlot(objects::GPS0_HANDLER, length * 0, DeviceHandlerIF::PERFORM_OPERATION); + + thisSequence->addSlot(objects::GPS0_HANDLER, length * 0, DeviceHandlerIF::SEND_READ); + thisSequence->addSlot(objects::GPS0_HANDLER, length * 0, DeviceHandlerIF::GET_READ); + + thisSequence->addSlot(objects::GPS0_HANDLER, length * 0.5, DeviceHandlerIF::SEND_READ); + thisSequence->addSlot(objects::GPS0_HANDLER, length * 0.5, DeviceHandlerIF::GET_READ); +#endif static_cast(length); if (thisSequence->checkSequence() != HasReturnvaluesIF::RETURN_OK) { sif::error << "Test PST initialization failed" << std::endl; @@ -627,6 +637,7 @@ ReturnValue_t pst::pstTest(FixedTimeslotTaskIF* thisSequence) { return HasReturnvaluesIF::RETURN_OK; } +#if TE7020 == 1 ReturnValue_t pst::pollingSequenceTE0720(FixedTimeslotTaskIF *thisSequence) { uint32_t length = thisSequence->getPeriodMs(); @@ -675,4 +686,4 @@ ReturnValue_t pst::pollingSequenceTE0720(FixedTimeslotTaskIF *thisSequence) { } return HasReturnvaluesIF::RETURN_OK; } - +#endif /* TE7020 == 1 */ diff --git a/linux/fsfwconfig/pollingsequence/pollingSequenceFactory.h b/linux/fsfwconfig/pollingsequence/pollingSequenceFactory.h index 32d35169..a2b5edfb 100644 --- a/linux/fsfwconfig/pollingsequence/pollingSequenceFactory.h +++ b/linux/fsfwconfig/pollingsequence/pollingSequenceFactory.h @@ -1,7 +1,14 @@ #ifndef POLLINGSEQUENCEFACTORY_H_ #define POLLINGSEQUENCEFACTORY_H_ -#include +#include "OBSWConfig.h" +#if defined(RASPBERRY_PI) +#include "rpiConfig.h" +#elif defined(XIPHOS_Q7S) +#include "q7sConfig.h" +#endif + +#include "fsfw/returnvalues/HasReturnvaluesIF.h" class FixedTimeslotTaskIF; @@ -48,11 +55,13 @@ ReturnValue_t pstI2c(FixedTimeslotTaskIF* thisSequence); */ ReturnValue_t pstTest(FixedTimeslotTaskIF* thisSequence); - +#if TE7020 == 1 /** * @brief This polling sequence will be created when the software is compiled for the TE0720. */ ReturnValue_t pollingSequenceTE0720(FixedTimeslotTaskIF* thisSequence); +#endif + } diff --git a/mission/devices/GPSHandler.cpp b/mission/devices/GPSHandler.cpp index be227f9c..3fdb6ab1 100644 --- a/mission/devices/GPSHandler.cpp +++ b/mission/devices/GPSHandler.cpp @@ -50,11 +50,25 @@ ReturnValue_t GPSHandler::scanForReply(const uint8_t *start, size_t len, DeviceCommandId_t *foundId, size_t *foundLen) { // Pass data to GPS library if(len > 0) { + sif::info << "GPSHandler::scanForReply: Received " << len << " bytes" << std::endl; + if (internalState == InternalStates::WAIT_FIRST_MESSAGE) { + // TODO: Check whether data is valid by chcking whether NMEA start string is valid + commandExecuted = true; + } int result = lwgps_process(&gpsData, start, len); - if(result != 0) { + if(result != 1) { sif::warning << "GPSHandler::scanForReply: Issue processing GPS data with lwgps" << std::endl; } + else { + sif::info << "GPS Data" << std::endl; + // Print messages + printf("Valid status: %d\n", gpsData.is_valid); + printf("Latitude: %f degrees\n", gpsData.latitude); + printf("Longitude: %f degrees\n", gpsData.longitude); + printf("Altitude: %f meters\n", gpsData.altitude); + } + *foundLen = len; } return HasReturnvaluesIF::RETURN_OK; From 3fe66b6e43598b71e85e51f992176a351eeaea43 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Thu, 24 Jun 2021 08:51:49 +0200 Subject: [PATCH 010/111] fsfw update --- fsfw | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fsfw b/fsfw index cae69d54..5f9a6bb1 160000 --- a/fsfw +++ b/fsfw @@ -1 +1 @@ -Subproject commit cae69d540097acba46bffa47fd7afc6a8a19bd15 +Subproject commit 5f9a6bb155eb59981e7ff851b7efaa1ae25e42b4 From fdd76fb600aa2d088bd11185d848fc9835895761 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Thu, 24 Jun 2021 11:16:08 +0200 Subject: [PATCH 011/111] fsfw update, rm3100 update --- fsfw | 2 +- mission/devices/MGMHandlerRM3100.cpp | 10 +++++----- mission/devices/MGMHandlerRM3100.h | 11 +++++------ 3 files changed, 11 insertions(+), 12 deletions(-) diff --git a/fsfw b/fsfw index 5f9a6bb1..c0c4a319 160000 --- a/fsfw +++ b/fsfw @@ -1 +1 @@ -Subproject commit 5f9a6bb155eb59981e7ff851b7efaa1ae25e42b4 +Subproject commit c0c4a3190f1e54d4b5982656f5cc52218928d6ca diff --git a/mission/devices/MGMHandlerRM3100.cpp b/mission/devices/MGMHandlerRM3100.cpp index 4fd654d3..0f7fc729 100644 --- a/mission/devices/MGMHandlerRM3100.cpp +++ b/mission/devices/MGMHandlerRM3100.cpp @@ -1,10 +1,10 @@ -#include #include "MGMHandlerRM3100.h" -#include -#include -#include -#include +#include "fsfw/datapool/PoolReadGuard.h" +#include "fsfw/globalfunctions/bitutility.h" +#include "fsfw/devicehandlers/DeviceHandlerMessage.h" +#include "fsfw/objectmanager/SystemObjectIF.h" +#include "fsfw/returnvalues/HasReturnvaluesIF.h" MGMHandlerRM3100::MGMHandlerRM3100(object_id_t objectId, diff --git a/mission/devices/MGMHandlerRM3100.h b/mission/devices/MGMHandlerRM3100.h index 95175b47..48173e65 100644 --- a/mission/devices/MGMHandlerRM3100.h +++ b/mission/devices/MGMHandlerRM3100.h @@ -1,13 +1,12 @@ #ifndef MISSION_DEVICES_MGMRM3100HANDLER_H_ #define MISSION_DEVICES_MGMRM3100HANDLER_H_ +#include "OBSWConfig.h" #include "devicedefinitions/MGMHandlerRM3100Definitions.h" -#include - -#include +#include "fsfw/devicehandlers/DeviceHandlerBase.h" #if OBSW_VERBOSE_LEVEL >= 1 -#include +#include "fsfw/globalfunctions/PeriodicOperationDivider.h" #endif /** @@ -21,11 +20,11 @@ class MGMHandlerRM3100: public DeviceHandlerBase { public: static const uint8_t INTERFACE_ID = CLASS_ID::MGM_RM3100; - //! P1: TMRC value which was set, P2: 0 + //! [EXPORT] : [COMMENT] P1: TMRC value which was set, P2: 0 static constexpr Event tmrcSet = event::makeEvent(SUBSYSTEM_ID::MGM_RM3100, 0x00, severity::INFO); - //! P1: First two bytes new Cycle Count X + //! [EXPORT] : [COMMENT] Cycle counter set. P1: First two bytes new Cycle Count X //! P1: Second two bytes new Cycle Count Y //! P2: New cycle count Z static constexpr Event cycleCountersSet = event::makeEvent( From a076c7d5938518d963718b5f70f2b4623c80f1d3 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Thu, 24 Jun 2021 11:17:36 +0200 Subject: [PATCH 012/111] fsfw update --- fsfw | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fsfw b/fsfw index c0c4a319..38f2f69c 160000 --- a/fsfw +++ b/fsfw @@ -1 +1 @@ -Subproject commit c0c4a3190f1e54d4b5982656f5cc52218928d6ca +Subproject commit 38f2f69c784c74cd87a10dce6c968325cf1cb472 From 2a01de731fa51fd0d2c811b0223790c7b60d5994 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Thu, 24 Jun 2021 11:23:49 +0200 Subject: [PATCH 013/111] added ninja scripts --- ...e_cmake_debug_cfg.sh => make_debug_cfg.sh} | 0 ...e_relwithdeb_cfg.sh => make_reldeb_cfg.sh} | 0 ...ake_release_cfg.sh => make_release_cfg.sh} | 0 cmake/scripts/Q7S/ninja_debug_cfg.sh | 23 +++++++++++++++++++ ...e_cmake_debug_cfg.sh => make_debug_cfg.sh} | 0 ...e_relwithdeb_cfg.sh => make_reldeb_cfg.sh} | 0 ...ake_release_cfg.sh => make_release_cfg.sh} | 0 ...e_cmake_size_cfg.sh => ninja_debug_cfg.sh} | 12 ++++------ 8 files changed, 27 insertions(+), 8 deletions(-) rename cmake/scripts/Q7S/{create_cmake_debug_cfg.sh => make_debug_cfg.sh} (100%) rename cmake/scripts/Q7S/{create_cmake_relwithdeb_cfg.sh => make_reldeb_cfg.sh} (100%) rename cmake/scripts/Q7S/{create_cmake_release_cfg.sh => make_release_cfg.sh} (100%) create mode 100755 cmake/scripts/Q7S/ninja_debug_cfg.sh rename cmake/scripts/RPi/{create_cmake_debug_cfg.sh => make_debug_cfg.sh} (100%) rename cmake/scripts/RPi/{create_cmake_relwithdeb_cfg.sh => make_reldeb_cfg.sh} (100%) rename cmake/scripts/RPi/{create_cmake_release_cfg.sh => make_release_cfg.sh} (100%) rename cmake/scripts/RPi/{create_cmake_size_cfg.sh => ninja_debug_cfg.sh} (63%) diff --git a/cmake/scripts/Q7S/create_cmake_debug_cfg.sh b/cmake/scripts/Q7S/make_debug_cfg.sh similarity index 100% rename from cmake/scripts/Q7S/create_cmake_debug_cfg.sh rename to cmake/scripts/Q7S/make_debug_cfg.sh diff --git a/cmake/scripts/Q7S/create_cmake_relwithdeb_cfg.sh b/cmake/scripts/Q7S/make_reldeb_cfg.sh similarity index 100% rename from cmake/scripts/Q7S/create_cmake_relwithdeb_cfg.sh rename to cmake/scripts/Q7S/make_reldeb_cfg.sh diff --git a/cmake/scripts/Q7S/create_cmake_release_cfg.sh b/cmake/scripts/Q7S/make_release_cfg.sh similarity index 100% rename from cmake/scripts/Q7S/create_cmake_release_cfg.sh rename to cmake/scripts/Q7S/make_release_cfg.sh diff --git a/cmake/scripts/Q7S/ninja_debug_cfg.sh b/cmake/scripts/Q7S/ninja_debug_cfg.sh new file mode 100755 index 00000000..3a8ac631 --- /dev/null +++ b/cmake/scripts/Q7S/ninja_debug_cfg.sh @@ -0,0 +1,23 @@ +#!/bin/sh +counter=0 +while [ ${counter} -lt 5 ] +do + cd .. + if [ -f "cmake_build_config.py" ];then + break + fi + counter=$((counter=counter + 1)) +done + +if [ "${counter}" -ge 5 ];then + echo "cmake_build_config.py not found in upper directories!" + exit 1 +fi + +os_fsfw="linux" +tgt_bsp="arm/q7s" +build_dir="build-Debug-Q7S" +build_generator="Ninja" + +python3 cmake_build_config.py -o "${os_fsfw}" -g "${build_generator}" -b "debug" -t "${tgt_bsp}" \ + -l"${build_dir}" diff --git a/cmake/scripts/RPi/create_cmake_debug_cfg.sh b/cmake/scripts/RPi/make_debug_cfg.sh similarity index 100% rename from cmake/scripts/RPi/create_cmake_debug_cfg.sh rename to cmake/scripts/RPi/make_debug_cfg.sh diff --git a/cmake/scripts/RPi/create_cmake_relwithdeb_cfg.sh b/cmake/scripts/RPi/make_reldeb_cfg.sh similarity index 100% rename from cmake/scripts/RPi/create_cmake_relwithdeb_cfg.sh rename to cmake/scripts/RPi/make_reldeb_cfg.sh diff --git a/cmake/scripts/RPi/create_cmake_release_cfg.sh b/cmake/scripts/RPi/make_release_cfg.sh similarity index 100% rename from cmake/scripts/RPi/create_cmake_release_cfg.sh rename to cmake/scripts/RPi/make_release_cfg.sh diff --git a/cmake/scripts/RPi/create_cmake_size_cfg.sh b/cmake/scripts/RPi/ninja_debug_cfg.sh similarity index 63% rename from cmake/scripts/RPi/create_cmake_size_cfg.sh rename to cmake/scripts/RPi/ninja_debug_cfg.sh index f7bad84e..c05ae446 100755 --- a/cmake/scripts/RPi/create_cmake_size_cfg.sh +++ b/cmake/scripts/RPi/ninja_debug_cfg.sh @@ -16,12 +16,8 @@ fi os_fsfw="linux" tgt_bsp="arm/raspberrypi" -build_generator="" -if [ "${OS}" = "Windows_NT" ]; then - build_generator="MinGW Makefiles" -# Could be other OS but this works for now. -else - build_generator="Unix Makefiles" -fi +build_generator="Ninja" +build_dir="build-Debug-RPi" -python3 cmake_build_config.py -o "${os_fsfw}" -g "${build_generator}" -b "size" -t "${tgt_bsp}" +python3 cmake_build_config.py -o "${os_fsfw}" -g "${build_generator}" -b "debug" -t "${tgt_bsp}" \ + -l"${build_dir}" From a30483b37ea9b9bdc179a7d334a3ed5fdf7634a0 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Thu, 24 Jun 2021 11:24:19 +0200 Subject: [PATCH 014/111] small README fix --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index a03d7272..53c1cfad 100644 --- a/README.md +++ b/README.md @@ -79,7 +79,7 @@ wget https://eive-cloud.irs.uni-stuttgart.de/index.php/s/2Fp2ag6NGnbtAsK/downloa 3. Run the following commands in MinGW64 ```sh - pacman -Syuuu + pacman -Syu ``` It is recommended to install the full base development toolchain From 1e3b91789c9aa5148e8a176580a630ca50cf833e Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Thu, 24 Jun 2021 11:42:40 +0200 Subject: [PATCH 015/111] continued gps handler --- bsp_linux_board/ObjectFactory.cpp | 4 +- mission/devices/CMakeLists.txt | 3 +- ...{GPSHandler.cpp => GPSHyperionHandler.cpp} | 52 +++++++++++++------ .../{GPSHandler.h => GPSHyperionHandler.h} | 20 ++++--- .../devicedefinitions/GPSDefinitions.h | 24 ++++++++- 5 files changed, 74 insertions(+), 29 deletions(-) rename mission/devices/{GPSHandler.cpp => GPSHyperionHandler.cpp} (55%) rename mission/devices/{GPSHandler.h => GPSHyperionHandler.h} (72%) diff --git a/bsp_linux_board/ObjectFactory.cpp b/bsp_linux_board/ObjectFactory.cpp index f4ae00bf..c5e12868 100644 --- a/bsp_linux_board/ObjectFactory.cpp +++ b/bsp_linux_board/ObjectFactory.cpp @@ -1,6 +1,6 @@ #include #include -#include +#include #include "ObjectFactory.h" #include "objects/systemObjectList.h" @@ -157,7 +157,7 @@ void ObjectFactory::produce(void* args){ UartModes::CANONICAL, 9600, 1024); uartCookie->setToFlushInput(true); uartCookie->setReadCycles(6); - GPSHandler* gpsHandler = new GPSHandler(objects::GPS0_HANDLER, + GPSHyperionHandler* gpsHandler = new GPSHyperionHandler(objects::GPS0_HANDLER, objects::UART_COM_IF, uartCookie); gpsHandler->setStartUpImmediately(); #endif diff --git a/mission/devices/CMakeLists.txt b/mission/devices/CMakeLists.txt index 735e595b..8eb96538 100644 --- a/mission/devices/CMakeLists.txt +++ b/mission/devices/CMakeLists.txt @@ -1,6 +1,5 @@ target_sources(${TARGET_NAME} PUBLIC - GPSHandler.cpp - # GyroL3GD20Handler.cpp + GPSHyperionHandler.cpp MGMHandlerLIS3MDL.cpp MGMHandlerRM3100.cpp GomspaceDeviceHandler.cpp diff --git a/mission/devices/GPSHandler.cpp b/mission/devices/GPSHyperionHandler.cpp similarity index 55% rename from mission/devices/GPSHandler.cpp rename to mission/devices/GPSHyperionHandler.cpp index 3fdb6ab1..248b7193 100644 --- a/mission/devices/GPSHandler.cpp +++ b/mission/devices/GPSHyperionHandler.cpp @@ -1,17 +1,19 @@ -#include "GPSHandler.h" +#include "GPSHyperionHandler.h" #include "devicedefinitions/GPSDefinitions.h" +#include "fsfw/datapool/PoolReadGuard.h" + #include "lwgps/lwgps.h" -GPSHandler::GPSHandler(object_id_t objectId, object_id_t deviceCommunication, +GPSHyperionHandler::GPSHyperionHandler(object_id_t objectId, object_id_t deviceCommunication, CookieIF *comCookie): - DeviceHandlerBase(objectId, deviceCommunication, comCookie) { + DeviceHandlerBase(objectId, deviceCommunication, comCookie), gpsSet(this) { lwgps_init(&gpsData); } -GPSHandler::~GPSHandler() {} +GPSHyperionHandler::~GPSHyperionHandler() {} -void GPSHandler::doStartUp() { +void GPSHyperionHandler::doStartUp() { if(internalState == InternalStates::NONE) { commandExecuted = false; internalState = InternalStates::WAIT_FIRST_MESSAGE; @@ -26,27 +28,27 @@ void GPSHandler::doStartUp() { } } -void GPSHandler::doShutDown() { +void GPSHyperionHandler::doShutDown() { internalState = InternalStates::NONE; commandExecuted = false; setMode(MODE_OFF); } -ReturnValue_t GPSHandler::buildTransitionDeviceCommand(DeviceCommandId_t *id) { +ReturnValue_t GPSHyperionHandler::buildTransitionDeviceCommand(DeviceCommandId_t *id) { return HasReturnvaluesIF::RETURN_OK; } -ReturnValue_t GPSHandler::buildNormalDeviceCommand(DeviceCommandId_t *id) { +ReturnValue_t GPSHyperionHandler::buildNormalDeviceCommand(DeviceCommandId_t *id) { return HasReturnvaluesIF::RETURN_OK; } -ReturnValue_t GPSHandler::buildCommandFromCommand( +ReturnValue_t GPSHyperionHandler::buildCommandFromCommand( DeviceCommandId_t deviceCommand, const uint8_t *commandData, size_t commandDataLen) { return HasReturnvaluesIF::RETURN_OK; } -ReturnValue_t GPSHandler::scanForReply(const uint8_t *start, size_t len, +ReturnValue_t GPSHyperionHandler::scanForReply(const uint8_t *start, size_t len, DeviceCommandId_t *foundId, size_t *foundLen) { // Pass data to GPS library if(len > 0) { @@ -61,12 +63,30 @@ ReturnValue_t GPSHandler::scanForReply(const uint8_t *start, size_t len, << std::endl; } else { - sif::info << "GPS Data" << std::endl; + // The data from the device will generally be read all at once. Therefore, we + // can set all field here + PoolReadGuard pg(&gpsSet); + if(pg.getReadResult() != HasReturnvaluesIF::RETURN_OK) { +#if FSFW_VERBOSE_LEVEL >= 1 + sif::warning << "GPSHyperionHandler::scanForReply: Reading dataset failed" + << std::endl; +#endif + } // Print messages + if(gpsData.is_valid) { + // Set all entries valid now, set invalid on case basis if values are sanitized + gpsSet.setValidity(true, true); + } + gpsSet.latitude.value = gpsData.latitude; + gpsSet.longitude.value = gpsData.latitude; + gpsSet.fixMode.value = gpsData.fix_mode; +#if FSFW_HAL_DEBUG_HYPERION_GPS == 1 + sif::info << "GPS Data" << std::endl; printf("Valid status: %d\n", gpsData.is_valid); printf("Latitude: %f degrees\n", gpsData.latitude); printf("Longitude: %f degrees\n", gpsData.longitude); printf("Altitude: %f meters\n", gpsData.altitude); +#endif } *foundLen = len; } @@ -74,25 +94,25 @@ ReturnValue_t GPSHandler::scanForReply(const uint8_t *start, size_t len, } -ReturnValue_t GPSHandler::interpretDeviceReply(DeviceCommandId_t id, +ReturnValue_t GPSHyperionHandler::interpretDeviceReply(DeviceCommandId_t id, const uint8_t *packet) { return HasReturnvaluesIF::RETURN_OK; } -uint32_t GPSHandler::getTransitionDelayMs(Mode_t from, Mode_t to) { +uint32_t GPSHyperionHandler::getTransitionDelayMs(Mode_t from, Mode_t to) { return 5000; } -ReturnValue_t GPSHandler::initializeLocalDataPool( +ReturnValue_t GPSHyperionHandler::initializeLocalDataPool( localpool::DataPool &localDataPoolMap, LocalDataPoolManager &poolManager) { return HasReturnvaluesIF::RETURN_OK; } -void GPSHandler::fillCommandAndReplyMap() { +void GPSHyperionHandler::fillCommandAndReplyMap() { // Reply length does not matter, packets should always arrive periodically insertInReplyMap(GpsHyperion::GPS_REPLY, 4, nullptr, 0, true); } -void GPSHandler::modeChanged() { +void GPSHyperionHandler::modeChanged() { internalState = InternalStates::NONE; } diff --git a/mission/devices/GPSHandler.h b/mission/devices/GPSHyperionHandler.h similarity index 72% rename from mission/devices/GPSHandler.h rename to mission/devices/GPSHyperionHandler.h index 298871e4..5685ac86 100644 --- a/mission/devices/GPSHandler.h +++ b/mission/devices/GPSHyperionHandler.h @@ -1,20 +1,25 @@ -#ifndef MISSION_DEVICES_GPSHANDLER_H_ -#define MISSION_DEVICES_GPSHANDLER_H_ +#ifndef MISSION_DEVICES_GPSHYPERIONHANDLER_H_ +#define MISSION_DEVICES_GPSHYPERIONHANDLER_H_ -#include +#include "fsfw/devicehandlers/DeviceHandlerBase.h" +#include "devicedefinitions/GPSDefinitions.h" #include "lwgps/lwgps.h" +#ifndef FSFW_HAL_DEBUG_HYPERION_GPS +#define FSFW_HAL_DEBUG_HYPERION_GPS 0 +#endif + /** * @brief Device handler for the Hyperion HT-GPS200 device * @details * Flight manual: * https://egit.irs.uni-stuttgart.de/redmine/projects/eive-flight-manual/wiki/Hyperion_HT-GPS200 */ -class GPSHandler: public DeviceHandlerBase { +class GPSHyperionHandler: public DeviceHandlerBase { public: - GPSHandler(object_id_t objectId, object_id_t deviceCommunication, + GPSHyperionHandler(object_id_t objectId, object_id_t deviceCommunication, CookieIF* comCookie); - virtual ~GPSHandler(); + virtual ~GPSHyperionHandler(); protected: enum class InternalStates { @@ -48,6 +53,7 @@ protected: private: lwgps_t gpsData = {}; + GpsPrimaryDataset gpsSet; }; -#endif /* MISSION_DEVICES_GPSHANDLER_H_ */ +#endif /* MISSION_DEVICES_GPSHYPERIONHANDLER_H_ */ diff --git a/mission/devices/devicedefinitions/GPSDefinitions.h b/mission/devices/devicedefinitions/GPSDefinitions.h index cb3cfd1a..72433f66 100644 --- a/mission/devices/devicedefinitions/GPSDefinitions.h +++ b/mission/devices/devicedefinitions/GPSDefinitions.h @@ -1,21 +1,41 @@ #ifndef MISSION_DEVICES_DEVICEDEFINITIONS_GPSDEFINITIONS_H_ #define MISSION_DEVICES_DEVICEDEFINITIONS_GPSDEFINITIONS_H_ -#include +#include "fsfw/devicehandlers/DeviceHandlerIF.h" +#include "fsfw/datapoollocal/StaticLocalDataSet.h" namespace GpsHyperion { static constexpr DeviceCommandId_t GPS_REPLY = 0; -enum GpsPoolIds: lp_id_t { +static constexpr uint32_t DATASET_ID = 0; +enum GpsPoolIds: lp_id_t { + LATITUDE = 0, + LONGITUDE = 1, + ALTITUDE = 2, + FIX_MODE = 3, }; } class GpsPrimaryDataset: public StaticLocalDataSet<5> { public: + GpsPrimaryDataset(object_id_t gpsId): + StaticLocalDataSet(sid_t(gpsId, GpsHyperion::DATASET_ID)) { + setAllVariablesReadOnly(); + } + + lp_var_t latitude = lp_var_t(sid.objectId, + GpsHyperion::LATITUDE, this); + lp_var_t longitude = lp_var_t(sid.objectId, + GpsHyperion::LONGITUDE, this); + lp_var_t altitude = lp_var_t(sid.objectId, GpsHyperion::ALTITUDE, this); + lp_var_t fixMode = lp_var_t(sid.objectId, GpsHyperion::FIX_MODE, this); private: + friend class GPSHyperionHandler; + GpsPrimaryDataset(HasLocalDataPoolIF* hkOwner): + StaticLocalDataSet(hkOwner, GpsHyperion::DATASET_ID) {} }; #endif /* MISSION_DEVICES_DEVICEDEFINITIONS_GPSDEFINITIONS_H_ */ From 8284ebec9f41b3748983dcabe12ea8f67e101379 Mon Sep 17 00:00:00 2001 From: Martin Zietz Date: Thu, 24 Jun 2021 12:04:36 +0200 Subject: [PATCH 016/111] rw wip --- bsp_q7s/ObjectFactory.cpp | 34 ++++++++++----- bsp_q7s/gpio/gpioCallbacks.cpp | 8 ++-- bsp_q7s/spiCallbacks/rwSpiCallback.cpp | 42 ++++++++++++++----- common/config/spiConf.h | 2 +- linux/fsfwconfig/devices/gpioIds.h | 6 +++ mission/devices/RwHandler.cpp | 10 ++++- mission/devices/RwHandler.h | 6 +++ .../devices/devicedefinitions/RwDefinitions.h | 28 +++++++------ 8 files changed, 95 insertions(+), 41 deletions(-) diff --git a/bsp_q7s/ObjectFactory.cpp b/bsp_q7s/ObjectFactory.cpp index 821d94fd..7507b5e6 100644 --- a/bsp_q7s/ObjectFactory.cpp +++ b/bsp_q7s/ObjectFactory.cpp @@ -552,25 +552,39 @@ void ObjectFactory::produce(void* args){ new PlocHandler(objects::PLOC_HANDLER, objects::UART_COM_IF, plocUartCookie); GpioCookie* gpioCookieRw = new GpioCookie; - GpioCallback* enRw1 = new GpioCallback(std::string("Chip select reaction wheel 1"), gpio::OUT, + GpioCallback* csRw1 = new GpioCallback(std::string("Chip select reaction wheel 1"), gpio::OUT, 1, &gpioCallbacks::spiCsDecoderCallback, gpioComIF); - gpioCookieRw->addGpio(gpioIds::EN_RW1, enRw1); - GpioCallback* enRw2 = new GpioCallback(std::string("Chip select reaction wheel 2"), gpio::OUT, + gpioCookieRw->addGpio(gpioIds::CS_RW1, csRw1); + GpioCallback* csRw2 = new GpioCallback(std::string("Chip select reaction wheel 2"), gpio::OUT, 1, &gpioCallbacks::spiCsDecoderCallback, gpioComIF); - gpioCookieRw->addGpio(gpioIds::EN_RW2, enRw2); - GpioCallback* enRw3 = new GpioCallback(std::string("Chip select reaction wheel 3"), gpio::OUT, + gpioCookieRw->addGpio(gpioIds::CS_RW2, csRw2); + GpioCallback* csRw3 = new GpioCallback(std::string("Chip select reaction wheel 3"), gpio::OUT, 1, &gpioCallbacks::spiCsDecoderCallback, gpioComIF); - gpioCookieRw->addGpio(gpioIds::EN_RW3, enRw3); - GpioCallback* enRw4 = new GpioCallback(std::string("Chip select reaction wheel 4"), gpio::OUT, + gpioCookieRw->addGpio(gpioIds::CS_RW3, csRw3); + GpioCallback* csRw4 = new GpioCallback(std::string("Chip select reaction wheel 4"), gpio::OUT, 1, &gpioCallbacks::spiCsDecoderCallback, gpioComIF); - gpioCookieRw->addGpio(gpioIds::EN_RW4, enRw4); + gpioCookieRw->addGpio(gpioIds::CS_RW4, csRw4); + + GpiodRegular* enRw1 = new GpiodRegular(std::string("gpiochip5"), 7, + std::string("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); + gpioCookieRw->addGpio(gpioIds::EN_RW2, enRw2); + GpiodRegular* enRw3 = new GpiodRegular(std::string("gpiochip5"), 11, + std::string("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); + gpioCookieRw->addGpio(gpioIds::EN_RW4, enRw4); gpioComIF->addGpios(gpioCookieRw); - auto rw1SpiCookie = new SpiCookie(addresses::RW1, gpioIds::EN_RW1, "/dev/spidev2.0", + auto rw1SpiCookie = new SpiCookie(addresses::RW1, gpioIds::CS_RW1, "/dev/spidev2.0", RwDefinitions::MAX_REPLY_SIZE, spi::RW_MODE, spi::RW_SPEED, &rwSpiCallback, nullptr); - auto rwHandler1 = new RwHandler(objects::RW1, objects::SPI_COM_IF, rw1SpiCookie); + auto rwHandler1 = new RwHandler(objects::RW1, objects::SPI_COM_IF, rw1SpiCookie, gpioComIF, + gpioIds::EN_RW1); rwHandler1->setStartUpImmediately(); rw1SpiCookie->setCallbackArgs(rwHandler1); diff --git a/bsp_q7s/gpio/gpioCallbacks.cpp b/bsp_q7s/gpio/gpioCallbacks.cpp index ede2311a..49e22249 100644 --- a/bsp_q7s/gpio/gpioCallbacks.cpp +++ b/bsp_q7s/gpio/gpioCallbacks.cpp @@ -220,22 +220,22 @@ void spiCsDecoderCallback(gpioId_t gpioId, gpio::GpioOperation gpioOp, int value selectY6(); break; } - case(gpioIds::EN_RW1): { + case(gpioIds::CS_RW1): { enableRwDecoder(); selectY0(); break; } - case(gpioIds::EN_RW2): { + case(gpioIds::CS_RW2): { enableRwDecoder(); selectY1(); break; } - case(gpioIds::EN_RW3): { + case(gpioIds::CS_RW3): { enableRwDecoder(); selectY3(); break; } - case(gpioIds::EN_RW4): { + case(gpioIds::CS_RW4): { enableRwDecoder(); selectY4(); break; diff --git a/bsp_q7s/spiCallbacks/rwSpiCallback.cpp b/bsp_q7s/spiCallbacks/rwSpiCallback.cpp index d1abf55e..2ad2d9fd 100644 --- a/bsp_q7s/spiCallbacks/rwSpiCallback.cpp +++ b/bsp_q7s/spiCallbacks/rwSpiCallback.cpp @@ -90,6 +90,7 @@ ReturnValue_t rwSpiCallback(SpiComIF* comIf, SpiCookie *cookie, const uint8_t *s default: writeBuffer[0] = *(sendData + idx); writeSize = 1; + break; } if (write(fileDescriptor, writeBuffer, writeSize) != static_cast(writeSize)) { sif::error << "rwSpiCallback: Write failed!" << std::endl; @@ -139,19 +140,28 @@ ReturnValue_t rwSpiCallback(SpiComIF* comIf, SpiCookie *cookie, const uint8_t *s size_t replyBufferSize = cookie->getMaxBufferSize(); + /** There must be a delay of 20 ms after sending the command */ + usleep(RwDefinitions::SPI_REPLY_DELAY); + + /** Receiving reply data */ uint8_t byteRead = 0; /** Reading the reply frame */ - if(read(fileDescriptor, &byteRead, 1) != 1) { - if(gpioId != gpio::NO_GPIO) { - if (gpioIF->pullHigh(gpioId) != HasReturnvaluesIF::RETURN_OK) { - sif::error << "rwSpiCallback: Failed to pull chip select high" << std::endl; - } - } - if(mutex->unlockMutex() != HasReturnvaluesIF::RETURN_OK) { - sif::error << "rwSpiCallback: Failed to unlock mutex"; - } - sif::error << "rwSpiCallback: Failed to read first byte of reply frame" << std::endl; - return RwHandler::SPI_READ_FAILURE; +// if(read(fileDescriptor, &byteRead, 1) != 1) { +// if(gpioId != gpio::NO_GPIO) { +// if (gpioIF->pullHigh(gpioId) != HasReturnvaluesIF::RETURN_OK) { +// sif::error << "rwSpiCallback: Failed to pull chip select high" << std::endl; +// } +// } +// if(mutex->unlockMutex() != HasReturnvaluesIF::RETURN_OK) { +// sif::error << "rwSpiCallback: Failed to unlock mutex"; +// } +// sif::error << "rwSpiCallback: Failed to read first byte of reply frame" << std::endl; +// return RwHandler::SPI_READ_FAILURE; +// } + + uint8_t readbuffer[10]; + if(read(fileDescriptor, readbuffer, 10) != 10) { + sif::error << "Failed to read all bytes" << std::endl;; } /** First byte must be the start sign 0x7E */ @@ -168,8 +178,18 @@ ReturnValue_t rwSpiCallback(SpiComIF* comIf, SpiCookie *cookie, const uint8_t *s return RwHandler::MISSING_START_SIGN; } + /** + * The reaction wheel responds with empty frames while preparing the reply data. + * However, receiving more than 5 empty frames will be interpreted as an error. + */ + for (int idx = 0; idx < 10; idx++) { + sif::error << "rwSpiCallback: Empty frame timeout"; + return RwHandler::NO_REPLY; + } + size_t decodedFrameLen = 0; for (; decodedFrameLen < replyBufferSize; decodedFrameLen++) { + byteRead = 0; if(read(fileDescriptor, &byteRead, 1) != 1) { sif::error << "rwSpiCallback: Read failed" << std::endl; return RwHandler::SPI_READ_FAILURE; diff --git a/common/config/spiConf.h b/common/config/spiConf.h index d76ac9b8..47600eb3 100644 --- a/common/config/spiConf.h +++ b/common/config/spiConf.h @@ -26,7 +26,7 @@ static constexpr spi::SpiModes DEFAULT_MAX_1227_MODE = spi::SpiModes::MODE_3; static constexpr uint32_t DEFAULT_ADIS16507_SPEED = 976'000; static constexpr spi::SpiModes DEFAULT_ADIS16507_MODE = spi::SpiModes::MODE_3; -static constexpr uint32_t RW_SPEED = 300'000; +static constexpr uint32_t RW_SPEED = 300000; static constexpr spi::SpiModes RW_MODE = spi::SpiModes::MODE_0; } diff --git a/linux/fsfwconfig/devices/gpioIds.h b/linux/fsfwconfig/devices/gpioIds.h index 0a541477..718bc9bf 100644 --- a/linux/fsfwconfig/devices/gpioIds.h +++ b/linux/fsfwconfig/devices/gpioIds.h @@ -74,6 +74,12 @@ namespace gpioIds { EN_RW2, EN_RW3, EN_RW4, + + CS_RW1, + CS_RW2, + CS_RW3, + CS_RW4, + EN_RW_CS }; } diff --git a/mission/devices/RwHandler.cpp b/mission/devices/RwHandler.cpp index c029372b..a80c97cc 100644 --- a/mission/devices/RwHandler.cpp +++ b/mission/devices/RwHandler.cpp @@ -6,7 +6,8 @@ RwHandler::RwHandler(object_id_t objectId, object_id_t comIF, CookieIF * comCookie, LinuxLibgpioIF* gpioComIF, gpioId_t enableGpio) : - DeviceHandlerBase(objectId, comIF, comCookie), temperatureSet(this), statusSet(this) { + DeviceHandlerBase(objectId, comIF, comCookie), gpioComIF(gpioComIF), enableGpio(enableGpio), + temperatureSet(this), statusSet(this) { if (comCookie == NULL) { sif::error << "RwHandler: Invalid com cookie" << std::endl; } @@ -19,6 +20,9 @@ RwHandler::~RwHandler() { } void RwHandler::doStartUp() { + if(gpioComIF->pullHigh(enableGpio) != RETURN_OK) { + sif::debug << "RwHandler::doStartUp: Failed to pull enable gpio to high"; + } #if OBSW_SWITCH_TO_NORMAL_MODE_AFTER_STARTUP == 1 setMode(MODE_NORMAL); #else @@ -27,7 +31,9 @@ void RwHandler::doStartUp() { } void RwHandler::doShutDown() { - + if(gpioComIF->pullLow(enableGpio) != RETURN_OK) { + sif::debug << "RwHandler::doStartUp: Failed to pull enable gpio to low"; + } } ReturnValue_t RwHandler::buildNormalDeviceCommand(DeviceCommandId_t * id) { diff --git a/mission/devices/RwHandler.h b/mission/devices/RwHandler.h index f68b57b7..0a9d58d0 100644 --- a/mission/devices/RwHandler.h +++ b/mission/devices/RwHandler.h @@ -3,6 +3,7 @@ #include #include +#include #include /** @@ -43,6 +44,8 @@ public: static const ReturnValue_t INVALID_SUBSTITUTE = MAKE_RETURN_CODE(0xB3); //! [EXPORT] : [COMMENT] HDLC decoding mechanism never receives the end sign 0x7E static const ReturnValue_t MISSING_END_SIGN = MAKE_RETURN_CODE(0xB4); + //! [EXPORT] : [COMMENT] Reaction wheel only responds with empty frames. + static const ReturnValue_t NO_REPLY = MAKE_RETURN_CODE(0xB5); protected: void doStartUp() override; @@ -76,6 +79,9 @@ private: //! [EXPORT] : [COMMENT] Reaction wheel reply has invalid crc static const ReturnValue_t CRC_ERROR = MAKE_RETURN_CODE(0xA4); + LinuxLibgpioIF* gpioComIF = nullptr; + gpioId_t enableGpio = gpio::NO_GPIO; + RwDefinitions::TemperatureSet temperatureSet; RwDefinitions::StatusSet statusSet; diff --git a/mission/devices/devicedefinitions/RwDefinitions.h b/mission/devices/devicedefinitions/RwDefinitions.h index 247b7bc6..23907eb3 100644 --- a/mission/devices/devicedefinitions/RwDefinitions.h +++ b/mission/devices/devicedefinitions/RwDefinitions.h @@ -8,6 +8,8 @@ namespace RwDefinitions { +static const uint32_t SPI_REPLY_DELAY = 70000; //us + enum PoolIds: lp_id_t { TEMPERATURE_C, CURR_SPEED, @@ -16,25 +18,25 @@ enum PoolIds: lp_id_t { CLC_MODE }; -static constexpr DeviceCommandId_t GET_RW_STATUS = 4; -static constexpr DeviceCommandId_t SET_SPEED = 6; -static constexpr DeviceCommandId_t GET_TEMPERATURE = 8; +static const DeviceCommandId_t GET_RW_STATUS = 4; +static const DeviceCommandId_t SET_SPEED = 6; +static const DeviceCommandId_t GET_TEMPERATURE = 8; -static constexpr uint32_t TEMPERATURE_SET_ID = GET_TEMPERATURE; -static constexpr uint32_t STATUS_SET_ID = GET_RW_STATUS; +static const uint32_t TEMPERATURE_SET_ID = GET_TEMPERATURE; +static const uint32_t STATUS_SET_ID = GET_RW_STATUS; -static constexpr size_t SIZE_GET_RW_STATUS = 14; -static constexpr size_t SIZE_SET_SPEED_REPLY = 4; -static constexpr size_t SIZE_GET_TEMPERATURE_REPLY = 8; +static const size_t SIZE_GET_RW_STATUS = 14; +static const size_t SIZE_SET_SPEED_REPLY = 4; +static const size_t SIZE_GET_TEMPERATURE_REPLY = 8; /** Max size when requesting telemetry */ -static constexpr size_t SIZE_GET_TELEMETRY_REPLY = 83; +static const size_t SIZE_GET_TELEMETRY_REPLY = 83; /** Set speed command has maximum size */ -static constexpr size_t MAX_CMD_SIZE = 9; -static constexpr size_t MAX_REPLY_SIZE = SIZE_GET_TELEMETRY_REPLY; +static const size_t MAX_CMD_SIZE = 9; +static const size_t MAX_REPLY_SIZE = SIZE_GET_TELEMETRY_REPLY; -static constexpr uint8_t TEMPERATURE_SET_ENTRIES = 1; -static constexpr uint8_t STATUS_SET_ENTRIES = 4; +static const uint8_t TEMPERATURE_SET_ENTRIES = 1; +static const uint8_t STATUS_SET_ENTRIES = 4; /** * @brief This dataset can be used to store the temperature of a reaction wheel. From 0d12a925693d64fe1afde09f137001ac771341ab Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Thu, 24 Jun 2021 13:55:51 +0200 Subject: [PATCH 017/111] gps contd --- mission/devices/GPSHyperionHandler.cpp | 32 +++++++++++++++++++ .../devicedefinitions/GPSDefinitions.h | 26 ++++++++++++++- 2 files changed, 57 insertions(+), 1 deletion(-) diff --git a/mission/devices/GPSHyperionHandler.cpp b/mission/devices/GPSHyperionHandler.cpp index 248b7193..1f68881c 100644 --- a/mission/devices/GPSHyperionHandler.cpp +++ b/mission/devices/GPSHyperionHandler.cpp @@ -2,6 +2,7 @@ #include "devicedefinitions/GPSDefinitions.h" #include "fsfw/datapool/PoolReadGuard.h" +#include "fsfw/timemanager/Clock.h" #include "lwgps/lwgps.h" @@ -77,9 +78,28 @@ ReturnValue_t GPSHyperionHandler::scanForReply(const uint8_t *start, size_t len, // Set all entries valid now, set invalid on case basis if values are sanitized gpsSet.setValidity(true, true); } + // Negative latitude -> South direction gpsSet.latitude.value = gpsData.latitude; + // Negative longitude -> West direction gpsSet.longitude.value = gpsData.latitude; gpsSet.fixMode.value = gpsData.fix_mode; + gpsSet.satInUse.value = gpsData.sats_in_use; + Clock::TimeOfDay_t timeStruct = {}; + timeStruct.day = gpsData.date; + timeStruct.hour = gpsData.hours; + timeStruct.minute = gpsData.minutes; + timeStruct.month = gpsData.month; + timeStruct.second = gpsData.seconds; + // Convert two-digit year to full year (AD) + timeStruct.year = gpsData.year + 2000; + timeval timeval = {}; + Clock::convertTimeOfDayToTimeval(&timeStruct, &timeval); + gpsSet.year = timeStruct.year; + gpsSet.month = gpsData.month; + gpsSet.day = gpsData.date; + gpsSet.hours = gpsData.hours; + gpsSet.minutes = gpsData.minutes; + gpsSet.seconds = gpsData.seconds; #if FSFW_HAL_DEBUG_HYPERION_GPS == 1 sif::info << "GPS Data" << std::endl; printf("Valid status: %d\n", gpsData.is_valid); @@ -105,6 +125,18 @@ uint32_t GPSHyperionHandler::getTransitionDelayMs(Mode_t from, Mode_t to) { ReturnValue_t GPSHyperionHandler::initializeLocalDataPool( localpool::DataPool &localDataPoolMap, LocalDataPoolManager &poolManager) { + localDataPoolMap.emplace(GpsHyperion::ALTITUDE, new PoolEntry({0.0})); + localDataPoolMap.emplace(GpsHyperion::LONGITUDE, new PoolEntry({0.0})); + localDataPoolMap.emplace(GpsHyperion::LATITUDE, new PoolEntry({0.0})); + localDataPoolMap.emplace(GpsHyperion::YEAR, new PoolEntry()); + localDataPoolMap.emplace(GpsHyperion::MONTH, new PoolEntry()); + localDataPoolMap.emplace(GpsHyperion::DAY, new PoolEntry()); + localDataPoolMap.emplace(GpsHyperion::HOURS, new PoolEntry()); + localDataPoolMap.emplace(GpsHyperion::MINUTES, new PoolEntry()); + localDataPoolMap.emplace(GpsHyperion::SECONDS, new PoolEntry()); + localDataPoolMap.emplace(GpsHyperion::UNIX_SECONDS, new PoolEntry()); + localDataPoolMap.emplace(GpsHyperion::SATS_IN_USE, new PoolEntry()); + localDataPoolMap.emplace(GpsHyperion::FIX_MODE, new PoolEntry()); return HasReturnvaluesIF::RETURN_OK; } diff --git a/mission/devices/devicedefinitions/GPSDefinitions.h b/mission/devices/devicedefinitions/GPSDefinitions.h index 72433f66..8f147651 100644 --- a/mission/devices/devicedefinitions/GPSDefinitions.h +++ b/mission/devices/devicedefinitions/GPSDefinitions.h @@ -15,11 +15,26 @@ enum GpsPoolIds: lp_id_t { LONGITUDE = 1, ALTITUDE = 2, FIX_MODE = 3, + SATS_IN_USE = 4, + UNIX_SECONDS = 5, + YEAR = 6, + MONTH = 7, + DAY = 8, + HOURS = 9, + MINUTES = 10, + SECONDS = 11 +}; + +enum GpsFixModes: uint8_t { + INVALID = 0, + NO_FIX = 1, + FIX_2D = 2, + FIX_3D = 3 }; } -class GpsPrimaryDataset: public StaticLocalDataSet<5> { +class GpsPrimaryDataset: public StaticLocalDataSet<18> { public: GpsPrimaryDataset(object_id_t gpsId): StaticLocalDataSet(sid_t(gpsId, GpsHyperion::DATASET_ID)) { @@ -32,6 +47,15 @@ public: GpsHyperion::LONGITUDE, this); lp_var_t altitude = lp_var_t(sid.objectId, GpsHyperion::ALTITUDE, this); lp_var_t fixMode = lp_var_t(sid.objectId, GpsHyperion::FIX_MODE, this); + lp_var_t satInUse = lp_var_t(sid.objectId, GpsHyperion::SATS_IN_USE, this); + lp_var_t year = lp_var_t(sid.objectId, GpsHyperion::YEAR, this); + lp_var_t month = lp_var_t(sid.objectId, GpsHyperion::MONTH, this); + lp_var_t day = lp_var_t(sid.objectId, GpsHyperion::DAY, this); + lp_var_t hours = lp_var_t(sid.objectId, GpsHyperion::HOURS, this); + lp_var_t minutes = lp_var_t(sid.objectId, GpsHyperion::MINUTES, this); + lp_var_t seconds = lp_var_t(sid.objectId, GpsHyperion::SECONDS, this); + lp_var_t unixSeconds = lp_var_t(sid.objectId, + GpsHyperion::UNIX_SECONDS, this); private: friend class GPSHyperionHandler; GpsPrimaryDataset(HasLocalDataPoolIF* hkOwner): From 136c859c90f9aa878776c8ba9584f1659a8de524 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Thu, 24 Jun 2021 14:17:24 +0200 Subject: [PATCH 018/111] lis3 minor form changes --- mission/devices/MGMHandlerLIS3MDL.cpp | 6 ++++-- mission/devices/MGMHandlerLIS3MDL.h | 8 ++++---- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/mission/devices/MGMHandlerLIS3MDL.cpp b/mission/devices/MGMHandlerLIS3MDL.cpp index 15f6e325..63bf607c 100644 --- a/mission/devices/MGMHandlerLIS3MDL.cpp +++ b/mission/devices/MGMHandlerLIS3MDL.cpp @@ -1,7 +1,9 @@ -#include #include "MGMHandlerLIS3MDL.h" -#include +#include "fsfw/datapool/PoolReadGuard.h" +#if OBSW_VERBOSE_LEVEL >= 1 +#include "fsfw/globalfunctions/PeriodicOperationDivider.h" +#endif MGMHandlerLIS3MDL::MGMHandlerLIS3MDL(object_id_t objectId, object_id_t deviceCommunication, CookieIF* comCookie): diff --git a/mission/devices/MGMHandlerLIS3MDL.h b/mission/devices/MGMHandlerLIS3MDL.h index 3cc08a6b..bb64e63a 100644 --- a/mission/devices/MGMHandlerLIS3MDL.h +++ b/mission/devices/MGMHandlerLIS3MDL.h @@ -1,13 +1,13 @@ #ifndef MISSION_DEVICES_MGMLIS3MDLHANDLER_H_ #define MISSION_DEVICES_MGMLIS3MDLHANDLER_H_ +#include "OBSWConfig.h" #include "devicedefinitions/MGMHandlerLIS3Definitions.h" +#include "events/subsystemIdRanges.h" -#include -#include +#include "fsfw/devicehandlers/DeviceHandlerBase.h" -#include -#include +class PeriodicOperationDivider; /** * @brief Device handler object for the LIS3MDL 3-axis magnetometer From bc087e2a7a1506e049277f09b0218d3cf5c0b4db Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Thu, 24 Jun 2021 14:19:25 +0200 Subject: [PATCH 019/111] removed unused code --- mission/devices/MGMHandlerLIS3MDL.cpp | 7 ++----- mission/devices/MGMHandlerLIS3MDL.h | 3 --- 2 files changed, 2 insertions(+), 8 deletions(-) diff --git a/mission/devices/MGMHandlerLIS3MDL.cpp b/mission/devices/MGMHandlerLIS3MDL.cpp index 63bf607c..85cb3407 100644 --- a/mission/devices/MGMHandlerLIS3MDL.cpp +++ b/mission/devices/MGMHandlerLIS3MDL.cpp @@ -302,9 +302,9 @@ ReturnValue_t MGMHandlerLIS3MDL::interpretDeviceReply(DeviceCommandId_t id, sif::printInfo("X: %f " "\xC2\xB5" "T\n", mgmX); sif::printInfo("Y: %f " "\xC2\xB5" "T\n", mgmY); sif::printInfo("Z: %f " "\xC2\xB5" "T\n", mgmZ); -#endif +#endif /* FSFW_CPP_OSTREAM_ENABLED == 0 */ } -#endif +#endif /* OBSW_VERBOSE_LEVEL >= 1 */ PoolReadGuard readHelper(&dataset); if(readHelper.getReadResult() == HasReturnvaluesIF::RETURN_OK) { dataset.fieldStrengthX = mgmX; @@ -484,6 +484,3 @@ ReturnValue_t MGMHandlerLIS3MDL::initializeLocalDataPool( new PoolEntry({0.0})); return HasReturnvaluesIF::RETURN_OK; } - -void MGMHandlerLIS3MDL::performOperationHook() { -} diff --git a/mission/devices/MGMHandlerLIS3MDL.h b/mission/devices/MGMHandlerLIS3MDL.h index bb64e63a..5d8364ee 100644 --- a/mission/devices/MGMHandlerLIS3MDL.h +++ b/mission/devices/MGMHandlerLIS3MDL.h @@ -162,9 +162,6 @@ private: #if OBSW_VERBOSE_LEVEL >= 1 PeriodicOperationDivider* debugDivider; #endif - - void performOperationHook() override; - }; #endif /* MISSION_DEVICES_MGMLIS3MDLHANDLER_H_ */ From ed0aafa5437c036ec059476e9e8f25f0143debad Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Thu, 24 Jun 2021 16:17:38 +0200 Subject: [PATCH 020/111] updated object IDs --- common/config/commonObjects.h | 48 ++++---- linux/fsfwconfig/objects/systemObjectList.h | 128 +++++++++++--------- 2 files changed, 97 insertions(+), 79 deletions(-) diff --git a/common/config/commonObjects.h b/common/config/commonObjects.h index 1651f6a0..b153065e 100644 --- a/common/config/commonObjects.h +++ b/common/config/commonObjects.h @@ -6,34 +6,34 @@ namespace objects { enum commonObjects: uint32_t { /* First Byte 0x50-0x52 reserved for PUS Services **/ - CCSDS_PACKET_DISTRIBUTOR = 0x50000100, - PUS_PACKET_DISTRIBUTOR = 0x50000200, - UDP_BRIDGE = 0x50000300, - UDP_POLLING_TASK = 0x50000400, + CCSDS_PACKET_DISTRIBUTOR = 0x50000100, + PUS_PACKET_DISTRIBUTOR = 0x50000200, + UDP_BRIDGE = 0x50000300, + UDP_POLLING_TASK = 0x50000400, /* 0x43 ('C') for Controllers */ - THERMAL_CONTROLLER = 0x43001000, - ATTITUDE_CONTROLLER = 0x43002000, - ACS_CONTROLLER = 0x43003000, - CORE_CONTROLLER = 0x43004000, + THERMAL_CONTROLLER = 0x43400001, + ACS_CONTROLLER = 0x43100002, + CORE_CONTROLLER = 0x43000003, - /* 0x44 ('D') for device handlers */ - P60DOCK_HANDLER = 0x44000001, - PDU1_HANDLER = 0x44000002, - PDU2_HANDLER = 0x44000003, - ACU_HANDLER = 0x44000004, - TMP1075_HANDLER_1 = 0x44000005, - TMP1075_HANDLER_2 = 0x44000006, - MGM_0_LIS3_HANDLER = 0x44000007, - MGM_1_RM3100_HANDLER = 0x44000008, - MGM_2_LIS3_HANDLER = 0x44000009, - MGM_3_RM3100_HANDLER = 0x44000010, - GYRO_0_ADIS_HANDLER = 0x44000011, - GYRO_1_L3G_HANDLER = 0x44000012, - GYRO_2_L3G_HANDLER = 0x44000013, + /* 0x44 ('D') for device handlers */ + P60DOCK_HANDLER = 0x44200001, + PDU1_HANDLER = 0x44200002, + PDU2_HANDLER = 0x44200003, + ACU_HANDLER = 0x44200004, + TMP1075_HANDLER_1 = 0x44400005, + TMP1075_HANDLER_2 = 0x44400006, + MGM_0_LIS3_HANDLER = 0x44100007, + MGM_1_RM3100_HANDLER = 0x44100008, + MGM_2_LIS3_HANDLER = 0x44100009, + MGM_3_RM3100_HANDLER = 0x44100010, + GYRO_0_ADIS_HANDLER = 0x44100011, + GYRO_1_L3G_HANDLER = 0x44100012, + GYRO_2_ADIS_HANDLER = 0x44100013, + GYRO_3_L3G_HANDLER = 0x44100014, - IMTQ_HANDLER = 0x44000014, - PLOC_HANDLER = 0x44000015, + IMTQ_HANDLER = 0x44100014, + PLOC_HANDLER = 0x44300015, SUS_1 = 0x44000016, SUS_2 = 0x44000017, diff --git a/linux/fsfwconfig/objects/systemObjectList.h b/linux/fsfwconfig/objects/systemObjectList.h index 5d5cdee1..a1c644da 100644 --- a/linux/fsfwconfig/objects/systemObjectList.h +++ b/linux/fsfwconfig/objects/systemObjectList.h @@ -6,67 +6,85 @@ #include // The objects will be instantiated in the ID order +// For naming scheme see flight manual +/* +https://egit.irs.uni-stuttgart.de/redmine/projects/eive-flight-manual/wiki/EIVE_Project_IDs + +Second byte first four bits is the subsystem: +OBDH 0x0 +ACS 0x1 +EPS 0x2 +PL 0x3 +TCS 0x4 +COM 0x5 + +Second byte last four bits is the bus: +None 0x0 +GPIO 0x1 +SPI 0x2 +UART 0x3 +I2C 0x4 +CAN 0x5 + +Third byte is an assembly counter if there are multiple redundant devices. +Fourth byte is a unique counter. + + */ namespace objects { - enum sourceObjects: uint32_t { - /* 0x53 reserved for FSFW */ - FW_ADDRESS_START = PUS_SERVICE_1_VERIFICATION, - FW_ADDRESS_END = TIME_STAMPER, +enum sourceObjects: uint32_t { + /* 0x53 reserved for FSFW */ + FW_ADDRESS_START = PUS_SERVICE_1_VERIFICATION, + FW_ADDRESS_END = TIME_STAMPER, + PUS_SERVICE_6 = 0x51000500, - CCSDS_IP_CORE_BRIDGE = 0x50000500, + CCSDS_IP_CORE_BRIDGE = 0x73500000, + TM_FUNNEL = 0x73000100, - PUS_SERVICE_6 = 0x51000500, + /* 0x49 ('I') for Communication Interfaces **/ + ARDUINO_COM_IF = 0x49000000, + CSP_COM_IF = 0x49050001, + I2C_COM_IF = 0x49040002, + UART_COM_IF = 0x49030003, + SPI_COM_IF = 0x49020004, + GPIO_IF = 0x49010005, - TM_FUNNEL = 0x52000002, + /* Custom device handler */ + PCDU_HANDLER = 0x44200032, + SOLAR_ARRAY_DEPL_HANDLER = 0x44410033, + SYRLINKS_HK_HANDLER = 0x44530034, + HEATER_HANDLER = 0x44410035, + /** + * Not yet specified which pt1000 will measure which device/location in the satellite. + * Therefore object ids are named according to the IC naming of the RTDs in the schematic. + */ + RTD_IC3 = 0x44420036, + RTD_IC4 = 0x44420037, + RTD_IC5 = 0x44420038, + RTD_IC6 = 0x44420039, + RTD_IC7 = 0x44420040, + RTD_IC8 = 0x44420041, + RTD_IC9 = 0x44420042, + RTD_IC10 = 0x44420043, + RTD_IC11 = 0x44420044, + RTD_IC12 = 0x44420045, + RTD_IC13 = 0x44420046, + RTD_IC14 = 0x44420047, + RTD_IC15 = 0x44420048, + RTD_IC16 = 0x44420049, + RTD_IC17 = 0x44420050, + RTD_IC18 = 0x44420051, - /* 0x49 ('I') for Communication Interfaces **/ - ARDUINO_COM_IF = 0x49000001, - CSP_COM_IF = 0x49000002, - I2C_COM_IF = 0x49000003, - UART_COM_IF = 0x49000004, - SPI_COM_IF = 0x49000005, + RAD_SENSOR = 0x44300052, - /* 0x47 ('G') for Gpio Interfaces */ - GPIO_IF = 0x47000001, - - /* Custom device handler */ - PCDU_HANDLER = 0x44001000, - SOLAR_ARRAY_DEPL_HANDLER = 0x44001001, - SYRLINKS_HK_HANDLER = 0x44001002, - - /* 0x54 ('T') for thermal objects */ - HEATER_HANDLER = 0x54000003, - /** - * Not yet specified which pt1000 will measure which device/location in the satellite. - * Therefore object ids are named according to the IC naming of the RTDs in the schematic. - */ - RTD_IC3 = 0x54000004, - RTD_IC4 = 0x54000005, - RTD_IC5 = 0x54000006, - RTD_IC6 = 0x54000007, - RTD_IC7 = 0x54000008, - RTD_IC8 = 0x54000009, - RTD_IC9 = 0x5400000A, - RTD_IC10 = 0x5400000B, - RTD_IC11 = 0x5400000C, - RTD_IC12 = 0x5400000D, - RTD_IC13 = 0x5400000E, - RTD_IC14 = 0x5400000F, - RTD_IC15 = 0x5400001F, - RTD_IC16 = 0x5400002F, - RTD_IC17 = 0x5400003F, - RTD_IC18 = 0x5400004F, - - RAD_SENSOR = 0x54000050, - - /* 0x54 ('T') for test handlers */ - TEST_TASK = 0x54694269, - LIBGPIOD_TEST = 0x54123456, - SPI_TEST = 0x54000010, - UART_TEST = 0x54000020, - DUMMY_INTERFACE = 0x5400CAFE, - DUMMY_HANDLER = 0x5400AFFE, - P60DOCK_TEST_TASK = 0x00005060 - }; + /* 0x54 ('T') for test handlers */ + TEST_TASK = 0x54694269, + LIBGPIOD_TEST = 0x54123456, + SPI_TEST = 0x54000010, + UART_TEST = 0x54000020, + DUMMY_INTERFACE = 0x5400CAFE, + DUMMY_HANDLER = 0x5400AFFE, + P60DOCK_TEST_TASK = 0x00005060 +}; } #endif /* BSP_CONFIG_OBJECTS_SYSTEMOBJECTLIST_H_ */ From ff8fd518baa095598a20963a46ed1797eb251751 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Thu, 24 Jun 2021 16:35:04 +0200 Subject: [PATCH 021/111] tmtc update --- tmtc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tmtc b/tmtc index 5be05c2a..f4e5bc19 160000 --- a/tmtc +++ b/tmtc @@ -1 +1 @@ -Subproject commit 5be05c2a929dfc908b8de61250e4db890b010fa5 +Subproject commit f4e5bc19568fc9786a3e5ac0a9164dbfe1dcbbe3 From fe65099b584e10da9d076a642d4f6d2b46ba18d0 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Thu, 24 Jun 2021 16:36:42 +0200 Subject: [PATCH 022/111] added bus descriptors --- common/config/commonObjects.h | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/common/config/commonObjects.h b/common/config/commonObjects.h index b153065e..a813fc11 100644 --- a/common/config/commonObjects.h +++ b/common/config/commonObjects.h @@ -23,17 +23,17 @@ enum commonObjects: uint32_t { ACU_HANDLER = 0x44200004, TMP1075_HANDLER_1 = 0x44400005, TMP1075_HANDLER_2 = 0x44400006, - MGM_0_LIS3_HANDLER = 0x44100007, - MGM_1_RM3100_HANDLER = 0x44100008, - MGM_2_LIS3_HANDLER = 0x44100009, - MGM_3_RM3100_HANDLER = 0x44100010, - GYRO_0_ADIS_HANDLER = 0x44100011, - GYRO_1_L3G_HANDLER = 0x44100012, - GYRO_2_ADIS_HANDLER = 0x44100013, - GYRO_3_L3G_HANDLER = 0x44100014, + MGM_0_LIS3_HANDLER = 0x44120007, + MGM_1_RM3100_HANDLER = 0x44120008, + MGM_2_LIS3_HANDLER = 0x44120009, + MGM_3_RM3100_HANDLER = 0x44120010, + GYRO_0_ADIS_HANDLER = 0x44120011, + GYRO_1_L3G_HANDLER = 0x44120012, + GYRO_2_ADIS_HANDLER = 0x44120013, + GYRO_3_L3G_HANDLER = 0x44120014, - IMTQ_HANDLER = 0x44100014, - PLOC_HANDLER = 0x44300015, + IMTQ_HANDLER = 0x44140014, + PLOC_HANDLER = 0x44330015, SUS_1 = 0x44000016, SUS_2 = 0x44000017, From 32c23ae2de81e88379ed031d50bf59d7545c7147 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Thu, 24 Jun 2021 16:39:46 +0200 Subject: [PATCH 023/111] update dev handler IDs --- common/config/commonObjects.h | 50 ++++++++++----------- linux/fsfwconfig/objects/systemObjectList.h | 42 ++++++++--------- 2 files changed, 46 insertions(+), 46 deletions(-) diff --git a/common/config/commonObjects.h b/common/config/commonObjects.h index a813fc11..24d7cc27 100644 --- a/common/config/commonObjects.h +++ b/common/config/commonObjects.h @@ -17,20 +17,20 @@ enum commonObjects: uint32_t { CORE_CONTROLLER = 0x43000003, /* 0x44 ('D') for device handlers */ - P60DOCK_HANDLER = 0x44200001, - PDU1_HANDLER = 0x44200002, - PDU2_HANDLER = 0x44200003, - ACU_HANDLER = 0x44200004, - TMP1075_HANDLER_1 = 0x44400005, - TMP1075_HANDLER_2 = 0x44400006, - MGM_0_LIS3_HANDLER = 0x44120007, - MGM_1_RM3100_HANDLER = 0x44120008, - MGM_2_LIS3_HANDLER = 0x44120009, - MGM_3_RM3100_HANDLER = 0x44120010, - GYRO_0_ADIS_HANDLER = 0x44120011, - GYRO_1_L3G_HANDLER = 0x44120012, - GYRO_2_ADIS_HANDLER = 0x44120013, - GYRO_3_L3G_HANDLER = 0x44120014, + P60DOCK_HANDLER = 0x44200000, + PDU1_HANDLER = 0x44200001, + PDU2_HANDLER = 0x44200002, + ACU_HANDLER = 0x44200003, + TMP1075_HANDLER_1 = 0x44400004, + TMP1075_HANDLER_2 = 0x44400005, + MGM_0_LIS3_HANDLER = 0x44120006, + MGM_1_RM3100_HANDLER = 0x44120007, + MGM_2_LIS3_HANDLER = 0x44120008, + MGM_3_RM3100_HANDLER = 0x44120009, + GYRO_0_ADIS_HANDLER = 0x44120010, + GYRO_1_L3G_HANDLER = 0x44120011, + GYRO_2_ADIS_HANDLER = 0x44120012, + GYRO_3_L3G_HANDLER = 0x44120013, IMTQ_HANDLER = 0x44140014, PLOC_HANDLER = 0x44330015, @@ -39,18 +39,18 @@ enum commonObjects: uint32_t { SUS_2 = 0x44000017, SUS_3 = 0x44000018, SUS_4 = 0x44000019, - SUS_5 = 0x4400001A, - SUS_6 = 0x4400001B, - SUS_7 = 0x4400001C, - SUS_8 = 0x4400001D, - SUS_9 = 0x4400001E, - SUS_10 = 0x4400001F, - SUS_11 = 0x44000021, - SUS_12 = 0x44000022, - SUS_13 = 0x44000023, + SUS_5 = 0x44000020, + SUS_6 = 0x44000021, + SUS_7 = 0x44000022, + SUS_8 = 0x44000023, + SUS_9 = 0x44000024, + SUS_10 = 0x44000025, + SUS_11 = 0x44000026, + SUS_12 = 0x44000027, + SUS_13 = 0x44000028, - GPS0_HANDLER = 0x44001000, - GPS1_HANDLER = 0x44002000 + GPS0_HANDLER = 0x44130029, + GPS1_HANDLER = 0x44130130 }; } diff --git a/linux/fsfwconfig/objects/systemObjectList.h b/linux/fsfwconfig/objects/systemObjectList.h index a1c644da..05fbc997 100644 --- a/linux/fsfwconfig/objects/systemObjectList.h +++ b/linux/fsfwconfig/objects/systemObjectList.h @@ -49,32 +49,32 @@ enum sourceObjects: uint32_t { GPIO_IF = 0x49010005, /* Custom device handler */ - PCDU_HANDLER = 0x44200032, - SOLAR_ARRAY_DEPL_HANDLER = 0x44410033, - SYRLINKS_HK_HANDLER = 0x44530034, - HEATER_HANDLER = 0x44410035, + PCDU_HANDLER = 0x44200050, + SOLAR_ARRAY_DEPL_HANDLER = 0x44410051, + SYRLINKS_HK_HANDLER = 0x44530052, + HEATER_HANDLER = 0x44410053, /** * Not yet specified which pt1000 will measure which device/location in the satellite. * Therefore object ids are named according to the IC naming of the RTDs in the schematic. */ - RTD_IC3 = 0x44420036, - RTD_IC4 = 0x44420037, - RTD_IC5 = 0x44420038, - RTD_IC6 = 0x44420039, - RTD_IC7 = 0x44420040, - RTD_IC8 = 0x44420041, - RTD_IC9 = 0x44420042, - RTD_IC10 = 0x44420043, - RTD_IC11 = 0x44420044, - RTD_IC12 = 0x44420045, - RTD_IC13 = 0x44420046, - RTD_IC14 = 0x44420047, - RTD_IC15 = 0x44420048, - RTD_IC16 = 0x44420049, - RTD_IC17 = 0x44420050, - RTD_IC18 = 0x44420051, + RTD_IC3 = 0x44420054, + RTD_IC4 = 0x44420056, + RTD_IC5 = 0x44420057, + RTD_IC6 = 0x44420058, + RTD_IC7 = 0x44420059, + RTD_IC8 = 0x44420060, + RTD_IC9 = 0x44420061, + RTD_IC10 = 0x44420062, + RTD_IC11 = 0x44420063, + RTD_IC12 = 0x44420064, + RTD_IC13 = 0x44420065, + RTD_IC14 = 0x44420066, + RTD_IC15 = 0x44420067, + RTD_IC16 = 0x44420068, + RTD_IC17 = 0x44420069, + RTD_IC18 = 0x44420070, - RAD_SENSOR = 0x44300052, + RAD_SENSOR = 0x44300071, /* 0x54 ('T') for test handlers */ TEST_TASK = 0x54694269, From cd395aa9c444d10846bc1ef5b263a7e09278e7d8 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Thu, 24 Jun 2021 16:43:15 +0200 Subject: [PATCH 024/111] updated object IDs again --- common/config/commonObjects.h | 12 ++++++------ tmtc | 2 +- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/common/config/commonObjects.h b/common/config/commonObjects.h index 24d7cc27..a8d8fc4f 100644 --- a/common/config/commonObjects.h +++ b/common/config/commonObjects.h @@ -17,12 +17,12 @@ enum commonObjects: uint32_t { CORE_CONTROLLER = 0x43000003, /* 0x44 ('D') for device handlers */ - P60DOCK_HANDLER = 0x44200000, - PDU1_HANDLER = 0x44200001, - PDU2_HANDLER = 0x44200002, - ACU_HANDLER = 0x44200003, - TMP1075_HANDLER_1 = 0x44400004, - TMP1075_HANDLER_2 = 0x44400005, + P60DOCK_HANDLER = 0x44250000, + PDU1_HANDLER = 0x44250001, + PDU2_HANDLER = 0x44250002, + ACU_HANDLER = 0x44250003, + TMP1075_HANDLER_1 = 0x44420004, + TMP1075_HANDLER_2 = 0x44420005, MGM_0_LIS3_HANDLER = 0x44120006, MGM_1_RM3100_HANDLER = 0x44120007, MGM_2_LIS3_HANDLER = 0x44120008, diff --git a/tmtc b/tmtc index f4e5bc19..8a66b2a7 160000 --- a/tmtc +++ b/tmtc @@ -1 +1 @@ -Subproject commit f4e5bc19568fc9786a3e5ac0a9164dbfe1dcbbe3 +Subproject commit 8a66b2a721882acf342d1e25c9967db3651a919f From a167b53096098ce63c23a623bacd33a3586c0560 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Thu, 24 Jun 2021 16:49:36 +0200 Subject: [PATCH 025/111] moved some object ids --- common/config/commonObjects.h | 51 +++++++++++++++------ linux/fsfwconfig/objects/systemObjectList.h | 31 ++----------- tmtc | 2 +- 3 files changed, 42 insertions(+), 42 deletions(-) diff --git a/common/config/commonObjects.h b/common/config/commonObjects.h index a8d8fc4f..205c025f 100644 --- a/common/config/commonObjects.h +++ b/common/config/commonObjects.h @@ -35,22 +35,43 @@ enum commonObjects: uint32_t { IMTQ_HANDLER = 0x44140014, PLOC_HANDLER = 0x44330015, - SUS_1 = 0x44000016, - SUS_2 = 0x44000017, - SUS_3 = 0x44000018, - SUS_4 = 0x44000019, - SUS_5 = 0x44000020, - SUS_6 = 0x44000021, - SUS_7 = 0x44000022, - SUS_8 = 0x44000023, - SUS_9 = 0x44000024, - SUS_10 = 0x44000025, - SUS_11 = 0x44000026, - SUS_12 = 0x44000027, - SUS_13 = 0x44000028, + /** + * Not yet specified which pt1000 will measure which device/location in the satellite. + * Therefore object ids are named according to the IC naming of the RTDs in the schematic. + */ + RTD_IC3 = 0x44420016, + RTD_IC4 = 0x44420017, + RTD_IC5 = 0x44420018, + RTD_IC6 = 0x44420019, + RTD_IC7 = 0x44420020, + RTD_IC8 = 0x44420021, + RTD_IC9 = 0x44420022, + RTD_IC10 = 0x44420023, + RTD_IC11 = 0x44420024, + RTD_IC12 = 0x44420025, + RTD_IC13 = 0x44420026, + RTD_IC14 = 0x44420027, + RTD_IC15 = 0x44420028, + RTD_IC16 = 0x44420029, + RTD_IC17 = 0x44420030, + RTD_IC18 = 0x44420031, - GPS0_HANDLER = 0x44130029, - GPS1_HANDLER = 0x44130130 + SUS_1 = 0x44120032, + SUS_2 = 0x44120033, + SUS_3 = 0x44120034, + SUS_4 = 0x44120035, + SUS_5 = 0x44120036, + SUS_6 = 0x44120037, + SUS_7 = 0x44120038, + SUS_8 = 0x44120039, + SUS_9 = 0x44120040, + SUS_10 = 0x44120041, + SUS_11 = 0x44120042, + SUS_12 = 0x44120043, + SUS_13 = 0x44120044, + + GPS0_HANDLER = 0x44130045, + GPS1_HANDLER = 0x44130146 }; } diff --git a/linux/fsfwconfig/objects/systemObjectList.h b/linux/fsfwconfig/objects/systemObjectList.h index 05fbc997..eb5333c2 100644 --- a/linux/fsfwconfig/objects/systemObjectList.h +++ b/linux/fsfwconfig/objects/systemObjectList.h @@ -49,32 +49,11 @@ enum sourceObjects: uint32_t { GPIO_IF = 0x49010005, /* Custom device handler */ - PCDU_HANDLER = 0x44200050, - SOLAR_ARRAY_DEPL_HANDLER = 0x44410051, - SYRLINKS_HK_HANDLER = 0x44530052, - HEATER_HANDLER = 0x44410053, - /** - * Not yet specified which pt1000 will measure which device/location in the satellite. - * Therefore object ids are named according to the IC naming of the RTDs in the schematic. - */ - RTD_IC3 = 0x44420054, - RTD_IC4 = 0x44420056, - RTD_IC5 = 0x44420057, - RTD_IC6 = 0x44420058, - RTD_IC7 = 0x44420059, - RTD_IC8 = 0x44420060, - RTD_IC9 = 0x44420061, - RTD_IC10 = 0x44420062, - RTD_IC11 = 0x44420063, - RTD_IC12 = 0x44420064, - RTD_IC13 = 0x44420065, - RTD_IC14 = 0x44420066, - RTD_IC15 = 0x44420067, - RTD_IC16 = 0x44420068, - RTD_IC17 = 0x44420069, - RTD_IC18 = 0x44420070, - - RAD_SENSOR = 0x44300071, + PCDU_HANDLER = 0x442000A1, + SOLAR_ARRAY_DEPL_HANDLER = 0x444100A2, + SYRLINKS_HK_HANDLER = 0x445300A3, + HEATER_HANDLER = 0x444100A4, + RAD_SENSOR = 0x443200A5, /* 0x54 ('T') for test handlers */ TEST_TASK = 0x54694269, diff --git a/tmtc b/tmtc index 8a66b2a7..2a986248 160000 --- a/tmtc +++ b/tmtc @@ -1 +1 @@ -Subproject commit 8a66b2a721882acf342d1e25c9967db3651a919f +Subproject commit 2a9862489d57e2ccbf8b9ca5017f5e89395acddf From d0dd39986c4292ba1bea6fd84400291ce43eae1b Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Thu, 24 Jun 2021 16:50:36 +0200 Subject: [PATCH 026/111] logical addresses fix --- linux/fsfwconfig/devices/addresses.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/linux/fsfwconfig/devices/addresses.h b/linux/fsfwconfig/devices/addresses.h index 0deb8490..99fa00ac 100644 --- a/linux/fsfwconfig/devices/addresses.h +++ b/linux/fsfwconfig/devices/addresses.h @@ -17,7 +17,8 @@ namespace addresses { GYRO_0_ADIS = objects::GYRO_0_ADIS_HANDLER, GYRO_1_L3G = objects::GYRO_1_L3G_HANDLER, - GYRO_2_L3G = objects::GYRO_2_L3G_HANDLER, + GYRO_2_ADIS = objects::GYRO_2_ADIS_HANDLER, + GYRO_3_L3G = objects::GYRO_3_L3G_HANDLER, RAD_SENSOR = objects::RAD_SENSOR, From b5fdeb93bb70f26a1ee19c567d937eda66e9b0c8 Mon Sep 17 00:00:00 2001 From: "Jakob.Meier" Date: Thu, 24 Jun 2021 17:32:42 +0200 Subject: [PATCH 027/111] get temperature and status of reaction wheel --- bsp_q7s/spiCallbacks/rwSpiCallback.cpp | 127 ++++++------------ bsp_q7s/spiCallbacks/rwSpiCallback.h | 9 ++ fsfw_hal | 2 +- mission/devices/RwHandler.cpp | 39 ++++-- .../devices/devicedefinitions/RwDefinitions.h | 9 ++ 5 files changed, 89 insertions(+), 97 deletions(-) diff --git a/bsp_q7s/spiCallbacks/rwSpiCallback.cpp b/bsp_q7s/spiCallbacks/rwSpiCallback.cpp index 2ad2d9fd..41ba70d9 100644 --- a/bsp_q7s/spiCallbacks/rwSpiCallback.cpp +++ b/bsp_q7s/spiCallbacks/rwSpiCallback.cpp @@ -62,14 +62,7 @@ ReturnValue_t rwSpiCallback(SpiComIF* comIf, SpiCookie *cookie, const uint8_t *s if (write(fileDescriptor, writeBuffer, writeSize) != static_cast(writeSize)) { sif::error << "rwSpiCallback: Write failed!" << std::endl; - if(gpioId != gpio::NO_GPIO) { - if (gpioIF->pullHigh(gpioId) != HasReturnvaluesIF::RETURN_OK) { - sif::error << "rwSpiCallback: Failed to pull chip select high" << std::endl; - } - } - if(mutex->unlockMutex() != HasReturnvaluesIF::RETURN_OK) { - sif::error << "rwSpiCallback: Failed to unlock mutex" << std::endl;; - } + closeSpi(gpioId, gpioIF, mutex); return RwHandler::SPI_WRITE_FAILURE; } @@ -94,14 +87,7 @@ ReturnValue_t rwSpiCallback(SpiComIF* comIf, SpiCookie *cookie, const uint8_t *s } if (write(fileDescriptor, writeBuffer, writeSize) != static_cast(writeSize)) { sif::error << "rwSpiCallback: Write failed!" << std::endl; - if(gpioId != gpio::NO_GPIO) { - if (gpioIF->pullHigh(gpioId) != HasReturnvaluesIF::RETURN_OK) { - sif::error << "rwSpiCallback: Failed to pull chip select high" << std::endl; - } - } - if(mutex->unlockMutex() != HasReturnvaluesIF::RETURN_OK) { - sif::error << "rwSpiCallback: Failed to unlock mutex"; - } + closeSpi(gpioId, gpioIF, mutex); return RwHandler::SPI_WRITE_FAILURE; } idx++; @@ -113,28 +99,14 @@ ReturnValue_t rwSpiCallback(SpiComIF* comIf, SpiCookie *cookie, const uint8_t *s if (write(fileDescriptor, writeBuffer, writeSize) != static_cast(writeSize)) { sif::error << "rwSpiCallback: Write failed!" << std::endl; - if(gpioId != gpio::NO_GPIO) { - if (gpioIF->pullHigh(gpioId) != HasReturnvaluesIF::RETURN_OK) { - sif::error << "rwSpiCallback: Failed to pull chip select high" << std::endl; - } - } - if(mutex->unlockMutex() != HasReturnvaluesIF::RETURN_OK) { - sif::error << "rwSpiCallback: Failed to unlock mutex"; - } + closeSpi(gpioId, gpioIF, mutex); return RwHandler::SPI_WRITE_FAILURE; } uint8_t* rxBuf = nullptr; result = comIf->getReadBuffer(cookie->getSpiAddress(), &rxBuf); if(result != HasReturnvaluesIF::RETURN_OK) { - if(gpioId != gpio::NO_GPIO) { - if (gpioIF->pullHigh(gpioId) != HasReturnvaluesIF::RETURN_OK) { - sif::error << "rwSpiCallback: Failed to pull chip select high" << std::endl; - } - } - if(mutex->unlockMutex() != HasReturnvaluesIF::RETURN_OK) { - sif::error << "rwSpiCallback: Failed to unlock mutex"; - } + closeSpi(gpioId, gpioIF, mutex); return result; } @@ -143,56 +115,40 @@ ReturnValue_t rwSpiCallback(SpiComIF* comIf, SpiCookie *cookie, const uint8_t *s /** There must be a delay of 20 ms after sending the command */ usleep(RwDefinitions::SPI_REPLY_DELAY); - /** Receiving reply data */ - uint8_t byteRead = 0; - /** Reading the reply frame */ -// if(read(fileDescriptor, &byteRead, 1) != 1) { -// if(gpioId != gpio::NO_GPIO) { -// if (gpioIF->pullHigh(gpioId) != HasReturnvaluesIF::RETURN_OK) { -// sif::error << "rwSpiCallback: Failed to pull chip select high" << std::endl; -// } -// } -// if(mutex->unlockMutex() != HasReturnvaluesIF::RETURN_OK) { -// sif::error << "rwSpiCallback: Failed to unlock mutex"; -// } -// sif::error << "rwSpiCallback: Failed to read first byte of reply frame" << std::endl; -// return RwHandler::SPI_READ_FAILURE; -// } - - uint8_t readbuffer[10]; - if(read(fileDescriptor, readbuffer, 10) != 10) { - sif::error << "Failed to read all bytes" << std::endl;; - } - - /** First byte must be the start sign 0x7E */ - if (byteRead != 0x7E) { - sif::error << "rwSpiCallback: First byte of reply is not 0x7E" << std::endl; - if(gpioId != gpio::NO_GPIO) { - if (gpioIF->pullHigh(gpioId) != HasReturnvaluesIF::RETURN_OK) { - sif::error << "rwSpiCallback: Failed to pull chip select high" << std::endl; - } - } - if(mutex->unlockMutex() != HasReturnvaluesIF::RETURN_OK) { - sif::error << "rwSpiCallback: Failed to unlock mutex"; - } - return RwHandler::MISSING_START_SIGN; - } - /** * The reaction wheel responds with empty frames while preparing the reply data. * However, receiving more than 5 empty frames will be interpreted as an error. */ + uint8_t byteRead = 0; for (int idx = 0; idx < 10; idx++) { - sif::error << "rwSpiCallback: Empty frame timeout"; - return RwHandler::NO_REPLY; + if(read(fileDescriptor, &byteRead, 1) != 1) { + sif::error << "rwSpiCallback: Read failed" << std::endl; + closeSpi(gpioId, gpioIF, mutex); + return RwHandler::SPI_READ_FAILURE; + } + + if (byteRead != 0x7E) { + break; + } + + if (idx == 9) { + sif::error << "rwSpiCallback: Empty frame timeout" << std::endl; + closeSpi(gpioId, gpioIF, mutex); + return RwHandler::NO_REPLY; + } } size_t decodedFrameLen = 0; - for (; decodedFrameLen < replyBufferSize; decodedFrameLen++) { - byteRead = 0; - if(read(fileDescriptor, &byteRead, 1) != 1) { - sif::error << "rwSpiCallback: Read failed" << std::endl; - return RwHandler::SPI_READ_FAILURE; + while(decodedFrameLen < replyBufferSize) { + + /** First byte already read in */ + if (decodedFrameLen != 0) { + byteRead = 0; + if(read(fileDescriptor, &byteRead, 1) != 1) { + sif::error << "rwSpiCallback: Read failed" << std::endl; + result = RwHandler::SPI_READ_FAILURE; + break; + } } if (byteRead == 0x7E) { @@ -217,6 +173,7 @@ ReturnValue_t rwSpiCallback(SpiComIF* comIf, SpiCookie *cookie, const uint8_t *s } else { sif::error << "rwSpiCallback: Invalid substitute" << std::endl; + closeSpi(gpioId, gpioIF, mutex); result = RwHandler::INVALID_SUBSTITUTE; break; } @@ -250,16 +207,18 @@ ReturnValue_t rwSpiCallback(SpiComIF* comIf, SpiCookie *cookie, const uint8_t *s cookie->assignTransferSize(decodedFrameLen); - if(gpioId != gpio::NO_GPIO) { - if (gpioIF->pullHigh(gpioId) != HasReturnvaluesIF::RETURN_OK) { - sif::error << "rwSpiCallback: Failed to pull chip select high" << std::endl; - } - } + closeSpi(gpioId, gpioIF, mutex); - if(gpioId != gpio::NO_GPIO) { - if(mutex->unlockMutex() != HasReturnvaluesIF::RETURN_OK) { - sif::error << "rwSpiCallback: Failed to unlock mutex" << std::endl; - } - } return result; } + +void closeSpi (gpioId_t gpioId, GpioIF* gpioIF, MutexIF* mutex) { + if(gpioId != gpio::NO_GPIO) { + if (gpioIF->pullHigh(gpioId) != HasReturnvaluesIF::RETURN_OK) { + sif::error << "closeSpi: Failed to pull chip select high" << std::endl; + } + } + if(mutex->unlockMutex() != HasReturnvaluesIF::RETURN_OK) { + sif::error << "closeSpi: Failed to unlock mutex" << std::endl;; + } +} diff --git a/bsp_q7s/spiCallbacks/rwSpiCallback.h b/bsp_q7s/spiCallbacks/rwSpiCallback.h index d882bee4..e684c1c1 100644 --- a/bsp_q7s/spiCallbacks/rwSpiCallback.h +++ b/bsp_q7s/spiCallbacks/rwSpiCallback.h @@ -18,4 +18,13 @@ ReturnValue_t rwSpiCallback(SpiComIF* comIf, SpiCookie *cookie, const uint8_t *sendData, size_t sendLen, void* args); +/** + * @brief This function closes a spi session. Pulls the chip select to high an releases the + * mutex. + * @param gpioId Gpio ID of chip select + * @param gpioIF Pointer to gpio interface to drive the chip select + * @param mutex The spi mutex + */ +void closeSpi(gpioId_t gpioId, GpioIF* gpioIF, MutexIF* mutex); + #endif /* BSP_Q7S_RW_SPI_CALLBACK_H_ */ diff --git a/fsfw_hal b/fsfw_hal index 8fe5d0af..2e243e3b 160000 --- a/fsfw_hal +++ b/fsfw_hal @@ -1 +1 @@ -Subproject commit 8fe5d0afa0857025d9dee3c6f266c2503a22c517 +Subproject commit 2e243e3b294870b0c93f85c6b8ff0c74f4f9cce7 diff --git a/mission/devices/RwHandler.cpp b/mission/devices/RwHandler.cpp index a80c97cc..23c49eba 100644 --- a/mission/devices/RwHandler.cpp +++ b/mission/devices/RwHandler.cpp @@ -40,9 +40,11 @@ ReturnValue_t RwHandler::buildNormalDeviceCommand(DeviceCommandId_t * id) { switch (communicationStep) { case CommunicationStep::READ_TEMPERATURE: *id = RwDefinitions::GET_TEMPERATURE; + communicationStep = CommunicationStep::GET_RW_SATUS; break; case CommunicationStep::GET_RW_SATUS: *id = RwDefinitions::GET_RW_STATUS; + communicationStep = CommunicationStep::READ_TEMPERATURE; break; default: sif::debug << "RwHandler::buildNormalDeviceCommand: Invalid communication step" @@ -61,6 +63,12 @@ ReturnValue_t RwHandler::buildCommandFromCommand(DeviceCommandId_t deviceCommand ReturnValue_t result = RETURN_OK; switch (deviceCommand) { + case (RwDefinitions::RESET_MCU): { + commandBuffer[0] = static_cast(RwDefinitions::RESET_MCU); + rawPacket = commandBuffer; + rawPacketLen = 1; + return RETURN_OK; + } case (RwDefinitions::GET_RW_STATUS): { prepareGetStatusCmd(commandData, commandDataLen); return RETURN_OK; @@ -89,6 +97,9 @@ ReturnValue_t RwHandler::buildCommandFromCommand(DeviceCommandId_t deviceCommand } void RwHandler::fillCommandAndReplyMap() { + this->insertInCommandMap(RwDefinitions::RESET_MCU); + this->insertInCommandAndReplyMap(RwDefinitions::GET_RW_STATUS, 1, &statusSet, + RwDefinitions::SIZE_GET_RW_STATUS); this->insertInCommandAndReplyMap(RwDefinitions::GET_TEMPERATURE, 1, &temperatureSet, RwDefinitions::SIZE_GET_TEMPERATURE_REPLY); this->insertInCommandAndReplyMap(RwDefinitions::SET_SPEED, 1, nullptr, @@ -98,7 +109,7 @@ void RwHandler::fillCommandAndReplyMap() { ReturnValue_t RwHandler::scanForReply(const uint8_t *start, size_t remainingSize, DeviceCommandId_t *foundId, size_t *foundLen) { - switch (*(start + 1)) { + switch (*(start)) { case (static_cast(RwDefinitions::GET_RW_STATUS)): { *foundLen = RwDefinitions::SIZE_GET_RW_STATUS; *foundId = RwDefinitions::GET_RW_STATUS; @@ -129,14 +140,15 @@ ReturnValue_t RwHandler::scanForReply(const uint8_t *start, size_t remainingSize ReturnValue_t RwHandler::interpretDeviceReply(DeviceCommandId_t id, const uint8_t *packet) { /** Check result code */ - if (*(packet + 1) != 0) { + if (*(packet + 1) == RwDefinitions::ERROR) { return EXECUTION_FAILED; } /** Received in little endian byte order */ uint16_t replyCrc = *(packet + sizeOfReply - 1) << 8 | *(packet + sizeOfReply - 2) ; - if (CRC::crc16ccitt(packet, sizeOfReply, 0xFFFF) != replyCrc) { + if (CRC::crc16ccitt(packet, sizeOfReply - 2, 0xFFFF) != replyCrc) { + sif::error << "RwHandler::interpretDeviceReply: cRC error" << std::endl; return CRC_ERROR; } @@ -237,10 +249,12 @@ void RwHandler::prepareSetSpeedCmd(const uint8_t * commandData, size_t commandDa } void RwHandler::handleGetRwStatusReply(const uint8_t* packet) { - uint8_t offset = 0; - statusSet.currSpeed = *(packet + 3) << 24 | *(packet + 2) << 16 | *(packet + 1) << 1 | *packet; + uint8_t offset = 2; + statusSet.currSpeed = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 + | *(packet + offset + 1) << 1 | *(packet + offset); offset += 4; - statusSet.referenceSpeed = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 | *(packet + offset + 1) << 1 | *(packet + offset); + statusSet.referenceSpeed = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 + | *(packet + offset + 1) << 1 | *(packet + offset); offset += 4; statusSet.state = *(packet + offset); offset += 1; @@ -251,16 +265,17 @@ void RwHandler::handleGetRwStatusReply(const uint8_t* packet) { << " * 0.1 RPM" << std::endl; sif::info << "RwHandler::handleGetRwStatusReply: Reference speed is: " << statusSet.referenceSpeed << " * 0.1 RPM" << std::endl; - sif::info << "RwHandler::handleGetRwStatusReply: State is: " << statusSet.state - << " * 0.1 RPM" << std::endl; - sif::info << "RwHandler::handleGetRwStatusReply: clc mode is: " << statusSet.clcMode - << " * 0.1 RPM" << std::endl; + sif::info << "RwHandler::handleGetRwStatusReply: State is: " + << (unsigned int) statusSet.state.value << std::endl; + sif::info << "RwHandler::handleGetRwStatusReply: clc mode is: " + << (unsigned int) statusSet.clcMode.value << std::endl; #endif } void RwHandler::handleTemperatureReply(const uint8_t* packet) { - temperatureSet.temperatureCelcius = *(packet + 3) << 24 | *(packet + 2) << 16 - | *(packet + 1) << 1 | *packet; + uint8_t offset = 2; + temperatureSet.temperatureCelcius = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 + | *(packet + offset + 1) << 1 | *(packet + offset); #if OBSW_VERBOSE_LEVEL >= 1 && RW_DEBUG == 1 sif::info << "RwHandler::handleTemperatureReply: Temperature: " << temperatureSet.temperatureCelcius << " °C" << std::endl; diff --git a/mission/devices/devicedefinitions/RwDefinitions.h b/mission/devices/devicedefinitions/RwDefinitions.h index 23907eb3..4fe2d368 100644 --- a/mission/devices/devicedefinitions/RwDefinitions.h +++ b/mission/devices/devicedefinitions/RwDefinitions.h @@ -18,6 +18,15 @@ enum PoolIds: lp_id_t { CLC_MODE }; +enum States: uint8_t { + ERROR, + IDLE, + COASTING, + RUNNING_SPEED_STABLE, + RUNNING_SPEED_CHANGING +}; + +static const DeviceCommandId_t RESET_MCU = 1; static const DeviceCommandId_t GET_RW_STATUS = 4; static const DeviceCommandId_t SET_SPEED = 6; static const DeviceCommandId_t GET_TEMPERATURE = 8; From 675cd29df38505e60fb55df8c855b9ee77ac3e23 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Thu, 24 Jun 2021 17:52:09 +0200 Subject: [PATCH 028/111] added assembly index --- common/config/commonObjects.h | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/common/config/commonObjects.h b/common/config/commonObjects.h index 205c025f..93369350 100644 --- a/common/config/commonObjects.h +++ b/common/config/commonObjects.h @@ -24,13 +24,13 @@ enum commonObjects: uint32_t { TMP1075_HANDLER_1 = 0x44420004, TMP1075_HANDLER_2 = 0x44420005, MGM_0_LIS3_HANDLER = 0x44120006, - MGM_1_RM3100_HANDLER = 0x44120007, - MGM_2_LIS3_HANDLER = 0x44120008, - MGM_3_RM3100_HANDLER = 0x44120009, + MGM_1_RM3100_HANDLER = 0x44120107, + MGM_2_LIS3_HANDLER = 0x44120208, + MGM_3_RM3100_HANDLER = 0x44120309, GYRO_0_ADIS_HANDLER = 0x44120010, - GYRO_1_L3G_HANDLER = 0x44120011, - GYRO_2_ADIS_HANDLER = 0x44120012, - GYRO_3_L3G_HANDLER = 0x44120013, + GYRO_1_L3G_HANDLER = 0x44120111, + GYRO_2_ADIS_HANDLER = 0x44120212, + GYRO_3_L3G_HANDLER = 0x44120313, IMTQ_HANDLER = 0x44140014, PLOC_HANDLER = 0x44330015, From 06e719327639e27c72c599e3c6dda613bd5a2d91 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Thu, 24 Jun 2021 18:05:41 +0200 Subject: [PATCH 029/111] set id is now 0 --- mission/devices/devicedefinitions/MGMHandlerLIS3Definitions.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/mission/devices/devicedefinitions/MGMHandlerLIS3Definitions.h b/mission/devices/devicedefinitions/MGMHandlerLIS3Definitions.h index f58d6f03..c15b60ef 100644 --- a/mission/devices/devicedefinitions/MGMHandlerLIS3Definitions.h +++ b/mission/devices/devicedefinitions/MGMHandlerLIS3Definitions.h @@ -20,8 +20,8 @@ static constexpr size_t MAX_BUFFER_SIZE = 16; static constexpr uint8_t GAUSS_TO_MICROTESLA_FACTOR = 100; -static const DeviceCommandId_t SETUP_MGM = 0x00; -static const DeviceCommandId_t READ_CONFIG_AND_DATA = 0x01; +static const DeviceCommandId_t READ_CONFIG_AND_DATA = 0x00; +static const DeviceCommandId_t SETUP_MGM = 0x01; static const DeviceCommandId_t READ_TEMPERATURE = 0x02; static const DeviceCommandId_t IDENTIFY_DEVICE = 0x03; static const DeviceCommandId_t TEMP_SENSOR_ENABLE = 0x04; From e5e3c6cacf90a8dd504e5cb23ac7628b4663be43 Mon Sep 17 00:00:00 2001 From: "Jakob.Meier" Date: Fri, 25 Jun 2021 12:07:33 +0200 Subject: [PATCH 030/111] updated tmtc --- tmtc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tmtc b/tmtc index 36582621..3d263737 160000 --- a/tmtc +++ b/tmtc @@ -1 +1 @@ -Subproject commit 36582621f2de1c558aa3909704545e326614d462 +Subproject commit 3d26373726199b0d07f0ce344a184ccd9a0a6041 From ced90934bbd18ab9a3bd2e379eb35559913e4b0e Mon Sep 17 00:00:00 2001 From: "Jakob.Meier" Date: Fri, 25 Jun 2021 12:17:07 +0200 Subject: [PATCH 031/111] added tmtc update --- tmtc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tmtc b/tmtc index 3d263737..899cd942 160000 --- a/tmtc +++ b/tmtc @@ -1 +1 @@ -Subproject commit 3d26373726199b0d07f0ce344a184ccd9a0a6041 +Subproject commit 899cd942ce7136f371e93d270a6c6c149c0698cb From ce3fee33e0b23bd3cdb4c2ff2f04ab6a22494474 Mon Sep 17 00:00:00 2001 From: Martin Zietz Date: Fri, 25 Jun 2021 15:25:54 +0200 Subject: [PATCH 032/111] rw handler fixes --- linux/fsfwconfig/OBSWConfig.h.in | 2 ++ .../pollingsequence/pollingSequenceFactory.cpp | 11 +++++++++++ mission/devices/RwHandler.cpp | 12 ++++++------ tmtc | 2 +- 4 files changed, 20 insertions(+), 7 deletions(-) diff --git a/linux/fsfwconfig/OBSWConfig.h.in b/linux/fsfwconfig/OBSWConfig.h.in index b3002cf4..ce1a7526 100644 --- a/linux/fsfwconfig/OBSWConfig.h.in +++ b/linux/fsfwconfig/OBSWConfig.h.in @@ -20,6 +20,7 @@ debugging. */ #define OBSW_PRINT_MISSED_DEADLINES 1 #define OBSW_ADD_TEST_CODE 1 #define OBSW_ADD_TEST_PST 1 +#define OBSW_ADD_GPS 0 #define TEST_LIBGPIOD 0 #define TEST_RADIATION_SENSOR_HANDLER 0 @@ -43,6 +44,7 @@ debugging. */ #define DEBUG_SUS 1 #define DEBUG_RTD 1 #define IMTQ_DEBUG 1 +#define RW_DEBUG 1 // Leave at one as the BSP is linux. Used by the ADIS16507 device handler #define OBSW_ADIS16507_LINUX_COM_IF 1 diff --git a/linux/fsfwconfig/pollingsequence/pollingSequenceFactory.cpp b/linux/fsfwconfig/pollingsequence/pollingSequenceFactory.cpp index 6ba4083d..9bb73857 100644 --- a/linux/fsfwconfig/pollingsequence/pollingSequenceFactory.cpp +++ b/linux/fsfwconfig/pollingsequence/pollingSequenceFactory.cpp @@ -432,50 +432,61 @@ ReturnValue_t pst::pstI2c(FixedTimeslotTaskIF *thisSequence) { ReturnValue_t pst::pstUart(FixedTimeslotTaskIF *thisSequence) { // Length of a communication cycle uint32_t length = thisSequence->getPeriodMs(); + thisSequence->addSlot(objects::PLOC_HANDLER, length * 0, DeviceHandlerIF::PERFORM_OPERATION); thisSequence->addSlot(objects::SYRLINKS_HK_HANDLER, length * 0, DeviceHandlerIF::PERFORM_OPERATION); +#if OBSW_ADD_GPS == 1 thisSequence->addSlot(objects::GPS0_HANDLER, length * 0, DeviceHandlerIF::PERFORM_OPERATION); thisSequence->addSlot(objects::GPS1_HANDLER, length * 0, DeviceHandlerIF::PERFORM_OPERATION); +#endif thisSequence->addSlot(objects::PLOC_HANDLER, length * 0.2, DeviceHandlerIF::SEND_WRITE); thisSequence->addSlot(objects::SYRLINKS_HK_HANDLER, length * 0.2, DeviceHandlerIF::SEND_WRITE); +#if OBSW_ADD_GPS == 1 thisSequence->addSlot(objects::GPS0_HANDLER, length * 0.2, DeviceHandlerIF::SEND_WRITE); thisSequence->addSlot(objects::GPS1_HANDLER, length * 0.2, DeviceHandlerIF::SEND_WRITE); +#endif thisSequence->addSlot(objects::PLOC_HANDLER, length * 0.4, DeviceHandlerIF::GET_WRITE); thisSequence->addSlot(objects::SYRLINKS_HK_HANDLER, length * 0.4, DeviceHandlerIF::GET_WRITE); +#if OBSW_ADD_GPS == 1 thisSequence->addSlot(objects::GPS0_HANDLER, length * 0.4, DeviceHandlerIF::GET_WRITE); thisSequence->addSlot(objects::GPS1_HANDLER, length * 0.4, DeviceHandlerIF::GET_WRITE); +#endif thisSequence->addSlot(objects::PLOC_HANDLER, length * 0.6, DeviceHandlerIF::SEND_READ); thisSequence->addSlot(objects::SYRLINKS_HK_HANDLER, length * 0.6, DeviceHandlerIF::SEND_READ); +#if OBSW_ADD_GPS == 1 thisSequence->addSlot(objects::GPS0_HANDLER, length * 0.6, DeviceHandlerIF::SEND_READ); thisSequence->addSlot(objects::GPS1_HANDLER, length * 0.6, DeviceHandlerIF::SEND_READ); +#endif thisSequence->addSlot(objects::PLOC_HANDLER, length * 0.8, DeviceHandlerIF::GET_READ); thisSequence->addSlot(objects::SYRLINKS_HK_HANDLER, length * 0.8, DeviceHandlerIF::GET_READ); +#if OBSW_ADD_GPS == 1 thisSequence->addSlot(objects::GPS0_HANDLER, length * 0.8, DeviceHandlerIF::GET_READ); thisSequence->addSlot(objects::GPS1_HANDLER, length * 0.8, DeviceHandlerIF::GET_READ); +#endif if (thisSequence->checkSequence() != HasReturnvaluesIF::RETURN_OK) { sif::error << "UART PST initialization failed" << std::endl; diff --git a/mission/devices/RwHandler.cpp b/mission/devices/RwHandler.cpp index 23c49eba..a9d9dde3 100644 --- a/mission/devices/RwHandler.cpp +++ b/mission/devices/RwHandler.cpp @@ -208,7 +208,7 @@ ReturnValue_t RwHandler::checkSpeedAndRampTime(const uint8_t* commandData, size_ return INVALID_SPEED; } - uint16_t rampTime = *commandData << 8 | *(commandData + 1); + uint16_t rampTime = *(commandData + 4) << 8 | *(commandData + 5); if (rampTime < 10 || rampTime > 10000) { sif::error << "RwHandler::checkSpeedAndRampTime: Command has invalid ramp time" @@ -238,8 +238,8 @@ void RwHandler::prepareSetSpeedCmd(const uint8_t * commandData, size_t commandDa commandBuffer[3] = *(commandData + 1); commandBuffer[4] = *commandData; /** Ramp time (ms) */ - commandBuffer[5] = *(commandData + 1); - commandBuffer[6] = *commandData; + commandBuffer[5] = *(commandData + 5); + commandBuffer[6] = *(commandData + 4); uint16_t crc = CRC::crc16ccitt(commandBuffer, 7, 0xFFFF); commandBuffer[7] = static_cast(crc & 0xFF); @@ -251,10 +251,10 @@ void RwHandler::prepareSetSpeedCmd(const uint8_t * commandData, size_t commandDa void RwHandler::handleGetRwStatusReply(const uint8_t* packet) { uint8_t offset = 2; statusSet.currSpeed = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 - | *(packet + offset + 1) << 1 | *(packet + offset); + | *(packet + offset + 1) << 8 | *(packet + offset); offset += 4; statusSet.referenceSpeed = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 - | *(packet + offset + 1) << 1 | *(packet + offset); + | *(packet + offset + 1) << 8 | *(packet + offset); offset += 4; statusSet.state = *(packet + offset); offset += 1; @@ -275,7 +275,7 @@ void RwHandler::handleGetRwStatusReply(const uint8_t* packet) { void RwHandler::handleTemperatureReply(const uint8_t* packet) { uint8_t offset = 2; temperatureSet.temperatureCelcius = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 - | *(packet + offset + 1) << 1 | *(packet + offset); + | *(packet + offset + 1) << 8 | *(packet + offset); #if OBSW_VERBOSE_LEVEL >= 1 && RW_DEBUG == 1 sif::info << "RwHandler::handleTemperatureReply: Temperature: " << temperatureSet.temperatureCelcius << " °C" << std::endl; diff --git a/tmtc b/tmtc index 899cd942..19b76d96 160000 --- a/tmtc +++ b/tmtc @@ -1 +1 @@ -Subproject commit 899cd942ce7136f371e93d270a6c6c149c0698cb +Subproject commit 19b76d961c61966a0093d3768f62d99196e1c9b2 From 0139df43714c1a130259e81984d394ece1f5511b Mon Sep 17 00:00:00 2001 From: "Jakob.Meier" Date: Fri, 25 Jun 2021 15:47:33 +0200 Subject: [PATCH 033/111] modified rw definitions --- mission/devices/devicedefinitions/RwDefinitions.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/mission/devices/devicedefinitions/RwDefinitions.h b/mission/devices/devicedefinitions/RwDefinitions.h index 4fe2d368..e07e01b0 100644 --- a/mission/devices/devicedefinitions/RwDefinitions.h +++ b/mission/devices/devicedefinitions/RwDefinitions.h @@ -27,6 +27,8 @@ enum States: uint8_t { }; static const DeviceCommandId_t RESET_MCU = 1; +static const DeviceCommandId_t GET_LAST_RESET_STATUS = 2; +static const DeviceCommandId_t CLEAR_LAST_RESET_STATUS = 3; static const DeviceCommandId_t GET_RW_STATUS = 4; static const DeviceCommandId_t SET_SPEED = 6; static const DeviceCommandId_t GET_TEMPERATURE = 8; From 7c8127714e33fc7ddfecfe33e66c30cf92fd1bf9 Mon Sep 17 00:00:00 2001 From: "Jakob.Meier" Date: Fri, 25 Jun 2021 16:00:32 +0200 Subject: [PATCH 034/111] added init command --- mission/devices/RwHandler.cpp | 17 ++++++++++++++++- mission/devices/RwHandler.h | 7 +++++++ .../devices/devicedefinitions/RwDefinitions.h | 1 + tmtc | 2 +- 4 files changed, 25 insertions(+), 2 deletions(-) diff --git a/mission/devices/RwHandler.cpp b/mission/devices/RwHandler.cpp index a9d9dde3..7254ee0e 100644 --- a/mission/devices/RwHandler.cpp +++ b/mission/devices/RwHandler.cpp @@ -55,7 +55,8 @@ ReturnValue_t RwHandler::buildNormalDeviceCommand(DeviceCommandId_t * id) { } ReturnValue_t RwHandler::buildTransitionDeviceCommand(DeviceCommandId_t * id) { - return RETURN_OK; + *id = RwDefinitions::INIT_RW_CONTROLLER; + return buildCommandFromCommand(*id, nullptr, 0);; } ReturnValue_t RwHandler::buildCommandFromCommand(DeviceCommandId_t deviceCommand, @@ -73,6 +74,10 @@ ReturnValue_t RwHandler::buildCommandFromCommand(DeviceCommandId_t deviceCommand prepareGetStatusCmd(commandData, commandDataLen); return RETURN_OK; } + case (RwDefinitions::INIT_RW_CONTROLLER): { + prepareInitRwCommand(); + return RETURN_OK; + } case (RwDefinitions::SET_SPEED): { if (commandDataLen != 6) { sif::error << "RwHandler::buildCommandFromCommand: Received set speed command with" @@ -100,6 +105,7 @@ void RwHandler::fillCommandAndReplyMap() { this->insertInCommandMap(RwDefinitions::RESET_MCU); this->insertInCommandAndReplyMap(RwDefinitions::GET_RW_STATUS, 1, &statusSet, RwDefinitions::SIZE_GET_RW_STATUS); + this->insertInCommandMap(RwDefinitions::INIT_RW_CONTROLLER); this->insertInCommandAndReplyMap(RwDefinitions::GET_TEMPERATURE, 1, &temperatureSet, RwDefinitions::SIZE_GET_TEMPERATURE_REPLY); this->insertInCommandAndReplyMap(RwDefinitions::SET_SPEED, 1, nullptr, @@ -228,6 +234,15 @@ void RwHandler::prepareGetTemperatureCmd() { rawPacketLen = 3; } +void RwHandler::prepareInitRwCommand() { + commandBuffer[0] = static_cast(RwDefinitions::INIT_RW_CONTROLLER); + uint16_t crc = CRC::crc16ccitt(commandBuffer, 1, 0xFFFF); + commandBuffer[1] = static_cast(crc & 0xFF); + commandBuffer[2] = static_cast(crc >> 8 & 0xFF); + rawPacket = commandBuffer; + rawPacketLen = 3; +} + void RwHandler::prepareSetSpeedCmd(const uint8_t * commandData, size_t commandDataLen) { commandBuffer[0] = static_cast(RwDefinitions::SET_SPEED); diff --git a/mission/devices/RwHandler.h b/mission/devices/RwHandler.h index 0a9d58d0..fcde9c81 100644 --- a/mission/devices/RwHandler.h +++ b/mission/devices/RwHandler.h @@ -121,6 +121,13 @@ private: */ void prepareGetTemperatureCmd(); + /** + * @brief This function fills the commandBuffer with the data to request initialize the + * reaction wheel controller. This command must be sent as soon as the state of a + * reaction wheel is equal to 1 which indicates an error. + */ + void prepareInitRwCommand(); + /** * @brief This function handles the reply of the get temperature command. * diff --git a/mission/devices/devicedefinitions/RwDefinitions.h b/mission/devices/devicedefinitions/RwDefinitions.h index e07e01b0..a38b0acf 100644 --- a/mission/devices/devicedefinitions/RwDefinitions.h +++ b/mission/devices/devicedefinitions/RwDefinitions.h @@ -30,6 +30,7 @@ static const DeviceCommandId_t RESET_MCU = 1; static const DeviceCommandId_t GET_LAST_RESET_STATUS = 2; static const DeviceCommandId_t CLEAR_LAST_RESET_STATUS = 3; static const DeviceCommandId_t GET_RW_STATUS = 4; +static const DeviceCommandId_t INIT_RW_CONTROLLER = 5; static const DeviceCommandId_t SET_SPEED = 6; static const DeviceCommandId_t GET_TEMPERATURE = 8; diff --git a/tmtc b/tmtc index 19b76d96..899cd942 160000 --- a/tmtc +++ b/tmtc @@ -1 +1 @@ -Subproject commit 19b76d961c61966a0093d3768f62d99196e1c9b2 +Subproject commit 899cd942ce7136f371e93d270a6c6c149c0698cb From 8ef9760f78b283d53ac94512b9f9556c63e3099c Mon Sep 17 00:00:00 2001 From: "Jakob.Meier" Date: Mon, 28 Jun 2021 08:57:37 +0200 Subject: [PATCH 035/111] added get reset and clear reset command to rw handler --- mission/devices/RwHandler.cpp | 90 ++++++++++++++++--- mission/devices/RwHandler.h | 37 +++++++- .../devices/devicedefinitions/RwDefinitions.h | 26 +++++- 3 files changed, 137 insertions(+), 16 deletions(-) diff --git a/mission/devices/RwHandler.cpp b/mission/devices/RwHandler.cpp index 7254ee0e..83a136b8 100644 --- a/mission/devices/RwHandler.cpp +++ b/mission/devices/RwHandler.cpp @@ -7,7 +7,7 @@ RwHandler::RwHandler(object_id_t objectId, object_id_t comIF, CookieIF * comCookie, LinuxLibgpioIF* gpioComIF, gpioId_t enableGpio) : DeviceHandlerBase(objectId, comIF, comCookie), gpioComIF(gpioComIF), enableGpio(enableGpio), - temperatureSet(this), statusSet(this) { + temperatureSet(this), statusSet(this), lastResetStatusSet(this) { if (comCookie == NULL) { sif::error << "RwHandler: Invalid com cookie" << std::endl; } @@ -20,6 +20,9 @@ RwHandler::~RwHandler() { } void RwHandler::doStartUp() { + if (!startupPerformed) { + return; + } if(gpioComIF->pullHigh(enableGpio) != RETURN_OK) { sif::debug << "RwHandler::doStartUp: Failed to pull enable gpio to high"; } @@ -34,6 +37,7 @@ void RwHandler::doShutDown() { if(gpioComIF->pullLow(enableGpio) != RETURN_OK) { sif::debug << "RwHandler::doStartUp: Failed to pull enable gpio to low"; } + startupPerformed = false; } ReturnValue_t RwHandler::buildNormalDeviceCommand(DeviceCommandId_t * id) { @@ -55,7 +59,25 @@ ReturnValue_t RwHandler::buildNormalDeviceCommand(DeviceCommandId_t * id) { } ReturnValue_t RwHandler::buildTransitionDeviceCommand(DeviceCommandId_t * id) { - *id = RwDefinitions::INIT_RW_CONTROLLER; + switch (startupStep) { + case StartupStep::GET_RESET_STATUS: + *id = RwDefinitions::GET_LAST_RESET_STATUS; + startupStep = StartupStep::CLEAR_RESET_STATUS; + break; + case StartupStep::CLEAR_RESET_STATUS: + *id = RwDefinitions::CLEAR_LAST_RESET_STATUS; + startupStep = StartupStep::INIT_RW; + break; + case StartupStep::INIT_RW: + *id = RwDefinitions::INIT_RW_CONTROLLER; + startupStep = StartupStep::GET_RESET_STATUS; + startupPerformed = true; + break; + default: + sif::debug << "RwHandler::buildTransitionDeviceCommand: Invalid startup step" + << std::endl; + break; + } return buildCommandFromCommand(*id, nullptr, 0);; } @@ -70,6 +92,14 @@ ReturnValue_t RwHandler::buildCommandFromCommand(DeviceCommandId_t deviceCommand rawPacketLen = 1; return RETURN_OK; } + case (RwDefinitions::GET_LAST_RESET_STATUS): { + prepareGetLastResetStatusCommand(); + return RETURN_OK; + } + case (RwDefinitions::CLEAR_LAST_RESET_STATUS): { + prepareClearResetStatusCommand(); + return RETURN_OK; + } case (RwDefinitions::GET_RW_STATUS): { prepareGetStatusCmd(commandData, commandDataLen); return RETURN_OK; @@ -103,6 +133,9 @@ ReturnValue_t RwHandler::buildCommandFromCommand(DeviceCommandId_t deviceCommand void RwHandler::fillCommandAndReplyMap() { this->insertInCommandMap(RwDefinitions::RESET_MCU); + this->insertInCommandAndReplyMap(RwDefinitions::GET_LAST_RESET_STATUS, 1, &lastResetStatusSet, + RwDefinitions::SIZE_GET_RESET_STATUS); + this->insertInCommandMap(RwDefinitions::CLEAR_LAST_RESET_STATUS); this->insertInCommandAndReplyMap(RwDefinitions::GET_RW_STATUS, 1, &statusSet, RwDefinitions::SIZE_GET_RW_STATUS); this->insertInCommandMap(RwDefinitions::INIT_RW_CONTROLLER); @@ -116,6 +149,11 @@ ReturnValue_t RwHandler::scanForReply(const uint8_t *start, size_t remainingSize DeviceCommandId_t *foundId, size_t *foundLen) { switch (*(start)) { + case (static_cast(RwDefinitions::GET_LAST_RESET_STATUS)): { + *foundLen = RwDefinitions::SIZE_GET_RESET_STATUS; + *foundId = RwDefinitions::GET_LAST_RESET_STATUS; + break; + } case (static_cast(RwDefinitions::GET_RW_STATUS)): { *foundLen = RwDefinitions::SIZE_GET_RW_STATUS; *foundId = RwDefinitions::GET_RW_STATUS; @@ -159,6 +197,10 @@ ReturnValue_t RwHandler::interpretDeviceReply(DeviceCommandId_t id, const uint8_ } switch (id) { + case (RwDefinitions::GET_LAST_RESET_STATUS): { + handleResetStatusReply(packet); + break; + } case (RwDefinitions::GET_RW_STATUS): { handleGetRwStatusReply(packet); break; @@ -195,6 +237,24 @@ ReturnValue_t RwHandler::initializeLocalDataPool(localpool::DataPool& localDataP return RETURN_OK; } +void RwHandler::prepareGetLastResetStatusCommand() { + commandBuffer[0] = static_cast(RwDefinitions::GET_LAST_RESET_STATUS); + uint16_t crc = CRC::crc16ccitt(commandBuffer, 1, 0xFFFF); + commandBuffer[1] = static_cast(crc & 0xFF); + commandBuffer[2] = static_cast(crc >> 8 & 0xFF); + rawPacket = commandBuffer; + rawPacketLen = 3; +} + +void RwHandler::prepareClearResetStatusCommand() { + commandBuffer[0] = static_cast(RwDefinitions::CLEAR_LAST_RESET_STATUS); + uint16_t crc = CRC::crc16ccitt(commandBuffer, 1, 0xFFFF); + commandBuffer[1] = static_cast(crc & 0xFF); + commandBuffer[2] = static_cast(crc >> 8 & 0xFF); + rawPacket = commandBuffer; + rawPacketLen = 3; +} + void RwHandler::prepareGetStatusCmd(const uint8_t * commandData, size_t commandDataLen) { commandBuffer[0] = static_cast(RwDefinitions::GET_RW_STATUS); @@ -225,15 +285,6 @@ ReturnValue_t RwHandler::checkSpeedAndRampTime(const uint8_t* commandData, size_ return RETURN_OK; } -void RwHandler::prepareGetTemperatureCmd() { - commandBuffer[0] = static_cast(RwDefinitions::GET_TEMPERATURE); - uint16_t crc = CRC::crc16ccitt(commandBuffer, 1, 0xFFFF); - commandBuffer[1] = static_cast(crc & 0xFF); - commandBuffer[2] = static_cast(crc >> 8 & 0xFF); - rawPacket = commandBuffer; - rawPacketLen = 3; -} - void RwHandler::prepareInitRwCommand() { commandBuffer[0] = static_cast(RwDefinitions::INIT_RW_CONTROLLER); uint16_t crc = CRC::crc16ccitt(commandBuffer, 1, 0xFFFF); @@ -243,6 +294,14 @@ void RwHandler::prepareInitRwCommand() { rawPacketLen = 3; } +void RwHandler::prepareGetTemperatureCmd() { + commandBuffer[0] = static_cast(RwDefinitions::GET_TEMPERATURE); + uint16_t crc = CRC::crc16ccitt(commandBuffer, 1, 0xFFFF); + commandBuffer[1] = static_cast(crc & 0xFF); + commandBuffer[2] = static_cast(crc >> 8 & 0xFF); + rawPacket = commandBuffer; + rawPacketLen = 3; +} void RwHandler::prepareSetSpeedCmd(const uint8_t * commandData, size_t commandDataLen) { commandBuffer[0] = static_cast(RwDefinitions::SET_SPEED); @@ -263,6 +322,15 @@ void RwHandler::prepareSetSpeedCmd(const uint8_t * commandData, size_t commandDa rawPacketLen = 9; } +void RwHandler::handleResetStatusReply(const uint8_t* packet) { + uint8_t offset = 2; + lastResetStatusSet.lastResetStatus = *(packet + offset); +#if OBSW_VERBOSE_LEVEL >= 1 && RW_DEBUG == 1 + sif::info << "RwHandler::handleResetStatusReply: Last reset status: " + << static_cast(lastResetStatusSet.lastResetStatus.value) << std::endl; +#endif +} + void RwHandler::handleGetRwStatusReply(const uint8_t* packet) { uint8_t offset = 2; statusSet.currSpeed = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 diff --git a/mission/devices/RwHandler.h b/mission/devices/RwHandler.h index fcde9c81..29a2ae52 100644 --- a/mission/devices/RwHandler.h +++ b/mission/devices/RwHandler.h @@ -84,6 +84,7 @@ private: RwDefinitions::TemperatureSet temperatureSet; RwDefinitions::StatusSet statusSet; + RwDefinitions::LastResetSatus lastResetStatusSet; uint8_t commandBuffer[RwDefinitions::MAX_CMD_SIZE]; @@ -95,8 +96,28 @@ private: CommunicationStep communicationStep = CommunicationStep::READ_TEMPERATURE; + enum class StartupStep { + GET_RESET_STATUS, + CLEAR_RESET_STATUS, + INIT_RW + }; + + StartupStep startupStep = StartupStep::GET_RESET_STATUS; + size_t sizeOfReply = 0; + bool startupPerformed = false; + + /** + * @brief This function prepares the command to request the last reset status + */ + void prepareGetLastResetStatusCommand(); + + /** + * @brief Fills the command buffer with the command to clear the reset status. + */ + void prepareClearResetStatusCommand(); + /** * @brief This function prepares the send buffer with the data to request the status of * the reaction wheel. @@ -110,6 +131,13 @@ private: */ ReturnValue_t checkSpeedAndRampTime(const uint8_t * commandData, size_t commandDataLen); + /** + * @brief This function fills the commandBuffer with the data to request initialize the + * reaction wheel controller. This command must be sent as soon as the state of a + * reaction wheel is equal to 1 which indicates an error. + */ + void prepareInitRwCommand(); + /** * @brief This function prepares the set speed command from the commandData received with * an action message. @@ -122,11 +150,12 @@ private: void prepareGetTemperatureCmd(); /** - * @brief This function fills the commandBuffer with the data to request initialize the - * reaction wheel controller. This command must be sent as soon as the state of a - * reaction wheel is equal to 1 which indicates an error. + * @brief This function writes the last reset status retrieved with the get last reset status + * command into the reset status dataset. + * + * @param packet Pointer to the buffer holding the reply data. */ - void prepareInitRwCommand(); + void handleResetStatusReply(const uint8_t* packet); /** * @brief This function handles the reply of the get temperature command. diff --git a/mission/devices/devicedefinitions/RwDefinitions.h b/mission/devices/devicedefinitions/RwDefinitions.h index a38b0acf..73de0e57 100644 --- a/mission/devices/devicedefinitions/RwDefinitions.h +++ b/mission/devices/devicedefinitions/RwDefinitions.h @@ -15,7 +15,8 @@ enum PoolIds: lp_id_t { CURR_SPEED, REFERENCE_SPEED, STATE, - CLC_MODE + CLC_MODE, + LAST_RESET_STATUS }; enum States: uint8_t { @@ -30,13 +31,16 @@ static const DeviceCommandId_t RESET_MCU = 1; static const DeviceCommandId_t GET_LAST_RESET_STATUS = 2; static const DeviceCommandId_t CLEAR_LAST_RESET_STATUS = 3; static const DeviceCommandId_t GET_RW_STATUS = 4; +/** This command is needed to recover from error state */ static const DeviceCommandId_t INIT_RW_CONTROLLER = 5; static const DeviceCommandId_t SET_SPEED = 6; static const DeviceCommandId_t GET_TEMPERATURE = 8; static const uint32_t TEMPERATURE_SET_ID = GET_TEMPERATURE; static const uint32_t STATUS_SET_ID = GET_RW_STATUS; +static const uint32_t LAST_RESET_ID = GET_LAST_RESET_STATUS; +static const size_t SIZE_GET_RESET_STATUS = 5; static const size_t SIZE_GET_RW_STATUS = 14; static const size_t SIZE_SET_SPEED_REPLY = 4; static const size_t SIZE_GET_TEMPERATURE_REPLY = 8; @@ -47,6 +51,7 @@ static const size_t SIZE_GET_TELEMETRY_REPLY = 83; static const size_t MAX_CMD_SIZE = 9; static const size_t MAX_REPLY_SIZE = SIZE_GET_TELEMETRY_REPLY; +static const uint8_t LAST_RESET_ENTRIES = 1; static const uint8_t TEMPERATURE_SET_ENTRIES = 1; static const uint8_t STATUS_SET_ENTRIES = 4; @@ -94,6 +99,25 @@ public: PoolIds::CLC_MODE, this); }; +/** + * @brief This dataset stores the last reset status. + */ +class LastResetSatus: + public StaticLocalDataSet { +public: + + LastResetSatus(HasLocalDataPoolIF* owner): + StaticLocalDataSet(owner, LAST_RESET_ID) { + } + + LastResetSatus(object_id_t objectId): + StaticLocalDataSet(sid_t(objectId, LAST_RESET_ID)) { + } + + lp_var_t lastResetStatus = lp_var_t(sid.objectId, + PoolIds::LAST_RESET_STATUS, this); +}; + } #endif /* MISSION_DEVICES_DEVICEDEFINITIONS_RWDEFINITIONS_H_ */ From 516ef34b21a0f563418729c23b64f421ecd3467e Mon Sep 17 00:00:00 2001 From: "Jakob.Meier" Date: Mon, 28 Jun 2021 09:31:10 +0200 Subject: [PATCH 036/111] added periodically polling of reset status in rw handler --- mission/devices/RwHandler.cpp | 6 +++++- mission/devices/RwHandler.h | 1 + 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/mission/devices/RwHandler.cpp b/mission/devices/RwHandler.cpp index 83a136b8..7d84bfcf 100644 --- a/mission/devices/RwHandler.cpp +++ b/mission/devices/RwHandler.cpp @@ -42,13 +42,17 @@ void RwHandler::doShutDown() { ReturnValue_t RwHandler::buildNormalDeviceCommand(DeviceCommandId_t * id) { switch (communicationStep) { + case CommunicationStep::GET_RESET_STATUS: + *id = RwDefinitions::GET_LAST_RESET_STATUS; + communicationStep = CommunicationStep::READ_TEMPERATURE; + break; case CommunicationStep::READ_TEMPERATURE: *id = RwDefinitions::GET_TEMPERATURE; communicationStep = CommunicationStep::GET_RW_SATUS; break; case CommunicationStep::GET_RW_SATUS: *id = RwDefinitions::GET_RW_STATUS; - communicationStep = CommunicationStep::READ_TEMPERATURE; + communicationStep = CommunicationStep::GET_RESET_STATUS; break; default: sif::debug << "RwHandler::buildNormalDeviceCommand: Invalid communication step" diff --git a/mission/devices/RwHandler.h b/mission/devices/RwHandler.h index 29a2ae52..9521034c 100644 --- a/mission/devices/RwHandler.h +++ b/mission/devices/RwHandler.h @@ -90,6 +90,7 @@ private: uint8_t commandBuffer[RwDefinitions::MAX_CMD_SIZE]; enum class CommunicationStep { + GET_RESET_STATUS, READ_TEMPERATURE, GET_RW_SATUS }; From 23731e367c410ae958c000fcd96828e6d0826bf9 Mon Sep 17 00:00:00 2001 From: Martin Zietz Date: Mon, 28 Jun 2021 14:07:37 +0200 Subject: [PATCH 037/111] added second reaction wheel --- bsp_q7s/ObjectFactory.cpp | 16 ++++- bsp_q7s/spiCallbacks/rwSpiCallback.cpp | 4 +- .../pollingSequenceFactory.cpp | 6 ++ mission/devices/RwHandler.cpp | 67 +++++++++++++------ mission/devices/RwHandler.h | 9 ++- .../devices/devicedefinitions/RwDefinitions.h | 2 + tmtc | 2 +- 7 files changed, 76 insertions(+), 30 deletions(-) diff --git a/bsp_q7s/ObjectFactory.cpp b/bsp_q7s/ObjectFactory.cpp index 7507b5e6..8229536b 100644 --- a/bsp_q7s/ObjectFactory.cpp +++ b/bsp_q7s/ObjectFactory.cpp @@ -582,12 +582,26 @@ void ObjectFactory::produce(void* args){ auto rw1SpiCookie = new SpiCookie(addresses::RW1, gpioIds::CS_RW1, "/dev/spidev2.0", RwDefinitions::MAX_REPLY_SIZE, spi::RW_MODE, spi::RW_SPEED, &rwSpiCallback, nullptr); + auto rw2SpiCookie = new SpiCookie(addresses::RW2, gpioIds::CS_RW2, "/dev/spidev2.0", + RwDefinitions::MAX_REPLY_SIZE, spi::RW_MODE, spi::RW_SPEED, &rwSpiCallback, nullptr); + auto rw3SpiCookie = new SpiCookie(addresses::RW3, gpioIds::CS_RW3, "/dev/spidev2.0", + RwDefinitions::MAX_REPLY_SIZE, spi::RW_MODE, spi::RW_SPEED, &rwSpiCallback, nullptr); + auto rw4SpiCookie = new SpiCookie(addresses::RW4, gpioIds::CS_RW4, "/dev/spidev2.0", + RwDefinitions::MAX_REPLY_SIZE, spi::RW_MODE, spi::RW_SPEED, &rwSpiCallback, nullptr); + (void) rw3SpiCookie; + (void) rw4SpiCookie; auto rwHandler1 = new RwHandler(objects::RW1, objects::SPI_COM_IF, rw1SpiCookie, gpioComIF, gpioIds::EN_RW1); - rwHandler1->setStartUpImmediately(); + (void) rwHandler1; +// rwHandler1->setStartUpImmediately(); rw1SpiCookie->setCallbackArgs(rwHandler1); + auto rwHandler2 = new RwHandler(objects::RW2, objects::SPI_COM_IF, rw2SpiCookie, gpioComIF, + gpioIds::EN_RW1); + rwHandler2->setStartUpImmediately(); + rw2SpiCookie->setCallbackArgs(rwHandler2); + #endif /* TE0720 == 0 */ new UdpTmTcBridge(objects::UDP_BRIDGE, objects::CCSDS_PACKET_DISTRIBUTOR); diff --git a/bsp_q7s/spiCallbacks/rwSpiCallback.cpp b/bsp_q7s/spiCallbacks/rwSpiCallback.cpp index 41ba70d9..bfb1892c 100644 --- a/bsp_q7s/spiCallbacks/rwSpiCallback.cpp +++ b/bsp_q7s/spiCallbacks/rwSpiCallback.cpp @@ -93,7 +93,7 @@ ReturnValue_t rwSpiCallback(SpiComIF* comIf, SpiCookie *cookie, const uint8_t *s idx++; } - /** Sending frame start sign */ + /** Sending frame end sign */ writeBuffer[0] = 0x7E; writeSize = 1; @@ -155,7 +155,7 @@ ReturnValue_t rwSpiCallback(SpiComIF* comIf, SpiCookie *cookie, const uint8_t *s /** Reached end of frame */ break; } - else if (byteRead == 0xD) { + else if (byteRead == 0x7D) { if(read(fileDescriptor, &byteRead, 1) != 1) { sif::error << "rwSpiCallback: Read failed" << std::endl; result = RwHandler::SPI_READ_FAILURE; diff --git a/linux/fsfwconfig/pollingsequence/pollingSequenceFactory.cpp b/linux/fsfwconfig/pollingsequence/pollingSequenceFactory.cpp index 9bb73857..35f38919 100644 --- a/linux/fsfwconfig/pollingsequence/pollingSequenceFactory.cpp +++ b/linux/fsfwconfig/pollingsequence/pollingSequenceFactory.cpp @@ -407,6 +407,12 @@ ReturnValue_t pst::pstSpi(FixedTimeslotTaskIF *thisSequence) { thisSequence->addSlot(objects::RW1, length * 0.6, DeviceHandlerIF::SEND_READ); thisSequence->addSlot(objects::RW1, length * 0.8, DeviceHandlerIF::GET_READ); + thisSequence->addSlot(objects::RW2, length * 0, DeviceHandlerIF::PERFORM_OPERATION); + thisSequence->addSlot(objects::RW2, length * 0.2, DeviceHandlerIF::SEND_WRITE); + thisSequence->addSlot(objects::RW2, length * 0.4, DeviceHandlerIF::GET_WRITE); + thisSequence->addSlot(objects::RW2, length * 0.6, DeviceHandlerIF::SEND_READ); + thisSequence->addSlot(objects::RW2, length * 0.8, DeviceHandlerIF::GET_READ); + if (thisSequence->checkSequence() != HasReturnvaluesIF::RETURN_OK) { sif::error << "SPI PST initialization failed" << std::endl; return HasReturnvaluesIF::RETURN_FAILED; diff --git a/mission/devices/RwHandler.cpp b/mission/devices/RwHandler.cpp index 7d84bfcf..c789fb64 100644 --- a/mission/devices/RwHandler.cpp +++ b/mission/devices/RwHandler.cpp @@ -20,12 +20,19 @@ RwHandler::~RwHandler() { } void RwHandler::doStartUp() { - if (!startupPerformed) { - return; - } - if(gpioComIF->pullHigh(enableGpio) != RETURN_OK) { - sif::debug << "RwHandler::doStartUp: Failed to pull enable gpio to high"; + switch (startupStep) { + case StartupStep::ENABLE_RW: { + if(gpioComIF->pullHigh(enableGpio) != RETURN_OK) { + sif::debug << "RwHandler::doStartUp: Failed to pull enable gpio to high"; + } + return; } + case StartupStep::STARTUP_COMPLETE: + break; + default: + return; + } + #if OBSW_SWITCH_TO_NORMAL_MODE_AFTER_STARTUP == 1 setMode(MODE_NORMAL); #else @@ -37,7 +44,8 @@ void RwHandler::doShutDown() { if(gpioComIF->pullLow(enableGpio) != RETURN_OK) { sif::debug << "RwHandler::doStartUp: Failed to pull enable gpio to low"; } - startupPerformed = false; + /** Reset startup step for next doStartUp routine */ + startupStep = StartupStep::ENABLE_RW; } ReturnValue_t RwHandler::buildNormalDeviceCommand(DeviceCommandId_t * id) { @@ -64,7 +72,7 @@ ReturnValue_t RwHandler::buildNormalDeviceCommand(DeviceCommandId_t * id) { ReturnValue_t RwHandler::buildTransitionDeviceCommand(DeviceCommandId_t * id) { switch (startupStep) { - case StartupStep::GET_RESET_STATUS: + case StartupStep::ENABLE_RW: *id = RwDefinitions::GET_LAST_RESET_STATUS; startupStep = StartupStep::CLEAR_RESET_STATUS; break; @@ -74,9 +82,10 @@ ReturnValue_t RwHandler::buildTransitionDeviceCommand(DeviceCommandId_t * id) { break; case StartupStep::INIT_RW: *id = RwDefinitions::INIT_RW_CONTROLLER; - startupStep = StartupStep::GET_RESET_STATUS; - startupPerformed = true; + startupStep = StartupStep::STARTUP_COMPLETE; break; + case StartupStep::STARTUP_COMPLETE: + break; default: sif::debug << "RwHandler::buildTransitionDeviceCommand: Invalid startup step" << std::endl; @@ -136,17 +145,19 @@ ReturnValue_t RwHandler::buildCommandFromCommand(DeviceCommandId_t deviceCommand } void RwHandler::fillCommandAndReplyMap() { - this->insertInCommandMap(RwDefinitions::RESET_MCU); - this->insertInCommandAndReplyMap(RwDefinitions::GET_LAST_RESET_STATUS, 1, &lastResetStatusSet, - RwDefinitions::SIZE_GET_RESET_STATUS); - this->insertInCommandMap(RwDefinitions::CLEAR_LAST_RESET_STATUS); - this->insertInCommandAndReplyMap(RwDefinitions::GET_RW_STATUS, 1, &statusSet, - RwDefinitions::SIZE_GET_RW_STATUS); - this->insertInCommandMap(RwDefinitions::INIT_RW_CONTROLLER); - this->insertInCommandAndReplyMap(RwDefinitions::GET_TEMPERATURE, 1, &temperatureSet, - RwDefinitions::SIZE_GET_TEMPERATURE_REPLY); - this->insertInCommandAndReplyMap(RwDefinitions::SET_SPEED, 1, nullptr, - RwDefinitions::SIZE_SET_SPEED_REPLY); + this->insertInCommandMap(RwDefinitions::RESET_MCU); + this->insertInCommandAndReplyMap(RwDefinitions::GET_LAST_RESET_STATUS, 1, &lastResetStatusSet, + RwDefinitions::SIZE_GET_RESET_STATUS); + this->insertInCommandAndReplyMap(RwDefinitions::CLEAR_LAST_RESET_STATUS, 1, nullptr, + RwDefinitions::SIZE_CLEAR_RESET_STATUS); + this->insertInCommandAndReplyMap(RwDefinitions::GET_RW_STATUS, 1, &statusSet, + RwDefinitions::SIZE_GET_RW_STATUS); + this->insertInCommandAndReplyMap(RwDefinitions::INIT_RW_CONTROLLER, 1, nullptr, + RwDefinitions::SIZE_INIT_RW); + this->insertInCommandAndReplyMap(RwDefinitions::GET_TEMPERATURE, 1, &temperatureSet, + RwDefinitions::SIZE_GET_TEMPERATURE_REPLY); + this->insertInCommandAndReplyMap(RwDefinitions::SET_SPEED, 1, nullptr, + RwDefinitions::SIZE_SET_SPEED_REPLY); } ReturnValue_t RwHandler::scanForReply(const uint8_t *start, size_t remainingSize, @@ -158,11 +169,21 @@ ReturnValue_t RwHandler::scanForReply(const uint8_t *start, size_t remainingSize *foundId = RwDefinitions::GET_LAST_RESET_STATUS; break; } + case (static_cast(RwDefinitions::CLEAR_LAST_RESET_STATUS)): { + *foundLen = RwDefinitions::SIZE_CLEAR_RESET_STATUS; + *foundId = RwDefinitions::CLEAR_LAST_RESET_STATUS; + break; + } case (static_cast(RwDefinitions::GET_RW_STATUS)): { *foundLen = RwDefinitions::SIZE_GET_RW_STATUS; *foundId = RwDefinitions::GET_RW_STATUS; break; } + case (static_cast(RwDefinitions::INIT_RW_CONTROLLER)): { + *foundLen = RwDefinitions::SIZE_INIT_RW; + *foundId = RwDefinitions::INIT_RW_CONTROLLER; + break; + } case (static_cast(RwDefinitions::SET_SPEED)): { *foundLen = RwDefinitions::SIZE_SET_SPEED_REPLY; *foundId = RwDefinitions::SET_SPEED; @@ -189,6 +210,8 @@ ReturnValue_t RwHandler::interpretDeviceReply(DeviceCommandId_t id, const uint8_ /** Check result code */ if (*(packet + 1) == RwDefinitions::ERROR) { + sif::error << "RwHandler::interpretDeviceReply: Command execution failed. Command id: " + << id << std::endl; return EXECUTION_FAILED; } @@ -209,6 +232,8 @@ ReturnValue_t RwHandler::interpretDeviceReply(DeviceCommandId_t id, const uint8_ handleGetRwStatusReply(packet); break; } + case (RwDefinitions::CLEAR_LAST_RESET_STATUS): + case (RwDefinitions::INIT_RW_CONTROLLER): case (RwDefinitions::SET_SPEED): // no reply data expected break; @@ -230,7 +255,7 @@ void RwHandler::setNormalDatapoolEntriesInvalid() { } uint32_t RwHandler::getTransitionDelayMs(Mode_t modeFrom, Mode_t modeTo) { - return 5000; + return 15000; } ReturnValue_t RwHandler::initializeLocalDataPool(localpool::DataPool& localDataPoolMap, diff --git a/mission/devices/RwHandler.h b/mission/devices/RwHandler.h index 9521034c..a3d9ff1c 100644 --- a/mission/devices/RwHandler.h +++ b/mission/devices/RwHandler.h @@ -98,17 +98,16 @@ private: CommunicationStep communicationStep = CommunicationStep::READ_TEMPERATURE; enum class StartupStep { - GET_RESET_STATUS, + ENABLE_RW, CLEAR_RESET_STATUS, - INIT_RW + INIT_RW, + STARTUP_COMPLETE }; - StartupStep startupStep = StartupStep::GET_RESET_STATUS; + StartupStep startupStep = StartupStep::ENABLE_RW; size_t sizeOfReply = 0; - bool startupPerformed = false; - /** * @brief This function prepares the command to request the last reset status */ diff --git a/mission/devices/devicedefinitions/RwDefinitions.h b/mission/devices/devicedefinitions/RwDefinitions.h index 73de0e57..e383920e 100644 --- a/mission/devices/devicedefinitions/RwDefinitions.h +++ b/mission/devices/devicedefinitions/RwDefinitions.h @@ -41,6 +41,8 @@ static const uint32_t STATUS_SET_ID = GET_RW_STATUS; static const uint32_t LAST_RESET_ID = GET_LAST_RESET_STATUS; static const size_t SIZE_GET_RESET_STATUS = 5; +static const size_t SIZE_CLEAR_RESET_STATUS = 4; +static const size_t SIZE_INIT_RW = 4; static const size_t SIZE_GET_RW_STATUS = 14; static const size_t SIZE_SET_SPEED_REPLY = 4; static const size_t SIZE_GET_TEMPERATURE_REPLY = 8; diff --git a/tmtc b/tmtc index 899cd942..19b76d96 160000 --- a/tmtc +++ b/tmtc @@ -1 +1 @@ -Subproject commit 899cd942ce7136f371e93d270a6c6c149c0698cb +Subproject commit 19b76d961c61966a0093d3768f62d99196e1c9b2 From cf7dd233ea23125615b11337c7f38d28a081134d Mon Sep 17 00:00:00 2001 From: "Jakob.Meier" Date: Mon, 28 Jun 2021 14:39:08 +0200 Subject: [PATCH 038/111] rw2 enable fix --- bsp_q7s/ObjectFactory.cpp | 2 +- tmtc | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/bsp_q7s/ObjectFactory.cpp b/bsp_q7s/ObjectFactory.cpp index 8229536b..a84e314f 100644 --- a/bsp_q7s/ObjectFactory.cpp +++ b/bsp_q7s/ObjectFactory.cpp @@ -598,7 +598,7 @@ void ObjectFactory::produce(void* args){ rw1SpiCookie->setCallbackArgs(rwHandler1); auto rwHandler2 = new RwHandler(objects::RW2, objects::SPI_COM_IF, rw2SpiCookie, gpioComIF, - gpioIds::EN_RW1); + gpioIds::EN_RW2); rwHandler2->setStartUpImmediately(); rw2SpiCookie->setCallbackArgs(rwHandler2); diff --git a/tmtc b/tmtc index 19b76d96..10ea97ff 160000 --- a/tmtc +++ b/tmtc @@ -1 +1 @@ -Subproject commit 19b76d961c61966a0093d3768f62d99196e1c9b2 +Subproject commit 10ea97ff0b685014f8f79b124edc8009db6fd879 From 6afa3ee61b28d975c2b9812cb37656effba67e31 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Mon, 28 Jun 2021 17:49:24 +0200 Subject: [PATCH 039/111] gitmodules and tmtc update --- .gitmodules | 2 +- tmtc | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.gitmodules b/.gitmodules index 44a86d86..6bde354a 100644 --- a/.gitmodules +++ b/.gitmodules @@ -9,7 +9,7 @@ url = https://egit.irs.uni-stuttgart.de/eive/fsfw.git [submodule "tmtc"] path = tmtc - url = https://egit.irs.uni-stuttgart.de/eive/eive_tmtc.git + url = https://egit.irs.uni-stuttgart.de/eive/eive-tmtc.git [submodule "thirdparty/lwgps"] path = thirdparty/lwgps url = https://github.com/rmspacefish/lwgps.git diff --git a/tmtc b/tmtc index 2a986248..98deb844 160000 --- a/tmtc +++ b/tmtc @@ -1 +1 @@ -Subproject commit 2a9862489d57e2ccbf8b9ca5017f5e89395acddf +Subproject commit 98deb8444f84e94dc0252ad3c51eb61574174b90 From 703f29af26fa7eff687b1b4b1d13ba403135a56a Mon Sep 17 00:00:00 2001 From: Martin Zietz Date: Tue, 29 Jun 2021 09:50:50 +0200 Subject: [PATCH 040/111] created all rw objects --- bsp_q7s/ObjectFactory.cpp | 17 ++++++++++++++--- bsp_q7s/gpio/gpioCallbacks.cpp | 4 ++-- .../pollingsequence/pollingSequenceFactory.cpp | 12 ++++++++++++ mission/devices/RwHandler.cpp | 2 +- 4 files changed, 29 insertions(+), 6 deletions(-) diff --git a/bsp_q7s/ObjectFactory.cpp b/bsp_q7s/ObjectFactory.cpp index a84e314f..84c26605 100644 --- a/bsp_q7s/ObjectFactory.cpp +++ b/bsp_q7s/ObjectFactory.cpp @@ -588,8 +588,6 @@ void ObjectFactory::produce(void* args){ RwDefinitions::MAX_REPLY_SIZE, spi::RW_MODE, spi::RW_SPEED, &rwSpiCallback, nullptr); auto rw4SpiCookie = new SpiCookie(addresses::RW4, gpioIds::CS_RW4, "/dev/spidev2.0", RwDefinitions::MAX_REPLY_SIZE, spi::RW_MODE, spi::RW_SPEED, &rwSpiCallback, nullptr); - (void) rw3SpiCookie; - (void) rw4SpiCookie; auto rwHandler1 = new RwHandler(objects::RW1, objects::SPI_COM_IF, rw1SpiCookie, gpioComIF, gpioIds::EN_RW1); @@ -599,9 +597,22 @@ void ObjectFactory::produce(void* args){ auto rwHandler2 = new RwHandler(objects::RW2, objects::SPI_COM_IF, rw2SpiCookie, gpioComIF, gpioIds::EN_RW2); - rwHandler2->setStartUpImmediately(); +// rwHandler2->setStartUpImmediately(); + (void) rwHandler2; rw2SpiCookie->setCallbackArgs(rwHandler2); + auto rwHandler3 = new RwHandler(objects::RW3, objects::SPI_COM_IF, rw3SpiCookie, gpioComIF, + gpioIds::EN_RW3); +// rwHandler3->setStartUpImmediately(); + (void) rwHandler3; +// rw3SpiCookie->setCallbackArgs(rwHandler3); + + auto rwHandler4 = new RwHandler(objects::RW4, objects::SPI_COM_IF, rw4SpiCookie, gpioComIF, + gpioIds::EN_RW4); +// (void) rwHandler4; + rwHandler4->setStartUpImmediately(); + rw4SpiCookie->setCallbackArgs(rwHandler4); + #endif /* TE0720 == 0 */ new UdpTmTcBridge(objects::UDP_BRIDGE, objects::CCSDS_PACKET_DISTRIBUTOR); diff --git a/bsp_q7s/gpio/gpioCallbacks.cpp b/bsp_q7s/gpio/gpioCallbacks.cpp index 49e22249..5499517b 100644 --- a/bsp_q7s/gpio/gpioCallbacks.cpp +++ b/bsp_q7s/gpio/gpioCallbacks.cpp @@ -232,12 +232,12 @@ void spiCsDecoderCallback(gpioId_t gpioId, gpio::GpioOperation gpioOp, int value } case(gpioIds::CS_RW3): { enableRwDecoder(); - selectY3(); + selectY2(); break; } case(gpioIds::CS_RW4): { enableRwDecoder(); - selectY4(); + selectY3(); break; } default: diff --git a/linux/fsfwconfig/pollingsequence/pollingSequenceFactory.cpp b/linux/fsfwconfig/pollingsequence/pollingSequenceFactory.cpp index 35f38919..be184b6b 100644 --- a/linux/fsfwconfig/pollingsequence/pollingSequenceFactory.cpp +++ b/linux/fsfwconfig/pollingsequence/pollingSequenceFactory.cpp @@ -413,6 +413,18 @@ ReturnValue_t pst::pstSpi(FixedTimeslotTaskIF *thisSequence) { thisSequence->addSlot(objects::RW2, length * 0.6, DeviceHandlerIF::SEND_READ); thisSequence->addSlot(objects::RW2, length * 0.8, DeviceHandlerIF::GET_READ); + thisSequence->addSlot(objects::RW3, length * 0, DeviceHandlerIF::PERFORM_OPERATION); + thisSequence->addSlot(objects::RW3, length * 0.2, DeviceHandlerIF::SEND_WRITE); + thisSequence->addSlot(objects::RW3, length * 0.4, DeviceHandlerIF::GET_WRITE); + thisSequence->addSlot(objects::RW3, length * 0.6, DeviceHandlerIF::SEND_READ); + thisSequence->addSlot(objects::RW3, length * 0.8, DeviceHandlerIF::GET_READ); + + thisSequence->addSlot(objects::RW4, length * 0, DeviceHandlerIF::PERFORM_OPERATION); + thisSequence->addSlot(objects::RW4, length * 0.2, DeviceHandlerIF::SEND_WRITE); + thisSequence->addSlot(objects::RW4, length * 0.4, DeviceHandlerIF::GET_WRITE); + thisSequence->addSlot(objects::RW4, length * 0.6, DeviceHandlerIF::SEND_READ); + thisSequence->addSlot(objects::RW4, length * 0.8, DeviceHandlerIF::GET_READ); + if (thisSequence->checkSequence() != HasReturnvaluesIF::RETURN_OK) { sif::error << "SPI PST initialization failed" << std::endl; return HasReturnvaluesIF::RETURN_FAILED; diff --git a/mission/devices/RwHandler.cpp b/mission/devices/RwHandler.cpp index c789fb64..d423aac1 100644 --- a/mission/devices/RwHandler.cpp +++ b/mission/devices/RwHandler.cpp @@ -298,7 +298,7 @@ ReturnValue_t RwHandler::checkSpeedAndRampTime(const uint8_t* commandData, size_ int32_t speed = *commandData << 24 | *(commandData + 1) << 16 | *(commandData + 2) << 8 | *(commandData + 3); - if (speed < -65000 || speed > 65000 || (speed > -1000 && speed < 1000)) { + if ((speed < -65000 || speed > 65000 || (speed > -1000 && speed < 1000)) && (speed != 0)) { sif::error << "RwHandler::checkSpeedAndRampTime: Command has invalid speed" << std::endl; return INVALID_SPEED; } From bd1e737634c69eb5ad5f219b23ab4f168aa02697 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Tue, 29 Jun 2021 11:23:18 +0200 Subject: [PATCH 041/111] fsfw_hal and tmtc update --- fsfw_hal | 2 +- tmtc | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/fsfw_hal b/fsfw_hal index 2533af3b..0f0fc0c2 160000 --- a/fsfw_hal +++ b/fsfw_hal @@ -1 +1 @@ -Subproject commit 2533af3b53804bc68436236370911e013a2b8f64 +Subproject commit 0f0fc0c2a69494de78856d956b679d9ee6ec339f diff --git a/tmtc b/tmtc index 98deb844..9d98eb6b 160000 --- a/tmtc +++ b/tmtc @@ -1 +1 @@ -Subproject commit 98deb8444f84e94dc0252ad3c51eb61574174b90 +Subproject commit 9d98eb6b606b40fa26aad12786894d1a99cb726c From 6e70f2254d6c2072948a715f4ee44fe6e8842383 Mon Sep 17 00:00:00 2001 From: "Jakob.Meier" Date: Tue, 29 Jun 2021 16:08:20 +0200 Subject: [PATCH 042/111] all reaction wheels working --- bsp_q7s/ObjectFactory.cpp | 10 +- linux/fsfwconfig/OBSWConfig.h.in | 2 +- mission/devices/RwHandler.cpp | 103 ++++++++++-------- mission/devices/RwHandler.h | 23 ++-- .../devices/devicedefinitions/RwDefinitions.h | 17 ++- tmtc | 2 +- 6 files changed, 86 insertions(+), 71 deletions(-) diff --git a/bsp_q7s/ObjectFactory.cpp b/bsp_q7s/ObjectFactory.cpp index 84c26605..a4a876a3 100644 --- a/bsp_q7s/ObjectFactory.cpp +++ b/bsp_q7s/ObjectFactory.cpp @@ -591,26 +591,18 @@ void ObjectFactory::produce(void* args){ auto rwHandler1 = new RwHandler(objects::RW1, objects::SPI_COM_IF, rw1SpiCookie, gpioComIF, gpioIds::EN_RW1); - (void) rwHandler1; -// rwHandler1->setStartUpImmediately(); rw1SpiCookie->setCallbackArgs(rwHandler1); auto rwHandler2 = new RwHandler(objects::RW2, objects::SPI_COM_IF, rw2SpiCookie, gpioComIF, gpioIds::EN_RW2); -// rwHandler2->setStartUpImmediately(); - (void) rwHandler2; rw2SpiCookie->setCallbackArgs(rwHandler2); auto rwHandler3 = new RwHandler(objects::RW3, objects::SPI_COM_IF, rw3SpiCookie, gpioComIF, gpioIds::EN_RW3); -// rwHandler3->setStartUpImmediately(); - (void) rwHandler3; -// rw3SpiCookie->setCallbackArgs(rwHandler3); + rw3SpiCookie->setCallbackArgs(rwHandler3); auto rwHandler4 = new RwHandler(objects::RW4, objects::SPI_COM_IF, rw4SpiCookie, gpioComIF, gpioIds::EN_RW4); -// (void) rwHandler4; - rwHandler4->setStartUpImmediately(); rw4SpiCookie->setCallbackArgs(rwHandler4); #endif /* TE0720 == 0 */ diff --git a/linux/fsfwconfig/OBSWConfig.h.in b/linux/fsfwconfig/OBSWConfig.h.in index ce1a7526..a5a439ab 100644 --- a/linux/fsfwconfig/OBSWConfig.h.in +++ b/linux/fsfwconfig/OBSWConfig.h.in @@ -52,7 +52,7 @@ debugging. */ #include "OBSWVersion.h" /* Can be used to switch device to NORMAL mode immediately */ -#define OBSW_SWITCH_TO_NORMAL_MODE_AFTER_STARTUP 1 +#define OBSW_SWITCH_TO_NORMAL_MODE_AFTER_STARTUP 0 #ifdef __cplusplus diff --git a/mission/devices/RwHandler.cpp b/mission/devices/RwHandler.cpp index d423aac1..45c721a8 100644 --- a/mission/devices/RwHandler.cpp +++ b/mission/devices/RwHandler.cpp @@ -20,18 +20,12 @@ RwHandler::~RwHandler() { } void RwHandler::doStartUp() { - switch (startupStep) { - case StartupStep::ENABLE_RW: { - if(gpioComIF->pullHigh(enableGpio) != RETURN_OK) { - sif::debug << "RwHandler::doStartUp: Failed to pull enable gpio to high"; - } - return; - } - case StartupStep::STARTUP_COMPLETE: - break; - default: - return; - } + + internalState = InternalState::GET_RESET_STATUS; + + if(gpioComIF->pullHigh(enableGpio) != RETURN_OK) { + sif::debug << "RwHandler::doStartUp: Failed to pull enable gpio to high"; + } #if OBSW_SWITCH_TO_NORMAL_MODE_AFTER_STARTUP == 1 setMode(MODE_NORMAL); @@ -44,23 +38,26 @@ void RwHandler::doShutDown() { if(gpioComIF->pullLow(enableGpio) != RETURN_OK) { sif::debug << "RwHandler::doStartUp: Failed to pull enable gpio to low"; } - /** Reset startup step for next doStartUp routine */ - startupStep = StartupStep::ENABLE_RW; } ReturnValue_t RwHandler::buildNormalDeviceCommand(DeviceCommandId_t * id) { - switch (communicationStep) { - case CommunicationStep::GET_RESET_STATUS: + switch (internalState) { + case InternalState::GET_RESET_STATUS: *id = RwDefinitions::GET_LAST_RESET_STATUS; - communicationStep = CommunicationStep::READ_TEMPERATURE; + internalState = InternalState::READ_TEMPERATURE; break; - case CommunicationStep::READ_TEMPERATURE: + case InternalState::CLEAR_RESET_STATUS: + *id = RwDefinitions::CLEAR_LAST_RESET_STATUS; + /** After reset status is cleared, reset status will be polled again for verification */ + internalState = InternalState::GET_RESET_STATUS; + break; + case InternalState::READ_TEMPERATURE: *id = RwDefinitions::GET_TEMPERATURE; - communicationStep = CommunicationStep::GET_RW_SATUS; + internalState = InternalState::GET_RW_SATUS; break; - case CommunicationStep::GET_RW_SATUS: + case InternalState::GET_RW_SATUS: *id = RwDefinitions::GET_RW_STATUS; - communicationStep = CommunicationStep::GET_RESET_STATUS; + internalState = InternalState::GET_RESET_STATUS; break; default: sif::debug << "RwHandler::buildNormalDeviceCommand: Invalid communication step" @@ -71,27 +68,7 @@ ReturnValue_t RwHandler::buildNormalDeviceCommand(DeviceCommandId_t * id) { } ReturnValue_t RwHandler::buildTransitionDeviceCommand(DeviceCommandId_t * id) { - switch (startupStep) { - case StartupStep::ENABLE_RW: - *id = RwDefinitions::GET_LAST_RESET_STATUS; - startupStep = StartupStep::CLEAR_RESET_STATUS; - break; - case StartupStep::CLEAR_RESET_STATUS: - *id = RwDefinitions::CLEAR_LAST_RESET_STATUS; - startupStep = StartupStep::INIT_RW; - break; - case StartupStep::INIT_RW: - *id = RwDefinitions::INIT_RW_CONTROLLER; - startupStep = StartupStep::STARTUP_COMPLETE; - break; - case StartupStep::STARTUP_COMPLETE: - break; - default: - sif::debug << "RwHandler::buildTransitionDeviceCommand: Invalid startup step" - << std::endl; - break; - } - return buildCommandFromCommand(*id, nullptr, 0);; + return RETURN_OK; } ReturnValue_t RwHandler::buildCommandFromCommand(DeviceCommandId_t deviceCommand, @@ -100,9 +77,7 @@ ReturnValue_t RwHandler::buildCommandFromCommand(DeviceCommandId_t deviceCommand switch (deviceCommand) { case (RwDefinitions::RESET_MCU): { - commandBuffer[0] = static_cast(RwDefinitions::RESET_MCU); - rawPacket = commandBuffer; - rawPacketLen = 1; + prepareResetMcuCommand(); return RETURN_OK; } case (RwDefinitions::GET_LAST_RESET_STATUS): { @@ -255,7 +230,7 @@ void RwHandler::setNormalDatapoolEntriesInvalid() { } uint32_t RwHandler::getTransitionDelayMs(Mode_t modeFrom, Mode_t modeTo) { - return 15000; + return 500; } ReturnValue_t RwHandler::initializeLocalDataPool(localpool::DataPool& localDataPoolMap, @@ -263,9 +238,23 @@ ReturnValue_t RwHandler::initializeLocalDataPool(localpool::DataPool& localDataP localDataPoolMap.emplace(RwDefinitions::TEMPERATURE_C, new PoolEntry( { 0 })); + localDataPoolMap.emplace(RwDefinitions::CURR_SPEED, new PoolEntry( { 0 })); + localDataPoolMap.emplace(RwDefinitions::REFERENCE_SPEED, new PoolEntry( { 0 })); + localDataPoolMap.emplace(RwDefinitions::STATE, new PoolEntry( { 0 })); + localDataPoolMap.emplace(RwDefinitions::CLC_MODE, new PoolEntry( { 0 })); + + localDataPoolMap.emplace(RwDefinitions::LAST_RESET_STATUS, new PoolEntry( { 0 })); + localDataPoolMap.emplace(RwDefinitions::CURRRENT_RESET_STATUS, new PoolEntry( { 0 })); + return RETURN_OK; } +void RwHandler::prepareResetMcuCommand() { + commandBuffer[0] = static_cast(RwDefinitions::RESET_MCU); + rawPacket = commandBuffer; + rawPacketLen = 1; +} + void RwHandler::prepareGetLastResetStatusCommand() { commandBuffer[0] = static_cast(RwDefinitions::GET_LAST_RESET_STATUS); uint16_t crc = CRC::crc16ccitt(commandBuffer, 1, 0xFFFF); @@ -352,15 +341,24 @@ void RwHandler::prepareSetSpeedCmd(const uint8_t * commandData, size_t commandDa } void RwHandler::handleResetStatusReply(const uint8_t* packet) { + PoolReadGuard rg(&lastResetStatusSet); uint8_t offset = 2; - lastResetStatusSet.lastResetStatus = *(packet + offset); + uint8_t resetStatus = *(packet + offset); + if (resetStatus != RwDefinitions::CLEARED) { + internalState = InternalState::CLEAR_RESET_STATUS; + lastResetStatusSet.lastResetStatus = resetStatus; + } + lastResetStatusSet.currentResetStatus = resetStatus; #if OBSW_VERBOSE_LEVEL >= 1 && RW_DEBUG == 1 sif::info << "RwHandler::handleResetStatusReply: Last reset status: " << static_cast(lastResetStatusSet.lastResetStatus.value) << std::endl; + sif::info << "RwHandler::handleResetStatusReply: Current reset status: " + << static_cast(lastResetStatusSet.currentResetStatus.value) << std::endl; #endif } void RwHandler::handleGetRwStatusReply(const uint8_t* packet) { + PoolReadGuard rg(&statusSet); uint8_t offset = 2; statusSet.currSpeed = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 | *(packet + offset + 1) << 8 | *(packet + offset); @@ -372,6 +370,16 @@ void RwHandler::handleGetRwStatusReply(const uint8_t* packet) { offset += 1; statusSet.clcMode = *(packet + offset); + if (statusSet.state == RwDefinitions::ERROR) { + /** + * This requires the commanding of the init reaction wheel controller command to recover + * form error state which must be handled by the FDIR instance. + */ + triggerEvent(ERROR_STATE); + sif::error << "RwHandler::handleGetRwStatusReply: Reaction wheel in error state" + << std::endl; + } + #if OBSW_VERBOSE_LEVEL >= 1 && RW_DEBUG == 1 sif::info << "RwHandler::handleGetRwStatusReply: Current speed is: " << statusSet.currSpeed << " * 0.1 RPM" << std::endl; @@ -385,6 +393,7 @@ void RwHandler::handleGetRwStatusReply(const uint8_t* packet) { } void RwHandler::handleTemperatureReply(const uint8_t* packet) { + PoolReadGuard rg(&temperatureSet); uint8_t offset = 2; temperatureSet.temperatureCelcius = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 | *(packet + offset + 1) << 8 | *(packet + offset); diff --git a/mission/devices/RwHandler.h b/mission/devices/RwHandler.h index a3d9ff1c..11fb4a30 100644 --- a/mission/devices/RwHandler.h +++ b/mission/devices/RwHandler.h @@ -79,6 +79,9 @@ private: //! [EXPORT] : [COMMENT] Reaction wheel reply has invalid crc static const ReturnValue_t CRC_ERROR = MAKE_RETURN_CODE(0xA4); + //! [EXPORT] : [COMMENT] Reaction wheel signals an error state + static const Event ERROR_STATE = MAKE_EVENT(1, severity::HIGH); + LinuxLibgpioIF* gpioComIF = nullptr; gpioId_t enableGpio = gpio::NO_GPIO; @@ -89,25 +92,23 @@ private: uint8_t commandBuffer[RwDefinitions::MAX_CMD_SIZE]; - enum class CommunicationStep { + enum class InternalState { GET_RESET_STATUS, + CLEAR_RESET_STATUS, READ_TEMPERATURE, GET_RW_SATUS }; - CommunicationStep communicationStep = CommunicationStep::READ_TEMPERATURE; - - enum class StartupStep { - ENABLE_RW, - CLEAR_RESET_STATUS, - INIT_RW, - STARTUP_COMPLETE - }; - - StartupStep startupStep = StartupStep::ENABLE_RW; + InternalState internalState = InternalState::GET_RESET_STATUS; size_t sizeOfReply = 0; + /** + * @brief This function fills the command buffer with the data to reset the MCU on a reaction + * wheel. + */ + void prepareResetMcuCommand(); + /** * @brief This function prepares the command to request the last reset status */ diff --git a/mission/devices/devicedefinitions/RwDefinitions.h b/mission/devices/devicedefinitions/RwDefinitions.h index e383920e..fbdbd5cf 100644 --- a/mission/devices/devicedefinitions/RwDefinitions.h +++ b/mission/devices/devicedefinitions/RwDefinitions.h @@ -16,7 +16,8 @@ enum PoolIds: lp_id_t { REFERENCE_SPEED, STATE, CLC_MODE, - LAST_RESET_STATUS + LAST_RESET_STATUS, + CURRRENT_RESET_STATUS }; enum States: uint8_t { @@ -27,6 +28,16 @@ enum States: uint8_t { RUNNING_SPEED_CHANGING }; +enum LastResetStatus: uint8_t { + CLEARED = 0, + PIN_RESET = 1, + POR_PDR_BOR_RESET = 2, + SOFTWARE_RESET = 4, + INDEPENDENT_WATCHDOG_RESET = 8, + WINDOW_WATCHDOG_RESET = 16, + LOW_POWER_RESET = 32 +}; + static const DeviceCommandId_t RESET_MCU = 1; static const DeviceCommandId_t GET_LAST_RESET_STATUS = 2; static const DeviceCommandId_t CLEAR_LAST_RESET_STATUS = 3; @@ -53,7 +64,7 @@ static const size_t SIZE_GET_TELEMETRY_REPLY = 83; static const size_t MAX_CMD_SIZE = 9; static const size_t MAX_REPLY_SIZE = SIZE_GET_TELEMETRY_REPLY; -static const uint8_t LAST_RESET_ENTRIES = 1; +static const uint8_t LAST_RESET_ENTRIES = 2; static const uint8_t TEMPERATURE_SET_ENTRIES = 1; static const uint8_t STATUS_SET_ENTRIES = 4; @@ -118,6 +129,8 @@ public: lp_var_t lastResetStatus = lp_var_t(sid.objectId, PoolIds::LAST_RESET_STATUS, this); + lp_var_t currentResetStatus = lp_var_t(sid.objectId, + PoolIds::CURRRENT_RESET_STATUS, this); }; } diff --git a/tmtc b/tmtc index 10ea97ff..a8ea01bb 160000 --- a/tmtc +++ b/tmtc @@ -1 +1 @@ -Subproject commit 10ea97ff0b685014f8f79b124edc8009db6fd879 +Subproject commit a8ea01bb2fced3d7562af4b200080e424468e9c6 From e3d38f16e032e55f5d0ae14edad60c04a471c592 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Tue, 29 Jun 2021 16:09:32 +0200 Subject: [PATCH 043/111] added event manager --- bsp_q7s/InitMission.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/bsp_q7s/InitMission.cpp b/bsp_q7s/InitMission.cpp index 25cd6abf..3e655255 100644 --- a/bsp_q7s/InitMission.cpp +++ b/bsp_q7s/InitMission.cpp @@ -104,10 +104,14 @@ void initmission::initTasks() { PeriodicTaskIF* pusEvents = factory->createPeriodicTask( "PUS_EVENTS", 60, PeriodicTaskIF::MINIMUM_STACK_SIZE, 0.200, missedDeadlineFunc); - result = pusVerification->addComponent(objects::PUS_SERVICE_5_EVENT_REPORTING); + result = pusEvents->addComponent(objects::PUS_SERVICE_5_EVENT_REPORTING); if(result != HasReturnvaluesIF::RETURN_OK) { initmission::printAddObjectError("PUS_EVENTS", objects::PUS_SERVICE_5_EVENT_REPORTING); } + result = pusEvents->addComponent(objects::EVENT_MANAGER); + if(result != HasReturnvaluesIF::RETURN_OK) { + initmission::printAddObjectError("PUS_MGMT", objects::EVENT_MANAGER); + } PeriodicTaskIF* pusHighPrio = factory->createPeriodicTask( "PUS_HIGH_PRIO", 50, PeriodicTaskIF::MINIMUM_STACK_SIZE, 0.200, missedDeadlineFunc); From 9335befdc67466308eafd41523be30a48c61e754 Mon Sep 17 00:00:00 2001 From: "Jakob.Meier" Date: Tue, 29 Jun 2021 16:10:19 +0200 Subject: [PATCH 044/111] tmtc update --- tmtc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tmtc b/tmtc index a8ea01bb..09cab194 160000 --- a/tmtc +++ b/tmtc @@ -1 +1 @@ -Subproject commit a8ea01bb2fced3d7562af4b200080e424468e9c6 +Subproject commit 09cab1941fad0bbe8fa54234f7513c61e22038ca From f583fc1d99b767fc39beaca7e9120427b7a616c8 Mon Sep 17 00:00:00 2001 From: "Jakob.Meier" Date: Tue, 29 Jun 2021 17:27:39 +0200 Subject: [PATCH 045/111] generator runs and rw transition delay --- generators/bsp_q7s_events.csv | 9 + generators/bsp_q7s_objects.csv | 129 ++++---- generators/events/translateEvents.cpp | 31 +- generators/objects/translateObjects.cpp | 313 ++++++++++-------- linux/fsfwconfig/events/translateEvents.cpp | 31 +- linux/fsfwconfig/objects/translateObjects.cpp | 313 ++++++++++-------- mission/devices/RwHandler.cpp | 4 +- 7 files changed, 471 insertions(+), 359 deletions(-) diff --git a/generators/bsp_q7s_events.csv b/generators/bsp_q7s_events.csv index 81459869..c895aebb 100644 --- a/generators/bsp_q7s_events.csv +++ b/generators/bsp_q7s_events.csv @@ -81,3 +81,12 @@ 11102;ACK_FAILURE;LOW; ;../../mission/devices/PlocHandler.h 11103;EXE_FAILURE;LOW; ;../../mission/devices/PlocHandler.h 11104;CRC_FAILURE_EVENT;LOW; ;../../mission/devices/PlocHandler.h +11201;SELF_TEST_I2C_FAILURE;LOW; ;../../mission/devices/IMTQHandler.h +11202;SELF_TEST_SPI_FAILURE;LOW; ;../../mission/devices/IMTQHandler.h +11203;SELF_TEST_ADC_FAILURE;LOW; ;../../mission/devices/IMTQHandler.h +11204;SELF_TEST_PWM_FAILURE;LOW; ;../../mission/devices/IMTQHandler.h +11205;SELF_TEST_TC_FAILURE;LOW; ;../../mission/devices/IMTQHandler.h +11206;SELF_TEST_MTM_RANGE_FAILURE;LOW; ;../../mission/devices/IMTQHandler.h +11207;SELF_TEST_COIL_CURRENT_FAILURE;LOW; ;../../mission/devices/IMTQHandler.h +11208;INVALID_ERROR_BYTE;LOW; ;../../mission/devices/IMTQHandler.h +11301;ERROR_STATE;HIGH; ;../../mission/devices/RwHandler.h diff --git a/generators/bsp_q7s_objects.csv b/generators/bsp_q7s_objects.csv index 8df83d6a..e0180089 100644 --- a/generators/bsp_q7s_objects.csv +++ b/generators/bsp_q7s_objects.csv @@ -1,52 +1,74 @@ 0x00005060;P60DOCK_TEST_TASK -0x44000001;P60DOCK_HANDLER -0x44000002;PDU1_HANDLER -0x44000003;PDU2_HANDLER -0x44000004;ACU_HANDLER -0x44000005;TMP1075_HANDLER_1 -0x44000006;TMP1075_HANDLER_2 -0x44000007;MGM_0_LIS3_HANDLER -0x44000008;MGM_1_RM3100_HANDLER -0x44000009;MGM_2_LIS3_HANDLER -0x44000010;MGM_3_RM3100_HANDLER -0x44000011;GYRO_0_ADIS_HANDLER -0x44000012;GYRO_1_L3G_HANDLER -0x44000013;GYRO_2_L3G_HANDLER -0x44000014;IMTQ_HANDLER -0x44000015;PLOC_HANDLER -0x44000016;SUS_1 -0x44000017;SUS_2 -0x44000018;SUS_3 -0x44000019;SUS_4 -0x4400001A;SUS_5 -0x4400001B;SUS_6 -0x4400001C;SUS_7 -0x4400001D;SUS_8 -0x4400001E;SUS_9 -0x4400001F;SUS_10 -0x44000021;SUS_11 -0x44000022;SUS_12 -0x44000023;SUS_13 -0x44001000;PCDU_HANDLER -0x44001001;SOLAR_ARRAY_DEPL_HANDLER -0x44001002;SYRLINKS_HK_HANDLER -0x47000001;GPIO_IF -0x49000001;ARDUINO_COM_IF -0x49000002;CSP_COM_IF -0x49000003;I2C_COM_IF -0x49000004;UART_COM_IF -0x49000005;SPI_COM_IF +0x43000003;CORE_CONTROLLER +0x43100002;ACS_CONTROLLER +0x43400001;THERMAL_CONTROLLER +0x44120006;MGM_0_LIS3_HANDLER +0x44120010;GYRO_0_ADIS_HANDLER +0x44120032;SUS_1 +0x44120033;SUS_2 +0x44120034;SUS_3 +0x44120035;SUS_4 +0x44120036;SUS_5 +0x44120037;SUS_6 +0x44120038;SUS_7 +0x44120039;SUS_8 +0x44120040;SUS_9 +0x44120041;SUS_10 +0x44120042;SUS_11 +0x44120043;SUS_12 +0x44120044;SUS_13 +0x44120107;MGM_1_RM3100_HANDLER +0x44120111;GYRO_1_L3G_HANDLER +0x44120208;MGM_2_LIS3_HANDLER +0x44120212;GYRO_2_ADIS_HANDLER +0x44120309;MGM_3_RM3100_HANDLER +0x44120313;GYRO_3_L3G_HANDLER +0x44130045;GPS0_HANDLER +0x44130146;GPS1_HANDLER +0x44140014;IMTQ_HANDLER +0x442000A1;PCDU_HANDLER +0x44210001;RW1 +0x44210002;RW2 +0x44210003;RW3 +0x44210004;RW4 +0x44250000;P60DOCK_HANDLER +0x44250001;PDU1_HANDLER +0x44250002;PDU2_HANDLER +0x44250003;ACU_HANDLER +0x443200A5;RAD_SENSOR +0x44330015;PLOC_HANDLER +0x444100A2;SOLAR_ARRAY_DEPL_HANDLER +0x444100A4;HEATER_HANDLER +0x44420004;TMP1075_HANDLER_1 +0x44420005;TMP1075_HANDLER_2 +0x44420016;RTD_IC3 +0x44420017;RTD_IC4 +0x44420018;RTD_IC5 +0x44420019;RTD_IC6 +0x44420020;RTD_IC7 +0x44420021;RTD_IC8 +0x44420022;RTD_IC9 +0x44420023;RTD_IC10 +0x44420024;RTD_IC11 +0x44420025;RTD_IC12 +0x44420026;RTD_IC13 +0x44420027;RTD_IC14 +0x44420028;RTD_IC15 +0x44420029;RTD_IC16 +0x44420030;RTD_IC17 +0x44420031;RTD_IC18 +0x445300A3;SYRLINKS_HK_HANDLER +0x49000000;ARDUINO_COM_IF +0x49010005;GPIO_IF +0x49020004;SPI_COM_IF +0x49030003;UART_COM_IF +0x49040002;I2C_COM_IF +0x49050001;CSP_COM_IF 0x50000100;CCSDS_PACKET_DISTRIBUTOR 0x50000200;PUS_PACKET_DISTRIBUTOR 0x50000300;UDP_BRIDGE 0x50000400;UDP_POLLING_TASK -0x51000300;PUS_SERVICE_3 -0x51000400;PUS_SERVICE_5 0x51000500;PUS_SERVICE_6 -0x51000800;PUS_SERVICE_8 -0x51002300;PUS_SERVICE_23 -0x51020100;PUS_SERVICE_201 -0x52000002;TM_FUNNEL 0x53000000;FSFW_OBJECTS_START 0x53000001;PUS_SERVICE_1_VERIFICATION 0x53000002;PUS_SERVICE_2_DEVICE_ACCESS @@ -67,27 +89,12 @@ 0x534f0300;IPC_STORE 0x53500010;TIME_STAMPER 0x53ffffff;FSFW_OBJECTS_END -0x54000003;HEATER_HANDLER -0x54000004;RTD_IC3 -0x54000005;RTD_IC4 -0x54000006;RTD_IC5 -0x54000007;RTD_IC6 -0x54000008;RTD_IC7 -0x54000009;RTD_IC8 -0x5400000A;RTD_IC9 -0x5400000B;RTD_IC10 -0x5400000C;RTD_IC11 -0x5400000D;RTD_IC12 -0x5400000E;RTD_IC13 -0x5400000F;RTD_IC14 0x54000010;SPI_TEST -0x5400001F;RTD_IC15 -0x5400002F;RTD_IC16 -0x5400003F;RTD_IC17 -0x5400004F;RTD_IC18 -0x54000050;RAD_SENSOR +0x54000020;UART_TEST 0x5400AFFE;DUMMY_HANDLER 0x5400CAFE;DUMMY_INTERFACE 0x54123456;LIBGPIOD_TEST 0x54694269;TEST_TASK +0x73000100;TM_FUNNEL +0x73500000;CCSDS_IP_CORE_BRIDGE 0xFFFFFFFF;NO_OBJECT diff --git a/generators/events/translateEvents.cpp b/generators/events/translateEvents.cpp index c3af08e1..9ae81646 100644 --- a/generators/events/translateEvents.cpp +++ b/generators/events/translateEvents.cpp @@ -1,7 +1,7 @@ /** - * @brief Auto-generated event translation file. Contains 83 translations. + * @brief Auto-generated event translation file. Contains 92 translations. * @details - * Generated on: 2021-06-08 17:09:32 + * Generated on: 2021-06-29 16:20:09 */ #include "translateEvents.h" @@ -88,6 +88,15 @@ const char *MEMORY_READ_RPT_CRC_FAILURE_STRING = "MEMORY_READ_RPT_CRC_FAILURE"; const char *ACK_FAILURE_STRING = "ACK_FAILURE"; const char *EXE_FAILURE_STRING = "EXE_FAILURE"; const char *CRC_FAILURE_EVENT_STRING = "CRC_FAILURE_EVENT"; +const char *SELF_TEST_I2C_FAILURE_STRING = "SELF_TEST_I2C_FAILURE"; +const char *SELF_TEST_SPI_FAILURE_STRING = "SELF_TEST_SPI_FAILURE"; +const char *SELF_TEST_ADC_FAILURE_STRING = "SELF_TEST_ADC_FAILURE"; +const char *SELF_TEST_PWM_FAILURE_STRING = "SELF_TEST_PWM_FAILURE"; +const char *SELF_TEST_TC_FAILURE_STRING = "SELF_TEST_TC_FAILURE"; +const char *SELF_TEST_MTM_RANGE_FAILURE_STRING = "SELF_TEST_MTM_RANGE_FAILURE"; +const char *SELF_TEST_COIL_CURRENT_FAILURE_STRING = "SELF_TEST_COIL_CURRENT_FAILURE"; +const char *INVALID_ERROR_BYTE_STRING = "INVALID_ERROR_BYTE"; +const char *ERROR_STATE_STRING = "ERROR_STATE"; const char * translateEvents(Event event) { switch( (event & 0xffff) ) { @@ -257,6 +266,24 @@ const char * translateEvents(Event event) { return EXE_FAILURE_STRING; case(11104): return CRC_FAILURE_EVENT_STRING; + case(11201): + return SELF_TEST_I2C_FAILURE_STRING; + case(11202): + return SELF_TEST_SPI_FAILURE_STRING; + case(11203): + return SELF_TEST_ADC_FAILURE_STRING; + case(11204): + return SELF_TEST_PWM_FAILURE_STRING; + case(11205): + return SELF_TEST_TC_FAILURE_STRING; + case(11206): + return SELF_TEST_MTM_RANGE_FAILURE_STRING; + case(11207): + return SELF_TEST_COIL_CURRENT_FAILURE_STRING; + case(11208): + return INVALID_ERROR_BYTE_STRING; + case(11301): + return ERROR_STATE_STRING; default: return "UNKNOWN_EVENT"; } diff --git a/generators/objects/translateObjects.cpp b/generators/objects/translateObjects.cpp index 47b55435..2068158b 100644 --- a/generators/objects/translateObjects.cpp +++ b/generators/objects/translateObjects.cpp @@ -1,27 +1,17 @@ -/** +/** * @brief Auto-generated object translation file. * @details - * Contains 93 translations. - * Generated on: 2021-05-18 16:48:46 + * Contains 100 translations. + * Generated on: 2021-06-29 16:19:57 */ #include "translateObjects.h" const char *P60DOCK_TEST_TASK_STRING = "P60DOCK_TEST_TASK"; -const char *P60DOCK_HANDLER_STRING = "P60DOCK_HANDLER"; -const char *PDU1_HANDLER_STRING = "PDU1_HANDLER"; -const char *PDU2_HANDLER_STRING = "PDU2_HANDLER"; -const char *ACU_HANDLER_STRING = "ACU_HANDLER"; -const char *TMP1075_HANDLER_1_STRING = "TMP1075_HANDLER_1"; -const char *TMP1075_HANDLER_2_STRING = "TMP1075_HANDLER_2"; +const char *CORE_CONTROLLER_STRING = "CORE_CONTROLLER"; +const char *ACS_CONTROLLER_STRING = "ACS_CONTROLLER"; +const char *THERMAL_CONTROLLER_STRING = "THERMAL_CONTROLLER"; const char *MGM_0_LIS3_HANDLER_STRING = "MGM_0_LIS3_HANDLER"; -const char *MGM_1_RM3100_HANDLER_STRING = "MGM_1_RM3100_HANDLER"; -const char *MGM_2_LIS3_HANDLER_STRING = "MGM_2_LIS3_HANDLER"; -const char *MGM_3_RM3100_HANDLER_STRING = "MGM_3_RM3100_HANDLER"; const char *GYRO_0_ADIS_HANDLER_STRING = "GYRO_0_ADIS_HANDLER"; -const char *GYRO_1_L3G_HANDLER_STRING = "GYRO_1_L3G_HANDLER"; -const char *GYRO_2_L3G_HANDLER_STRING = "GYRO_2_L3G_HANDLER"; -const char *IMTQ_HANDLER_STRING = "IMTQ_HANDLER"; -const char *PLOC_HANDLER_STRING = "PLOC_HANDLER"; const char *SUS_1_STRING = "SUS_1"; const char *SUS_2_STRING = "SUS_2"; const char *SUS_3_STRING = "SUS_3"; @@ -35,26 +25,58 @@ const char *SUS_10_STRING = "SUS_10"; const char *SUS_11_STRING = "SUS_11"; const char *SUS_12_STRING = "SUS_12"; const char *SUS_13_STRING = "SUS_13"; +const char *MGM_1_RM3100_HANDLER_STRING = "MGM_1_RM3100_HANDLER"; +const char *GYRO_1_L3G_HANDLER_STRING = "GYRO_1_L3G_HANDLER"; +const char *MGM_2_LIS3_HANDLER_STRING = "MGM_2_LIS3_HANDLER"; +const char *GYRO_2_ADIS_HANDLER_STRING = "GYRO_2_ADIS_HANDLER"; +const char *MGM_3_RM3100_HANDLER_STRING = "MGM_3_RM3100_HANDLER"; +const char *GYRO_3_L3G_HANDLER_STRING = "GYRO_3_L3G_HANDLER"; +const char *GPS0_HANDLER_STRING = "GPS0_HANDLER"; +const char *GPS1_HANDLER_STRING = "GPS1_HANDLER"; +const char *IMTQ_HANDLER_STRING = "IMTQ_HANDLER"; const char *PCDU_HANDLER_STRING = "PCDU_HANDLER"; +const char *RW1_STRING = "RW1"; +const char *RW2_STRING = "RW2"; +const char *RW3_STRING = "RW3"; +const char *RW4_STRING = "RW4"; +const char *P60DOCK_HANDLER_STRING = "P60DOCK_HANDLER"; +const char *PDU1_HANDLER_STRING = "PDU1_HANDLER"; +const char *PDU2_HANDLER_STRING = "PDU2_HANDLER"; +const char *ACU_HANDLER_STRING = "ACU_HANDLER"; +const char *RAD_SENSOR_STRING = "RAD_SENSOR"; +const char *PLOC_HANDLER_STRING = "PLOC_HANDLER"; const char *SOLAR_ARRAY_DEPL_HANDLER_STRING = "SOLAR_ARRAY_DEPL_HANDLER"; +const char *HEATER_HANDLER_STRING = "HEATER_HANDLER"; +const char *TMP1075_HANDLER_1_STRING = "TMP1075_HANDLER_1"; +const char *TMP1075_HANDLER_2_STRING = "TMP1075_HANDLER_2"; +const char *RTD_IC3_STRING = "RTD_IC3"; +const char *RTD_IC4_STRING = "RTD_IC4"; +const char *RTD_IC5_STRING = "RTD_IC5"; +const char *RTD_IC6_STRING = "RTD_IC6"; +const char *RTD_IC7_STRING = "RTD_IC7"; +const char *RTD_IC8_STRING = "RTD_IC8"; +const char *RTD_IC9_STRING = "RTD_IC9"; +const char *RTD_IC10_STRING = "RTD_IC10"; +const char *RTD_IC11_STRING = "RTD_IC11"; +const char *RTD_IC12_STRING = "RTD_IC12"; +const char *RTD_IC13_STRING = "RTD_IC13"; +const char *RTD_IC14_STRING = "RTD_IC14"; +const char *RTD_IC15_STRING = "RTD_IC15"; +const char *RTD_IC16_STRING = "RTD_IC16"; +const char *RTD_IC17_STRING = "RTD_IC17"; +const char *RTD_IC18_STRING = "RTD_IC18"; const char *SYRLINKS_HK_HANDLER_STRING = "SYRLINKS_HK_HANDLER"; -const char *GPIO_IF_STRING = "GPIO_IF"; const char *ARDUINO_COM_IF_STRING = "ARDUINO_COM_IF"; -const char *CSP_COM_IF_STRING = "CSP_COM_IF"; -const char *I2C_COM_IF_STRING = "I2C_COM_IF"; -const char *UART_COM_IF_STRING = "UART_COM_IF"; +const char *GPIO_IF_STRING = "GPIO_IF"; const char *SPI_COM_IF_STRING = "SPI_COM_IF"; +const char *UART_COM_IF_STRING = "UART_COM_IF"; +const char *I2C_COM_IF_STRING = "I2C_COM_IF"; +const char *CSP_COM_IF_STRING = "CSP_COM_IF"; const char *CCSDS_PACKET_DISTRIBUTOR_STRING = "CCSDS_PACKET_DISTRIBUTOR"; const char *PUS_PACKET_DISTRIBUTOR_STRING = "PUS_PACKET_DISTRIBUTOR"; const char *UDP_BRIDGE_STRING = "UDP_BRIDGE"; const char *UDP_POLLING_TASK_STRING = "UDP_POLLING_TASK"; -const char *PUS_SERVICE_3_STRING = "PUS_SERVICE_3"; -const char *PUS_SERVICE_5_STRING = "PUS_SERVICE_5"; const char *PUS_SERVICE_6_STRING = "PUS_SERVICE_6"; -const char *PUS_SERVICE_8_STRING = "PUS_SERVICE_8"; -const char *PUS_SERVICE_23_STRING = "PUS_SERVICE_23"; -const char *PUS_SERVICE_201_STRING = "PUS_SERVICE_201"; -const char *TM_FUNNEL_STRING = "TM_FUNNEL"; const char *FSFW_OBJECTS_START_STRING = "FSFW_OBJECTS_START"; const char *PUS_SERVICE_1_VERIFICATION_STRING = "PUS_SERVICE_1_VERIFICATION"; const char *PUS_SERVICE_2_DEVICE_ACCESS_STRING = "PUS_SERVICE_2_DEVICE_ACCESS"; @@ -75,109 +97,150 @@ const char *TM_STORE_STRING = "TM_STORE"; const char *IPC_STORE_STRING = "IPC_STORE"; const char *TIME_STAMPER_STRING = "TIME_STAMPER"; const char *FSFW_OBJECTS_END_STRING = "FSFW_OBJECTS_END"; -const char *HEATER_HANDLER_STRING = "HEATER_HANDLER"; -const char *RTD_IC3_STRING = "RTD_IC3"; -const char *RTD_IC4_STRING = "RTD_IC4"; -const char *RTD_IC5_STRING = "RTD_IC5"; -const char *RTD_IC6_STRING = "RTD_IC6"; -const char *RTD_IC7_STRING = "RTD_IC7"; -const char *RTD_IC8_STRING = "RTD_IC8"; -const char *RTD_IC9_STRING = "RTD_IC9"; -const char *RTD_IC10_STRING = "RTD_IC10"; -const char *RTD_IC11_STRING = "RTD_IC11"; -const char *RTD_IC12_STRING = "RTD_IC12"; -const char *RTD_IC13_STRING = "RTD_IC13"; -const char *RTD_IC14_STRING = "RTD_IC14"; const char *SPI_TEST_STRING = "SPI_TEST"; -const char *RTD_IC15_STRING = "RTD_IC15"; -const char *RTD_IC16_STRING = "RTD_IC16"; -const char *RTD_IC17_STRING = "RTD_IC17"; -const char *RTD_IC18_STRING = "RTD_IC18"; -const char *RAD_SENSOR_STRING = "RAD_SENSOR"; +const char *UART_TEST_STRING = "UART_TEST"; const char *DUMMY_HANDLER_STRING = "DUMMY_HANDLER"; const char *DUMMY_INTERFACE_STRING = "DUMMY_INTERFACE"; const char *LIBGPIOD_TEST_STRING = "LIBGPIOD_TEST"; const char *TEST_TASK_STRING = "TEST_TASK"; +const char *TM_FUNNEL_STRING = "TM_FUNNEL"; +const char *CCSDS_IP_CORE_BRIDGE_STRING = "CCSDS_IP_CORE_BRIDGE"; const char *NO_OBJECT_STRING = "NO_OBJECT"; const char* translateObject(object_id_t object) { switch( (object & 0xFFFFFFFF) ) { case 0x00005060: return P60DOCK_TEST_TASK_STRING; - case 0x44000001: - return P60DOCK_HANDLER_STRING; - case 0x44000002: - return PDU1_HANDLER_STRING; - case 0x44000003: - return PDU2_HANDLER_STRING; - case 0x44000004: - return ACU_HANDLER_STRING; - case 0x44000005: - return TMP1075_HANDLER_1_STRING; - case 0x44000006: - return TMP1075_HANDLER_2_STRING; - case 0x44000007: + case 0x43000003: + return CORE_CONTROLLER_STRING; + case 0x43100002: + return ACS_CONTROLLER_STRING; + case 0x43400001: + return THERMAL_CONTROLLER_STRING; + case 0x44120006: return MGM_0_LIS3_HANDLER_STRING; - case 0x44000008: - return MGM_1_RM3100_HANDLER_STRING; - case 0x44000009: - return MGM_2_LIS3_HANDLER_STRING; - case 0x44000010: - return MGM_3_RM3100_HANDLER_STRING; - case 0x44000011: + case 0x44120010: return GYRO_0_ADIS_HANDLER_STRING; - case 0x44000012: - return GYRO_1_L3G_HANDLER_STRING; - case 0x44000013: - return GYRO_2_L3G_HANDLER_STRING; - case 0x44000014: - return IMTQ_HANDLER_STRING; - case 0x44000015: - return PLOC_HANDLER_STRING; - case 0x44000016: + case 0x44120032: return SUS_1_STRING; - case 0x44000017: + case 0x44120033: return SUS_2_STRING; - case 0x44000018: + case 0x44120034: return SUS_3_STRING; - case 0x44000019: + case 0x44120035: return SUS_4_STRING; - case 0x4400001A: + case 0x44120036: return SUS_5_STRING; - case 0x4400001B: + case 0x44120037: return SUS_6_STRING; - case 0x4400001C: + case 0x44120038: return SUS_7_STRING; - case 0x4400001D: + case 0x44120039: return SUS_8_STRING; - case 0x4400001E: + case 0x44120040: return SUS_9_STRING; - case 0x4400001F: + case 0x44120041: return SUS_10_STRING; - case 0x44000021: + case 0x44120042: return SUS_11_STRING; - case 0x44000022: + case 0x44120043: return SUS_12_STRING; - case 0x44000023: + case 0x44120044: return SUS_13_STRING; - case 0x44001000: + case 0x44120107: + return MGM_1_RM3100_HANDLER_STRING; + case 0x44120111: + return GYRO_1_L3G_HANDLER_STRING; + case 0x44120208: + return MGM_2_LIS3_HANDLER_STRING; + case 0x44120212: + return GYRO_2_ADIS_HANDLER_STRING; + case 0x44120309: + return MGM_3_RM3100_HANDLER_STRING; + case 0x44120313: + return GYRO_3_L3G_HANDLER_STRING; + case 0x44130045: + return GPS0_HANDLER_STRING; + case 0x44130146: + return GPS1_HANDLER_STRING; + case 0x44140014: + return IMTQ_HANDLER_STRING; + case 0x442000A1: return PCDU_HANDLER_STRING; - case 0x44001001: + case 0x44210001: + return RW1_STRING; + case 0x44210002: + return RW2_STRING; + case 0x44210003: + return RW3_STRING; + case 0x44210004: + return RW4_STRING; + case 0x44250000: + return P60DOCK_HANDLER_STRING; + case 0x44250001: + return PDU1_HANDLER_STRING; + case 0x44250002: + return PDU2_HANDLER_STRING; + case 0x44250003: + return ACU_HANDLER_STRING; + case 0x443200A5: + return RAD_SENSOR_STRING; + case 0x44330015: + return PLOC_HANDLER_STRING; + case 0x444100A2: return SOLAR_ARRAY_DEPL_HANDLER_STRING; - case 0x44001002: + case 0x444100A4: + return HEATER_HANDLER_STRING; + case 0x44420004: + return TMP1075_HANDLER_1_STRING; + case 0x44420005: + return TMP1075_HANDLER_2_STRING; + case 0x44420016: + return RTD_IC3_STRING; + case 0x44420017: + return RTD_IC4_STRING; + case 0x44420018: + return RTD_IC5_STRING; + case 0x44420019: + return RTD_IC6_STRING; + case 0x44420020: + return RTD_IC7_STRING; + case 0x44420021: + return RTD_IC8_STRING; + case 0x44420022: + return RTD_IC9_STRING; + case 0x44420023: + return RTD_IC10_STRING; + case 0x44420024: + return RTD_IC11_STRING; + case 0x44420025: + return RTD_IC12_STRING; + case 0x44420026: + return RTD_IC13_STRING; + case 0x44420027: + return RTD_IC14_STRING; + case 0x44420028: + return RTD_IC15_STRING; + case 0x44420029: + return RTD_IC16_STRING; + case 0x44420030: + return RTD_IC17_STRING; + case 0x44420031: + return RTD_IC18_STRING; + case 0x445300A3: return SYRLINKS_HK_HANDLER_STRING; - case 0x47000001: - return GPIO_IF_STRING; - case 0x49000001: + case 0x49000000: return ARDUINO_COM_IF_STRING; - case 0x49000002: - return CSP_COM_IF_STRING; - case 0x49000003: - return I2C_COM_IF_STRING; - case 0x49000004: - return UART_COM_IF_STRING; - case 0x49000005: + case 0x49010005: + return GPIO_IF_STRING; + case 0x49020004: return SPI_COM_IF_STRING; + case 0x49030003: + return UART_COM_IF_STRING; + case 0x49040002: + return I2C_COM_IF_STRING; + case 0x49050001: + return CSP_COM_IF_STRING; case 0x50000100: return CCSDS_PACKET_DISTRIBUTOR_STRING; case 0x50000200: @@ -186,20 +249,8 @@ const char* translateObject(object_id_t object) { return UDP_BRIDGE_STRING; case 0x50000400: return UDP_POLLING_TASK_STRING; - case 0x51000300: - return PUS_SERVICE_3_STRING; - case 0x51000400: - return PUS_SERVICE_5_STRING; case 0x51000500: return PUS_SERVICE_6_STRING; - case 0x51000800: - return PUS_SERVICE_8_STRING; - case 0x51002300: - return PUS_SERVICE_23_STRING; - case 0x51020100: - return PUS_SERVICE_201_STRING; - case 0x52000002: - return TM_FUNNEL_STRING; case 0x53000000: return FSFW_OBJECTS_START_STRING; case 0x53000001: @@ -240,44 +291,10 @@ const char* translateObject(object_id_t object) { return TIME_STAMPER_STRING; case 0x53ffffff: return FSFW_OBJECTS_END_STRING; - case 0x54000003: - return HEATER_HANDLER_STRING; - case 0x54000004: - return RTD_IC3_STRING; - case 0x54000005: - return RTD_IC4_STRING; - case 0x54000006: - return RTD_IC5_STRING; - case 0x54000007: - return RTD_IC6_STRING; - case 0x54000008: - return RTD_IC7_STRING; - case 0x54000009: - return RTD_IC8_STRING; - case 0x5400000A: - return RTD_IC9_STRING; - case 0x5400000B: - return RTD_IC10_STRING; - case 0x5400000C: - return RTD_IC11_STRING; - case 0x5400000D: - return RTD_IC12_STRING; - case 0x5400000E: - return RTD_IC13_STRING; - case 0x5400000F: - return RTD_IC14_STRING; case 0x54000010: return SPI_TEST_STRING; - case 0x5400001F: - return RTD_IC15_STRING; - case 0x5400002F: - return RTD_IC16_STRING; - case 0x5400003F: - return RTD_IC17_STRING; - case 0x5400004F: - return RTD_IC18_STRING; - case 0x54000050: - return RAD_SENSOR_STRING; + case 0x54000020: + return UART_TEST_STRING; case 0x5400AFFE: return DUMMY_HANDLER_STRING; case 0x5400CAFE: @@ -286,6 +303,10 @@ const char* translateObject(object_id_t object) { return LIBGPIOD_TEST_STRING; case 0x54694269: return TEST_TASK_STRING; + case 0x73000100: + return TM_FUNNEL_STRING; + case 0x73500000: + return CCSDS_IP_CORE_BRIDGE_STRING; case 0xFFFFFFFF: return NO_OBJECT_STRING; default: diff --git a/linux/fsfwconfig/events/translateEvents.cpp b/linux/fsfwconfig/events/translateEvents.cpp index c3af08e1..9ae81646 100644 --- a/linux/fsfwconfig/events/translateEvents.cpp +++ b/linux/fsfwconfig/events/translateEvents.cpp @@ -1,7 +1,7 @@ /** - * @brief Auto-generated event translation file. Contains 83 translations. + * @brief Auto-generated event translation file. Contains 92 translations. * @details - * Generated on: 2021-06-08 17:09:32 + * Generated on: 2021-06-29 16:20:09 */ #include "translateEvents.h" @@ -88,6 +88,15 @@ const char *MEMORY_READ_RPT_CRC_FAILURE_STRING = "MEMORY_READ_RPT_CRC_FAILURE"; const char *ACK_FAILURE_STRING = "ACK_FAILURE"; const char *EXE_FAILURE_STRING = "EXE_FAILURE"; const char *CRC_FAILURE_EVENT_STRING = "CRC_FAILURE_EVENT"; +const char *SELF_TEST_I2C_FAILURE_STRING = "SELF_TEST_I2C_FAILURE"; +const char *SELF_TEST_SPI_FAILURE_STRING = "SELF_TEST_SPI_FAILURE"; +const char *SELF_TEST_ADC_FAILURE_STRING = "SELF_TEST_ADC_FAILURE"; +const char *SELF_TEST_PWM_FAILURE_STRING = "SELF_TEST_PWM_FAILURE"; +const char *SELF_TEST_TC_FAILURE_STRING = "SELF_TEST_TC_FAILURE"; +const char *SELF_TEST_MTM_RANGE_FAILURE_STRING = "SELF_TEST_MTM_RANGE_FAILURE"; +const char *SELF_TEST_COIL_CURRENT_FAILURE_STRING = "SELF_TEST_COIL_CURRENT_FAILURE"; +const char *INVALID_ERROR_BYTE_STRING = "INVALID_ERROR_BYTE"; +const char *ERROR_STATE_STRING = "ERROR_STATE"; const char * translateEvents(Event event) { switch( (event & 0xffff) ) { @@ -257,6 +266,24 @@ const char * translateEvents(Event event) { return EXE_FAILURE_STRING; case(11104): return CRC_FAILURE_EVENT_STRING; + case(11201): + return SELF_TEST_I2C_FAILURE_STRING; + case(11202): + return SELF_TEST_SPI_FAILURE_STRING; + case(11203): + return SELF_TEST_ADC_FAILURE_STRING; + case(11204): + return SELF_TEST_PWM_FAILURE_STRING; + case(11205): + return SELF_TEST_TC_FAILURE_STRING; + case(11206): + return SELF_TEST_MTM_RANGE_FAILURE_STRING; + case(11207): + return SELF_TEST_COIL_CURRENT_FAILURE_STRING; + case(11208): + return INVALID_ERROR_BYTE_STRING; + case(11301): + return ERROR_STATE_STRING; default: return "UNKNOWN_EVENT"; } diff --git a/linux/fsfwconfig/objects/translateObjects.cpp b/linux/fsfwconfig/objects/translateObjects.cpp index 47b55435..2068158b 100644 --- a/linux/fsfwconfig/objects/translateObjects.cpp +++ b/linux/fsfwconfig/objects/translateObjects.cpp @@ -1,27 +1,17 @@ -/** +/** * @brief Auto-generated object translation file. * @details - * Contains 93 translations. - * Generated on: 2021-05-18 16:48:46 + * Contains 100 translations. + * Generated on: 2021-06-29 16:19:57 */ #include "translateObjects.h" const char *P60DOCK_TEST_TASK_STRING = "P60DOCK_TEST_TASK"; -const char *P60DOCK_HANDLER_STRING = "P60DOCK_HANDLER"; -const char *PDU1_HANDLER_STRING = "PDU1_HANDLER"; -const char *PDU2_HANDLER_STRING = "PDU2_HANDLER"; -const char *ACU_HANDLER_STRING = "ACU_HANDLER"; -const char *TMP1075_HANDLER_1_STRING = "TMP1075_HANDLER_1"; -const char *TMP1075_HANDLER_2_STRING = "TMP1075_HANDLER_2"; +const char *CORE_CONTROLLER_STRING = "CORE_CONTROLLER"; +const char *ACS_CONTROLLER_STRING = "ACS_CONTROLLER"; +const char *THERMAL_CONTROLLER_STRING = "THERMAL_CONTROLLER"; const char *MGM_0_LIS3_HANDLER_STRING = "MGM_0_LIS3_HANDLER"; -const char *MGM_1_RM3100_HANDLER_STRING = "MGM_1_RM3100_HANDLER"; -const char *MGM_2_LIS3_HANDLER_STRING = "MGM_2_LIS3_HANDLER"; -const char *MGM_3_RM3100_HANDLER_STRING = "MGM_3_RM3100_HANDLER"; const char *GYRO_0_ADIS_HANDLER_STRING = "GYRO_0_ADIS_HANDLER"; -const char *GYRO_1_L3G_HANDLER_STRING = "GYRO_1_L3G_HANDLER"; -const char *GYRO_2_L3G_HANDLER_STRING = "GYRO_2_L3G_HANDLER"; -const char *IMTQ_HANDLER_STRING = "IMTQ_HANDLER"; -const char *PLOC_HANDLER_STRING = "PLOC_HANDLER"; const char *SUS_1_STRING = "SUS_1"; const char *SUS_2_STRING = "SUS_2"; const char *SUS_3_STRING = "SUS_3"; @@ -35,26 +25,58 @@ const char *SUS_10_STRING = "SUS_10"; const char *SUS_11_STRING = "SUS_11"; const char *SUS_12_STRING = "SUS_12"; const char *SUS_13_STRING = "SUS_13"; +const char *MGM_1_RM3100_HANDLER_STRING = "MGM_1_RM3100_HANDLER"; +const char *GYRO_1_L3G_HANDLER_STRING = "GYRO_1_L3G_HANDLER"; +const char *MGM_2_LIS3_HANDLER_STRING = "MGM_2_LIS3_HANDLER"; +const char *GYRO_2_ADIS_HANDLER_STRING = "GYRO_2_ADIS_HANDLER"; +const char *MGM_3_RM3100_HANDLER_STRING = "MGM_3_RM3100_HANDLER"; +const char *GYRO_3_L3G_HANDLER_STRING = "GYRO_3_L3G_HANDLER"; +const char *GPS0_HANDLER_STRING = "GPS0_HANDLER"; +const char *GPS1_HANDLER_STRING = "GPS1_HANDLER"; +const char *IMTQ_HANDLER_STRING = "IMTQ_HANDLER"; const char *PCDU_HANDLER_STRING = "PCDU_HANDLER"; +const char *RW1_STRING = "RW1"; +const char *RW2_STRING = "RW2"; +const char *RW3_STRING = "RW3"; +const char *RW4_STRING = "RW4"; +const char *P60DOCK_HANDLER_STRING = "P60DOCK_HANDLER"; +const char *PDU1_HANDLER_STRING = "PDU1_HANDLER"; +const char *PDU2_HANDLER_STRING = "PDU2_HANDLER"; +const char *ACU_HANDLER_STRING = "ACU_HANDLER"; +const char *RAD_SENSOR_STRING = "RAD_SENSOR"; +const char *PLOC_HANDLER_STRING = "PLOC_HANDLER"; const char *SOLAR_ARRAY_DEPL_HANDLER_STRING = "SOLAR_ARRAY_DEPL_HANDLER"; +const char *HEATER_HANDLER_STRING = "HEATER_HANDLER"; +const char *TMP1075_HANDLER_1_STRING = "TMP1075_HANDLER_1"; +const char *TMP1075_HANDLER_2_STRING = "TMP1075_HANDLER_2"; +const char *RTD_IC3_STRING = "RTD_IC3"; +const char *RTD_IC4_STRING = "RTD_IC4"; +const char *RTD_IC5_STRING = "RTD_IC5"; +const char *RTD_IC6_STRING = "RTD_IC6"; +const char *RTD_IC7_STRING = "RTD_IC7"; +const char *RTD_IC8_STRING = "RTD_IC8"; +const char *RTD_IC9_STRING = "RTD_IC9"; +const char *RTD_IC10_STRING = "RTD_IC10"; +const char *RTD_IC11_STRING = "RTD_IC11"; +const char *RTD_IC12_STRING = "RTD_IC12"; +const char *RTD_IC13_STRING = "RTD_IC13"; +const char *RTD_IC14_STRING = "RTD_IC14"; +const char *RTD_IC15_STRING = "RTD_IC15"; +const char *RTD_IC16_STRING = "RTD_IC16"; +const char *RTD_IC17_STRING = "RTD_IC17"; +const char *RTD_IC18_STRING = "RTD_IC18"; const char *SYRLINKS_HK_HANDLER_STRING = "SYRLINKS_HK_HANDLER"; -const char *GPIO_IF_STRING = "GPIO_IF"; const char *ARDUINO_COM_IF_STRING = "ARDUINO_COM_IF"; -const char *CSP_COM_IF_STRING = "CSP_COM_IF"; -const char *I2C_COM_IF_STRING = "I2C_COM_IF"; -const char *UART_COM_IF_STRING = "UART_COM_IF"; +const char *GPIO_IF_STRING = "GPIO_IF"; const char *SPI_COM_IF_STRING = "SPI_COM_IF"; +const char *UART_COM_IF_STRING = "UART_COM_IF"; +const char *I2C_COM_IF_STRING = "I2C_COM_IF"; +const char *CSP_COM_IF_STRING = "CSP_COM_IF"; const char *CCSDS_PACKET_DISTRIBUTOR_STRING = "CCSDS_PACKET_DISTRIBUTOR"; const char *PUS_PACKET_DISTRIBUTOR_STRING = "PUS_PACKET_DISTRIBUTOR"; const char *UDP_BRIDGE_STRING = "UDP_BRIDGE"; const char *UDP_POLLING_TASK_STRING = "UDP_POLLING_TASK"; -const char *PUS_SERVICE_3_STRING = "PUS_SERVICE_3"; -const char *PUS_SERVICE_5_STRING = "PUS_SERVICE_5"; const char *PUS_SERVICE_6_STRING = "PUS_SERVICE_6"; -const char *PUS_SERVICE_8_STRING = "PUS_SERVICE_8"; -const char *PUS_SERVICE_23_STRING = "PUS_SERVICE_23"; -const char *PUS_SERVICE_201_STRING = "PUS_SERVICE_201"; -const char *TM_FUNNEL_STRING = "TM_FUNNEL"; const char *FSFW_OBJECTS_START_STRING = "FSFW_OBJECTS_START"; const char *PUS_SERVICE_1_VERIFICATION_STRING = "PUS_SERVICE_1_VERIFICATION"; const char *PUS_SERVICE_2_DEVICE_ACCESS_STRING = "PUS_SERVICE_2_DEVICE_ACCESS"; @@ -75,109 +97,150 @@ const char *TM_STORE_STRING = "TM_STORE"; const char *IPC_STORE_STRING = "IPC_STORE"; const char *TIME_STAMPER_STRING = "TIME_STAMPER"; const char *FSFW_OBJECTS_END_STRING = "FSFW_OBJECTS_END"; -const char *HEATER_HANDLER_STRING = "HEATER_HANDLER"; -const char *RTD_IC3_STRING = "RTD_IC3"; -const char *RTD_IC4_STRING = "RTD_IC4"; -const char *RTD_IC5_STRING = "RTD_IC5"; -const char *RTD_IC6_STRING = "RTD_IC6"; -const char *RTD_IC7_STRING = "RTD_IC7"; -const char *RTD_IC8_STRING = "RTD_IC8"; -const char *RTD_IC9_STRING = "RTD_IC9"; -const char *RTD_IC10_STRING = "RTD_IC10"; -const char *RTD_IC11_STRING = "RTD_IC11"; -const char *RTD_IC12_STRING = "RTD_IC12"; -const char *RTD_IC13_STRING = "RTD_IC13"; -const char *RTD_IC14_STRING = "RTD_IC14"; const char *SPI_TEST_STRING = "SPI_TEST"; -const char *RTD_IC15_STRING = "RTD_IC15"; -const char *RTD_IC16_STRING = "RTD_IC16"; -const char *RTD_IC17_STRING = "RTD_IC17"; -const char *RTD_IC18_STRING = "RTD_IC18"; -const char *RAD_SENSOR_STRING = "RAD_SENSOR"; +const char *UART_TEST_STRING = "UART_TEST"; const char *DUMMY_HANDLER_STRING = "DUMMY_HANDLER"; const char *DUMMY_INTERFACE_STRING = "DUMMY_INTERFACE"; const char *LIBGPIOD_TEST_STRING = "LIBGPIOD_TEST"; const char *TEST_TASK_STRING = "TEST_TASK"; +const char *TM_FUNNEL_STRING = "TM_FUNNEL"; +const char *CCSDS_IP_CORE_BRIDGE_STRING = "CCSDS_IP_CORE_BRIDGE"; const char *NO_OBJECT_STRING = "NO_OBJECT"; const char* translateObject(object_id_t object) { switch( (object & 0xFFFFFFFF) ) { case 0x00005060: return P60DOCK_TEST_TASK_STRING; - case 0x44000001: - return P60DOCK_HANDLER_STRING; - case 0x44000002: - return PDU1_HANDLER_STRING; - case 0x44000003: - return PDU2_HANDLER_STRING; - case 0x44000004: - return ACU_HANDLER_STRING; - case 0x44000005: - return TMP1075_HANDLER_1_STRING; - case 0x44000006: - return TMP1075_HANDLER_2_STRING; - case 0x44000007: + case 0x43000003: + return CORE_CONTROLLER_STRING; + case 0x43100002: + return ACS_CONTROLLER_STRING; + case 0x43400001: + return THERMAL_CONTROLLER_STRING; + case 0x44120006: return MGM_0_LIS3_HANDLER_STRING; - case 0x44000008: - return MGM_1_RM3100_HANDLER_STRING; - case 0x44000009: - return MGM_2_LIS3_HANDLER_STRING; - case 0x44000010: - return MGM_3_RM3100_HANDLER_STRING; - case 0x44000011: + case 0x44120010: return GYRO_0_ADIS_HANDLER_STRING; - case 0x44000012: - return GYRO_1_L3G_HANDLER_STRING; - case 0x44000013: - return GYRO_2_L3G_HANDLER_STRING; - case 0x44000014: - return IMTQ_HANDLER_STRING; - case 0x44000015: - return PLOC_HANDLER_STRING; - case 0x44000016: + case 0x44120032: return SUS_1_STRING; - case 0x44000017: + case 0x44120033: return SUS_2_STRING; - case 0x44000018: + case 0x44120034: return SUS_3_STRING; - case 0x44000019: + case 0x44120035: return SUS_4_STRING; - case 0x4400001A: + case 0x44120036: return SUS_5_STRING; - case 0x4400001B: + case 0x44120037: return SUS_6_STRING; - case 0x4400001C: + case 0x44120038: return SUS_7_STRING; - case 0x4400001D: + case 0x44120039: return SUS_8_STRING; - case 0x4400001E: + case 0x44120040: return SUS_9_STRING; - case 0x4400001F: + case 0x44120041: return SUS_10_STRING; - case 0x44000021: + case 0x44120042: return SUS_11_STRING; - case 0x44000022: + case 0x44120043: return SUS_12_STRING; - case 0x44000023: + case 0x44120044: return SUS_13_STRING; - case 0x44001000: + case 0x44120107: + return MGM_1_RM3100_HANDLER_STRING; + case 0x44120111: + return GYRO_1_L3G_HANDLER_STRING; + case 0x44120208: + return MGM_2_LIS3_HANDLER_STRING; + case 0x44120212: + return GYRO_2_ADIS_HANDLER_STRING; + case 0x44120309: + return MGM_3_RM3100_HANDLER_STRING; + case 0x44120313: + return GYRO_3_L3G_HANDLER_STRING; + case 0x44130045: + return GPS0_HANDLER_STRING; + case 0x44130146: + return GPS1_HANDLER_STRING; + case 0x44140014: + return IMTQ_HANDLER_STRING; + case 0x442000A1: return PCDU_HANDLER_STRING; - case 0x44001001: + case 0x44210001: + return RW1_STRING; + case 0x44210002: + return RW2_STRING; + case 0x44210003: + return RW3_STRING; + case 0x44210004: + return RW4_STRING; + case 0x44250000: + return P60DOCK_HANDLER_STRING; + case 0x44250001: + return PDU1_HANDLER_STRING; + case 0x44250002: + return PDU2_HANDLER_STRING; + case 0x44250003: + return ACU_HANDLER_STRING; + case 0x443200A5: + return RAD_SENSOR_STRING; + case 0x44330015: + return PLOC_HANDLER_STRING; + case 0x444100A2: return SOLAR_ARRAY_DEPL_HANDLER_STRING; - case 0x44001002: + case 0x444100A4: + return HEATER_HANDLER_STRING; + case 0x44420004: + return TMP1075_HANDLER_1_STRING; + case 0x44420005: + return TMP1075_HANDLER_2_STRING; + case 0x44420016: + return RTD_IC3_STRING; + case 0x44420017: + return RTD_IC4_STRING; + case 0x44420018: + return RTD_IC5_STRING; + case 0x44420019: + return RTD_IC6_STRING; + case 0x44420020: + return RTD_IC7_STRING; + case 0x44420021: + return RTD_IC8_STRING; + case 0x44420022: + return RTD_IC9_STRING; + case 0x44420023: + return RTD_IC10_STRING; + case 0x44420024: + return RTD_IC11_STRING; + case 0x44420025: + return RTD_IC12_STRING; + case 0x44420026: + return RTD_IC13_STRING; + case 0x44420027: + return RTD_IC14_STRING; + case 0x44420028: + return RTD_IC15_STRING; + case 0x44420029: + return RTD_IC16_STRING; + case 0x44420030: + return RTD_IC17_STRING; + case 0x44420031: + return RTD_IC18_STRING; + case 0x445300A3: return SYRLINKS_HK_HANDLER_STRING; - case 0x47000001: - return GPIO_IF_STRING; - case 0x49000001: + case 0x49000000: return ARDUINO_COM_IF_STRING; - case 0x49000002: - return CSP_COM_IF_STRING; - case 0x49000003: - return I2C_COM_IF_STRING; - case 0x49000004: - return UART_COM_IF_STRING; - case 0x49000005: + case 0x49010005: + return GPIO_IF_STRING; + case 0x49020004: return SPI_COM_IF_STRING; + case 0x49030003: + return UART_COM_IF_STRING; + case 0x49040002: + return I2C_COM_IF_STRING; + case 0x49050001: + return CSP_COM_IF_STRING; case 0x50000100: return CCSDS_PACKET_DISTRIBUTOR_STRING; case 0x50000200: @@ -186,20 +249,8 @@ const char* translateObject(object_id_t object) { return UDP_BRIDGE_STRING; case 0x50000400: return UDP_POLLING_TASK_STRING; - case 0x51000300: - return PUS_SERVICE_3_STRING; - case 0x51000400: - return PUS_SERVICE_5_STRING; case 0x51000500: return PUS_SERVICE_6_STRING; - case 0x51000800: - return PUS_SERVICE_8_STRING; - case 0x51002300: - return PUS_SERVICE_23_STRING; - case 0x51020100: - return PUS_SERVICE_201_STRING; - case 0x52000002: - return TM_FUNNEL_STRING; case 0x53000000: return FSFW_OBJECTS_START_STRING; case 0x53000001: @@ -240,44 +291,10 @@ const char* translateObject(object_id_t object) { return TIME_STAMPER_STRING; case 0x53ffffff: return FSFW_OBJECTS_END_STRING; - case 0x54000003: - return HEATER_HANDLER_STRING; - case 0x54000004: - return RTD_IC3_STRING; - case 0x54000005: - return RTD_IC4_STRING; - case 0x54000006: - return RTD_IC5_STRING; - case 0x54000007: - return RTD_IC6_STRING; - case 0x54000008: - return RTD_IC7_STRING; - case 0x54000009: - return RTD_IC8_STRING; - case 0x5400000A: - return RTD_IC9_STRING; - case 0x5400000B: - return RTD_IC10_STRING; - case 0x5400000C: - return RTD_IC11_STRING; - case 0x5400000D: - return RTD_IC12_STRING; - case 0x5400000E: - return RTD_IC13_STRING; - case 0x5400000F: - return RTD_IC14_STRING; case 0x54000010: return SPI_TEST_STRING; - case 0x5400001F: - return RTD_IC15_STRING; - case 0x5400002F: - return RTD_IC16_STRING; - case 0x5400003F: - return RTD_IC17_STRING; - case 0x5400004F: - return RTD_IC18_STRING; - case 0x54000050: - return RAD_SENSOR_STRING; + case 0x54000020: + return UART_TEST_STRING; case 0x5400AFFE: return DUMMY_HANDLER_STRING; case 0x5400CAFE: @@ -286,6 +303,10 @@ const char* translateObject(object_id_t object) { return LIBGPIOD_TEST_STRING; case 0x54694269: return TEST_TASK_STRING; + case 0x73000100: + return TM_FUNNEL_STRING; + case 0x73500000: + return CCSDS_IP_CORE_BRIDGE_STRING; case 0xFFFFFFFF: return NO_OBJECT_STRING; default: diff --git a/mission/devices/RwHandler.cpp b/mission/devices/RwHandler.cpp index 45c721a8..a5f6dbef 100644 --- a/mission/devices/RwHandler.cpp +++ b/mission/devices/RwHandler.cpp @@ -68,7 +68,7 @@ ReturnValue_t RwHandler::buildNormalDeviceCommand(DeviceCommandId_t * id) { } ReturnValue_t RwHandler::buildTransitionDeviceCommand(DeviceCommandId_t * id) { - return RETURN_OK; + return NOTHING_TO_SEND; } ReturnValue_t RwHandler::buildCommandFromCommand(DeviceCommandId_t deviceCommand, @@ -230,7 +230,7 @@ void RwHandler::setNormalDatapoolEntriesInvalid() { } uint32_t RwHandler::getTransitionDelayMs(Mode_t modeFrom, Mode_t modeTo) { - return 500; + return 5000; } ReturnValue_t RwHandler::initializeLocalDataPool(localpool::DataPool& localDataPoolMap, From e89719e398d506aecf3d2c61c3e3f1e3eaa47268 Mon Sep 17 00:00:00 2001 From: "Jakob.Meier" Date: Wed, 30 Jun 2021 08:21:14 +0200 Subject: [PATCH 046/111] save before using prepareDataLessCmd --- mission/devices/RwHandler.cpp | 56 ++++++++++-- mission/devices/RwHandler.h | 1 + .../devices/devicedefinitions/RwDefinitions.h | 91 ++++++++++++++++++- tmtc | 2 +- 4 files changed, 138 insertions(+), 12 deletions(-) diff --git a/mission/devices/RwHandler.cpp b/mission/devices/RwHandler.cpp index a5f6dbef..b637cbba 100644 --- a/mission/devices/RwHandler.cpp +++ b/mission/devices/RwHandler.cpp @@ -7,7 +7,7 @@ RwHandler::RwHandler(object_id_t objectId, object_id_t comIF, CookieIF * comCookie, LinuxLibgpioIF* gpioComIF, gpioId_t enableGpio) : DeviceHandlerBase(objectId, comIF, comCookie), gpioComIF(gpioComIF), enableGpio(enableGpio), - temperatureSet(this), statusSet(this), lastResetStatusSet(this) { + temperatureSet(this), statusSet(this), lastResetStatusSet(this), tmDataset(this) { if (comCookie == NULL) { sif::error << "RwHandler: Invalid com cookie" << std::endl; } @@ -113,6 +113,10 @@ ReturnValue_t RwHandler::buildCommandFromCommand(DeviceCommandId_t deviceCommand prepareGetTemperatureCmd(); return RETURN_OK; } + case (RwDefinitions::GET_TM): { + prepareGetTelemetryCmd(); + return RETURN_OK; + } default: return DeviceHandlerIF::COMMAND_NOT_IMPLEMENTED; } @@ -246,6 +250,29 @@ ReturnValue_t RwHandler::initializeLocalDataPool(localpool::DataPool& localDataP localDataPoolMap.emplace(RwDefinitions::LAST_RESET_STATUS, new PoolEntry( { 0 })); localDataPoolMap.emplace(RwDefinitions::CURRRENT_RESET_STATUS, new PoolEntry( { 0 })); + localDataPoolMap.emplace(RwDefinitions::TM_LAST_RESET_STATUS, new PoolEntry( { 0 })); + localDataPoolMap.emplace(RwDefinitions::TM_MCU_TEMPERATURE, new PoolEntry( { 0 })); + localDataPoolMap.emplace(RwDefinitions::TM_RW_STATE, new PoolEntry( { 0 })); + localDataPoolMap.emplace(RwDefinitions::TM_CLC_MODE, new PoolEntry( { 0 })); + localDataPoolMap.emplace(RwDefinitions::TM_RW_CURR_SPEED, new PoolEntry( { 0 })); + localDataPoolMap.emplace(RwDefinitions::TM_RW_REF_SPEED, new PoolEntry( { 0 })); + localDataPoolMap.emplace(RwDefinitions::INVALID_CRC_PACKETS, new PoolEntry( { 0 })); + localDataPoolMap.emplace(RwDefinitions::INVALID_LEN_PACKETS, new PoolEntry( { 0 })); + localDataPoolMap.emplace(RwDefinitions::INVALID_CMD_PACKETS, new PoolEntry( { 0 })); + localDataPoolMap.emplace(RwDefinitions::EXECUTED_REPLIES, new PoolEntry( { 0 })); + localDataPoolMap.emplace(RwDefinitions::COMMAND_REPLIES, new PoolEntry( { 0 })); + localDataPoolMap.emplace(RwDefinitions::UART_BYTES_WRITTEN, new PoolEntry( { 0 })); + localDataPoolMap.emplace(RwDefinitions::UART_BYTES_READ, new PoolEntry( { 0 })); + localDataPoolMap.emplace(RwDefinitions::UART_PARITY_ERRORS, new PoolEntry( { 0 })); + localDataPoolMap.emplace(RwDefinitions::UART_NOISE_ERRORS, new PoolEntry( { 0 })); + localDataPoolMap.emplace(RwDefinitions::UART_FRAME_ERRORS, new PoolEntry( { 0 })); + localDataPoolMap.emplace(RwDefinitions::UART_REG_OVERRUN_ERRORS, new PoolEntry( { 0 })); + localDataPoolMap.emplace(RwDefinitions::UART_TOTAL_ERRORS, new PoolEntry( { 0 })); + localDataPoolMap.emplace(RwDefinitions::SPI_BYTES_WRITTEN, new PoolEntry( { 0 })); + localDataPoolMap.emplace(RwDefinitions::SPI_BYTES_READ, new PoolEntry( { 0 })); + localDataPoolMap.emplace(RwDefinitions::SPI_REG_OVERRUN_ERRORS, new PoolEntry( { 0 })); + localDataPoolMap.emplace(RwDefinitions::SPI_TOTAL_ERRORS, new PoolEntry( { 0 })); + return RETURN_OK; } @@ -312,15 +339,6 @@ void RwHandler::prepareInitRwCommand() { rawPacketLen = 3; } -void RwHandler::prepareGetTemperatureCmd() { - commandBuffer[0] = static_cast(RwDefinitions::GET_TEMPERATURE); - uint16_t crc = CRC::crc16ccitt(commandBuffer, 1, 0xFFFF); - commandBuffer[1] = static_cast(crc & 0xFF); - commandBuffer[2] = static_cast(crc >> 8 & 0xFF); - rawPacket = commandBuffer; - rawPacketLen = 3; -} - void RwHandler::prepareSetSpeedCmd(const uint8_t * commandData, size_t commandDataLen) { commandBuffer[0] = static_cast(RwDefinitions::SET_SPEED); @@ -340,6 +358,24 @@ void RwHandler::prepareSetSpeedCmd(const uint8_t * commandData, size_t commandDa rawPacketLen = 9; } +void RwHandler::prepareGetTemperatureCmd() { + commandBuffer[0] = static_cast(RwDefinitions::GET_TEMPERATURE); + uint16_t crc = CRC::crc16ccitt(commandBuffer, 1, 0xFFFF); + commandBuffer[1] = static_cast(crc & 0xFF); + commandBuffer[2] = static_cast(crc >> 8 & 0xFF); + rawPacket = commandBuffer; + rawPacketLen = 3; +} + +void RwHandler::prepareGetTelemetryCmd() { + commandBuffer[0] = static_cast(RwDefinitions::GET_TM); + uint16_t crc = CRC::crc16ccitt(commandBuffer, 1, 0xFFFF); + commandBuffer[1] = static_cast(crc & 0xFF); + commandBuffer[2] = static_cast(crc >> 8 & 0xFF); + rawPacket = commandBuffer; + rawPacketLen = 3; +} + void RwHandler::handleResetStatusReply(const uint8_t* packet) { PoolReadGuard rg(&lastResetStatusSet); uint8_t offset = 2; diff --git a/mission/devices/RwHandler.h b/mission/devices/RwHandler.h index 11fb4a30..e447932d 100644 --- a/mission/devices/RwHandler.h +++ b/mission/devices/RwHandler.h @@ -88,6 +88,7 @@ private: RwDefinitions::TemperatureSet temperatureSet; RwDefinitions::StatusSet statusSet; RwDefinitions::LastResetSatus lastResetStatusSet; + RwDefinitions::TmDataset tmDataset; uint8_t commandBuffer[RwDefinitions::MAX_CMD_SIZE]; diff --git a/mission/devices/devicedefinitions/RwDefinitions.h b/mission/devices/devicedefinitions/RwDefinitions.h index fbdbd5cf..a477f47c 100644 --- a/mission/devices/devicedefinitions/RwDefinitions.h +++ b/mission/devices/devicedefinitions/RwDefinitions.h @@ -17,7 +17,30 @@ enum PoolIds: lp_id_t { STATE, CLC_MODE, LAST_RESET_STATUS, - CURRRENT_RESET_STATUS + CURRRENT_RESET_STATUS, + TM_LAST_RESET_STATUS, + TM_MCU_TEMPERATURE, + TM_RW_STATE, + TM_CLC_MODE, + TM_RW_CURR_SPEED, + TM_RW_REF_SPEED, + INVALID_CRC_PACKETS, + INVALID_LEN_PACKETS, + INVALID_CMD_PACKETS, + EXECUTED_REPLIES, + COMMAND_REPLIES, + UART_BYTES_WRITTEN, + UART_BYTES_READ, + UART_PARITY_ERRORS, + UART_NOISE_ERRORS, + UART_FRAME_ERRORS, + UART_REG_OVERRUN_ERRORS, + UART_TOTAL_ERRORS, + TOTAL_ERRORS, + SPI_BYTES_WRITTEN, + SPI_BYTES_READ, + SPI_REG_OVERRUN_ERRORS, + SPI_TOTAL_ERRORS }; enum States: uint8_t { @@ -46,10 +69,12 @@ static const DeviceCommandId_t GET_RW_STATUS = 4; static const DeviceCommandId_t INIT_RW_CONTROLLER = 5; static const DeviceCommandId_t SET_SPEED = 6; static const DeviceCommandId_t GET_TEMPERATURE = 8; +static const DeviceCommandId_t GET_TM = 9; static const uint32_t TEMPERATURE_SET_ID = GET_TEMPERATURE; static const uint32_t STATUS_SET_ID = GET_RW_STATUS; static const uint32_t LAST_RESET_ID = GET_LAST_RESET_STATUS; +static const uint32_t TM_SET_ID = GET_TM; static const size_t SIZE_GET_RESET_STATUS = 5; static const size_t SIZE_CLEAR_RESET_STATUS = 4; @@ -67,6 +92,7 @@ static const size_t MAX_REPLY_SIZE = SIZE_GET_TELEMETRY_REPLY; static const uint8_t LAST_RESET_ENTRIES = 2; static const uint8_t TEMPERATURE_SET_ENTRIES = 1; static const uint8_t STATUS_SET_ENTRIES = 4; +static const uint8_t TM_SET_ENTRIES = 22; /** * @brief This dataset can be used to store the temperature of a reaction wheel. @@ -133,6 +159,69 @@ public: PoolIds::CURRRENT_RESET_STATUS, this); }; +/** + * @brief This dataset stores telemetry data as specified in the datasheet of the nano avionics + * reaction wheels. https://eive-cloud.irs.uni-stuttgart.de/index.php/apps/files/?dir=/ + * EIVE_IRS/Arbeitsdaten/08_Used%20Components/Nanoavionics_Reactionwheels&fileid=181622 + */ +class TmDataset: + public StaticLocalDataSet { +public: + + TmDataset(HasLocalDataPoolIF* owner): + StaticLocalDataSet(owner, TM_SET_ID) { + } + + TmDataset(object_id_t objectId): + StaticLocalDataSet(sid_t(objectId, TM_SET_ID)) { + } + + lp_var_t lastResetStatus = lp_var_t(sid.objectId, + PoolIds::TM_LAST_RESET_STATUS, this); + lp_var_t mcuTemperature = lp_var_t(sid.objectId, + PoolIds::TM_MCU_TEMPERATURE, this); + lp_var_t rwState = lp_var_t(sid.objectId, + PoolIds::TM_RW_STATE, this); + lp_var_t rwClcMode = lp_var_t(sid.objectId, + PoolIds::TM_CLC_MODE, this); + lp_var_t rwCurrSpeed = lp_var_t(sid.objectId, + PoolIds::TM_RW_CURR_SPEED, this); + lp_var_t rwRefSpeed = lp_var_t(sid.objectId, + PoolIds::TM_RW_REF_SPEED, this); + lp_var_t numOfInvalidCrcPackets = lp_var_t(sid.objectId, + PoolIds::INVALID_CRC_PACKETS, this); + lp_var_t numOfInvalidLenPackets = lp_var_t(sid.objectId, + PoolIds::INVALID_LEN_PACKETS, this); + lp_var_t numOfInvalidCmdPackets = lp_var_t(sid.objectId, + PoolIds::INVALID_CMD_PACKETS, this); + lp_var_t numOfCmdExecutedReplies = lp_var_t(sid.objectId, + PoolIds::EXECUTED_REPLIES, this); + lp_var_t numOfCmdeplies = lp_var_t(sid.objectId, + PoolIds::COMMAND_REPLIES, this); + lp_var_t uartNumOfBytesWritten = lp_var_t(sid.objectId, + PoolIds::UART_BYTES_WRITTEN, this); + lp_var_t uartNumOfBytesRead = lp_var_t(sid.objectId, + PoolIds::UART_BYTES_READ, this); + lp_var_t uartNumOfParityErrors = lp_var_t(sid.objectId, + PoolIds::UART_PARITY_ERRORS, this); + lp_var_t uartNumOfNoiseErrors = lp_var_t(sid.objectId, + PoolIds::UART_NOISE_ERRORS, this); + lp_var_t uartNumOfFrameErrors = lp_var_t(sid.objectId, + PoolIds::UART_FRAME_ERRORS, this); + lp_var_t uartNumOfRegisterOverrunErrors = lp_var_t(sid.objectId, + PoolIds::UART_REG_OVERRUN_ERRORS, this); + lp_var_t uartTotalNumOfErrors = lp_var_t(sid.objectId, + PoolIds::UART_TOTAL_ERRORS, this); + lp_var_t spiNumOfBytesWritten = lp_var_t(sid.objectId, + PoolIds::SPI_BYTES_WRITTEN, this); + lp_var_t spiNumOfBytesRead = lp_var_t(sid.objectId, + PoolIds::SPI_BYTES_READ, this); + lp_var_t spiNumOfRegisterOverrunErrors = lp_var_t(sid.objectId, + PoolIds::SPI_REG_OVERRUN_ERRORS, this); + lp_var_t spiTotalNumOfErrors = lp_var_t(sid.objectId, + PoolIds::SPI_TOTAL_ERRORS, this); +}; + } #endif /* MISSION_DEVICES_DEVICEDEFINITIONS_RWDEFINITIONS_H_ */ diff --git a/tmtc b/tmtc index 09cab194..78b68307 160000 --- a/tmtc +++ b/tmtc @@ -1 +1 @@ -Subproject commit 09cab1941fad0bbe8fa54234f7513c61e22038ca +Subproject commit 78b68307825754b468404ee4ff006ee87e0bdd5f From 11776fe3319b7b039cb99cc7b31808957c66111b Mon Sep 17 00:00:00 2001 From: "Jakob.Meier" Date: Wed, 30 Jun 2021 15:07:26 +0200 Subject: [PATCH 047/111] added get telemetry command --- mission/devices/RwHandler.cpp | 202 ++++++++++++------ mission/devices/RwHandler.h | 41 +--- .../devices/devicedefinitions/RwDefinitions.h | 10 +- 3 files changed, 155 insertions(+), 98 deletions(-) diff --git a/mission/devices/RwHandler.cpp b/mission/devices/RwHandler.cpp index b637cbba..beb17602 100644 --- a/mission/devices/RwHandler.cpp +++ b/mission/devices/RwHandler.cpp @@ -77,23 +77,23 @@ ReturnValue_t RwHandler::buildCommandFromCommand(DeviceCommandId_t deviceCommand switch (deviceCommand) { case (RwDefinitions::RESET_MCU): { - prepareResetMcuCommand(); + prepareSimpleCommand(deviceCommand); return RETURN_OK; } case (RwDefinitions::GET_LAST_RESET_STATUS): { - prepareGetLastResetStatusCommand(); + prepareSimpleCommand(deviceCommand); return RETURN_OK; } case (RwDefinitions::CLEAR_LAST_RESET_STATUS): { - prepareClearResetStatusCommand(); + prepareSimpleCommand(deviceCommand); return RETURN_OK; } case (RwDefinitions::GET_RW_STATUS): { - prepareGetStatusCmd(commandData, commandDataLen); + prepareSimpleCommand(deviceCommand); return RETURN_OK; } case (RwDefinitions::INIT_RW_CONTROLLER): { - prepareInitRwCommand(); + prepareSimpleCommand(deviceCommand); return RETURN_OK; } case (RwDefinitions::SET_SPEED): { @@ -110,11 +110,11 @@ ReturnValue_t RwHandler::buildCommandFromCommand(DeviceCommandId_t deviceCommand return result; } case (RwDefinitions::GET_TEMPERATURE): { - prepareGetTemperatureCmd(); + prepareSimpleCommand(deviceCommand); return RETURN_OK; } case (RwDefinitions::GET_TM): { - prepareGetTelemetryCmd(); + prepareSimpleCommand(deviceCommand); return RETURN_OK; } default: @@ -137,6 +137,8 @@ void RwHandler::fillCommandAndReplyMap() { RwDefinitions::SIZE_GET_TEMPERATURE_REPLY); this->insertInCommandAndReplyMap(RwDefinitions::SET_SPEED, 1, nullptr, RwDefinitions::SIZE_SET_SPEED_REPLY); + this->insertInCommandAndReplyMap(RwDefinitions::GET_TM, 1, &tmDataset, + RwDefinitions::SIZE_GET_TELEMETRY_REPLY); } ReturnValue_t RwHandler::scanForReply(const uint8_t *start, size_t remainingSize, @@ -173,6 +175,12 @@ ReturnValue_t RwHandler::scanForReply(const uint8_t *start, size_t remainingSize *foundId = RwDefinitions::GET_TEMPERATURE; break; } + case (static_cast(RwDefinitions::GET_TM)): { +// *foundLen = RwDefinitions::SIZE_GET_TELEMETRY_REPLY; + *foundLen = 91; + *foundId = RwDefinitions::GET_TM; + break; + } default: { sif::debug << "RwHandler::scanForReply: Reply contains invalid command code" << std::endl; return RETURN_FAILED; @@ -220,6 +228,10 @@ ReturnValue_t RwHandler::interpretDeviceReply(DeviceCommandId_t id, const uint8_ handleTemperatureReply(packet); break; } + case (RwDefinitions::GET_TM): { + handleGetTelemetryReply(packet); + break; + } default: { sif::debug << "RwHandler::interpretDeviceReply: Unknown device reply id" << std::endl; return DeviceHandlerIF::UNKNOWN_DEVICE_REPLY; @@ -251,11 +263,11 @@ ReturnValue_t RwHandler::initializeLocalDataPool(localpool::DataPool& localDataP localDataPoolMap.emplace(RwDefinitions::CURRRENT_RESET_STATUS, new PoolEntry( { 0 })); localDataPoolMap.emplace(RwDefinitions::TM_LAST_RESET_STATUS, new PoolEntry( { 0 })); - localDataPoolMap.emplace(RwDefinitions::TM_MCU_TEMPERATURE, new PoolEntry( { 0 })); + localDataPoolMap.emplace(RwDefinitions::TM_MCU_TEMPERATURE, new PoolEntry( { 0 })); localDataPoolMap.emplace(RwDefinitions::TM_RW_STATE, new PoolEntry( { 0 })); localDataPoolMap.emplace(RwDefinitions::TM_CLC_MODE, new PoolEntry( { 0 })); - localDataPoolMap.emplace(RwDefinitions::TM_RW_CURR_SPEED, new PoolEntry( { 0 })); - localDataPoolMap.emplace(RwDefinitions::TM_RW_REF_SPEED, new PoolEntry( { 0 })); + localDataPoolMap.emplace(RwDefinitions::TM_RW_CURR_SPEED, new PoolEntry( { 0 })); + localDataPoolMap.emplace(RwDefinitions::TM_RW_REF_SPEED, new PoolEntry( { 0 })); localDataPoolMap.emplace(RwDefinitions::INVALID_CRC_PACKETS, new PoolEntry( { 0 })); localDataPoolMap.emplace(RwDefinitions::INVALID_LEN_PACKETS, new PoolEntry( { 0 })); localDataPoolMap.emplace(RwDefinitions::INVALID_CMD_PACKETS, new PoolEntry( { 0 })); @@ -276,33 +288,8 @@ ReturnValue_t RwHandler::initializeLocalDataPool(localpool::DataPool& localDataP return RETURN_OK; } -void RwHandler::prepareResetMcuCommand() { - commandBuffer[0] = static_cast(RwDefinitions::RESET_MCU); - rawPacket = commandBuffer; - rawPacketLen = 1; -} - -void RwHandler::prepareGetLastResetStatusCommand() { - commandBuffer[0] = static_cast(RwDefinitions::GET_LAST_RESET_STATUS); - uint16_t crc = CRC::crc16ccitt(commandBuffer, 1, 0xFFFF); - commandBuffer[1] = static_cast(crc & 0xFF); - commandBuffer[2] = static_cast(crc >> 8 & 0xFF); - rawPacket = commandBuffer; - rawPacketLen = 3; -} - -void RwHandler::prepareClearResetStatusCommand() { - commandBuffer[0] = static_cast(RwDefinitions::CLEAR_LAST_RESET_STATUS); - uint16_t crc = CRC::crc16ccitt(commandBuffer, 1, 0xFFFF); - commandBuffer[1] = static_cast(crc & 0xFF); - commandBuffer[2] = static_cast(crc >> 8 & 0xFF); - rawPacket = commandBuffer; - rawPacketLen = 3; -} - -void RwHandler::prepareGetStatusCmd(const uint8_t * commandData, size_t commandDataLen) { - commandBuffer[0] = static_cast(RwDefinitions::GET_RW_STATUS); - +void RwHandler::prepareSimpleCommand(DeviceCommandId_t id) { + commandBuffer[0] = static_cast(id); uint16_t crc = CRC::crc16ccitt(commandBuffer, 1, 0xFFFF); commandBuffer[1] = static_cast(crc & 0xFF); commandBuffer[2] = static_cast(crc >> 8 & 0xFF); @@ -330,15 +317,6 @@ ReturnValue_t RwHandler::checkSpeedAndRampTime(const uint8_t* commandData, size_ return RETURN_OK; } -void RwHandler::prepareInitRwCommand() { - commandBuffer[0] = static_cast(RwDefinitions::INIT_RW_CONTROLLER); - uint16_t crc = CRC::crc16ccitt(commandBuffer, 1, 0xFFFF); - commandBuffer[1] = static_cast(crc & 0xFF); - commandBuffer[2] = static_cast(crc >> 8 & 0xFF); - rawPacket = commandBuffer; - rawPacketLen = 3; -} - void RwHandler::prepareSetSpeedCmd(const uint8_t * commandData, size_t commandDataLen) { commandBuffer[0] = static_cast(RwDefinitions::SET_SPEED); @@ -358,24 +336,6 @@ void RwHandler::prepareSetSpeedCmd(const uint8_t * commandData, size_t commandDa rawPacketLen = 9; } -void RwHandler::prepareGetTemperatureCmd() { - commandBuffer[0] = static_cast(RwDefinitions::GET_TEMPERATURE); - uint16_t crc = CRC::crc16ccitt(commandBuffer, 1, 0xFFFF); - commandBuffer[1] = static_cast(crc & 0xFF); - commandBuffer[2] = static_cast(crc >> 8 & 0xFF); - rawPacket = commandBuffer; - rawPacketLen = 3; -} - -void RwHandler::prepareGetTelemetryCmd() { - commandBuffer[0] = static_cast(RwDefinitions::GET_TM); - uint16_t crc = CRC::crc16ccitt(commandBuffer, 1, 0xFFFF); - commandBuffer[1] = static_cast(crc & 0xFF); - commandBuffer[2] = static_cast(crc >> 8 & 0xFF); - rawPacket = commandBuffer; - rawPacketLen = 3; -} - void RwHandler::handleResetStatusReply(const uint8_t* packet) { PoolReadGuard rg(&lastResetStatusSet); uint8_t offset = 2; @@ -438,3 +398,117 @@ void RwHandler::handleTemperatureReply(const uint8_t* packet) { << temperatureSet.temperatureCelcius << " °C" << std::endl; #endif } + +void RwHandler::handleGetTelemetryReply(const uint8_t* packet) { + PoolReadGuard rg(&tmDataset); + uint8_t offset = 2; + tmDataset.lastResetStatus = *(packet + offset); + offset += 1; + tmDataset.mcuTemperature = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 + | *(packet + offset + 1) << 8 | *(packet + offset); + offset += 4; + offset += 8; + tmDataset.rwState = *(packet + offset); + offset += 1; + tmDataset.rwClcMode = *(packet + offset); + offset += 1; + tmDataset.rwCurrSpeed = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 + | *(packet + offset + 1) << 8 | *(packet + offset); + offset += 4; + tmDataset.rwRefSpeed = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 + | *(packet + offset + 1) << 8 | *(packet + offset); + offset += 4; + tmDataset.numOfInvalidCrcPackets = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 + | *(packet + offset + 1) << 8 | *(packet + offset); + offset += 4; + tmDataset.numOfInvalidLenPackets = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 + | *(packet + offset + 1) << 8 | *(packet + offset); + offset += 4; + tmDataset.numOfInvalidCmdPackets = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 + | *(packet + offset + 1) << 8 | *(packet + offset); + offset += 4; + tmDataset.numOfCmdExecutedReplies = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 + | *(packet + offset + 1) << 8 | *(packet + offset); + offset += 4; + tmDataset.numOfCmdReplies = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 + | *(packet + offset + 1) << 8 | *(packet + offset); + offset += 4; + tmDataset.uartNumOfBytesWritten = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 + | *(packet + offset + 1) << 8 | *(packet + offset); + offset += 4; + tmDataset.uartNumOfBytesRead = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 + | *(packet + offset + 1) << 8 | *(packet + offset); + offset += 4; + tmDataset.uartNumOfParityErrors = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 + | *(packet + offset + 1) << 8 | *(packet + offset); + offset += 4; + tmDataset.uartNumOfNoiseErrors = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 + | *(packet + offset + 1) << 8 | *(packet + offset); + offset += 4; + tmDataset.uartNumOfFrameErrors = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 + | *(packet + offset + 1) << 8 | *(packet + offset); + offset += 4; + tmDataset.uartNumOfRegisterOverrunErrors = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 + | *(packet + offset + 1) << 8 | *(packet + offset); + offset += 4; + tmDataset.uartTotalNumOfErrors = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 + | *(packet + offset + 1) << 8 | *(packet + offset); + offset += 4; + tmDataset.spiNumOfBytesWritten = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 + | *(packet + offset + 1) << 8 | *(packet + offset); + offset += 4; + tmDataset.spiNumOfBytesRead = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 + | *(packet + offset + 1) << 8 | *(packet + offset); + offset += 4; + tmDataset.spiNumOfRegisterOverrunErrors = *(packet + offset + 3) << 24 | *(packet + offset + 2) << 16 + | *(packet + offset + 1) << 8 | *(packet + offset); + 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 + sif::info << "RwHandler::handleTemperatureReply: Last reset status: " + << static_cast(tmDataset.lastResetStatus.value) << std::endl; + sif::info << "RwHandler::handleTemperatureReply: MCU temperature: " << tmDataset.mcuTemperature + << std::endl; + sif::info << "RwHandler::handleTemperatureReply: State: " + << static_cast(tmDataset.rwState.value) << std::endl; + sif::info << "RwHandler::handleTemperatureReply: CLC mode: " + << static_cast(tmDataset.rwClcMode.value) << std::endl; + sif::info << "RwHandler::handleTemperatureReply: Current speed: " << tmDataset.rwCurrSpeed + << std::endl; + sif::info << "RwHandler::handleTemperatureReply: Reference speed: " << tmDataset.rwRefSpeed + << std::endl; + sif::info << "RwHandler::handleTemperatureReply: Number of invalid CRC packets: " + << tmDataset.numOfInvalidCrcPackets << std::endl; + sif::info << "RwHandler::handleTemperatureReply: Number of invalid length packets: " + << tmDataset.numOfInvalidLenPackets << std::endl; + sif::info << "RwHandler::handleTemperatureReply: Number of invalid command packets: " + << tmDataset.numOfInvalidCmdPackets << std::endl; + sif::info << "RwHandler::handleTemperatureReply: Number of command executed replies: " + << tmDataset.numOfCmdExecutedReplies << std::endl; + sif::info << "RwHandler::handleTemperatureReply: Number of command replies: " + << tmDataset.numOfCmdReplies << std::endl; + sif::info << "RwHandler::handleTemperatureReply: UART number of bytes written: " + << tmDataset.uartNumOfBytesWritten << std::endl; + sif::info << "RwHandler::handleTemperatureReply: UART number of bytes read: " + << tmDataset.uartNumOfBytesRead << std::endl; + sif::info << "RwHandler::handleTemperatureReply: UART number of parity errors: " + << tmDataset.uartNumOfParityErrors << std::endl; + sif::info << "RwHandler::handleTemperatureReply: UART number of noise errors: " + << tmDataset.uartNumOfNoiseErrors << std::endl; + sif::info << "RwHandler::handleTemperatureReply: UART number of frame errors: " + << tmDataset.uartNumOfFrameErrors << std::endl; + sif::info << "RwHandler::handleTemperatureReply: UART number of register overrun errors: " + << tmDataset.uartNumOfRegisterOverrunErrors << std::endl; + sif::info << "RwHandler::handleTemperatureReply: UART number of total errors: " + << tmDataset.uartTotalNumOfErrors << std::endl; + sif::info << "RwHandler::handleTemperatureReply: SPI number of bytes written: " + << tmDataset.spiNumOfBytesWritten << std::endl; + sif::info << "RwHandler::handleTemperatureReply: SPI number of bytes read: " + << tmDataset.spiNumOfBytesRead << std::endl; + sif::info << "RwHandler::handleTemperatureReply: SPI number of register overrun errors: " + << tmDataset.spiNumOfRegisterOverrunErrors << std::endl; + sif::info << "RwHandler::handleTemperatureReply: SPI number of register total errors: " + << tmDataset.spiTotalNumOfErrors << std::endl; +#endif +} diff --git a/mission/devices/RwHandler.h b/mission/devices/RwHandler.h index e447932d..cd753be0 100644 --- a/mission/devices/RwHandler.h +++ b/mission/devices/RwHandler.h @@ -105,26 +105,11 @@ private: size_t sizeOfReply = 0; /** - * @brief This function fills the command buffer with the data to reset the MCU on a reaction - * wheel. + * @brief This function can be used to build commands which do not contain any data apart + * from the command id and the CRC. + * @param commandId The command id of the command to build. */ - void prepareResetMcuCommand(); - - /** - * @brief This function prepares the command to request the last reset status - */ - void prepareGetLastResetStatusCommand(); - - /** - * @brief Fills the command buffer with the command to clear the reset status. - */ - void prepareClearResetStatusCommand(); - - /** - * @brief This function prepares the send buffer with the data to request the status of - * the reaction wheel. - */ - void prepareGetStatusCmd(const uint8_t * commandData, size_t commandDataLen); + void prepareSimpleCommand(DeviceCommandId_t id); /** * @brief This function checks if the receiced speed and ramp time to set are in a valid @@ -133,24 +118,12 @@ private: */ ReturnValue_t checkSpeedAndRampTime(const uint8_t * commandData, size_t commandDataLen); - /** - * @brief This function fills the commandBuffer with the data to request initialize the - * reaction wheel controller. This command must be sent as soon as the state of a - * reaction wheel is equal to 1 which indicates an error. - */ - void prepareInitRwCommand(); - /** * @brief This function prepares the set speed command from the commandData received with * an action message. */ void prepareSetSpeedCmd(const uint8_t * commandData, size_t commandDataLen); - /** - * @brief This function fills the commandBuffer with the data to request the temperature. - */ - void prepareGetTemperatureCmd(); - /** * @brief This function writes the last reset status retrieved with the get last reset status * command into the reset status dataset. @@ -170,6 +143,12 @@ private: * @brief This function fills the status set with the data from the get-status-reply. */ void handleGetRwStatusReply(const uint8_t* packet); + + /** + * @brief This function fills the tmDataset with the reply data requested with get telemetry + * command. + */ + void handleGetTelemetryReply(const uint8_t* packet); }; #endif /* MISSION_DEVICES_RWHANDLER_H_ */ diff --git a/mission/devices/devicedefinitions/RwDefinitions.h b/mission/devices/devicedefinitions/RwDefinitions.h index a477f47c..d87c09fd 100644 --- a/mission/devices/devicedefinitions/RwDefinitions.h +++ b/mission/devices/devicedefinitions/RwDefinitions.h @@ -87,7 +87,11 @@ static const size_t SIZE_GET_TELEMETRY_REPLY = 83; /** Set speed command has maximum size */ static const size_t MAX_CMD_SIZE = 9; -static const size_t MAX_REPLY_SIZE = SIZE_GET_TELEMETRY_REPLY; +/** + * Max reply is reached when each byte is replaced by its substitude which should normally never + * happen. + */ +static const size_t MAX_REPLY_SIZE = 2 * SIZE_GET_TELEMETRY_REPLY; static const uint8_t LAST_RESET_ENTRIES = 2; static const uint8_t TEMPERATURE_SET_ENTRIES = 1; @@ -178,7 +182,7 @@ public: lp_var_t lastResetStatus = lp_var_t(sid.objectId, PoolIds::TM_LAST_RESET_STATUS, this); - lp_var_t mcuTemperature = lp_var_t(sid.objectId, + lp_var_t mcuTemperature = lp_var_t(sid.objectId, PoolIds::TM_MCU_TEMPERATURE, this); lp_var_t rwState = lp_var_t(sid.objectId, PoolIds::TM_RW_STATE, this); @@ -196,7 +200,7 @@ public: PoolIds::INVALID_CMD_PACKETS, this); lp_var_t numOfCmdExecutedReplies = lp_var_t(sid.objectId, PoolIds::EXECUTED_REPLIES, this); - lp_var_t numOfCmdeplies = lp_var_t(sid.objectId, + lp_var_t numOfCmdReplies = lp_var_t(sid.objectId, PoolIds::COMMAND_REPLIES, this); lp_var_t uartNumOfBytesWritten = lp_var_t(sid.objectId, PoolIds::UART_BYTES_WRITTEN, this); From 3f177d3321cadf80bf933bc1b8567cb9364fc9c5 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Wed, 30 Jun 2021 15:18:41 +0200 Subject: [PATCH 048/111] simple mode implemented --- CMakeLists.txt | 4 +++ bsp_q7s/CMakeLists.txt | 2 -- bsp_q7s/boardconfig/q7sConfig.h.in | 1 + bsp_q7s/core/CMakeLists.txt | 3 ++ bsp_q7s/{ => core}/InitMission.cpp | 0 bsp_q7s/{ => core}/InitMission.h | 0 bsp_q7s/{ => core}/ObjectFactory.cpp | 0 bsp_q7s/{ => core}/ObjectFactory.h | 0 bsp_q7s/core/obsw.cpp | 25 ++++++++++++++ bsp_q7s/core/obsw.h | 10 ++++++ bsp_q7s/main.cpp | 32 +++++------------ bsp_q7s/simple/simple.cpp | 5 +++ bsp_q7s/simple/simple.h | 10 ++++++ cmake/scripts/Q7S/make_debug_cfg.sh | 8 ++++- cmake/scripts/Q7S/make_release_cfg.sh | 11 ++++-- cmake/scripts/Q7S/ninja_debug_cfg.sh | 23 ------------- ...reldeb_cfg.sh => simple_make_debug_cfg.sh} | 12 +++++-- cmake/scripts/Q7S/simple_ninja_debug_cfg.sh | 34 +++++++++++++++++++ 18 files changed, 125 insertions(+), 55 deletions(-) rename bsp_q7s/{ => core}/InitMission.cpp (100%) rename bsp_q7s/{ => core}/InitMission.h (100%) rename bsp_q7s/{ => core}/ObjectFactory.cpp (100%) rename bsp_q7s/{ => core}/ObjectFactory.h (100%) create mode 100644 bsp_q7s/core/obsw.cpp create mode 100644 bsp_q7s/core/obsw.h create mode 100644 bsp_q7s/simple/simple.cpp create mode 100644 bsp_q7s/simple/simple.h delete mode 100755 cmake/scripts/Q7S/ninja_debug_cfg.sh rename cmake/scripts/Q7S/{make_reldeb_cfg.sh => simple_make_debug_cfg.sh} (59%) create mode 100755 cmake/scripts/Q7S/simple_ninja_debug_cfg.sh diff --git a/CMakeLists.txt b/CMakeLists.txt index 33c6edfc..10149bb6 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -15,6 +15,10 @@ cmake_minimum_required(VERSION 3.13) set(CMAKE_SCRIPT_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake") +if(TGT_BSP MATCHES "arm/q7s") + option(Q7S_SIMPLE_MODE OFF "Simple mode with a minimal main function") +endif() + option(ADD_ETL_LIB "Add ETL library" ON) if(NOT OS_FSFW) set(OS_FSFW host CACHE STRING "OS for the FSFW.") diff --git a/bsp_q7s/CMakeLists.txt b/bsp_q7s/CMakeLists.txt index ce790656..ca260250 100644 --- a/bsp_q7s/CMakeLists.txt +++ b/bsp_q7s/CMakeLists.txt @@ -1,7 +1,5 @@ target_sources(${TARGET_NAME} PUBLIC - InitMission.cpp main.cpp - ObjectFactory.cpp ) add_subdirectory(boardconfig) diff --git a/bsp_q7s/boardconfig/q7sConfig.h.in b/bsp_q7s/boardconfig/q7sConfig.h.in index 81b96a7e..6ee84821 100644 --- a/bsp_q7s/boardconfig/q7sConfig.h.in +++ b/bsp_q7s/boardconfig/q7sConfig.h.in @@ -1,6 +1,7 @@ #ifndef BSP_Q7S_BOARDCONFIG_Q7S_CONFIG_H_ #define BSP_Q7S_BOARDCONFIG_Q7S_CONFIG_H_ +#cmakedefine01 Q7S_SIMPLE_MODE #define Q7S_ADD_RTD_DEVICES 0 /* Only one of those 2 should be enabled! */ diff --git a/bsp_q7s/core/CMakeLists.txt b/bsp_q7s/core/CMakeLists.txt index 4b2364c1..fc397f2f 100644 --- a/bsp_q7s/core/CMakeLists.txt +++ b/bsp_q7s/core/CMakeLists.txt @@ -1,3 +1,6 @@ target_sources(${TARGET_NAME} PRIVATE CoreController.cpp + obsw.cpp + InitMission.cpp + ObjectFactory.cpp ) diff --git a/bsp_q7s/InitMission.cpp b/bsp_q7s/core/InitMission.cpp similarity index 100% rename from bsp_q7s/InitMission.cpp rename to bsp_q7s/core/InitMission.cpp diff --git a/bsp_q7s/InitMission.h b/bsp_q7s/core/InitMission.h similarity index 100% rename from bsp_q7s/InitMission.h rename to bsp_q7s/core/InitMission.h diff --git a/bsp_q7s/ObjectFactory.cpp b/bsp_q7s/core/ObjectFactory.cpp similarity index 100% rename from bsp_q7s/ObjectFactory.cpp rename to bsp_q7s/core/ObjectFactory.cpp diff --git a/bsp_q7s/ObjectFactory.h b/bsp_q7s/core/ObjectFactory.h similarity index 100% rename from bsp_q7s/ObjectFactory.h rename to bsp_q7s/core/ObjectFactory.h diff --git a/bsp_q7s/core/obsw.cpp b/bsp_q7s/core/obsw.cpp new file mode 100644 index 00000000..f813bcae --- /dev/null +++ b/bsp_q7s/core/obsw.cpp @@ -0,0 +1,25 @@ +#include "obsw.h" +#include "OBSWVersion.h" +#include "InitMission.h" +#include "fsfw/tasks/TaskFactory.h" +#include + +int obsw::obsw() { + std::cout << "-- EIVE OBSW --" << std::endl; +#if TE0720 == 0 + std::cout << "-- Compiled for Linux (Xiphos Q7S) --" << std::endl; +#else + std::cout << "-- Compiled for Linux (TE0720) --" << std::endl; +#endif + std::cout << "-- Software version " << SW_NAME << " v" << SW_VERSION << "." + << SW_SUBVERSION << "." << SW_SUBSUBVERSION << " -- " << std::endl; + std::cout << "-- " << __DATE__ << " " << __TIME__ << " --" << std::endl; + + initmission::initMission(); + + for(;;) { + /* Suspend main thread by sleeping it. */ + TaskFactory::delayTask(5000); + } + return 0; +} diff --git a/bsp_q7s/core/obsw.h b/bsp_q7s/core/obsw.h new file mode 100644 index 00000000..c2d974ae --- /dev/null +++ b/bsp_q7s/core/obsw.h @@ -0,0 +1,10 @@ +#ifndef BSP_Q7S_CORE_OBSW_H_ +#define BSP_Q7S_CORE_OBSW_H_ + +namespace obsw { + +int obsw(); + +}; + +#endif /* BSP_Q7S_CORE_OBSW_H_ */ diff --git a/bsp_q7s/main.cpp b/bsp_q7s/main.cpp index 06f454c2..93968b76 100644 --- a/bsp_q7s/main.cpp +++ b/bsp_q7s/main.cpp @@ -1,11 +1,10 @@ -#include "InitMission.h" -#include -#include -#include "OBSWConfig.h" +#include "q7sConfig.h" -#include - -#include +#if Q7S_SIMPLE_MODE == 0 +#include "core/obsw.h" +#else +#include "simple/simple.h" +#endif /** * @brief This is the main program for the target hardware. @@ -13,22 +12,9 @@ */ int main(void) { - std::cout << "-- EIVE OBSW --" << std::endl; -#if TE0720 == 0 - std::cout << "-- Compiled for Linux (Xiphos Q7S) --" << std::endl; +#if Q7S_SIMPLE_MODE == 0 + return obsw::obsw(); #else - std::cout << "-- Compiled for Linux (TE0720) --" << std::endl; + return simple::simple(); #endif - std::cout << "-- Software version " << SW_NAME << " v" << SW_VERSION << "." - << SW_SUBVERSION << "." << SW_SUBSUBVERSION << " -- " << std::endl; - std::cout << "-- " << __DATE__ << " " << __TIME__ << " --" << std::endl; - - initmission::initMission(); - - for(;;) { - /* Suspend main thread by sleeping it. */ - TaskFactory::delayTask(5000); - } } - - diff --git a/bsp_q7s/simple/simple.cpp b/bsp_q7s/simple/simple.cpp new file mode 100644 index 00000000..6261bfe3 --- /dev/null +++ b/bsp_q7s/simple/simple.cpp @@ -0,0 +1,5 @@ +#include "simple.h" + +int simple::simple() { + return 0; +} diff --git a/bsp_q7s/simple/simple.h b/bsp_q7s/simple/simple.h new file mode 100644 index 00000000..096a7b7c --- /dev/null +++ b/bsp_q7s/simple/simple.h @@ -0,0 +1,10 @@ +#ifndef BSP_Q7S_SIMPLE_SIMPLE_H_ +#define BSP_Q7S_SIMPLE_SIMPLE_H_ + +namespace simple { + +int simple(); + +} + +#endif /* BSP_Q7S_SIMPLE_SIMPLE_H_ */ diff --git a/cmake/scripts/Q7S/make_debug_cfg.sh b/cmake/scripts/Q7S/make_debug_cfg.sh index 4875c59a..4613d36a 100755 --- a/cmake/scripts/Q7S/make_debug_cfg.sh +++ b/cmake/scripts/Q7S/make_debug_cfg.sh @@ -20,10 +20,16 @@ build_dir="build-Debug-Q7S" build_generator="" if [ "${OS}" = "Windows_NT" ]; then build_generator="MinGW Makefiles" + python="py" # Could be other OS but this works for now. else build_generator="Unix Makefiles" + python="python3" fi -python3 cmake_build_config.py -o "${os_fsfw}" -g "${build_generator}" -b "debug" -t "${tgt_bsp}" \ +echo "Running command (without the leading +):" +set -x # Print command +${python} cmake_build_config.py -o "${os_fsfw}" -g "${build_generator}" -b "debug" -t "${tgt_bsp}" \ -l"${build_dir}" +# set +x + diff --git a/cmake/scripts/Q7S/make_release_cfg.sh b/cmake/scripts/Q7S/make_release_cfg.sh index 0e2c543c..9d7992f3 100755 --- a/cmake/scripts/Q7S/make_release_cfg.sh +++ b/cmake/scripts/Q7S/make_release_cfg.sh @@ -16,14 +16,19 @@ fi os_fsfw="linux" tgt_bsp="arm/q7s" -build_dir="build-Release-Q7S" +build_dir="build-Debug-Q7S" build_generator="" if [ "${OS}" = "Windows_NT" ]; then build_generator="MinGW Makefiles" + python="py" # Could be other OS but this works for now. else build_generator="Unix Makefiles" + python="python3" fi -python3 cmake_build_config.py -o "${os_fsfw}" -g "${build_generator}" -b "release" -t "${tgt_bsp}" \ - -l"${build_dir}" +echo "Running command (without the leading +):" +set -x # Print command +${python} cmake_build_config.py -o "${os_fsfw}" -g "${build_generator}" -b "debug" -t "${tgt_bsp}" \ + -l"${build_dir}" +# set +x diff --git a/cmake/scripts/Q7S/ninja_debug_cfg.sh b/cmake/scripts/Q7S/ninja_debug_cfg.sh deleted file mode 100755 index 3a8ac631..00000000 --- a/cmake/scripts/Q7S/ninja_debug_cfg.sh +++ /dev/null @@ -1,23 +0,0 @@ -#!/bin/sh -counter=0 -while [ ${counter} -lt 5 ] -do - cd .. - if [ -f "cmake_build_config.py" ];then - break - fi - counter=$((counter=counter + 1)) -done - -if [ "${counter}" -ge 5 ];then - echo "cmake_build_config.py not found in upper directories!" - exit 1 -fi - -os_fsfw="linux" -tgt_bsp="arm/q7s" -build_dir="build-Debug-Q7S" -build_generator="Ninja" - -python3 cmake_build_config.py -o "${os_fsfw}" -g "${build_generator}" -b "debug" -t "${tgt_bsp}" \ - -l"${build_dir}" diff --git a/cmake/scripts/Q7S/make_reldeb_cfg.sh b/cmake/scripts/Q7S/simple_make_debug_cfg.sh similarity index 59% rename from cmake/scripts/Q7S/make_reldeb_cfg.sh rename to cmake/scripts/Q7S/simple_make_debug_cfg.sh index 121f2d7e..2ca0ab79 100755 --- a/cmake/scripts/Q7S/make_reldeb_cfg.sh +++ b/cmake/scripts/Q7S/simple_make_debug_cfg.sh @@ -16,14 +16,20 @@ fi os_fsfw="linux" tgt_bsp="arm/q7s" -build_dir="build-Release-Q7S" +build_dir="build-Debug-Q7S" build_generator="" +definitions="Q7S_SIMPLE_MODE=On" if [ "${OS}" = "Windows_NT" ]; then build_generator="MinGW Makefiles" + python="py" # Could be other OS but this works for now. else build_generator="Unix Makefiles" + python="python3" fi -python3 cmake_build_config.py -o "${os_fsfw}" -g "${build_generator}" -b "reldeb" -t "${tgt_bsp}" \ - -l"${build_dir}" +echo "Running command (without the leading +):" +set -x # Print command +${python} cmake_build_config.py -o "${os_fsfw}" -g "${build_generator}" -b "debug" -t "${tgt_bsp}" \ + -l"${build_dir}" -d "${definitions} +# set +x diff --git a/cmake/scripts/Q7S/simple_ninja_debug_cfg.sh b/cmake/scripts/Q7S/simple_ninja_debug_cfg.sh new file mode 100755 index 00000000..0ec8a155 --- /dev/null +++ b/cmake/scripts/Q7S/simple_ninja_debug_cfg.sh @@ -0,0 +1,34 @@ +#!/bin/sh +counter=0 +while [ ${counter} -lt 5 ] +do + cd .. + if [ -f "cmake_build_config.py" ];then + break + fi + counter=$((counter=counter + 1)) +done + +if [ "${counter}" -ge 5 ];then + echo "cmake_build_config.py not found in upper directories!" + exit 1 +fi + +os_fsfw="linux" +tgt_bsp="arm/q7s" +build_dir="build-Debug-Q7S" +build_generator="Ninja" +definitions="Q7S_SIMPLE_MODE=On" +if [ "${OS}" = "Windows_NT" ]; then + python="py" +# Could be other OS but this works for now. +else + python="python3" +fi + +echo "Running command (without the leading +):" +set -x # Print command +${python} cmake_build_config.py -o "${os_fsfw}" -g "${build_generator}" -b "debug" -t "${tgt_bsp}" \ + -l"${build_dir}" -d "${definitions} +# set +x + From 7d7b119d01b35e6491be1efa6c43932fcfaef279 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Wed, 30 Jun 2021 15:32:15 +0200 Subject: [PATCH 049/111] simple mode working --- CMakeLists.txt | 43 +++++++++++---------- bsp_q7s/CMakeLists.txt | 14 ++++--- bsp_q7s/simple/CMakeLists.txt | 3 ++ cmake/scripts/Q7S/simple_make_debug_cfg.sh | 2 +- cmake/scripts/Q7S/simple_ninja_debug_cfg.sh | 2 +- 5 files changed, 37 insertions(+), 27 deletions(-) create mode 100644 bsp_q7s/simple/CMakeLists.txt diff --git a/CMakeLists.txt b/CMakeLists.txt index 10149bb6..10c3a349 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -78,9 +78,11 @@ if(TGT_BSP) OR ${TGT_BSP} MATCHES "arm/beagleboneblack" ) set(FSFW_CONFIG_PATH "linux/fsfwconfig") - set(ADD_LINUX_FILES TRUE) - set(ADD_CSP_LIB TRUE) - set(FSFW_HAL_ADD_LINUX ON) + if(NOT Q7S_SIMPLE_MODE) + set(ADD_LINUX_FILES TRUE) + set(ADD_CSP_LIB TRUE) + set(FSFW_HAL_ADD_LINUX ON) + endif() endif() if(${TGT_BSP} MATCHES "arm/raspberrypi") @@ -137,27 +139,33 @@ if(ADD_LINUX_FILES) add_subdirectory(${LINUX_PATH}) endif() -add_subdirectory(${LWGPS_LIB_PATH}) add_subdirectory(${BSP_PATH}) -add_subdirectory(${FSFW_PATH}) -add_subdirectory(${MISSION_PATH}) -add_subdirectory(${TEST_PATH}) -add_subdirectory(${FSFW_HAL_LIB_PATH}) add_subdirectory(${COMMON_PATH}) +if(NOT Q7S_SIMPLE_MODE) + add_subdirectory(${LWGPS_LIB_PATH}) + add_subdirectory(${FSFW_PATH}) + add_subdirectory(${MISSION_PATH}) + add_subdirectory(${TEST_PATH}) + add_subdirectory(${FSFW_HAL_LIB_PATH}) +endif() + + ################################################################################ # Post-Sources preparation ################################################################################ set_property(CACHE OS_FSFW PROPERTY STRINGS host linux) -# Add libraries for all sources. -target_link_libraries(${TARGET_NAME} PRIVATE - ${LIB_FSFW_NAME} - ${LIB_OS_NAME} - ${LIB_LWGPS_NAME} - ${LIB_FSFW_HAL_NAME} -) +if(NOT Q7S_SIMPLE_MODE) + # Add libraries for all sources. + target_link_libraries(${TARGET_NAME} PRIVATE + ${LIB_FSFW_NAME} + ${LIB_OS_NAME} + ${LIB_LWGPS_NAME} + ${LIB_FSFW_HAL_NAME} + ) +endif() if(ADD_ETL_LIB) target_link_libraries(${TARGET_NAME} PRIVATE @@ -247,8 +255,3 @@ add_custom_command( include (${CMAKE_SCRIPT_PATH}/BuildType.cmake) set_build_type() - - - - - diff --git a/bsp_q7s/CMakeLists.txt b/bsp_q7s/CMakeLists.txt index ca260250..bc027af0 100644 --- a/bsp_q7s/CMakeLists.txt +++ b/bsp_q7s/CMakeLists.txt @@ -2,8 +2,12 @@ target_sources(${TARGET_NAME} PUBLIC main.cpp ) -add_subdirectory(boardconfig) -add_subdirectory(comIF) -add_subdirectory(boardtest) -add_subdirectory(gpio) -add_subdirectory(core) +if(Q7S_SIMPLE_MODE) + add_subdirectory(simple) +else() + add_subdirectory(boardconfig) + add_subdirectory(comIF) + add_subdirectory(boardtest) + add_subdirectory(gpio) + add_subdirectory(core) +endif() diff --git a/bsp_q7s/simple/CMakeLists.txt b/bsp_q7s/simple/CMakeLists.txt new file mode 100644 index 00000000..399a1dd3 --- /dev/null +++ b/bsp_q7s/simple/CMakeLists.txt @@ -0,0 +1,3 @@ +target_sources(${TARGET_NAME} PRIVATE + simple.cpp +) diff --git a/cmake/scripts/Q7S/simple_make_debug_cfg.sh b/cmake/scripts/Q7S/simple_make_debug_cfg.sh index 2ca0ab79..8b687504 100755 --- a/cmake/scripts/Q7S/simple_make_debug_cfg.sh +++ b/cmake/scripts/Q7S/simple_make_debug_cfg.sh @@ -31,5 +31,5 @@ fi echo "Running command (without the leading +):" set -x # Print command ${python} cmake_build_config.py -o "${os_fsfw}" -g "${build_generator}" -b "debug" -t "${tgt_bsp}" \ - -l"${build_dir}" -d "${definitions} + -l"${build_dir}" -d "${definitions}" # set +x diff --git a/cmake/scripts/Q7S/simple_ninja_debug_cfg.sh b/cmake/scripts/Q7S/simple_ninja_debug_cfg.sh index 0ec8a155..fa4d64f3 100755 --- a/cmake/scripts/Q7S/simple_ninja_debug_cfg.sh +++ b/cmake/scripts/Q7S/simple_ninja_debug_cfg.sh @@ -29,6 +29,6 @@ fi echo "Running command (without the leading +):" set -x # Print command ${python} cmake_build_config.py -o "${os_fsfw}" -g "${build_generator}" -b "debug" -t "${tgt_bsp}" \ - -l"${build_dir}" -d "${definitions} + -l"${build_dir}" -d "${definitions}" # set +x From 55a49dd45c3d7e48c0733256fb022bd6a6b2a1ec Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Wed, 30 Jun 2021 15:36:27 +0200 Subject: [PATCH 050/111] updated more build scripts --- cmake/scripts/Linux/create_cmake_debug_cfg.sh | 8 +++++++- .../scripts/Linux/create_cmake_release_cfg.sh | 8 +++++++- .../ninja_debug_cfg.sh} | 18 +++++++++++------- cmake/scripts/RPi/make_debug_cfg.sh | 10 ++++++++-- cmake/scripts/RPi/ninja_debug_cfg.sh | 14 ++++++++++++-- 5 files changed, 45 insertions(+), 13 deletions(-) rename cmake/scripts/{RPi/make_reldeb_cfg.sh => Q7S/ninja_debug_cfg.sh} (53%) diff --git a/cmake/scripts/Linux/create_cmake_debug_cfg.sh b/cmake/scripts/Linux/create_cmake_debug_cfg.sh index 1207884e..8c626bf4 100755 --- a/cmake/scripts/Linux/create_cmake_debug_cfg.sh +++ b/cmake/scripts/Linux/create_cmake_debug_cfg.sh @@ -17,9 +17,15 @@ fi build_generator="Unix Makefiles" os_fsfw="linux" builddir="build-Debug-Host" +if [ "${OS}" = "Windows_NT" ]; then + python="py" +# Could be other OS but this works for now. +else + python="python3" +fi echo "Running command (without the leading +):" set -x # Print command -python3 cmake_build_config.py -o "${os_fsfw}" -g "${build_generator}" -b "debug" -l "${builddir}" +${python} cmake_build_config.py -o "${os_fsfw}" -g "${build_generator}" -b "debug" -l "${builddir}" # Use this if commands are added which should not be printed # set +x diff --git a/cmake/scripts/Linux/create_cmake_release_cfg.sh b/cmake/scripts/Linux/create_cmake_release_cfg.sh index 4412e671..95d87e70 100755 --- a/cmake/scripts/Linux/create_cmake_release_cfg.sh +++ b/cmake/scripts/Linux/create_cmake_release_cfg.sh @@ -17,9 +17,15 @@ fi build_generator="Unix Makefiles" os_fsfw="linux" builddir="build-Release-Host" +if [ "${OS}" = "Windows_NT" ]; then + python="py" +# Could be other OS but this works for now. +else + python="python3" +fi echo "Running command (without the leading +):" set -x # Print command -python3 cmake_build_config.py -o "${os_fsfw}" -g "${build_generator}" -b "debug" -l "${builddir}" +${python} cmake_build_config.py -o "${os_fsfw}" -g "${build_generator}" -b "release" -l "${builddir}" # Use this if commands are added which should not be printed # set +x diff --git a/cmake/scripts/RPi/make_reldeb_cfg.sh b/cmake/scripts/Q7S/ninja_debug_cfg.sh similarity index 53% rename from cmake/scripts/RPi/make_reldeb_cfg.sh rename to cmake/scripts/Q7S/ninja_debug_cfg.sh index de7651a7..2d3b333f 100755 --- a/cmake/scripts/RPi/make_reldeb_cfg.sh +++ b/cmake/scripts/Q7S/ninja_debug_cfg.sh @@ -15,15 +15,19 @@ if [ "${counter}" -ge 5 ];then fi os_fsfw="linux" -tgt_bsp="arm/raspberrypi" -build_generator="" -build_dir="RelWithDeb-RPi" +tgt_bsp="arm/q7s" +build_dir="build-Debug-Q7S" +build_generator="Ninja" if [ "${OS}" = "Windows_NT" ]; then - build_generator="MinGW Makefiles" + python="py" # Could be other OS but this works for now. else - build_generator="Unix Makefiles" + python="python3" fi -python3 cmake_build_config.py -o "${os_fsfw}" -g "${build_generator}" -b "reldeb" -t "${tgt_bsp}" \ - -l"${build_dir}" +echo "Running command (without the leading +):" +set -x # Print command +${python} cmake_build_config.py -o "${os_fsfw}" -g "${build_generator}" -b "debug" -t "${tgt_bsp}" \ + -l"${build_dir}" +# set +x + diff --git a/cmake/scripts/RPi/make_debug_cfg.sh b/cmake/scripts/RPi/make_debug_cfg.sh index 57561846..dbb178de 100755 --- a/cmake/scripts/RPi/make_debug_cfg.sh +++ b/cmake/scripts/RPi/make_debug_cfg.sh @@ -20,10 +20,16 @@ build_generator="" build_dir="build-Debug-RPi" if [ "${OS}" = "Windows_NT" ]; then build_generator="MinGW Makefiles" + python="py" # Could be other OS but this works for now. else build_generator="Unix Makefiles" + python="python3" fi -python3 cmake_build_config.py -o "${os_fsfw}" -g "${build_generator}" -b "debug" -t "${tgt_bsp}" \ - -l"${build_dir}" +echo "Running command (without the leading +):" +set -x # Print command +${python} cmake_build_config.py -o "${os_fsfw}" -g "${build_generator}" -b "debug" -t "${tgt_bsp}" \ + -l"${build_dir}" +# set +x + diff --git a/cmake/scripts/RPi/ninja_debug_cfg.sh b/cmake/scripts/RPi/ninja_debug_cfg.sh index c05ae446..3fa0e5f4 100755 --- a/cmake/scripts/RPi/ninja_debug_cfg.sh +++ b/cmake/scripts/RPi/ninja_debug_cfg.sh @@ -18,6 +18,16 @@ os_fsfw="linux" tgt_bsp="arm/raspberrypi" build_generator="Ninja" build_dir="build-Debug-RPi" +if [ "${OS}" = "Windows_NT" ]; then + python="py" +# Could be other OS but this works for now. +else + python="python3" +fi + +echo "Running command (without the leading +):" +set -x # Print command +${python} cmake_build_config.py -o "${os_fsfw}" -g "${build_generator}" -b "debug" -t "${tgt_bsp}" \ + -l"${build_dir}" +# set +x -python3 cmake_build_config.py -o "${os_fsfw}" -g "${build_generator}" -b "debug" -t "${tgt_bsp}" \ - -l"${build_dir}" From ddfa0b474b74bdf39c2d489739308758015735e9 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Wed, 30 Jun 2021 15:40:49 +0200 Subject: [PATCH 051/111] deleted unneeded file --- bsp_q7s/bsp_q7s.mk | 6 ------ 1 file changed, 6 deletions(-) delete mode 100644 bsp_q7s/bsp_q7s.mk diff --git a/bsp_q7s/bsp_q7s.mk b/bsp_q7s/bsp_q7s.mk deleted file mode 100644 index 93bfdc78..00000000 --- a/bsp_q7s/bsp_q7s.mk +++ /dev/null @@ -1,6 +0,0 @@ -CXXSRC += $(wildcard $(CURRENTPATH)/*.cpp) -CXXSRC += $(wildcard $(CURRENTPATH)/comIF/cookies/*.cpp) -CXXSRC += $(wildcard $(CURRENTPATH)/comIF/*.cpp) -CSRC += $(wildcard $(CURRENTPATH)/*.c) - -CSRC += $(wildcard $(CURRENTPATH)/boardconfig/*.c) \ No newline at end of file From 8e290b5831822b2734a0af00cb8ebb0864211837 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Wed, 30 Jun 2021 15:45:57 +0200 Subject: [PATCH 052/111] updated project file --- .../Q7S/{ => simple}/simple_make_debug_cfg.sh | 2 +- .../{ => simple}/simple_ninja_debug_cfg.sh | 2 +- misc/eclipse/.cproject | 186 ++++++++++++++++-- 3 files changed, 176 insertions(+), 14 deletions(-) rename cmake/scripts/Q7S/{ => simple}/simple_make_debug_cfg.sh (96%) rename cmake/scripts/Q7S/{ => simple}/simple_ninja_debug_cfg.sh (95%) diff --git a/cmake/scripts/Q7S/simple_make_debug_cfg.sh b/cmake/scripts/Q7S/simple/simple_make_debug_cfg.sh similarity index 96% rename from cmake/scripts/Q7S/simple_make_debug_cfg.sh rename to cmake/scripts/Q7S/simple/simple_make_debug_cfg.sh index 8b687504..b692184a 100755 --- a/cmake/scripts/Q7S/simple_make_debug_cfg.sh +++ b/cmake/scripts/Q7S/simple/simple_make_debug_cfg.sh @@ -16,7 +16,7 @@ fi os_fsfw="linux" tgt_bsp="arm/q7s" -build_dir="build-Debug-Q7S" +build_dir="build-Simple-Q7S" build_generator="" definitions="Q7S_SIMPLE_MODE=On" if [ "${OS}" = "Windows_NT" ]; then diff --git a/cmake/scripts/Q7S/simple_ninja_debug_cfg.sh b/cmake/scripts/Q7S/simple/simple_ninja_debug_cfg.sh similarity index 95% rename from cmake/scripts/Q7S/simple_ninja_debug_cfg.sh rename to cmake/scripts/Q7S/simple/simple_ninja_debug_cfg.sh index fa4d64f3..a3a55521 100755 --- a/cmake/scripts/Q7S/simple_ninja_debug_cfg.sh +++ b/cmake/scripts/Q7S/simple/simple_ninja_debug_cfg.sh @@ -16,7 +16,7 @@ fi os_fsfw="linux" tgt_bsp="arm/q7s" -build_dir="build-Debug-Q7S" +build_dir="build-Simple-Q7S" build_generator="Ninja" definitions="Q7S_SIMPLE_MODE=On" if [ "${OS}" = "Windows_NT" ]; then diff --git a/misc/eclipse/.cproject b/misc/eclipse/.cproject index 22a4a09c..a562e7b2 100644 --- a/misc/eclipse/.cproject +++ b/misc/eclipse/.cproject @@ -234,7 +234,7 @@ - + @@ -250,7 +250,7 @@ - + - + @@ -405,7 +405,7 @@ - + - + @@ -562,7 +562,7 @@ - + - + @@ -720,7 +720,7 @@ - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -869,6 +1028,9 @@ + + + @@ -876,9 +1038,9 @@ - - + + From 11419676cf8621ede1b179d8a9880e22e6e73fdb Mon Sep 17 00:00:00 2001 From: "Jakob.Meier" Date: Wed, 30 Jun 2021 15:46:58 +0200 Subject: [PATCH 053/111] added tmtc --- tmtc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tmtc b/tmtc index 78b68307..7a15062e 160000 --- a/tmtc +++ b/tmtc @@ -1 +1 @@ -Subproject commit 78b68307825754b468404ee4ff006ee87e0bdd5f +Subproject commit 7a15062efe696802e8a602a7b3b675265d75dac8 From 6c7b1a9e14ca0df2e7126106a8ad5c390146c1c1 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Wed, 30 Jun 2021 15:58:56 +0200 Subject: [PATCH 054/111] slight adaptions --- cmake/scripts/Q7S/simple/simple_make_debug_cfg.sh | 2 +- cmake/scripts/Q7S/simple/simple_ninja_debug_cfg.sh | 2 +- cmake/scripts/cmake_build_config.py | 0 3 files changed, 2 insertions(+), 2 deletions(-) mode change 100644 => 100755 cmake/scripts/cmake_build_config.py diff --git a/cmake/scripts/Q7S/simple/simple_make_debug_cfg.sh b/cmake/scripts/Q7S/simple/simple_make_debug_cfg.sh index b692184a..8a6c7b3f 100755 --- a/cmake/scripts/Q7S/simple/simple_make_debug_cfg.sh +++ b/cmake/scripts/Q7S/simple/simple_make_debug_cfg.sh @@ -31,5 +31,5 @@ fi echo "Running command (without the leading +):" set -x # Print command ${python} cmake_build_config.py -o "${os_fsfw}" -g "${build_generator}" -b "debug" -t "${tgt_bsp}" \ - -l"${build_dir}" -d "${definitions}" + -l "${build_dir}" -d "${definitions}" # set +x diff --git a/cmake/scripts/Q7S/simple/simple_ninja_debug_cfg.sh b/cmake/scripts/Q7S/simple/simple_ninja_debug_cfg.sh index a3a55521..965aae45 100755 --- a/cmake/scripts/Q7S/simple/simple_ninja_debug_cfg.sh +++ b/cmake/scripts/Q7S/simple/simple_ninja_debug_cfg.sh @@ -29,6 +29,6 @@ fi echo "Running command (without the leading +):" set -x # Print command ${python} cmake_build_config.py -o "${os_fsfw}" -g "${build_generator}" -b "debug" -t "${tgt_bsp}" \ - -l"${build_dir}" -d "${definitions}" + -l "${build_dir}" -d "${definitions}" # set +x diff --git a/cmake/scripts/cmake_build_config.py b/cmake/scripts/cmake_build_config.py old mode 100644 new mode 100755 From 3895eea24b6c6c4af38752682ee6dac43368d9d9 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Wed, 30 Jun 2021 16:15:46 +0200 Subject: [PATCH 055/111] added file system test --- bsp_q7s/CMakeLists.txt | 3 ++- bsp_q7s/boardconfig/q7sConfig.h.in | 2 ++ bsp_q7s/boardtest/CMakeLists.txt | 1 + bsp_q7s/boardtest/FileSystemTest.cpp | 14 ++++++++++++++ bsp_q7s/boardtest/FileSystemTest.h | 18 ++++++++++++++++++ bsp_q7s/simple/simple.cpp | 11 +++++++++++ 6 files changed, 48 insertions(+), 1 deletion(-) create mode 100644 bsp_q7s/boardtest/FileSystemTest.cpp create mode 100644 bsp_q7s/boardtest/FileSystemTest.h diff --git a/bsp_q7s/CMakeLists.txt b/bsp_q7s/CMakeLists.txt index bc027af0..d0ee0800 100644 --- a/bsp_q7s/CMakeLists.txt +++ b/bsp_q7s/CMakeLists.txt @@ -2,12 +2,13 @@ target_sources(${TARGET_NAME} PUBLIC main.cpp ) +add_subdirectory(boardtest) + if(Q7S_SIMPLE_MODE) add_subdirectory(simple) else() add_subdirectory(boardconfig) add_subdirectory(comIF) - add_subdirectory(boardtest) add_subdirectory(gpio) add_subdirectory(core) endif() diff --git a/bsp_q7s/boardconfig/q7sConfig.h.in b/bsp_q7s/boardconfig/q7sConfig.h.in index 6ee84821..bf509f0d 100644 --- a/bsp_q7s/boardconfig/q7sConfig.h.in +++ b/bsp_q7s/boardconfig/q7sConfig.h.in @@ -11,4 +11,6 @@ #define Q7S_ADD_SPI_TEST 0 #endif +#define Q7S_SIMPLE_ADD_FILE_SYSTEM_TEST 0 + #endif /* BSP_Q7S_BOARDCONFIG_Q7S_CONFIG_H_ */ diff --git a/bsp_q7s/boardtest/CMakeLists.txt b/bsp_q7s/boardtest/CMakeLists.txt index 0599b73f..9a5c0a0a 100644 --- a/bsp_q7s/boardtest/CMakeLists.txt +++ b/bsp_q7s/boardtest/CMakeLists.txt @@ -1,4 +1,5 @@ target_sources(${TARGET_NAME} PRIVATE + FileSystemTest.cpp ) diff --git a/bsp_q7s/boardtest/FileSystemTest.cpp b/bsp_q7s/boardtest/FileSystemTest.cpp new file mode 100644 index 00000000..fa504b0c --- /dev/null +++ b/bsp_q7s/boardtest/FileSystemTest.cpp @@ -0,0 +1,14 @@ +#include "FileSystemTest.h" + +#include +#include + +FileSystemTest::FileSystemTest() { + using namespace std; + SdCard sdCard = SdCard::SDC0; + cout << "SD Card Test for SD card " << static_cast(sdCard) << std::endl; + //std::system("echo Hello World"); +} + +FileSystemTest::~FileSystemTest() { +} diff --git a/bsp_q7s/boardtest/FileSystemTest.h b/bsp_q7s/boardtest/FileSystemTest.h new file mode 100644 index 00000000..907c86ca --- /dev/null +++ b/bsp_q7s/boardtest/FileSystemTest.h @@ -0,0 +1,18 @@ +#ifndef BSP_Q7S_BOARDTEST_FILESYSTEMTEST_H_ +#define BSP_Q7S_BOARDTEST_FILESYSTEMTEST_H_ + +enum SdCard { + SDC0, + SDC1 +}; + +class FileSystemTest { +public: + FileSystemTest(); + virtual~ FileSystemTest(); +private: +}; + + + +#endif /* BSP_Q7S_BOARDTEST_FILESYSTEMTEST_H_ */ diff --git a/bsp_q7s/simple/simple.cpp b/bsp_q7s/simple/simple.cpp index 6261bfe3..cc85c04f 100644 --- a/bsp_q7s/simple/simple.cpp +++ b/bsp_q7s/simple/simple.cpp @@ -1,5 +1,16 @@ #include "simple.h" +#include "q7sConfig.h" + +#if Q7S_SIMPLE_ADD_FILE_SYSTEM_TEST == 1 +#include "../boardtest/FileSystemTest.h" +#endif int simple::simple() { +#if Q7S_SIMPLE_ADD_FILE_SYSTEM_TEST == 1 + { + FileSystemTest fileSystemTest; + } +#endif return 0; } + From 89581d03aa31a265dab5c885f9f6a9f622862478 Mon Sep 17 00:00:00 2001 From: "Jakob.Meier" Date: Thu, 1 Jul 2021 07:25:28 +0200 Subject: [PATCH 056/111] comment in readme --- README.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/README.md b/README.md index 53c1cfad..69aa4dc1 100644 --- a/README.md +++ b/README.md @@ -626,6 +626,9 @@ gpioget Example to get state: gpioget gpiochip7 14 +Both the MIOs and EMIOs can be accessed via the zynq_gpio instance which comprises 118 pins +(54 MIOs and 64 EMIOs). + ## Running the EIVE OBSW on a Raspberry Pi Special section for running the EIVE OBSW on the Raspberry Pi. From 8e98de6f3cdb985065b1408dd871ebbd0b2bc3df Mon Sep 17 00:00:00 2001 From: "Jakob.Meier" Date: Thu, 1 Jul 2021 10:53:50 +0200 Subject: [PATCH 057/111] added spi mux functionality to the rwSpiCallback --- bsp_q7s/ObjectFactory.cpp | 37 +++++++++------- bsp_q7s/spi/Q7sSpiComIF.cpp | 9 ++++ bsp_q7s/spi/Q7sSpiComIF.h | 33 +++++++++++++++ bsp_q7s/spiCallbacks/rwSpiCallback.cpp | 58 ++++++++++++++++---------- bsp_q7s/spiCallbacks/rwSpiCallback.h | 16 ++++++- linux/fsfwconfig/devices/gpioIds.h | 4 +- 6 files changed, 117 insertions(+), 40 deletions(-) create mode 100644 bsp_q7s/spi/Q7sSpiComIF.cpp create mode 100644 bsp_q7s/spi/Q7sSpiComIF.h diff --git a/bsp_q7s/ObjectFactory.cpp b/bsp_q7s/ObjectFactory.cpp index 936b1cd2..991cd8b2 100644 --- a/bsp_q7s/ObjectFactory.cpp +++ b/bsp_q7s/ObjectFactory.cpp @@ -521,12 +521,6 @@ void ObjectFactory::produce(void* args){ Max31865PT1000Handler* rtdIc16 = new Max31865PT1000Handler(objects::RTD_IC16, objects::SPI_COM_IF, spiRtdIc16, 0); Max31865PT1000Handler* rtdIc17 = new Max31865PT1000Handler(objects::RTD_IC17, objects::SPI_COM_IF, spiRtdIc17, 0); Max31865PT1000Handler* rtdIc18 = new Max31865PT1000Handler(objects::RTD_IC18, objects::SPI_COM_IF, spiRtdIc18, 0); -<<<<<<< HEAD - rtdIc3->setStartUpImmediately(); -======= - rtdIc17->setStartUpImmediately(); ->>>>>>> develop -// rtdIc4->setStartUpImmediately(); (void) rtdIc3; (void) rtdIc4; @@ -542,7 +536,7 @@ void ObjectFactory::produce(void* args){ (void) rtdIc14; (void) rtdIc15; (void) rtdIc16; -// (void) rtdIc17; + (void) rtdIc17; (void) rtdIc18; #endif /* Q7S_ADD_RTD_DEVICES == 1 */ @@ -582,16 +576,29 @@ void ObjectFactory::produce(void* args){ std::string("Enable reaction wheel 4"), gpio::OUT, 0); gpioCookieRw->addGpio(gpioIds::EN_RW4, enRw4); + /** + * This GPIO is only internally connected to the SPI MUX module and responsible to disconnect + * 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); + gpioCookieRw->addGpio(gpioIds::SPI_MUX, spiMux); + gpioComIF->addGpios(gpioCookieRw); - auto rw1SpiCookie = new SpiCookie(addresses::RW1, gpioIds::CS_RW1, "/dev/spidev2.0", - RwDefinitions::MAX_REPLY_SIZE, spi::RW_MODE, spi::RW_SPEED, &rwSpiCallback, nullptr); - auto rw2SpiCookie = new SpiCookie(addresses::RW2, gpioIds::CS_RW2, "/dev/spidev2.0", - RwDefinitions::MAX_REPLY_SIZE, spi::RW_MODE, spi::RW_SPEED, &rwSpiCallback, nullptr); - auto rw3SpiCookie = new SpiCookie(addresses::RW3, gpioIds::CS_RW3, "/dev/spidev2.0", - RwDefinitions::MAX_REPLY_SIZE, spi::RW_MODE, spi::RW_SPEED, &rwSpiCallback, nullptr); - auto rw4SpiCookie = new SpiCookie(addresses::RW4, gpioIds::CS_RW4, "/dev/spidev2.0", - RwDefinitions::MAX_REPLY_SIZE, spi::RW_MODE, spi::RW_SPEED, &rwSpiCallback, nullptr); + auto rw1SpiCookie = new SpiCookie(addresses::RW1, gpioIds::CS_RW1, "/dev/spidev3.0", + 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", + 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", + 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", + RwDefinitions::MAX_REPLY_SIZE, spi::RW_MODE, spi::RW_SPEED, &rwSpiCallback::spiCallback, + nullptr); auto rwHandler1 = new RwHandler(objects::RW1, objects::SPI_COM_IF, rw1SpiCookie, gpioComIF, gpioIds::EN_RW1); diff --git a/bsp_q7s/spi/Q7sSpiComIF.cpp b/bsp_q7s/spi/Q7sSpiComIF.cpp new file mode 100644 index 00000000..23dbe551 --- /dev/null +++ b/bsp_q7s/spi/Q7sSpiComIF.cpp @@ -0,0 +1,9 @@ +#include + +Q7sSpiComIF::Q7sSpiComIF(object_id_t objectId, GpioIF* gpioComIF) : + SpiComIF(objectId, gpioComIF) { +} + +Q7sSpiComIF::~Q7sSpiComIF() { +} + diff --git a/bsp_q7s/spi/Q7sSpiComIF.h b/bsp_q7s/spi/Q7sSpiComIF.h new file mode 100644 index 00000000..a10d63dd --- /dev/null +++ b/bsp_q7s/spi/Q7sSpiComIF.h @@ -0,0 +1,33 @@ +#ifndef BSP_Q7S_SPI_Q7SSPICOMIF_H_ +#define BSP_Q7S_SPI_Q7SSPICOMIF_H_ + +#include + + +/** + * @brief This additional communication interface is required because the SPI busses behind the + * devices "/dev/spi2.0" and "dev/spidev3.0" are multiplexed to one SPI interface. + * This was necessary because the processing system spi (/dev/spi2.0) does not support + * frequencies lower than 650 kHz. To reach lower frequencies also the CPU frequency must + * be reduced which leads to other effects compromising kernel drivers. + * The nano avionics reaction wheels require a spi frequency between 150 kHz and 300 kHz + * why an additional AXI SPI core has been implemented in the programmable logic. However, + * the spi frequency of the AXI SPI core is not configurable during runtime. Therefore, + * this communication interface multiplexes either the hard-wired SPI or the AXI SPI to + * the SPI interface. The multiplexing is performed via a GPIO connected to a VHDL + * module responsible for switching between the to SPI peripherals. + */ +class Q7sSpiComIF: public SpiComIF { +public: + /** + * @brief Constructor + * + * @param objectId + * @param gpioComIF + * @param gpioSwitchId The gpio ID of the GPIO connected to the SPI mux module in the PL. + */ + Q7sSpiComIF(object_id_t objectId, GpioIF* gpioComIF, gpioId_t gpioSwitchId); + virtual ~Q7sSpiComIF(); +}; + +#endif /* BSP_Q7S_SPI_Q7SSPICOMIF_H_ */ diff --git a/bsp_q7s/spiCallbacks/rwSpiCallback.cpp b/bsp_q7s/spiCallbacks/rwSpiCallback.cpp index bfb1892c..f05fbbdf 100644 --- a/bsp_q7s/spiCallbacks/rwSpiCallback.cpp +++ b/bsp_q7s/spiCallbacks/rwSpiCallback.cpp @@ -3,15 +3,18 @@ #include #include #include +#include "devices/gpioIds.h" -ReturnValue_t rwSpiCallback(SpiComIF* comIf, SpiCookie *cookie, const uint8_t *sendData, +namespace rwSpiCallback { + +ReturnValue_t spiCallback(SpiComIF* comIf, SpiCookie *cookie, const uint8_t *sendData, size_t sendLen, void* args) { ReturnValue_t result = HasReturnvaluesIF::RETURN_OK; RwHandler* handler = reinterpret_cast(args); if(handler == nullptr) { - sif::error << "rwSpiCallback: Pointer to handler is invalid" + sif::error << "rwSpiCallback::spiCallback: Pointer to handler is invalid" << std::endl; return HasReturnvaluesIF::RETURN_FAILED; } @@ -21,9 +24,9 @@ ReturnValue_t rwSpiCallback(SpiComIF* comIf, SpiCookie *cookie, const uint8_t *s int fileDescriptor = 0; std::string device = cookie->getSpiDevice(); - UnixFileGuard fileHelper(device, &fileDescriptor, O_RDWR, "rwSpiCallback: "); + UnixFileGuard fileHelper(device, &fileDescriptor, O_RDWR, "rwSpiCallback::spiCallback: "); if(fileHelper.getOpenResult() != HasReturnvaluesIF::RETURN_OK) { - sif::error << "rwSpiCallback: Failed to open device file" << std::endl; + sif::error << "rwSpiCallback::spiCallback: Failed to open device file" << std::endl; return SpiComIF::OPENING_FILE_FAILED; } spi::SpiModes spiMode = spi::SpiModes::MODE_0; @@ -37,16 +40,19 @@ ReturnValue_t rwSpiCallback(SpiComIF* comIf, SpiCookie *cookie, const uint8_t *s uint32_t timeoutMs = 0; MutexIF* mutex = comIf->getMutex(&timeoutType, &timeoutMs); if(mutex == nullptr or gpioIF == nullptr) { - sif::debug << "rwSpiCallback: Mutex or GPIO interface invalid" << std::endl; + sif::debug << "rwSpiCallback::spiCallback: Mutex or GPIO interface invalid" << std::endl; return HasReturnvaluesIF::RETURN_FAILED; } - if(gpioId != gpio::NO_GPIO) { - result = mutex->lockMutex(timeoutType, timeoutMs); - if (result != HasReturnvaluesIF::RETURN_OK) { - sif::debug << "rwSpiCallback: Failed to lock mutex" << std::endl; - return result; - } + result = mutex->lockMutex(timeoutType, timeoutMs); + if (result != HasReturnvaluesIF::RETURN_OK) { + sif::debug << "rwSpiCallback::spiCallback: Failed to lock mutex" << std::endl; + return result; + } + + /** Disconnect PS SPI peripheral and select AXI SPI core */ + if(gpioIF->pullHigh(gpioIds::SPI_MUX) != HasReturnvaluesIF::RETURN_OK) { + sif::error << "rwSpiCallback::spiCallback: Failed to pull spi mux gpio high" << std::endl; } /** Sending frame start sign */ @@ -56,12 +62,12 @@ ReturnValue_t rwSpiCallback(SpiComIF* comIf, SpiCookie *cookie, const uint8_t *s // Pull SPI CS low. For now, no support for active high given if(gpioId != gpio::NO_GPIO) { if(gpioIF->pullLow(gpioId) != HasReturnvaluesIF::RETURN_OK) { - sif::error << "rwSpiCallback: Failed to pull chip select low" << std::endl; + sif::error << "rwSpiCallback::spiCallback: Failed to pull chip select low" << std::endl; } } if (write(fileDescriptor, writeBuffer, writeSize) != static_cast(writeSize)) { - sif::error << "rwSpiCallback: Write failed!" << std::endl; + sif::error << "rwSpiCallback::spiCallback: Write failed!" << std::endl; closeSpi(gpioId, gpioIF, mutex); return RwHandler::SPI_WRITE_FAILURE; } @@ -86,7 +92,7 @@ ReturnValue_t rwSpiCallback(SpiComIF* comIf, SpiCookie *cookie, const uint8_t *s break; } if (write(fileDescriptor, writeBuffer, writeSize) != static_cast(writeSize)) { - sif::error << "rwSpiCallback: Write failed!" << std::endl; + sif::error << "rwSpiCallback::spiCallback: Write failed!" << std::endl; closeSpi(gpioId, gpioIF, mutex); return RwHandler::SPI_WRITE_FAILURE; } @@ -98,7 +104,7 @@ ReturnValue_t rwSpiCallback(SpiComIF* comIf, SpiCookie *cookie, const uint8_t *s writeSize = 1; if (write(fileDescriptor, writeBuffer, writeSize) != static_cast(writeSize)) { - sif::error << "rwSpiCallback: Write failed!" << std::endl; + sif::error << "rwSpiCallback::spiCallback: Write failed!" << std::endl; closeSpi(gpioId, gpioIF, mutex); return RwHandler::SPI_WRITE_FAILURE; } @@ -122,7 +128,7 @@ ReturnValue_t rwSpiCallback(SpiComIF* comIf, SpiCookie *cookie, const uint8_t *s uint8_t byteRead = 0; for (int idx = 0; idx < 10; idx++) { if(read(fileDescriptor, &byteRead, 1) != 1) { - sif::error << "rwSpiCallback: Read failed" << std::endl; + sif::error << "rwSpiCallback::spiCallback: Read failed" << std::endl; closeSpi(gpioId, gpioIF, mutex); return RwHandler::SPI_READ_FAILURE; } @@ -132,7 +138,7 @@ ReturnValue_t rwSpiCallback(SpiComIF* comIf, SpiCookie *cookie, const uint8_t *s } if (idx == 9) { - sif::error << "rwSpiCallback: Empty frame timeout" << std::endl; + sif::error << "rwSpiCallback::spiCallback: Empty frame timeout" << std::endl; closeSpi(gpioId, gpioIF, mutex); return RwHandler::NO_REPLY; } @@ -145,7 +151,7 @@ ReturnValue_t rwSpiCallback(SpiComIF* comIf, SpiCookie *cookie, const uint8_t *s if (decodedFrameLen != 0) { byteRead = 0; if(read(fileDescriptor, &byteRead, 1) != 1) { - sif::error << "rwSpiCallback: Read failed" << std::endl; + sif::error << "rwSpiCallback::spiCallback: Read failed" << std::endl; result = RwHandler::SPI_READ_FAILURE; break; } @@ -157,7 +163,7 @@ ReturnValue_t rwSpiCallback(SpiComIF* comIf, SpiCookie *cookie, const uint8_t *s } else if (byteRead == 0x7D) { if(read(fileDescriptor, &byteRead, 1) != 1) { - sif::error << "rwSpiCallback: Read failed" << std::endl; + sif::error << "rwSpiCallback::spiCallback: Read failed" << std::endl; result = RwHandler::SPI_READ_FAILURE; break; } @@ -172,7 +178,7 @@ ReturnValue_t rwSpiCallback(SpiComIF* comIf, SpiCookie *cookie, const uint8_t *s continue; } else { - sif::error << "rwSpiCallback: Invalid substitute" << std::endl; + sif::error << "rwSpiCallback::spiCallback: Invalid substitute" << std::endl; closeSpi(gpioId, gpioIF, mutex); result = RwHandler::INVALID_SUBSTITUTE; break; @@ -191,12 +197,12 @@ ReturnValue_t rwSpiCallback(SpiComIF* comIf, SpiCookie *cookie, const uint8_t *s */ if (decodedFrameLen == replyBufferSize) { if(read(fileDescriptor, &byteRead, 1) != 1) { - sif::error << "rwSpiCallback: Failed to read last byte" << std::endl; + sif::error << "rwSpiCallback::spiCallback: Failed to read last byte" << std::endl; result = RwHandler::SPI_READ_FAILURE; break; } if (byteRead != 0x7E) { - sif::error << "rwSpiCallback: Missing end sign 0x7E" << std::endl; + sif::error << "rwSpiCallback::spiCallback: Missing end sign 0x7E" << std::endl; decodedFrameLen--; result = RwHandler::MISSING_END_SIGN; break; @@ -219,6 +225,12 @@ void closeSpi (gpioId_t gpioId, GpioIF* gpioIF, MutexIF* mutex) { } } if(mutex->unlockMutex() != HasReturnvaluesIF::RETURN_OK) { - sif::error << "closeSpi: Failed to unlock mutex" << std::endl;; + sif::error << "rwSpiCallback::closeSpi: Failed to unlock mutex" << std::endl;; + } + + /** Route SPI interface again to PS SPI peripheral */ + if(gpioIF->pullLow(gpioIds::SPI_MUX) != HasReturnvaluesIF::RETURN_OK) { + sif::error << "rwSpiCallback::spiCallback: Failed to pull spi mux gpio low" << std::endl; } } +} diff --git a/bsp_q7s/spiCallbacks/rwSpiCallback.h b/bsp_q7s/spiCallbacks/rwSpiCallback.h index e684c1c1..e5a79e64 100644 --- a/bsp_q7s/spiCallbacks/rwSpiCallback.h +++ b/bsp_q7s/spiCallbacks/rwSpiCallback.h @@ -3,6 +3,10 @@ #include #include +#include + + +namespace rwSpiCallback { /** * @brief This is the callback function to send commands to the nano avionics reaction wheels and @@ -14,8 +18,17 @@ * Arbeitsdaten/08_Used%20Components/Nanoavionics_Reactionwheels&fileid=181622 * Each command entails exactly one reply which will also be read in and decoded by this * function. + * Because the reaction wheels require a spi clock frequency of maximum 300 kHZ and minimum + * 150 kHz which is not supported by the processing system SPI peripheral an AXI SPI core + * has been implemented in the programmable logic. This AXI SPI core works with a fixed + * frequency of 250 kHz. + * To allow the parallel usage of the same physical SPI bus, a VHDL module has been + * implemented which is able to disconnect the hard-wired SPI peripheral of the PS and + * route the AXI SPI to the SPI lines. + * To switch between the to SPI peripherals, an EMIO is used which will also be controlled + * by this function. */ -ReturnValue_t rwSpiCallback(SpiComIF* comIf, SpiCookie *cookie, const uint8_t *sendData, +ReturnValue_t spiCallback(SpiComIF* comIf, SpiCookie *cookie, const uint8_t *sendData, size_t sendLen, void* args); /** @@ -27,4 +40,5 @@ ReturnValue_t rwSpiCallback(SpiComIF* comIf, SpiCookie *cookie, const uint8_t *s */ void closeSpi(gpioId_t gpioId, GpioIF* gpioIF, MutexIF* mutex); +} #endif /* BSP_Q7S_RW_SPI_CALLBACK_H_ */ diff --git a/linux/fsfwconfig/devices/gpioIds.h b/linux/fsfwconfig/devices/gpioIds.h index 718bc9bf..aad06629 100644 --- a/linux/fsfwconfig/devices/gpioIds.h +++ b/linux/fsfwconfig/devices/gpioIds.h @@ -80,7 +80,9 @@ namespace gpioIds { CS_RW3, CS_RW4, - EN_RW_CS + EN_RW_CS, + + SPI_MUX }; } From b82ed37766c4669289cdeac9388045887881b52c Mon Sep 17 00:00:00 2001 From: "Jakob.Meier" Date: Thu, 1 Jul 2021 11:56:13 +0200 Subject: [PATCH 058/111] commend rad sensor in again --- .../pollingsequence/pollingSequenceFactory.cpp | 18 ++++++++---------- mission/devices/RadiationSensorHandler.cpp | 2 +- tmtc | 2 +- 3 files changed, 10 insertions(+), 12 deletions(-) diff --git a/linux/fsfwconfig/pollingsequence/pollingSequenceFactory.cpp b/linux/fsfwconfig/pollingsequence/pollingSequenceFactory.cpp index be184b6b..4b201f2b 100644 --- a/linux/fsfwconfig/pollingsequence/pollingSequenceFactory.cpp +++ b/linux/fsfwconfig/pollingsequence/pollingSequenceFactory.cpp @@ -18,16 +18,6 @@ ReturnValue_t pst::pstGpio(FixedTimeslotTaskIF *thisSequence) thisSequence->addSlot(objects::SOLAR_ARRAY_DEPL_HANDLER, length * 0, DeviceHandlerIF::PERFORM_OPERATION); - // Radiation sensor - // 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); - // thisSequence->addSlot(objects::RAD_SENSOR, length * 0.6, DeviceHandlerIF::SEND_READ); - // thisSequence->addSlot(objects::RAD_SENSOR, length * 0.8, DeviceHandlerIF::GET_READ); - // if (length != 3000) { - // sif::warning << "pollingSequenceInitDefault: Frequency changed. Make sure timing critical " - // << "SUS sensors still produce correct values" << std::endl; - // } if (thisSequence->checkSequence() == HasReturnvaluesIF::RETURN_OK) { return HasReturnvaluesIF::RETURN_OK; } @@ -145,6 +135,14 @@ ReturnValue_t pst::pstSpi(FixedTimeslotTaskIF *thisSequence) { thisSequence->addSlot(objects::RTD_IC17, length * 0.8, DeviceHandlerIF::GET_READ); thisSequence->addSlot(objects::RTD_IC18, length * 0.8, DeviceHandlerIF::GET_READ); #endif /* Q7S_ADD_RTD_DEVICES */ + + /* Radiation sensor */ + 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); + thisSequence->addSlot(objects::RAD_SENSOR, length * 0.6, DeviceHandlerIF::SEND_READ); + thisSequence->addSlot(objects::RAD_SENSOR, length * 0.8, DeviceHandlerIF::GET_READ); + /** * The sun sensor will be shutdown as soon as the chip select is pulled high. Thus all * requests to a sun sensor must be performed consecutively. Another reason for calling multiple diff --git a/mission/devices/RadiationSensorHandler.cpp b/mission/devices/RadiationSensorHandler.cpp index bd16ddaf..65a877b6 100644 --- a/mission/devices/RadiationSensorHandler.cpp +++ b/mission/devices/RadiationSensorHandler.cpp @@ -44,7 +44,7 @@ ReturnValue_t RadiationSensorHandler::buildNormalDeviceCommand( break; } default: { - sif::debug << "RadiationSensorHandler::buildNormalDeviceCommand: Unknwon communication " + sif::debug << "RadiationSensorHandler::buildNormalDeviceCommand: Unknown communication " << "step" << std::endl; return HasReturnvaluesIF::RETURN_OK; } diff --git a/tmtc b/tmtc index 7a15062e..fe1bed90 160000 --- a/tmtc +++ b/tmtc @@ -1 +1 @@ -Subproject commit 7a15062efe696802e8a602a7b3b675265d75dac8 +Subproject commit fe1bed900adb688cbd3906617c974188a43c5535 From 5fc18f444eafb081320d5a89b6dd281c1d97b9f0 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Thu, 1 Jul 2021 14:53:00 +0200 Subject: [PATCH 059/111] updated tmtc --- bsp_q7s/boardtest/FileSystemTest.cpp | 4 ++-- tmtc | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/bsp_q7s/boardtest/FileSystemTest.cpp b/bsp_q7s/boardtest/FileSystemTest.cpp index fa504b0c..449d559c 100644 --- a/bsp_q7s/boardtest/FileSystemTest.cpp +++ b/bsp_q7s/boardtest/FileSystemTest.cpp @@ -6,8 +6,8 @@ FileSystemTest::FileSystemTest() { using namespace std; SdCard sdCard = SdCard::SDC0; - cout << "SD Card Test for SD card " << static_cast(sdCard) << std::endl; - //std::system("echo Hello World"); + cout << "SD Card Test for SD card qg" << static_cast(sdCard) << std::endl; + std::system("echo Hello World"); } FileSystemTest::~FileSystemTest() { diff --git a/tmtc b/tmtc index 9d98eb6b..941f4640 160000 --- a/tmtc +++ b/tmtc @@ -1 +1 @@ -Subproject commit 9d98eb6b606b40fa26aad12786894d1a99cb726c +Subproject commit 941f46401e13fb6ee5fc653875eebff8496133ec From 8862e0c3cb9d3669238a216cbd909888fbdf138a Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Mon, 5 Jul 2021 10:14:32 +0200 Subject: [PATCH 060/111] updated project file --- misc/eclipse/.cproject | 196 ++++------------------------------------- 1 file changed, 19 insertions(+), 177 deletions(-) diff --git a/misc/eclipse/.cproject b/misc/eclipse/.cproject index a562e7b2..fc222429 100644 --- a/misc/eclipse/.cproject +++ b/misc/eclipse/.cproject @@ -19,25 +19,25 @@ - + - @@ -77,19 +77,23 @@ - @@ -327,7 +331,7 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -1028,9 +873,6 @@ - - - @@ -1038,9 +880,9 @@ - - + + From e84989f64254d75a30f0357942f6655d8d71022f Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Mon, 5 Jul 2021 10:18:55 +0200 Subject: [PATCH 061/111] updated project file --- misc/eclipse/.cproject | 177 +++++++++++++++++++++++++++++++++++++++-- 1 file changed, 171 insertions(+), 6 deletions(-) diff --git a/misc/eclipse/.cproject b/misc/eclipse/.cproject index fc222429..5b42fcd3 100644 --- a/misc/eclipse/.cproject +++ b/misc/eclipse/.cproject @@ -131,7 +131,7 @@ - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + From 8ab288a4ba45aa68c8d9494bc7831e5306ba77bd Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Mon, 5 Jul 2021 10:24:38 +0200 Subject: [PATCH 062/111] added small printout --- bsp_q7s/main.cpp | 4 ++ misc/eclipse/.cproject | 88 +++++++++++++++++++++++------------------- 2 files changed, 52 insertions(+), 40 deletions(-) diff --git a/bsp_q7s/main.cpp b/bsp_q7s/main.cpp index 93968b76..88c679ca 100644 --- a/bsp_q7s/main.cpp +++ b/bsp_q7s/main.cpp @@ -6,12 +6,16 @@ #include "simple/simple.h" #endif +#include + /** * @brief This is the main program for the target hardware. * @return */ int main(void) { + using namespace std; + cout << "-- Q7S Simple Application --" << endl; #if Q7S_SIMPLE_MODE == 0 return obsw::obsw(); #else diff --git a/misc/eclipse/.cproject b/misc/eclipse/.cproject index 5b42fcd3..58022d69 100644 --- a/misc/eclipse/.cproject +++ b/misc/eclipse/.cproject @@ -960,6 +960,7 @@ @@ -969,6 +970,7 @@ + + From 7600e10f1b8647246d29639cea115f0bfa4ec3a9 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Thu, 8 Jul 2021 00:03:17 +0200 Subject: [PATCH 075/111] continued sd card manager --- bsp_q7s/memory/SdCardManager.cpp | 43 +++++++++++++++++++++++++++++--- bsp_q7s/memory/SdCardManager.h | 2 +- 2 files changed, 40 insertions(+), 5 deletions(-) diff --git a/bsp_q7s/memory/SdCardManager.cpp b/bsp_q7s/memory/SdCardManager.cpp index f04e518b..b6668045 100644 --- a/bsp_q7s/memory/SdCardManager.cpp +++ b/bsp_q7s/memory/SdCardManager.cpp @@ -1,5 +1,6 @@ #include "SdCardManager.h" #include "fsfw/ipc/MutexFactory.h" +#include "fsfw/serviceinterface/ServiceInterface.h" #include #include @@ -35,11 +36,38 @@ ReturnValue_t SdCardManager::switchOffSdCard(sd::SdCard sdCard) { } bool SdCardManager::sdCardActive(sd::SdCard sdCard) { - if(std::filesystem::exists("/tmp/sd_status.txt")) { - std::ifstream sdStatus("/tmp/sd_status.txt"); - return HasReturnvaluesIF::RETURN_OK; + using namespace std; + if(not filesystem::exists("/tmp/sd_status.txt")) { + ReturnValue_t result = updateSdCardStateFile(); + if(result != HasReturnvaluesIF::RETURN_OK) { + return result; + } } + // Now the file should exist in any case. Still check whether it exists. + fstream sdStatus("/tmp/sd_status.txt"); + if (not sdStatus.good()) { + return false; + } + string line; + uint8_t idx = 0; + while (std::getline(sdStatus, line)) { + istringstream iss(line); + string word; + if((sdCard == sd::SdCard::SLOT_0 and idx == 0) or + (sdCard == sd::SdCard::SLOT_1 and idx == 1)) { + while(iss >> word) { + if(word == "on") { + return true; + } + else { + return false; + } + } + } + idx++; + } + return HasReturnvaluesIF::RETURN_OK; return false; } @@ -51,5 +79,12 @@ void SdCardManager::setPreferredSdCard(sd::SdCard sdCard) { preferredSdCard = sdCard; } -void SdCardManager::updateSdCardStateFile() { +ReturnValue_t SdCardManager::updateSdCardStateFile() { + int result = std::system("q7hw sd info all > /tmp/sd_status.txt"); + if(result == 0) { + return HasReturnvaluesIF::RETURN_OK; + } + sif::warning << "SdCardManager::updateSdCardStateFile: system call failed with code " << + result << std::endl; + return HasReturnvaluesIF::RETURN_FAILED; } diff --git a/bsp_q7s/memory/SdCardManager.h b/bsp_q7s/memory/SdCardManager.h index 2a489d79..33b3db0c 100644 --- a/bsp_q7s/memory/SdCardManager.h +++ b/bsp_q7s/memory/SdCardManager.h @@ -46,7 +46,7 @@ public: private: SdCardManager(); - void updateSdCardStateFile(); + ReturnValue_t updateSdCardStateFile(); sd::SdCard preferredSdCard = sd::SdCard::SLOT_0; From e5c3e2da53e282833f2c1176a0eadf501a2e76bf Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Thu, 8 Jul 2021 11:23:08 +0200 Subject: [PATCH 076/111] continued sd card manager --- bsp_q7s/memory/SdCardManager.cpp | 82 ++++++++++++++++++++++++-------- bsp_q7s/memory/SdCardManager.h | 30 +++++++++++- bsp_q7s/memory/definitions.h | 3 +- 3 files changed, 91 insertions(+), 24 deletions(-) diff --git a/bsp_q7s/memory/SdCardManager.cpp b/bsp_q7s/memory/SdCardManager.cpp index b6668045..1458ef1f 100644 --- a/bsp_q7s/memory/SdCardManager.cpp +++ b/bsp_q7s/memory/SdCardManager.cpp @@ -25,50 +25,90 @@ SdCardManager* SdCardManager::instance() { } ReturnValue_t SdCardManager::switchOnSdCard(sd::SdCard sdCard) { - if(sdCardActive(sdCard)) { - return ALREADY_ON; - } - return HasReturnvaluesIF::RETURN_OK; +// if(sdCardActive(sdCard)) { +// return ALREADY_ON; +// } + return setSdCardState(sdCard, true); + } ReturnValue_t SdCardManager::switchOffSdCard(sd::SdCard sdCard) { - return HasReturnvaluesIF::RETURN_OK; +// if(not sdCardActive(sdCard)) { +// return ALREADY_OFF; +// } + return setSdCardState(sdCard, false); } -bool SdCardManager::sdCardActive(sd::SdCard sdCard) { +ReturnValue_t SdCardManager::setSdCardState(sd::SdCard sdCard, bool on) { + std::string sdstring = ""; + std::string statestring = ""; + if(sdCard == sd::SdCard::SLOT_0) { + sdstring = "0"; + } + else if(sdCard == sd::SdCard::SLOT_1) { + sdstring = "1"; + } + if(on) { + statestring = "on"; + } + else { + statestring = "off"; + } + std::ostringstream command; + command << "h7hw sd set " << sdstring << " " << statestring; + int result = std::system(command.str().c_str()); + if(result == 0) { + return HasReturnvaluesIF::RETURN_OK; + } + sif::warning << "SdCardManager::setSdCardState: system call failed with code " << + result << std::endl; + return HasReturnvaluesIF::RETURN_FAILED; +} + +ReturnValue_t SdCardManager::sdCardActive(std::pair& active) { using namespace std; if(not filesystem::exists("/tmp/sd_status.txt")) { - ReturnValue_t result = updateSdCardStateFile(); - if(result != HasReturnvaluesIF::RETURN_OK) { - return result; - } + return STATUS_FILE_NEXISTS; } // Now the file should exist in any case. Still check whether it exists. fstream sdStatus("/tmp/sd_status.txt"); if (not sdStatus.good()) { - return false; + return STATUS_FILE_NEXISTS; } string line; uint8_t idx = 0; + ReturnValue_t result = HasReturnvaluesIF::RETURN_OK; + bool on = false; + while (std::getline(sdStatus, line)) { istringstream iss(line); string word; - if((sdCard == sd::SdCard::SLOT_0 and idx == 0) or - (sdCard == sd::SdCard::SLOT_1 and idx == 1)) { - while(iss >> word) { - if(word == "on") { - return true; - } - else { - return false; - } + while(iss >> word) { + if(word == "on") { + on = true; + } + else if (word == "off") { + on = false; + } + else { + continue; + } + if(idx == 0) { + active.first = on; + } + else if(idx == 1) { + active.second = on; + } + else if(idx > 1) { + sif::warning << "SdCardManager::sdCardActive: Status file has more " + "than 2 lines!" << std::endl; + return STATUS_FILE_FORMAT_INVALID; } } idx++; } return HasReturnvaluesIF::RETURN_OK; - return false; } sd::SdCard SdCardManager::getPreferredSdCard() const { diff --git a/bsp_q7s/memory/SdCardManager.h b/bsp_q7s/memory/SdCardManager.h index 33b3db0c..98ecff24 100644 --- a/bsp_q7s/memory/SdCardManager.h +++ b/bsp_q7s/memory/SdCardManager.h @@ -7,6 +7,7 @@ #include "fsfw/returnvalues/HasReturnvaluesIF.h" #include +#include class MutexIF; @@ -21,6 +22,12 @@ public: static constexpr ReturnValue_t ALREADY_ON = HasReturnvaluesIF::makeReturnCode(INTERFACE_ID, 0); static constexpr ReturnValue_t ALREADY_OFF = HasReturnvaluesIF::makeReturnCode(INTERFACE_ID, 1); + static constexpr ReturnValue_t STATUS_FILE_NEXISTS = + HasReturnvaluesIF::makeReturnCode(INTERFACE_ID, 2); + static constexpr ReturnValue_t STATUS_FILE_FORMAT_INVALID = + HasReturnvaluesIF::makeReturnCode(INTERFACE_ID, 3); + static constexpr ReturnValue_t SYSTEM_CALL_ERROR = + HasReturnvaluesIF::makeReturnCode(INTERFACE_ID, 4); virtual ~SdCardManager(); @@ -39,14 +46,33 @@ public: ReturnValue_t switchOffSdCard(sd::SdCard sdCard); - bool sdCardActive(sd::SdCard sdCard); + /** + * Updated the state file or creates one if it does not exist. You need to call this + * function before calling #sdCardActiv + * @return - RETURN_OK if the state file was updated successfully + * - SYSTEM_CALL_ERROR if the call to create the status file failed + */ + ReturnValue_t updateSdCardStateFile(); + + /** + * Get the state of the SD cards. If the state file does not exist, this function will + * take care of updating it. If it does not, the function will use the state file to get + * the status of the SD cards and set the field of the provided boolean pair. + * @param active Pair of booleans, where the first entry is the state of the first SD card + * and the second one the state of the second SD card + * @return - RETURN_OK if the state was read successfully + * - STATUS_FILE_FORMAT_INVALID if there was an issue with the state file. The user + * should call #updateSdCardStateFile again in that case + * - STATUS_FILE_NEXISTS if the status file does not exist + */ + ReturnValue_t sdCardActive(std::pair& active); sd::SdCard getPreferedSdCard() const; private: SdCardManager(); - ReturnValue_t updateSdCardStateFile(); + ReturnValue_t setSdCardState(sd::SdCard sdCard, bool on); sd::SdCard preferredSdCard = sd::SdCard::SLOT_0; diff --git a/bsp_q7s/memory/definitions.h b/bsp_q7s/memory/definitions.h index 460f294b..9a998dcc 100644 --- a/bsp_q7s/memory/definitions.h +++ b/bsp_q7s/memory/definitions.h @@ -5,7 +5,8 @@ namespace sd { enum SdCard { SLOT_0, - SLOT_1 + SLOT_1, + BOTH }; } From 1312fe2369077f1630515bf375bf170edf3ee635 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Thu, 8 Jul 2021 12:07:39 +0200 Subject: [PATCH 077/111] updated core controller --- bsp_q7s/core/CoreController.cpp | 18 ++++++++++++++++++ bsp_q7s/core/CoreController.h | 2 ++ bsp_q7s/memory/SdCardManager.cpp | 28 +++++++++++++++++++--------- bsp_q7s/memory/SdCardManager.h | 12 ++++++++++++ 4 files changed, 51 insertions(+), 9 deletions(-) diff --git a/bsp_q7s/core/CoreController.cpp b/bsp_q7s/core/CoreController.cpp index 253efd91..6c2f042b 100644 --- a/bsp_q7s/core/CoreController.cpp +++ b/bsp_q7s/core/CoreController.cpp @@ -1,4 +1,5 @@ #include "CoreController.h" +#include "../memory/SdCardManager.h" CoreController::CoreController(object_id_t objectId): ExtendedControllerBase(objectId, objects::NO_OBJECT, 5) { @@ -20,6 +21,23 @@ LocalPoolDataSetBase* CoreController::getDataSetHandle(sid_t sid) { return nullptr; } +ReturnValue_t CoreController::initialize() { + // Find a way to store this non-volatile outside of SD cards (ProASIC?) + sd::SdCard preferredSdCard = sd::SdCard::SLOT_0; + // Creator or update status file + ReturnValue_t result = SdCardManager::instance()->updateSdCardStateFile(); + if(result != HasReturnvaluesIF::RETURN_OK) { + sif::warning << "CoreController::initialize: Updating SD card state file failed" + << std::endl; + } + result = SdCardManager::instance()->switchOnSdCard(preferredSdCard); + if(result != HasReturnvaluesIF::RETURN_OK) { + sif::warning << "CoreController::initialize: Turning SD card on failed" + << std::endl; + } + return HasReturnvaluesIF::RETURN_OK; +} + ReturnValue_t CoreController::checkModeCommand(Mode_t mode, Submode_t submode, uint32_t *msToReachTheMode) { return HasReturnvaluesIF::RETURN_OK; diff --git a/bsp_q7s/core/CoreController.h b/bsp_q7s/core/CoreController.h index bc8a1581..674ed073 100644 --- a/bsp_q7s/core/CoreController.h +++ b/bsp_q7s/core/CoreController.h @@ -7,6 +7,8 @@ class CoreController: public ExtendedControllerBase { public: CoreController(object_id_t objectId); + ReturnValue_t initialize() override; + ReturnValue_t handleCommandMessage(CommandMessage *message) override; void performControlOperation() override; private: diff --git a/bsp_q7s/memory/SdCardManager.cpp b/bsp_q7s/memory/SdCardManager.cpp index 1458ef1f..1341c132 100644 --- a/bsp_q7s/memory/SdCardManager.cpp +++ b/bsp_q7s/memory/SdCardManager.cpp @@ -25,17 +25,28 @@ SdCardManager* SdCardManager::instance() { } ReturnValue_t SdCardManager::switchOnSdCard(sd::SdCard sdCard) { -// if(sdCardActive(sdCard)) { -// return ALREADY_ON; -// } + std::pair active; + ReturnValue_t result = sdCardActive(active); + if(result != HasReturnvaluesIF::RETURN_OK) { + return result; + } + if((sdCard == sd::SdCard::SLOT_0 and active.first) or + (sdCard == sd::SdCard::SLOT_1 and active.second)) { + return ALREADY_ON; + } return setSdCardState(sdCard, true); - } ReturnValue_t SdCardManager::switchOffSdCard(sd::SdCard sdCard) { -// if(not sdCardActive(sdCard)) { -// return ALREADY_OFF; -// } + std::pair active; + ReturnValue_t result = sdCardActive(active); + if(result != HasReturnvaluesIF::RETURN_OK) { + return result; + } + if((sdCard == sd::SdCard::SLOT_0 and not active.first) or + (sdCard == sd::SdCard::SLOT_1 and not active.second)) { + return ALREADY_OFF; + } return setSdCardState(sdCard, false); } @@ -62,7 +73,7 @@ ReturnValue_t SdCardManager::setSdCardState(sd::SdCard sdCard, bool on) { } sif::warning << "SdCardManager::setSdCardState: system call failed with code " << result << std::endl; - return HasReturnvaluesIF::RETURN_FAILED; + return SYSTEM_CALL_ERROR; } ReturnValue_t SdCardManager::sdCardActive(std::pair& active) { @@ -78,7 +89,6 @@ ReturnValue_t SdCardManager::sdCardActive(std::pair& active) { } string line; uint8_t idx = 0; - ReturnValue_t result = HasReturnvaluesIF::RETURN_OK; bool on = false; while (std::getline(sdStatus, line)) { diff --git a/bsp_q7s/memory/SdCardManager.h b/bsp_q7s/memory/SdCardManager.h index 98ecff24..0c9c664d 100644 --- a/bsp_q7s/memory/SdCardManager.h +++ b/bsp_q7s/memory/SdCardManager.h @@ -42,8 +42,20 @@ public: sd::SdCard getPreferredSdCard() const; + /** + * Switch on the specified SD card + * @param sdCard + * @return - RETURN_OK on success, ALREADY_ON if it is already on, + * SYSTEM_CALL_ERROR on system error + */ ReturnValue_t switchOnSdCard(sd::SdCard sdCard); + /** + * Switch off the specified SD card + * @param sdCard + * @return - RETURN_OK on success, ALREADY_ON if it is already on, + * SYSTEM_CALL_ERROR on system error + */ ReturnValue_t switchOffSdCard(sd::SdCard sdCard); /** From 1e2eb597d93f9e9f9d1c010f9fb82f284e15cc29 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Thu, 8 Jul 2021 12:11:24 +0200 Subject: [PATCH 078/111] added core controller --- bsp_q7s/core/InitMission.cpp | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/bsp_q7s/core/InitMission.cpp b/bsp_q7s/core/InitMission.cpp index 3e655255..2bc334b9 100644 --- a/bsp_q7s/core/InitMission.cpp +++ b/bsp_q7s/core/InitMission.cpp @@ -44,6 +44,7 @@ void initmission::initMission() { void initmission::initTasks() { TaskFactory* factory = TaskFactory::instance(); + ReturnValue_t result = HasReturnvaluesIF::RETURN_OK; if(factory == nullptr) { /* Should never happen ! */ return; @@ -54,11 +55,18 @@ void initmission::initTasks() { void (*missedDeadlineFunc) (void) = nullptr; #endif + PeriodicTaskIF* coreController = factory->createPeriodicTask( + "CORE_CTRL", 60, PeriodicTaskIF::MINIMUM_STACK_SIZE, 0.4, missedDeadlineFunc); + result = coreController->addComponent(objects::CORE_CONTROLLER); + if(result != HasReturnvaluesIF::RETURN_OK) { + initmission::printAddObjectError("CORE_CTRL", objects::CORE_CONTROLLER); + + } + /* TMTC Distribution */ PeriodicTaskIF* tmTcDistributor = factory->createPeriodicTask( "DIST", 40, PeriodicTaskIF::MINIMUM_STACK_SIZE, 0.2, missedDeadlineFunc); - ReturnValue_t result = tmTcDistributor->addComponent( - objects::CCSDS_PACKET_DISTRIBUTOR); + result = tmTcDistributor->addComponent(objects::CCSDS_PACKET_DISTRIBUTOR); if(result != HasReturnvaluesIF::RETURN_OK) { initmission::printAddObjectError("CCSDS_DISTRIB", objects::CCSDS_PACKET_DISTRIBUTOR); } @@ -229,6 +237,7 @@ void initmission::initTasks() { tmTcDistributor->startTask(); udpBridgeTask->startTask(); udpPollingTask->startTask(); + coreController->startTask(); #if TE0720 == 0 uartPst->startTask(); From 008c6f975390301310a6807dea4aff32a7ca5c13 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Thu, 8 Jul 2021 12:13:38 +0200 Subject: [PATCH 079/111] linking again fs --- CMakeLists.txt | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index 10c3a349..cbf38410 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -51,6 +51,7 @@ set(LIB_CSP_NAME libcsp) set(LIB_FSFW_HAL_NAME fsfw_hal) set(LIB_LWGPS_NAME lwgps) set(THIRD_PARTY_FOLDER thirdparty) +set(LIB_CXX_FS -lstdc++fs) # Set path names set(FSFW_PATH fsfw) @@ -164,6 +165,7 @@ if(NOT Q7S_SIMPLE_MODE) ${LIB_OS_NAME} ${LIB_LWGPS_NAME} ${LIB_FSFW_HAL_NAME} + ${LIB_CXX_FS} ) endif() From ef3fb0457e0c726d210a184571acdacfe337c5d7 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Thu, 8 Jul 2021 12:22:41 +0200 Subject: [PATCH 080/111] updated file system handler --- bsp_q7s/memory/CMakeLists.txt | 2 +- bsp_q7s/memory/FileSystemHandler.cpp | 16 +++++++++++++ bsp_q7s/memory/FileSystemHandler.h | 36 ++++++++++++++++++++++++++++ bsp_q7s/memory/FileSystemManager.cpp | 7 ------ bsp_q7s/memory/FileSystemManager.h | 8 ------- fsfw | 2 +- 6 files changed, 54 insertions(+), 17 deletions(-) create mode 100644 bsp_q7s/memory/FileSystemHandler.cpp create mode 100644 bsp_q7s/memory/FileSystemHandler.h delete mode 100644 bsp_q7s/memory/FileSystemManager.cpp delete mode 100644 bsp_q7s/memory/FileSystemManager.h diff --git a/bsp_q7s/memory/CMakeLists.txt b/bsp_q7s/memory/CMakeLists.txt index 35ee43ea..e98971c4 100644 --- a/bsp_q7s/memory/CMakeLists.txt +++ b/bsp_q7s/memory/CMakeLists.txt @@ -1,5 +1,5 @@ target_sources(${TARGET_NAME} PRIVATE - FileSystemManager.cpp + FileSystemHandler.cpp SdCardAccess.cpp SdCardManager.cpp ) \ No newline at end of file diff --git a/bsp_q7s/memory/FileSystemHandler.cpp b/bsp_q7s/memory/FileSystemHandler.cpp new file mode 100644 index 00000000..7adb59fe --- /dev/null +++ b/bsp_q7s/memory/FileSystemHandler.cpp @@ -0,0 +1,16 @@ +#include "FileSystemHandler.h" + +#include "fsfw/tasks/TaskFactory.h" + +FileSystemHandler::FileSystemHandler(object_id_t fileSystemHandler): + SystemObject(fileSystemHandler) { +} + +ReturnValue_t FileSystemHandler::performOperation(uint8_t unsignedChar) { + while(true) { + // This task will have a low priority and will run permanently in the background + // so we will just run in a permanent loop here and check file system + // messages permanently + TaskFactory::instance()->delayTask(1000); + } +} diff --git a/bsp_q7s/memory/FileSystemHandler.h b/bsp_q7s/memory/FileSystemHandler.h new file mode 100644 index 00000000..c45bbd5e --- /dev/null +++ b/bsp_q7s/memory/FileSystemHandler.h @@ -0,0 +1,36 @@ +#ifndef BSP_Q7S_MEMORY_FILESYSTEMHANDLER_H_ +#define BSP_Q7S_MEMORY_FILESYSTEMHANDLER_H_ + +#include "fsfw/tasks/ExecutableObjectIF.h" +#include "fsfw/objectmanager/SystemObject.h" +#include "fsfw/memory/HasFileSystemIF.h" + +class FileSystemHandler: public SystemObject, + public ExecutableObjectIF, + public HasFileSystemIF { +public: + FileSystemHandler(object_id_t fileSystemHandler); + + ReturnValue_t performOperation(uint8_t) override; + + /** + * Function to get the MessageQueueId_t of the implementing object + * @return MessageQueueId_t of the object + */ + virtual MessageQueueId_t getCommandQueue() const = 0; + +private: + + ReturnValue_t appendToFile(const char* repositoryPath, + const char* filename, const uint8_t* data, size_t size, + uint16_t packetNumber, void* args = nullptr) override; + ReturnValue_t createFile(const char* repositoryPath, + const char* filename, const uint8_t* data = nullptr, + size_t size = 0, void* args = nullptr) override; + ReturnValue_t deleteFile(const char* repositoryPath, + const char* filename, void* args = nullptr) override; +}; + + + +#endif /* BSP_Q7S_MEMORY_FILESYSTEMMANAGER_H_ */ diff --git a/bsp_q7s/memory/FileSystemManager.cpp b/bsp_q7s/memory/FileSystemManager.cpp deleted file mode 100644 index 40c8e58a..00000000 --- a/bsp_q7s/memory/FileSystemManager.cpp +++ /dev/null @@ -1,7 +0,0 @@ -#include "FileSystemManager.h" - -class FileSystemManager { -public: - -private: -}; diff --git a/bsp_q7s/memory/FileSystemManager.h b/bsp_q7s/memory/FileSystemManager.h deleted file mode 100644 index 4fc8dc52..00000000 --- a/bsp_q7s/memory/FileSystemManager.h +++ /dev/null @@ -1,8 +0,0 @@ -#ifndef BSP_Q7S_MEMORY_FILESYSTEMMANAGER_H_ -#define BSP_Q7S_MEMORY_FILESYSTEMMANAGER_H_ - - - - - -#endif /* BSP_Q7S_MEMORY_FILESYSTEMMANAGER_H_ */ diff --git a/fsfw b/fsfw index c2b8507d..eef2fd3b 160000 --- a/fsfw +++ b/fsfw @@ -1 +1 @@ -Subproject commit c2b8507d2947c48e2a2cd19b71640471f436bc5c +Subproject commit eef2fd3b7ac764f06ed5d9a3c97c894d92a515fa From d5517b4d802b15775af2ad78e14c4a6d2eebc938 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Thu, 8 Jul 2021 12:32:24 +0200 Subject: [PATCH 081/111] contd file system handler --- bsp_q7s/memory/FileSystemHandler.cpp | 44 ++++++++++++++++++++++++++++ bsp_q7s/memory/FileSystemHandler.h | 5 +++- 2 files changed, 48 insertions(+), 1 deletion(-) diff --git a/bsp_q7s/memory/FileSystemHandler.cpp b/bsp_q7s/memory/FileSystemHandler.cpp index 7adb59fe..8dc3422b 100644 --- a/bsp_q7s/memory/FileSystemHandler.cpp +++ b/bsp_q7s/memory/FileSystemHandler.cpp @@ -1,16 +1,60 @@ #include "FileSystemHandler.h" #include "fsfw/tasks/TaskFactory.h" +#include "fsfw/memory/GenericFileSystemMessage.h" +#include "fsfw/ipc/QueueFactory.h" FileSystemHandler::FileSystemHandler(object_id_t fileSystemHandler): SystemObject(fileSystemHandler) { + mq = QueueFactory::instance()->createMessageQueue(50); +} + +FileSystemHandler::~FileSystemHandler() { + QueueFactory::instance()->deleteMessageQueue(mq); } ReturnValue_t FileSystemHandler::performOperation(uint8_t unsignedChar) { while(true) { + CommandMessage filemsg; + ReturnValue_t result = HasReturnvaluesIF::RETURN_OK; + while(true) { + result = mq->receiveMessage(&filemsg); + if(result == MessageQueueIF::EMPTY) { + break; + } + else if(result != HasReturnvaluesIF::RETURN_FAILED) { + sif::warning << "FileSystemHandler::performOperation: Message reception failed!" + << std::endl; + break; + } + Command_t command = filemsg.getCommand(); + switch(command) { + + } + } + // This task will have a low priority and will run permanently in the background // so we will just run in a permanent loop here and check file system // messages permanently TaskFactory::instance()->delayTask(1000); } } + +MessageQueueId_t FileSystemHandler::getCommandQueue() const { + return mq->getId(); +} + +ReturnValue_t FileSystemHandler::appendToFile(const char *repositoryPath, const char *filename, + const uint8_t *data, size_t size, uint16_t packetNumber, void *args) { + return HasReturnvaluesIF::RETURN_OK; +} + +ReturnValue_t FileSystemHandler::createFile(const char *repositoryPath, const char *filename, + const uint8_t *data, size_t size, void *args) { + return HasReturnvaluesIF::RETURN_OK; +} + +ReturnValue_t FileSystemHandler::deleteFile(const char *repositoryPath, const char *filename, + void *args) { + return HasReturnvaluesIF::RETURN_OK; +} diff --git a/bsp_q7s/memory/FileSystemHandler.h b/bsp_q7s/memory/FileSystemHandler.h index c45bbd5e..04cea3dc 100644 --- a/bsp_q7s/memory/FileSystemHandler.h +++ b/bsp_q7s/memory/FileSystemHandler.h @@ -1,6 +1,7 @@ #ifndef BSP_Q7S_MEMORY_FILESYSTEMHANDLER_H_ #define BSP_Q7S_MEMORY_FILESYSTEMHANDLER_H_ +#include "fsfw/ipc/MessageQueueIF.h" #include "fsfw/tasks/ExecutableObjectIF.h" #include "fsfw/objectmanager/SystemObject.h" #include "fsfw/memory/HasFileSystemIF.h" @@ -10,6 +11,7 @@ class FileSystemHandler: public SystemObject, public HasFileSystemIF { public: FileSystemHandler(object_id_t fileSystemHandler); + virtual~ FileSystemHandler(); ReturnValue_t performOperation(uint8_t) override; @@ -17,9 +19,10 @@ public: * Function to get the MessageQueueId_t of the implementing object * @return MessageQueueId_t of the object */ - virtual MessageQueueId_t getCommandQueue() const = 0; + MessageQueueId_t getCommandQueue() const override; private: + MessageQueueIF* mq = nullptr; ReturnValue_t appendToFile(const char* repositoryPath, const char* filename, const uint8_t* data, size_t size, From 61ddc3a080ab152cea3c97846699d9d5a61e1513 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Thu, 8 Jul 2021 12:36:41 +0200 Subject: [PATCH 082/111] updated README --- README.md | 4 ++++ bsp_q7s/memory/FileSystemHandler.cpp | 7 ++++++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 9391d883..917f64e3 100644 --- a/README.md +++ b/README.md @@ -71,6 +71,10 @@ twice) and generate this list manually with the following commands, according to /Vivado/2018.2/data/parts/installed_devices.txt ``` +For Linux, you can also download a more recent version of the +[Linaro 8.3.0 cross-compiler](https://developer.arm.com/tools-and-software/open-source-software/developer-tools/gnu-toolchain/gnu-a/downloads) +from [here](https://developer.arm.com/-/media/Files/downloads/gnu-a/8.3-2019.03/binrel/gcc-arm-8.3-2019.03-x86_64-arm-linux-gnueabihf.tar.xz?revision=e09a1c45-0ed3-4a8e-b06b-db3978fd8d56&la=en&hash=93ED4444B8B3A812B893373B490B90BBB28FD2E3) + ## Installing toolchain without Vivado You can download the toolchains for Windows and Linux diff --git a/bsp_q7s/memory/FileSystemHandler.cpp b/bsp_q7s/memory/FileSystemHandler.cpp index 8dc3422b..5f7e0435 100644 --- a/bsp_q7s/memory/FileSystemHandler.cpp +++ b/bsp_q7s/memory/FileSystemHandler.cpp @@ -29,7 +29,12 @@ ReturnValue_t FileSystemHandler::performOperation(uint8_t unsignedChar) { } Command_t command = filemsg.getCommand(); switch(command) { - + case(GenericFileSystemMessage::CMD_CREATE_DIRECTORY): { + break; + } + case(GenericFileSystemMessage::CMD_CREATE_FILE): { + break; + } } } From d20cf7c4bd3ea4fb2eb800c8858c7806ce340a79 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Thu, 8 Jul 2021 12:58:04 +0200 Subject: [PATCH 083/111] updated xiphos traq link --- README.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 917f64e3..bf8973d9 100644 --- a/README.md +++ b/README.md @@ -12,7 +12,8 @@ Target systems: * 766 MHz * Artix-7 FPGA (85K pogrammable logic cells) * Datasheet at https://eive-cloud.irs.uni-stuttgart.de/index.php/apps/files/?dir=/EIVE_IRS/Arbeitsdaten/08_Used%20Components/Q7S&fileid=340648 - * Also a lot of informatin about the Q7S can be found on the xiphos trac platform: https://trac.xiphos.com/trac/eive-q7/wiki/Q7RevB + * Also a lot of informatin about the Q7S can be found on + the [Xiphos Traq Platform](https://trac2.xiphos.ca/eive-q7). * Linux OS built with Yocto 2.5 * Linux Kernel https://github.com/XiphosSystemsCorp/linux-xlnx.git * Host System From 0360190a38d758d8220828118df986d88736569e Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Thu, 8 Jul 2021 13:19:08 +0200 Subject: [PATCH 084/111] update README --- README.md | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/README.md b/README.md index bf8973d9..8810fa56 100644 --- a/README.md +++ b/README.md @@ -583,6 +583,14 @@ Eclipse indexer. # Q7S Utilities and Troubleshooting +## pa3tool Host Tool + +The `pa3tool` is a host tool to interface with the ProASIC3 on the Q7S board. It was +installed on the clean room PC but it can also be found +[on the Traq platform](https://trac2.xiphos.ca/manual/attachment/wiki/WikiStart/libpa3-1.3.4.tar.gz). + +For more information, see Q7S datasheet. + ## Creating files with cat and echo The only folder which can be written in the root filesystem is the `tmp` folder. From 87381c9dc50f6b8cce64ad18ac5d9542281f32ec Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Thu, 8 Jul 2021 13:59:33 +0200 Subject: [PATCH 085/111] readme update --- README.md | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index 8810fa56..959a987b 100644 --- a/README.md +++ b/README.md @@ -6,16 +6,18 @@ Target systems: * OBC with Linux OS - * Xiphos Q7S - * Based on Zynq-7020 SoC (xc7z020clg484-2) - * Dual-core ARM Cortex-A9 - * 766 MHz - * Artix-7 FPGA (85K pogrammable logic cells) - * Datasheet at https://eive-cloud.irs.uni-stuttgart.de/index.php/apps/files/?dir=/EIVE_IRS/Arbeitsdaten/08_Used%20Components/Q7S&fileid=340648 - * Also a lot of informatin about the Q7S can be found on + * Xiphos Q7S + * Based on Zynq-7020 SoC (xc7z020clg484-2) + * Dual-core ARM Cortex-A9 + * 766 MHz + * Artix-7 FPGA (85K pogrammable logic cells) + * Datasheet at https://eive-cloud.irs.uni-stuttgart.de/index.php/apps/files/?dir=/EIVE_IRS/Arbeitsdaten/08_Used%20Components/Q7S&fileid=340648 + * Also a lot of informatin about the Q7S can be found on the [Xiphos Traq Platform](https://trac2.xiphos.ca/eive-q7). - * Linux OS built with Yocto 2.5 - * Linux Kernel https://github.com/XiphosSystemsCorp/linux-xlnx.git + * Linux OS built with Yocto 2.5 + * Linux Kernel https://github.com/XiphosSystemsCorp/linux-xlnx.git . EIVE version can be found + [here](https://egit.irs.uni-stuttgart.de/eive/q7s-linux-xlnx) + * Q7S base project can be found [here](https://egit.irs.uni-stuttgart.de/eive/q7s-base) * Host System * Generic software components which are not dependant on hardware can also be run on a host system. All host code is contained in the `bsp_hosted` folder From 9c9e3c5405935bfd4d72a360a97a1d92ac7cc8cd Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Thu, 8 Jul 2021 19:45:49 +0200 Subject: [PATCH 086/111] readme small correction --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 959a987b..774ca5ad 100644 --- a/README.md +++ b/README.md @@ -12,7 +12,7 @@ Target systems: * 766 MHz * Artix-7 FPGA (85K pogrammable logic cells) * Datasheet at https://eive-cloud.irs.uni-stuttgart.de/index.php/apps/files/?dir=/EIVE_IRS/Arbeitsdaten/08_Used%20Components/Q7S&fileid=340648 - * Also a lot of informatin about the Q7S can be found on + * Also a lot of information about the Q7S can be found on the [Xiphos Traq Platform](https://trac2.xiphos.ca/eive-q7). * Linux OS built with Yocto 2.5 * Linux Kernel https://github.com/XiphosSystemsCorp/linux-xlnx.git . EIVE version can be found From 190ddd0560c4ef994dc8bf34d7f08bf25d1ba616 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Thu, 8 Jul 2021 21:39:23 +0200 Subject: [PATCH 087/111] README update --- README.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 774ca5ad..0a9a565b 100644 --- a/README.md +++ b/README.md @@ -16,7 +16,8 @@ Target systems: the [Xiphos Traq Platform](https://trac2.xiphos.ca/eive-q7). * Linux OS built with Yocto 2.5 * Linux Kernel https://github.com/XiphosSystemsCorp/linux-xlnx.git . EIVE version can be found - [here](https://egit.irs.uni-stuttgart.de/eive/q7s-linux-xlnx) + [here](https://egit.irs.uni-stuttgart.de/eive/q7s-linux-xlnx) . Pre-compiled files can be + found [here](https://eive-cloud.irs.uni-stuttgart.de/index.php/apps/files/?dir=/EIVE_IRS/Software/q7s-linux-components&fileid=777299). * Q7S base project can be found [here](https://egit.irs.uni-stuttgart.de/eive/q7s-base) * Host System * Generic software components which are not dependant on hardware can also From a18f67d8ff9ac3a621abcf30ea7c4b5fc66d4186 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Thu, 8 Jul 2021 22:32:16 +0200 Subject: [PATCH 088/111] readme update --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 0a9a565b..b5fa8da6 100644 --- a/README.md +++ b/README.md @@ -19,6 +19,7 @@ Target systems: [here](https://egit.irs.uni-stuttgart.de/eive/q7s-linux-xlnx) . Pre-compiled files can be found [here](https://eive-cloud.irs.uni-stuttgart.de/index.php/apps/files/?dir=/EIVE_IRS/Software/q7s-linux-components&fileid=777299). * Q7S base project can be found [here](https://egit.irs.uni-stuttgart.de/eive/q7s-base) + * Minimal base project files can be found [here](https://eive-cloud.irs.uni-stuttgart.de/index.php/apps/files/?dir=/EIVE_IRS/Software/xiphos-q7s-sdk&fileid=510908) * Host System * Generic software components which are not dependant on hardware can also be run on a host system. All host code is contained in the `bsp_hosted` folder From dfee5b205ac5e3a50cb57aa354aaf8dbf6f359bd Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Thu, 8 Jul 2021 22:42:15 +0200 Subject: [PATCH 089/111] readme update --- README.md | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index b5fa8da6..6f55bc85 100644 --- a/README.md +++ b/README.md @@ -13,7 +13,8 @@ Target systems: * Artix-7 FPGA (85K pogrammable logic cells) * Datasheet at https://eive-cloud.irs.uni-stuttgart.de/index.php/apps/files/?dir=/EIVE_IRS/Arbeitsdaten/08_Used%20Components/Q7S&fileid=340648 * Also a lot of information about the Q7S can be found on - the [Xiphos Traq Platform](https://trac2.xiphos.ca/eive-q7). + the [Xiphos Traq Platform](https://trac2.xiphos.ca/eive-q7). Press on index to find all + relevant pages. * Linux OS built with Yocto 2.5 * Linux Kernel https://github.com/XiphosSystemsCorp/linux-xlnx.git . EIVE version can be found [here](https://egit.irs.uni-stuttgart.de/eive/q7s-linux-xlnx) . Pre-compiled files can be @@ -39,10 +40,13 @@ The CMake build system can be used to generate build systems as well (see helper ## Installing Vivado the the Xilinx development tools It's also possible to perform debugging with a normal Eclipse installation by installing -the TCF plugin and downloading the cross-compiler as specified in the section below. +the TCF plugin and downloading the cross-compiler as specified in the section below. However, +if you want to generate the `*.xdi` files necessary to update the firmware, you need to +installed Vivado with the SDK core tools. * Install Vivado 2018.2 and Xilinx SDK from https://www.xilinx.com/support/download/index.html/content/xilinx/en/downloadNav/vivado-design-tools/archive.html. - Install the Vivado Design Suite - HLx Editions - 2018.2 Full Product Installation instead of the updates. It is recommended to use the installer. + Install the Vivado Design Suite - HLx Editions - 2018.2 Full Product Installation instead of + the updates. It is recommended to use the installer. * Install settings. In the Devices selection, it is sufficient to pick SoC → Zynq-7000:
From ac6a968df6d5676e36c95e2c8be4e18ff186e8fb Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Fri, 9 Jul 2021 09:00:39 +0200 Subject: [PATCH 090/111] README update --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 6f55bc85..05881a16 100644 --- a/README.md +++ b/README.md @@ -17,7 +17,7 @@ Target systems: relevant pages. * Linux OS built with Yocto 2.5 * Linux Kernel https://github.com/XiphosSystemsCorp/linux-xlnx.git . EIVE version can be found - [here](https://egit.irs.uni-stuttgart.de/eive/q7s-linux-xlnx) . Pre-compiled files can be + [here](https://github.com/spacefisch/linux-xlnx) . Pre-compiled files can be found [here](https://eive-cloud.irs.uni-stuttgart.de/index.php/apps/files/?dir=/EIVE_IRS/Software/q7s-linux-components&fileid=777299). * Q7S base project can be found [here](https://egit.irs.uni-stuttgart.de/eive/q7s-base) * Minimal base project files can be found [here](https://eive-cloud.irs.uni-stuttgart.de/index.php/apps/files/?dir=/EIVE_IRS/Software/xiphos-q7s-sdk&fileid=510908) From 8980a696c9bf3e18bb54e8f90c6e69a189328c26 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Fri, 9 Jul 2021 14:11:26 +0200 Subject: [PATCH 091/111] added another useful command --- README.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/README.md b/README.md index 05881a16..ee2f62f2 100644 --- a/README.md +++ b/README.md @@ -697,6 +697,12 @@ candump can0 ## Useful Q7S Linux Commands +Display currently running image: + +```sh +xsc_boot_copy +``` + Rebooting currently running image: ```sh From bef73d73571df479ac7279aa57eece2dd80a1dd7 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Fri, 9 Jul 2021 16:57:34 +0200 Subject: [PATCH 092/111] writing api for scratch buffer --- bsp_q7s/memory/CMakeLists.txt | 1 + bsp_q7s/memory/SdCardManager.cpp | 2 ++ bsp_q7s/memory/scratchApi.cpp | 12 ++++++++ bsp_q7s/memory/scratchApi.h | 49 ++++++++++++++++++++++++++++++++ linux/utility/CMakeLists.txt | 1 + linux/utility/utility.cpp | 11 +++++++ linux/utility/utility.h | 13 +++++++++ 7 files changed, 89 insertions(+) create mode 100644 bsp_q7s/memory/scratchApi.cpp create mode 100644 bsp_q7s/memory/scratchApi.h create mode 100644 linux/utility/utility.cpp create mode 100644 linux/utility/utility.h diff --git a/bsp_q7s/memory/CMakeLists.txt b/bsp_q7s/memory/CMakeLists.txt index e98971c4..ada948fb 100644 --- a/bsp_q7s/memory/CMakeLists.txt +++ b/bsp_q7s/memory/CMakeLists.txt @@ -2,4 +2,5 @@ target_sources(${TARGET_NAME} PRIVATE FileSystemHandler.cpp SdCardAccess.cpp SdCardManager.cpp + scratchApi.cpp ) \ No newline at end of file diff --git a/bsp_q7s/memory/SdCardManager.cpp b/bsp_q7s/memory/SdCardManager.cpp index 1341c132..d23a4331 100644 --- a/bsp_q7s/memory/SdCardManager.cpp +++ b/bsp_q7s/memory/SdCardManager.cpp @@ -122,6 +122,8 @@ ReturnValue_t SdCardManager::sdCardActive(std::pair& active) { } sd::SdCard SdCardManager::getPreferredSdCard() const { + int result = std::system("xsc_scratch read PREFSD > /tmp/pref_sd.txt"); + return preferredSdCard; } diff --git a/bsp_q7s/memory/scratchApi.cpp b/bsp_q7s/memory/scratchApi.cpp new file mode 100644 index 00000000..0b159775 --- /dev/null +++ b/bsp_q7s/memory/scratchApi.cpp @@ -0,0 +1,12 @@ +#include "scratchApi.h" + +ReturnValue_t scratch::writeString(std::string name, std::string string) { + std::ostringstream oss; + oss << "xsc_scratch write " << name << " \"" << string << "\""; + int result = std::system(oss.str().c_str()); + if(result != 0) { + utility::handleSystemError(result, "scratch::String"); + return HasReturnvaluesIF::RETURN_FAILED; + } + return HasReturnvaluesIF::RETURN_OK; +} diff --git a/bsp_q7s/memory/scratchApi.h b/bsp_q7s/memory/scratchApi.h new file mode 100644 index 00000000..32e604a1 --- /dev/null +++ b/bsp_q7s/memory/scratchApi.h @@ -0,0 +1,49 @@ +#ifndef BSP_Q7S_MEMORY_SCRATCHAPI_H_ +#define BSP_Q7S_MEMORY_SCRATCHAPI_H_ + +#include "fsfw/returnvalues/HasReturnvaluesIF.h" +#include "linux/utility/utility.h" + +#include +#include +#include +#include + +/** + * @brief API for the scratch buffer + */ +namespace scratch { + +namespace { +static size_t counter = 0; +} + +template::value>::type> +inline ReturnValue_t writeNumber(std::string name, T num) noexcept { + std::ostringstream oss; + oss << "xsc_scratch write " << name << " " << num; + int result = std::system(oss.str().c_str()); + if(result != 0) { + utility::handleSystemError(result, "scratch::writeNumber"); + return HasReturnvaluesIF::RETURN_FAILED; + } + return HasReturnvaluesIF::RETURN_OK; +} + +template::value>::type> +inline ReturnValue_t readNumber(std::string name, T& num) noexcept { + std::ostringstream oss; + oss << "xsc_scratch read " << name << " > /tmp/scratchro" << counter++; + int result = std::system(oss.str().c_str()); + if(result != 0) { + utility::handleSystemError(result, "scratch::writeNumber"); + return HasReturnvaluesIF::RETURN_FAILED; + } + return HasReturnvaluesIF::RETURN_OK; +} + +ReturnValue_t writeString(std::string name, std::string string); + +} + +#endif /* BSP_Q7S_MEMORY_SCRATCHAPI_H_ */ diff --git a/linux/utility/CMakeLists.txt b/linux/utility/CMakeLists.txt index 45a7edcc..a3387531 100644 --- a/linux/utility/CMakeLists.txt +++ b/linux/utility/CMakeLists.txt @@ -1,4 +1,5 @@ target_sources(${TARGET_NAME} PUBLIC + utility.cpp ) diff --git a/linux/utility/utility.cpp b/linux/utility/utility.cpp new file mode 100644 index 00000000..69a3d08f --- /dev/null +++ b/linux/utility/utility.cpp @@ -0,0 +1,11 @@ +#include "OBSWConfig.h" +#include "FSFWConfig.h" +#include "utility.h" + +#include "fsfw/serviceinterface/ServiceInterface.h" + +void utility::handleSystemError(int retcode, std::string function) { +#if OBSW_VERBOSE_LEVEL >= 1 + sif::warning << function << ": System call failed with code " << retcode; +#endif +} diff --git a/linux/utility/utility.h b/linux/utility/utility.h new file mode 100644 index 00000000..3eb17a9b --- /dev/null +++ b/linux/utility/utility.h @@ -0,0 +1,13 @@ +#ifndef LINUX_UTILITY_UTILITY_H_ +#define LINUX_UTILITY_UTILITY_H_ + +#include "fsfw/returnvalues/HasReturnvaluesIF.h" +#include + +namespace utility { + +void handleSystemError(int retcode, std::string function); + +} + +#endif /* LINUX_UTILITY_UTILITY_H_ */ From e9cfa0c11709343e61f5e3349bc6c985cf245cd6 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Fri, 9 Jul 2021 17:21:26 +0200 Subject: [PATCH 093/111] testing scratch API --- bsp_q7s/boardtest/Q7STestTask.cpp | 15 +++++++++++++++ bsp_q7s/boardtest/Q7STestTask.h | 3 +++ bsp_q7s/memory/SdCardManager.cpp | 2 +- bsp_q7s/memory/scratchApi.h | 24 ++++++++++++++++++++---- 4 files changed, 39 insertions(+), 5 deletions(-) diff --git a/bsp_q7s/boardtest/Q7STestTask.cpp b/bsp_q7s/boardtest/Q7STestTask.cpp index ca64c8a6..a1470b79 100644 --- a/bsp_q7s/boardtest/Q7STestTask.cpp +++ b/bsp_q7s/boardtest/Q7STestTask.cpp @@ -3,6 +3,8 @@ #include "fsfw/timemanager/Stopwatch.h" #include "fsfw/tasks/TaskFactory.h" +#include "bsp_q7s/memory/scratchApi.h" + #include #include #include @@ -12,6 +14,7 @@ Q7STestTask::Q7STestTask(object_id_t objectId): TestTask(objectId) { ReturnValue_t Q7STestTask::performOneShotAction() { //sdCardTests(); + testScratchApi(); return TestTask::performOneShotAction(); } @@ -50,3 +53,15 @@ void Q7STestTask::fileTests() { system("echo \"Hallo Welt\" > /tmp/test2.txt"); system("echo \"Hallo Welt\""); } + +void Q7STestTask::testScratchApi() { + ReturnValue_t result = scratch::writeNumber("TEST", 1); + if(result != HasReturnvaluesIF::RETURN_OK) { + sif::debug << "Q7STestTask::scratchApiTest: Writing number failed" << std::endl; + } + int number = 0; + result = scratch::readNumber("TEST", number); + if(result != HasReturnvaluesIF::RETURN_OK) { + sif::debug << "Q7STestTask::scratchApiTest: Reading number failed" << std::endl; + } +} diff --git a/bsp_q7s/boardtest/Q7STestTask.h b/bsp_q7s/boardtest/Q7STestTask.h index 7056853e..664a8fa2 100644 --- a/bsp_q7s/boardtest/Q7STestTask.h +++ b/bsp_q7s/boardtest/Q7STestTask.h @@ -11,6 +11,9 @@ private: void sdCardTests(); void fileTests(); + + void testScratchApi(); + }; diff --git a/bsp_q7s/memory/SdCardManager.cpp b/bsp_q7s/memory/SdCardManager.cpp index d23a4331..6a7c5585 100644 --- a/bsp_q7s/memory/SdCardManager.cpp +++ b/bsp_q7s/memory/SdCardManager.cpp @@ -66,7 +66,7 @@ ReturnValue_t SdCardManager::setSdCardState(sd::SdCard sdCard, bool on) { statestring = "off"; } std::ostringstream command; - command << "h7hw sd set " << sdstring << " " << statestring; + command << "q7hw sd set " << sdstring << " " << statestring; int result = std::system(command.str().c_str()); if(result == 0) { return HasReturnvaluesIF::RETURN_OK; diff --git a/bsp_q7s/memory/scratchApi.h b/bsp_q7s/memory/scratchApi.h index 32e604a1..246515a1 100644 --- a/bsp_q7s/memory/scratchApi.h +++ b/bsp_q7s/memory/scratchApi.h @@ -2,9 +2,11 @@ #define BSP_Q7S_MEMORY_SCRATCHAPI_H_ #include "fsfw/returnvalues/HasReturnvaluesIF.h" +#include "fsfw/serviceinterface/ServiceInterface.h" #include "linux/utility/utility.h" #include +#include #include #include #include @@ -18,10 +20,11 @@ namespace { static size_t counter = 0; } -template::value>::type> +template::value>::type> inline ReturnValue_t writeNumber(std::string name, T num) noexcept { std::ostringstream oss; oss << "xsc_scratch write " << name << " " << num; + sif::debug << oss.str() << std::endl; int result = std::system(oss.str().c_str()); if(result != 0) { utility::handleSystemError(result, "scratch::writeNumber"); @@ -30,15 +33,28 @@ inline ReturnValue_t writeNumber(std::string name, T num) noexcept { return HasReturnvaluesIF::RETURN_OK; } -template::value>::type> +template::value>::type> inline ReturnValue_t readNumber(std::string name, T& num) noexcept { - std::ostringstream oss; - oss << "xsc_scratch read " << name << " > /tmp/scratchro" << counter++; + using namespace std; + string filename = "/tmp/sro" + counter++; + ostringstream oss; + oss << "xsc_scratch read " << name << " < " << filename; + sif::debug << oss.str() << std::endl; int result = std::system(oss.str().c_str()); if(result != 0) { utility::handleSystemError(result, "scratch::writeNumber"); return HasReturnvaluesIF::RETURN_FAILED; } + ifstream file(filename); + string line; + if (not std::getline(file, line)) { + return HasReturnvaluesIF::RETURN_FAILED; + } + + size_t pos = line.find("="); + std::string valueAsString = line.substr(pos); + sif::debug << valueAsString << std::endl; + num = std::stoi(valueAsString); return HasReturnvaluesIF::RETURN_OK; } From 59112cae76ebc2079c843acc433ac8b5b8bcf5df Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Fri, 9 Jul 2021 17:54:32 +0200 Subject: [PATCH 094/111] now a sd card will always be on --- bsp_q7s/core/CoreController.cpp | 18 +++++++++- bsp_q7s/memory/SdCardManager.cpp | 34 ++++++++++++------- bsp_q7s/memory/scratchApi.h | 21 +++++++----- linux/csp/CspComIF.cpp | 3 ++ .../libcsp/src/drivers/can/can_socketcan.c | 2 +- 5 files changed, 55 insertions(+), 23 deletions(-) diff --git a/bsp_q7s/core/CoreController.cpp b/bsp_q7s/core/CoreController.cpp index 6c2f042b..98ddb347 100644 --- a/bsp_q7s/core/CoreController.cpp +++ b/bsp_q7s/core/CoreController.cpp @@ -24,17 +24,33 @@ LocalPoolDataSetBase* CoreController::getDataSetHandle(sid_t sid) { ReturnValue_t CoreController::initialize() { // Find a way to store this non-volatile outside of SD cards (ProASIC?) sd::SdCard preferredSdCard = sd::SdCard::SLOT_0; + std::string printoutString; + if(preferredSdCard == sd::SdCard::SLOT_0) { + printoutString = "0"; + } + else { + printoutString = "1"; + } // Creator or update status file ReturnValue_t result = SdCardManager::instance()->updateSdCardStateFile(); if(result != HasReturnvaluesIF::RETURN_OK) { sif::warning << "CoreController::initialize: Updating SD card state file failed" << std::endl; } + + sif::info << "Switching on SD card " << printoutString << ".." << std::endl; + result = SdCardManager::instance()->switchOnSdCard(preferredSdCard); - if(result != HasReturnvaluesIF::RETURN_OK) { + if(result == SdCardManager::ALREADY_ON) { + sif::info << "SD card " << printoutString << " is already on" << std::endl; + } + else if(result != HasReturnvaluesIF::RETURN_OK) { sif::warning << "CoreController::initialize: Turning SD card on failed" << std::endl; } + else { + sif::info << "SD card " << printoutString << " was switched on" << std::endl; + } return HasReturnvaluesIF::RETURN_OK; } diff --git a/bsp_q7s/memory/SdCardManager.cpp b/bsp_q7s/memory/SdCardManager.cpp index 6a7c5585..af963180 100644 --- a/bsp_q7s/memory/SdCardManager.cpp +++ b/bsp_q7s/memory/SdCardManager.cpp @@ -89,30 +89,39 @@ ReturnValue_t SdCardManager::sdCardActive(std::pair& active) { } string line; uint8_t idx = 0; - bool on = false; while (std::getline(sdStatus, line)) { istringstream iss(line); string word; + sd::SdCard currentSd = sd::SdCard::SLOT_0; while(iss >> word) { + if (word == "1:") { + currentSd = sd::SdCard::SLOT_1; + } + if(word == "on") { - on = true; + if(currentSd == sd::SdCard::SLOT_0) { + active.first = true; + } + else { + active.second = true; + } } else if (word == "off") { - on = false; + if(currentSd == sd::SdCard::SLOT_0) { + active.first = false; + } + else { + active.second = false; + } } else { continue; } - if(idx == 0) { - active.first = on; - } - else if(idx == 1) { - active.second = on; - } - else if(idx > 1) { + + if(idx > 3) { sif::warning << "SdCardManager::sdCardActive: Status file has more " - "than 2 lines!" << std::endl; + "than 4 lines!" << std::endl; return STATUS_FILE_FORMAT_INVALID; } } @@ -122,8 +131,7 @@ ReturnValue_t SdCardManager::sdCardActive(std::pair& active) { } sd::SdCard SdCardManager::getPreferredSdCard() const { - int result = std::system("xsc_scratch read PREFSD > /tmp/pref_sd.txt"); - + //int result = std::system("xsc_scratch read PREFSD > /tmp/pref_sd.txt"); return preferredSdCard; } diff --git a/bsp_q7s/memory/scratchApi.h b/bsp_q7s/memory/scratchApi.h index 246515a1..09bf6bab 100644 --- a/bsp_q7s/memory/scratchApi.h +++ b/bsp_q7s/memory/scratchApi.h @@ -17,14 +17,13 @@ namespace scratch { namespace { -static size_t counter = 0; +static uint8_t counter = 0; } template::value>::type> inline ReturnValue_t writeNumber(std::string name, T num) noexcept { std::ostringstream oss; oss << "xsc_scratch write " << name << " " << num; - sif::debug << oss.str() << std::endl; int result = std::system(oss.str().c_str()); if(result != 0) { utility::handleSystemError(result, "scratch::writeNumber"); @@ -36,10 +35,10 @@ inline ReturnValue_t writeNumber(std::string name, T num) noexcept { template::value>::type> inline ReturnValue_t readNumber(std::string name, T& num) noexcept { using namespace std; - string filename = "/tmp/sro" + counter++; + string filename = "/tmp/sro" + std::to_string(counter++); ostringstream oss; - oss << "xsc_scratch read " << name << " < " << filename; - sif::debug << oss.str() << std::endl; + oss << "xsc_scratch read " << name << " > " << filename; + int result = std::system(oss.str().c_str()); if(result != 0) { utility::handleSystemError(result, "scratch::writeNumber"); @@ -52,9 +51,15 @@ inline ReturnValue_t readNumber(std::string name, T& num) noexcept { } size_t pos = line.find("="); - std::string valueAsString = line.substr(pos); - sif::debug << valueAsString << std::endl; - num = std::stoi(valueAsString); + std::string valueAsString = line.substr(pos + 1); + try { + num = std::stoi(valueAsString); + } + catch(std::invalid_argument& e) { + sif::warning << "scratch::readNumber: stoi call failed with " << e.what() << std::endl; + } + + std::remove(filename.c_str()); return HasReturnvaluesIF::RETURN_OK; } diff --git a/linux/csp/CspComIF.cpp b/linux/csp/CspComIF.cpp index a8f13963..07fe63d3 100644 --- a/linux/csp/CspComIF.cpp +++ b/linux/csp/CspComIF.cpp @@ -24,6 +24,8 @@ ReturnValue_t CspComIF::initializeInterface(CookieIF *cookie) { /* Perform CAN and CSP initialization only once */ if(cspDeviceMap.empty()){ + sif::info << "Performing " << canInterface << " initialization.." << std::endl; + /* Define the memory to allocate for the CSP stack */ int buf_count = 10; int buf_size = 300; @@ -57,6 +59,7 @@ ReturnValue_t CspComIF::initializeInterface(CookieIF *cookie) { sif::error << "Failed to start csp route task" << std::endl; return HasReturnvaluesIF::RETURN_FAILED; } + sif::info << canInterface << " initialized successfully" << std::endl; } uint8_t cspAddress = cspCookie->getCspAddress(); diff --git a/thirdparty/libcsp/src/drivers/can/can_socketcan.c b/thirdparty/libcsp/src/drivers/can/can_socketcan.c index 94c6bdde..00d6444e 100644 --- a/thirdparty/libcsp/src/drivers/can/can_socketcan.c +++ b/thirdparty/libcsp/src/drivers/can/can_socketcan.c @@ -142,7 +142,7 @@ csp_iface_t * csp_can_socketcan_init(const char * ifc, int bitrate, int promisc) struct sockaddr_can addr; pthread_t rx_thread; - printf("-I-: Initiating CAN interface %s\n", ifc); + //printf("-I-: Initiating CAN interface %s\n", ifc); #ifdef CSP_HAVE_LIBSOCKETCAN /* Set interface up */ From 55ada72a8fb6ba84c6d9598613127b5f25d43511 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Fri, 9 Jul 2021 17:55:09 +0200 Subject: [PATCH 095/111] bumped subversion --- common/config/OBSWVersion.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/common/config/OBSWVersion.h b/common/config/OBSWVersion.h index 7ac812e6..b796f146 100644 --- a/common/config/OBSWVersion.h +++ b/common/config/OBSWVersion.h @@ -4,7 +4,7 @@ const char* const SW_NAME = "eive"; #define SW_VERSION 1 -#define SW_SUBVERSION 2 +#define SW_SUBVERSION 3 #define SW_SUBSUBVERSION 0 #endif /* COMMON_CONFIG_OBSWVERSION_H_ */ From ce3e5c3f3f6d58cfa35efa600769425426258248 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Mon, 12 Jul 2021 10:43:41 +0200 Subject: [PATCH 096/111] section for rootfs differences --- README.md | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/README.md b/README.md index 05881a16..e9d4a9ef 100644 --- a/README.md +++ b/README.md @@ -703,6 +703,16 @@ Rebooting currently running image: xsc_boot_copy -r ``` +## Preparation of a fresh rootfs + +This section summarizes important changes between a fresh rootfs and the current +EIVE implementation + +- Mount point `/mnt/sd0` created for SD card 0. Created with `mkdir` +- Mount point `/mnt/sd1` created for SD card 1. Created with `mkdir` +- Folder `scripts` in `/home/root` folder. +- `scripts` folder currently contains `update_main_components.sh` script + # Running the EIVE OBSW on a Raspberry Pi Special section for running the EIVE OBSW on the Raspberry Pi. From 106c74ca43c77d4c4ecc990457d3ecedbf5c4520 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Mon, 12 Jul 2021 10:48:12 +0200 Subject: [PATCH 097/111] continued prep section --- README.md | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index ba494d96..356ccf75 100644 --- a/README.md +++ b/README.md @@ -709,16 +709,26 @@ Rebooting currently running image: xsc_boot_copy -r ``` -## Preparation of a fresh rootfs +## Preparation of a fresh rootfs and SD card This section summarizes important changes between a fresh rootfs and the current EIVE implementation +### rootfs + - Mount point `/mnt/sd0` created for SD card 0. Created with `mkdir` - Mount point `/mnt/sd1` created for SD card 1. Created with `mkdir` - Folder `scripts` in `/home/root` folder. - `scripts` folder currently contains `update_main_components.sh` script +### SD Cards + +- Folder `bin` for binaries, for example the OBSW +- Folder `misc` for miscellaneous files +- Folder `tc` for telecommands +- Folder `tm` for telemetry +- Folder `xdi` for XDI components (e.g. for firmware or device tree updates) + # Running the EIVE OBSW on a Raspberry Pi Special section for running the EIVE OBSW on the Raspberry Pi. From 4fc56417bc839bf4e1f6137bc1e326a3b93325d0 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Mon, 12 Jul 2021 11:37:10 +0200 Subject: [PATCH 098/111] mounting SD cards now as well --- bsp_q7s/memory/SdCardManager.cpp | 181 ++++++++++++++++++++++++++----- bsp_q7s/memory/SdCardManager.h | 28 ++++- bsp_q7s/memory/definitions.h | 9 ++ 3 files changed, 184 insertions(+), 34 deletions(-) diff --git a/bsp_q7s/memory/SdCardManager.cpp b/bsp_q7s/memory/SdCardManager.cpp index af963180..8c67ea2c 100644 --- a/bsp_q7s/memory/SdCardManager.cpp +++ b/bsp_q7s/memory/SdCardManager.cpp @@ -1,4 +1,6 @@ #include "SdCardManager.h" +#include "linux/utility/utility.h" + #include "fsfw/ipc/MutexFactory.h" #include "fsfw/serviceinterface/ServiceInterface.h" @@ -24,29 +26,66 @@ SdCardManager* SdCardManager::instance() { return SdCardManager::factoryInstance; } -ReturnValue_t SdCardManager::switchOnSdCard(sd::SdCard sdCard) { - std::pair active; +ReturnValue_t SdCardManager::switchOnSdCard(sd::SdCard sdCard, bool doMountSdCard) { + std::pair active; ReturnValue_t result = sdCardActive(active); + // Not allowed, this function turns on one SD card + if(sdCard == sd::SdCard::BOTH) { + sif::warning << "SdCardManager::switchOffSdCard: API does not allow sd::SdStatus::BOTH" + << std::endl; + return HasReturnvaluesIF::RETURN_FAILED; + } if(result != HasReturnvaluesIF::RETURN_OK) { return result; } - if((sdCard == sd::SdCard::SLOT_0 and active.first) or - (sdCard == sd::SdCard::SLOT_1 and active.second)) { - return ALREADY_ON; + if(sdCard == sd::SdCard::SLOT_0) { + if(active.first == sd::SdStatus::ON or active.first == sd::SdStatus::MOUNTED) { + return ALREADY_ON; + } } - return setSdCardState(sdCard, true); + else if(sdCard == sd::SdCard::SLOT_1) { + if(active.second == sd::SdStatus::ON or active.second == sd::SdStatus::MOUNTED) { + return ALREADY_ON; + } + } + result = setSdCardState(sdCard, true); + if(result != HasReturnvaluesIF::RETURN_OK or not doMountSdCard) { + return result; + } + + return mountSdCard(sdCard); } -ReturnValue_t SdCardManager::switchOffSdCard(sd::SdCard sdCard) { - std::pair active; +ReturnValue_t SdCardManager::switchOffSdCard(sd::SdCard sdCard, bool doUnmountSdCard) { + std::pair active; ReturnValue_t result = sdCardActive(active); if(result != HasReturnvaluesIF::RETURN_OK) { return result; } - if((sdCard == sd::SdCard::SLOT_0 and not active.first) or - (sdCard == sd::SdCard::SLOT_1 and not active.second)) { - return ALREADY_OFF; + // Not allowed, this function turns on off SD card + if(sdCard == sd::SdCard::BOTH) { + sif::warning << "SdCardManager::switchOffSdCard: API does not allow sd::SdStatus::BOTH" + << std::endl; + return HasReturnvaluesIF::RETURN_FAILED; } + if(sdCard == sd::SdCard::SLOT_0) { + if(active.first == sd::SdStatus::OFF) { + return ALREADY_OFF; + } + } + else if(sdCard == sd::SdCard::SLOT_1) { + if(active.second == sd::SdStatus::OFF) { + return ALREADY_OFF; + } + } + + if(doUnmountSdCard) { + result = unmountSdCard(sdCard); + if(result != HasReturnvaluesIF::RETURN_OK) { + return result; + } + } + return setSdCardState(sdCard, false); } @@ -76,7 +115,7 @@ ReturnValue_t SdCardManager::setSdCardState(sd::SdCard sdCard, bool on) { return SYSTEM_CALL_ERROR; } -ReturnValue_t SdCardManager::sdCardActive(std::pair& active) { +ReturnValue_t SdCardManager::sdCardActive(std::pair& active) { using namespace std; if(not filesystem::exists("/tmp/sd_status.txt")) { return STATUS_FILE_NEXISTS; @@ -89,45 +128,127 @@ ReturnValue_t SdCardManager::sdCardActive(std::pair& active) { } string line; uint8_t idx = 0; - + sd::SdCard currentSd = sd::SdCard::SLOT_0; + // Process status file line by line while (std::getline(sdStatus, line)) { - istringstream iss(line); - string word; - sd::SdCard currentSd = sd::SdCard::SLOT_0; - while(iss >> word) { + processSdStatusLine(active, line, idx, currentSd); + } + return HasReturnvaluesIF::RETURN_OK; +} + +ReturnValue_t SdCardManager::mountSdCard(sd::SdCard sdCard) { + using namespace std; + if(sdCard == sd::SdCard::BOTH) { + sif::warning << "SdCardManager::mountSdCard: API does not allow sd::SdStatus::BOTH" + << std::endl; + return HasReturnvaluesIF::RETURN_FAILED; + } + std::string mountDev; + std::string mountPoint; + if(sdCard == sd::SdCard::SLOT_0) { + mountDev = SD_0_DEV_NAME; + mountPoint = SD_0_MOUNT_POINT; + } + else if(sdCard == sd::SdCard::SLOT_1) { + mountDev = SD_0_DEV_NAME; + mountPoint = SD_1_MOUNT_POINT; + } + if(not std::filesystem::exists(mountDev)) { + sif::warning << "SdCardManager::mountSdCard: Device file does not exists. Make sure to" + " turn on the SD card" << std::endl; + return MOUNT_ERROR; + } + + string sdMountCommand = "mount " + mountDev + " " + mountPoint; + int result = system(sdMountCommand.c_str()); + if (result != 0) { + utility::handleSystemError(result, "SdCardManager::mountSdCard"); + return SYSTEM_CALL_ERROR; + } + return HasReturnvaluesIF::RETURN_OK; +} + +ReturnValue_t SdCardManager::unmountSdCard(sd::SdCard sdCard) { + using namespace std; + if(sdCard == sd::SdCard::BOTH) { + sif::warning << "SdCardManager::unmountSdCard: API does not allow sd::SdStatus::BOTH" + << std::endl; + return HasReturnvaluesIF::RETURN_FAILED; + } + string mountPoint; + if(sdCard == sd::SdCard::SLOT_0) { + mountPoint = SD_0_MOUNT_POINT; + } + else if(sdCard == sd::SdCard::SLOT_1) { + mountPoint = SD_1_MOUNT_POINT; + } + if(filesystem::is_empty(mountPoint)) { + // The mount point will always exist, but if it is empty, that is strong hint that + // the SD card was not mounted properly. Still proceed with operation. + sif::warning << "SdCardManager::unmountSdCard: Mount point is empty!" << std::endl; + } + string sdUnmountCommand = "umount " + mountPoint; + int result = system(sdUnmountCommand.c_str()); + if (result != 0) { + utility::handleSystemError(result, "SdCardManager::unmountSdCard"); + return SYSTEM_CALL_ERROR; + } + return HasReturnvaluesIF::RETURN_OK; +} + +void SdCardManager::processSdStatusLine(std::pair &active, + std::string& line, uint8_t& idx, sd::SdCard& currentSd) { + using namespace std; + istringstream iss(line); + string word; + bool slotLine = false; + bool mountLine = false; + while(iss >> word) { + if (word == "Slot") { + slotLine = true; + } + if(word == "Mounted") { + mountLine = true; + } + + if(slotLine) { if (word == "1:") { currentSd = sd::SdCard::SLOT_1; } if(word == "on") { if(currentSd == sd::SdCard::SLOT_0) { - active.first = true; + active.first = sd::SdStatus::ON; } else { - active.second = true; + active.second = sd::SdStatus::ON; } } else if (word == "off") { if(currentSd == sd::SdCard::SLOT_0) { - active.first = false; + active.first = sd::SdStatus::OFF; } else { - active.second = false; + active.second = sd::SdStatus::OFF; } } - else { - continue; - } + } - if(idx > 3) { - sif::warning << "SdCardManager::sdCardActive: Status file has more " - "than 4 lines!" << std::endl; - return STATUS_FILE_FORMAT_INVALID; + if(mountLine) { + if(currentSd == sd::SdCard::SLOT_0) { + active.first = sd::SdStatus::MOUNTED; + } + else { + active.second = sd::SdStatus::MOUNTED; } } - idx++; + + if(idx > 5) { + sif::warning << "SdCardManager::sdCardActive: /tmp/sd_status.txt has more than 6 " + "lines and might be invalid!" << std::endl; + } } - return HasReturnvaluesIF::RETURN_OK; + idx++; } sd::SdCard SdCardManager::getPreferredSdCard() const { diff --git a/bsp_q7s/memory/SdCardManager.h b/bsp_q7s/memory/SdCardManager.h index 0c9c664d..9052d9b0 100644 --- a/bsp_q7s/memory/SdCardManager.h +++ b/bsp_q7s/memory/SdCardManager.h @@ -8,6 +8,7 @@ #include #include +#include class MutexIF; @@ -26,8 +27,17 @@ public: HasReturnvaluesIF::makeReturnCode(INTERFACE_ID, 2); static constexpr ReturnValue_t STATUS_FILE_FORMAT_INVALID = HasReturnvaluesIF::makeReturnCode(INTERFACE_ID, 3); + static constexpr ReturnValue_t MOUNT_ERROR = HasReturnvaluesIF::makeReturnCode(INTERFACE_ID, 4); + static constexpr ReturnValue_t UNMOUNT_ERROR = + HasReturnvaluesIF::makeReturnCode(INTERFACE_ID, 5); static constexpr ReturnValue_t SYSTEM_CALL_ERROR = - HasReturnvaluesIF::makeReturnCode(INTERFACE_ID, 4); + HasReturnvaluesIF::makeReturnCode(INTERFACE_ID, 6); + + // C++17 does not support constexpr std::string yet + static constexpr char SD_0_DEV_NAME[] = "/dev/mmcblk0p1"; + static constexpr char SD_1_DEV_NAME[] = "/dev/mmcblk1p1"; + static constexpr char SD_0_MOUNT_POINT[] = "/mnt/sd0"; + static constexpr char SD_1_MOUNT_POINT[] = "/mnt/sd1"; virtual ~SdCardManager(); @@ -45,18 +55,22 @@ public: /** * Switch on the specified SD card * @param sdCard + * @param doMountSdCard Mount the SD card after switching it on, which is necessary + * to use it * @return - RETURN_OK on success, ALREADY_ON if it is already on, * SYSTEM_CALL_ERROR on system error */ - ReturnValue_t switchOnSdCard(sd::SdCard sdCard); + ReturnValue_t switchOnSdCard(sd::SdCard sdCard, bool doMountSdCard = true); /** * Switch off the specified SD card * @param sdCard + * @param doUnmountSdCard Unmount the SD card before switching the card off, which makes + * the operation safer * @return - RETURN_OK on success, ALREADY_ON if it is already on, * SYSTEM_CALL_ERROR on system error */ - ReturnValue_t switchOffSdCard(sd::SdCard sdCard); + ReturnValue_t switchOffSdCard(sd::SdCard sdCard, bool doUnmountSdCard = true); /** * Updated the state file or creates one if it does not exist. You need to call this @@ -77,7 +91,10 @@ public: * should call #updateSdCardStateFile again in that case * - STATUS_FILE_NEXISTS if the status file does not exist */ - ReturnValue_t sdCardActive(std::pair& active); + ReturnValue_t sdCardActive(std::pair& active); + + ReturnValue_t mountSdCard(sd::SdCard sdCard); + ReturnValue_t unmountSdCard(sd::SdCard sdCard); sd::SdCard getPreferedSdCard() const; @@ -88,6 +105,9 @@ private: sd::SdCard preferredSdCard = sd::SdCard::SLOT_0; + void processSdStatusLine(std::pair& active, + std::string& line, uint8_t& idx, sd::SdCard& currentSd); + static SdCardManager* factoryInstance; }; diff --git a/bsp_q7s/memory/definitions.h b/bsp_q7s/memory/definitions.h index 9a998dcc..a2d29d9b 100644 --- a/bsp_q7s/memory/definitions.h +++ b/bsp_q7s/memory/definitions.h @@ -1,8 +1,17 @@ #ifndef BSP_Q7S_MEMORY_DEFINITIONS_H_ #define BSP_Q7S_MEMORY_DEFINITIONS_H_ +#include + namespace sd { +enum SdStatus: uint8_t { + OFF = 0, + ON = 1, + // A mounted SD card is on as well + MOUNTED = 2 +}; + enum SdCard { SLOT_0, SLOT_1, From 658e9a49071682b9fe6d16de66cdebb5e3eb34cd Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Mon, 12 Jul 2021 11:47:23 +0200 Subject: [PATCH 099/111] added docs and improvements --- bsp_q7s/memory/SdCardManager.cpp | 8 +++++--- bsp_q7s/memory/SdCardManager.h | 20 ++++++++++++++++---- 2 files changed, 21 insertions(+), 7 deletions(-) diff --git a/bsp_q7s/memory/SdCardManager.cpp b/bsp_q7s/memory/SdCardManager.cpp index 8c67ea2c..3a7afc42 100644 --- a/bsp_q7s/memory/SdCardManager.cpp +++ b/bsp_q7s/memory/SdCardManager.cpp @@ -117,12 +117,12 @@ ReturnValue_t SdCardManager::setSdCardState(sd::SdCard sdCard, bool on) { ReturnValue_t SdCardManager::sdCardActive(std::pair& active) { using namespace std; - if(not filesystem::exists("/tmp/sd_status.txt")) { + if(not filesystem::exists(SD_STATE_FILE)) { return STATUS_FILE_NEXISTS; } // Now the file should exist in any case. Still check whether it exists. - fstream sdStatus("/tmp/sd_status.txt"); + fstream sdStatus(SD_STATE_FILE); if (not sdStatus.good()) { return STATUS_FILE_NEXISTS; } @@ -261,7 +261,9 @@ void SdCardManager::setPreferredSdCard(sd::SdCard sdCard) { } ReturnValue_t SdCardManager::updateSdCardStateFile() { - int result = std::system("q7hw sd info all > /tmp/sd_status.txt"); + // Use q7hw utility and pipe the command output into the state file + std::string updateCmd = "q7hw sd info all > " + SD_STATE_FILE; + int result = std::system(updateCmd.c_str()); if(result == 0) { return HasReturnvaluesIF::RETURN_OK; } diff --git a/bsp_q7s/memory/SdCardManager.h b/bsp_q7s/memory/SdCardManager.h index 9052d9b0..810536fe 100644 --- a/bsp_q7s/memory/SdCardManager.h +++ b/bsp_q7s/memory/SdCardManager.h @@ -38,6 +38,7 @@ public: static constexpr char SD_1_DEV_NAME[] = "/dev/mmcblk1p1"; static constexpr char SD_0_MOUNT_POINT[] = "/mnt/sd0"; static constexpr char SD_1_MOUNT_POINT[] = "/mnt/sd1"; + static constexpr char SD_STATE_FILE[] = "/tmp/sd_status.txt"; virtual ~SdCardManager(); @@ -53,7 +54,7 @@ public: sd::SdCard getPreferredSdCard() const; /** - * Switch on the specified SD card + * Switch on the specified SD card. * @param sdCard * @param doMountSdCard Mount the SD card after switching it on, which is necessary * to use it @@ -63,7 +64,7 @@ public: ReturnValue_t switchOnSdCard(sd::SdCard sdCard, bool doMountSdCard = true); /** - * Switch off the specified SD card + * Switch off the specified SD card. * @param sdCard * @param doUnmountSdCard Unmount the SD card before switching the card off, which makes * the operation safer @@ -73,8 +74,8 @@ public: ReturnValue_t switchOffSdCard(sd::SdCard sdCard, bool doUnmountSdCard = true); /** - * Updated the state file or creates one if it does not exist. You need to call this - * function before calling #sdCardActiv + * Update the state file or creates one if it does not exist. You need to call this + * function before calling #sdCardActive * @return - RETURN_OK if the state file was updated successfully * - SYSTEM_CALL_ERROR if the call to create the status file failed */ @@ -93,7 +94,18 @@ public: */ ReturnValue_t sdCardActive(std::pair& active); + /** + * Mount the specified SD card. This is necessary to use it. + * @param sdCard + * @return + */ ReturnValue_t mountSdCard(sd::SdCard sdCard); + /** + * Unmount the specified SD card. This is recommended before switching it off. The SD card + * can't be used after it has been unmounted. + * @param sdCard + * @return + */ ReturnValue_t unmountSdCard(sd::SdCard sdCard); sd::SdCard getPreferedSdCard() const; From bf2a4d0ad786476b0d84d8a92d06ff406615163c Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Mon, 12 Jul 2021 11:49:19 +0200 Subject: [PATCH 100/111] fix so it compiles --- bsp_q7s/core/CoreController.cpp | 2 +- bsp_q7s/memory/SdCardManager.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/bsp_q7s/core/CoreController.cpp b/bsp_q7s/core/CoreController.cpp index 98ddb347..ced75056 100644 --- a/bsp_q7s/core/CoreController.cpp +++ b/bsp_q7s/core/CoreController.cpp @@ -40,7 +40,7 @@ ReturnValue_t CoreController::initialize() { sif::info << "Switching on SD card " << printoutString << ".." << std::endl; - result = SdCardManager::instance()->switchOnSdCard(preferredSdCard); + result = SdCardManager::instance()->switchOnSdCard(preferredSdCard, true); if(result == SdCardManager::ALREADY_ON) { sif::info << "SD card " << printoutString << " is already on" << std::endl; } diff --git a/bsp_q7s/memory/SdCardManager.cpp b/bsp_q7s/memory/SdCardManager.cpp index 3a7afc42..9c47f0de 100644 --- a/bsp_q7s/memory/SdCardManager.cpp +++ b/bsp_q7s/memory/SdCardManager.cpp @@ -262,7 +262,7 @@ void SdCardManager::setPreferredSdCard(sd::SdCard sdCard) { ReturnValue_t SdCardManager::updateSdCardStateFile() { // Use q7hw utility and pipe the command output into the state file - std::string updateCmd = "q7hw sd info all > " + SD_STATE_FILE; + std::string updateCmd = "q7hw sd info all > " + std::string(SD_STATE_FILE); int result = std::system(updateCmd.c_str()); if(result == 0) { return HasReturnvaluesIF::RETURN_OK; From 37feaa0a549c1d3da21ba57dcc513e2edbb0e592 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Mon, 12 Jul 2021 13:26:02 +0200 Subject: [PATCH 101/111] sd card is now mounted as well --- bsp_q7s/core/CoreController.cpp | 7 +++++-- bsp_q7s/memory/SdCardManager.cpp | 13 +++++++++++-- bsp_q7s/memory/SdCardManager.h | 19 ++++++++++++------- 3 files changed, 28 insertions(+), 11 deletions(-) diff --git a/bsp_q7s/core/CoreController.cpp b/bsp_q7s/core/CoreController.cpp index ced75056..421a96d9 100644 --- a/bsp_q7s/core/CoreController.cpp +++ b/bsp_q7s/core/CoreController.cpp @@ -41,7 +41,10 @@ ReturnValue_t CoreController::initialize() { sif::info << "Switching on SD card " << printoutString << ".." << std::endl; result = SdCardManager::instance()->switchOnSdCard(preferredSdCard, true); - if(result == SdCardManager::ALREADY_ON) { + if(result == SdCardManager::ALREADY_MOUNTED) { + sif::info << "SD card " << printoutString << " is already on and mounted" << std::endl; + } + else if(result == SdCardManager::ALREADY_ON) { sif::info << "SD card " << printoutString << " is already on" << std::endl; } else if(result != HasReturnvaluesIF::RETURN_OK) { @@ -49,7 +52,7 @@ ReturnValue_t CoreController::initialize() { << std::endl; } else { - sif::info << "SD card " << printoutString << " was switched on" << std::endl; + sif::info << "SD card " << printoutString << " was switched on and mounted" << std::endl; } return HasReturnvaluesIF::RETURN_OK; } diff --git a/bsp_q7s/memory/SdCardManager.cpp b/bsp_q7s/memory/SdCardManager.cpp index 9c47f0de..232000a3 100644 --- a/bsp_q7s/memory/SdCardManager.cpp +++ b/bsp_q7s/memory/SdCardManager.cpp @@ -39,9 +39,18 @@ ReturnValue_t SdCardManager::switchOnSdCard(sd::SdCard sdCard, bool doMountSdCar return result; } if(sdCard == sd::SdCard::SLOT_0) { - if(active.first == sd::SdStatus::ON or active.first == sd::SdStatus::MOUNTED) { - return ALREADY_ON; + if(active.first == sd::SdStatus::MOUNTED) { + return ALREADY_MOUNTED; } + else if(active.first == sd::SdStatus::ON) { + if(not doMountSdCard) { + return ALREADY_ON; + } + else { + return mountSdCard(sdCard); + } + } + } else if(sdCard == sd::SdCard::SLOT_1) { if(active.second == sd::SdStatus::ON or active.second == sd::SdStatus::MOUNTED) { diff --git a/bsp_q7s/memory/SdCardManager.h b/bsp_q7s/memory/SdCardManager.h index 810536fe..b3a33d42 100644 --- a/bsp_q7s/memory/SdCardManager.h +++ b/bsp_q7s/memory/SdCardManager.h @@ -21,17 +21,22 @@ class SdCardManager { public: static constexpr uint8_t INTERFACE_ID = CLASS_ID::SD_CARD_MANAGER; - static constexpr ReturnValue_t ALREADY_ON = HasReturnvaluesIF::makeReturnCode(INTERFACE_ID, 0); - static constexpr ReturnValue_t ALREADY_OFF = HasReturnvaluesIF::makeReturnCode(INTERFACE_ID, 1); - static constexpr ReturnValue_t STATUS_FILE_NEXISTS = + static constexpr ReturnValue_t ALREADY_ON = + HasReturnvaluesIF::makeReturnCode(INTERFACE_ID, 0); + static constexpr ReturnValue_t ALREADY_MOUNTED = + HasReturnvaluesIF::makeReturnCode(INTERFACE_ID, 1); + static constexpr ReturnValue_t ALREADY_OFF = HasReturnvaluesIF::makeReturnCode(INTERFACE_ID, 2); + static constexpr ReturnValue_t STATUS_FILE_NEXISTS = + HasReturnvaluesIF::makeReturnCode(INTERFACE_ID, 10); static constexpr ReturnValue_t STATUS_FILE_FORMAT_INVALID = - HasReturnvaluesIF::makeReturnCode(INTERFACE_ID, 3); - static constexpr ReturnValue_t MOUNT_ERROR = HasReturnvaluesIF::makeReturnCode(INTERFACE_ID, 4); + HasReturnvaluesIF::makeReturnCode(INTERFACE_ID, 11); + static constexpr ReturnValue_t MOUNT_ERROR = + HasReturnvaluesIF::makeReturnCode(INTERFACE_ID, 12); static constexpr ReturnValue_t UNMOUNT_ERROR = - HasReturnvaluesIF::makeReturnCode(INTERFACE_ID, 5); + HasReturnvaluesIF::makeReturnCode(INTERFACE_ID, 13); static constexpr ReturnValue_t SYSTEM_CALL_ERROR = - HasReturnvaluesIF::makeReturnCode(INTERFACE_ID, 6); + HasReturnvaluesIF::makeReturnCode(INTERFACE_ID, 14); // C++17 does not support constexpr std::string yet static constexpr char SD_0_DEV_NAME[] = "/dev/mmcblk0p1"; From 9284398b8bccdb83544bd84d4362a61c23ac544b Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Mon, 12 Jul 2021 14:32:20 +0200 Subject: [PATCH 102/111] cold redundant and hot redundant configuration --- bsp_q7s/boardconfig/q7sConfig.h.in | 11 +++ bsp_q7s/core/CoreController.cpp | 127 +++++++++++++++++++++++------ bsp_q7s/core/CoreController.h | 2 + bsp_q7s/memory/SdCardManager.cpp | 42 ++++++---- bsp_q7s/memory/SdCardManager.h | 8 +- bsp_q7s/memory/definitions.h | 2 +- bsp_q7s/memory/scratchApi.h | 2 + 7 files changed, 149 insertions(+), 45 deletions(-) diff --git a/bsp_q7s/boardconfig/q7sConfig.h.in b/bsp_q7s/boardconfig/q7sConfig.h.in index 9bed2a4a..92c47994 100644 --- a/bsp_q7s/boardconfig/q7sConfig.h.in +++ b/bsp_q7s/boardconfig/q7sConfig.h.in @@ -4,6 +4,17 @@ #include #cmakedefine01 Q7S_SIMPLE_MODE + +#define Q7S_SD_NONE 0 +#define Q7S_SD_COLD_REDUNDANT 1 +#define Q7S_SD_HOT_REDUNDANT 2 +// The OBSW will perform different actions to set up the SD cards depending on the flag set here +// Set to Q7S_SD_NONE: Don't do anything +// Set to Q7S_COLD_REDUNDANT: On startup, get the prefered SD card, turn it on and mount it, and +// turn off the second SD card if it is on +// Set to Q7S_HOT_REDUNDANT: On startup, turn on both SD cards and mount them +#define Q7S_SD_CARD_CONFIG 1 + #define Q7S_ADD_RTD_DEVICES 0 /* Only one of those 2 should be enabled! */ diff --git a/bsp_q7s/core/CoreController.cpp b/bsp_q7s/core/CoreController.cpp index 421a96d9..f7f907d0 100644 --- a/bsp_q7s/core/CoreController.cpp +++ b/bsp_q7s/core/CoreController.cpp @@ -1,8 +1,10 @@ #include "CoreController.h" +#include "q7sConfig.h" + #include "../memory/SdCardManager.h" CoreController::CoreController(object_id_t objectId): - ExtendedControllerBase(objectId, objects::NO_OBJECT, 5) { +ExtendedControllerBase(objectId, objects::NO_OBJECT, 5) { } ReturnValue_t CoreController::handleCommandMessage(CommandMessage *message) { @@ -22,15 +24,19 @@ LocalPoolDataSetBase* CoreController::getDataSetHandle(sid_t sid) { } ReturnValue_t CoreController::initialize() { - // Find a way to store this non-volatile outside of SD cards (ProASIC?) - sd::SdCard preferredSdCard = sd::SdCard::SLOT_0; - std::string printoutString; - if(preferredSdCard == sd::SdCard::SLOT_0) { - printoutString = "0"; - } - else { - printoutString = "1"; - } + return sdCardInit(); +} + +ReturnValue_t CoreController::checkModeCommand(Mode_t mode, Submode_t submode, + uint32_t *msToReachTheMode) { + return HasReturnvaluesIF::RETURN_OK; +} + +ReturnValue_t CoreController::sdCardInit() { +#if Q7S_SD_CARD_CONFIG == Q7S_SD_NONE + sif::info << "No SD card initialization will be performed" << std::endl; + return HasReturnvaluesIF::RETURN_OK; +#else // Creator or update status file ReturnValue_t result = SdCardManager::instance()->updateSdCardStateFile(); if(result != HasReturnvaluesIF::RETURN_OK) { @@ -38,26 +44,99 @@ ReturnValue_t CoreController::initialize() { << std::endl; } - sif::info << "Switching on SD card " << printoutString << ".." << std::endl; + SdCardManager* sdcMan = SdCardManager::instance(); + auto sdStatus = std::pair(sd::SdStatus::OFF, sd::SdStatus::OFF); + result = sdcMan->getSdCardActiveStatus(sdStatus); + if(result != HasReturnvaluesIF::RETURN_OK) { + sif::warning << "Getting SD card activity status failed" << std::endl; + } - result = SdCardManager::instance()->switchOnSdCard(preferredSdCard, true); - if(result == SdCardManager::ALREADY_MOUNTED) { - sif::info << "SD card " << printoutString << " is already on and mounted" << std::endl; - } - else if(result == SdCardManager::ALREADY_ON) { - sif::info << "SD card " << printoutString << " is already on" << std::endl; - } - else if(result != HasReturnvaluesIF::RETURN_OK) { - sif::warning << "CoreController::initialize: Turning SD card on failed" +#if Q7S_SD_CARD_CONFIG == Q7S_SD_COLD_REDUNDANT + sif::info << "Cold redundant SD card configuration" << std::endl; + sd::SdCard preferredSdCard = sd::SdCard::SLOT_0; + result = sdcMan->getPreferredSdCard(preferredSdCard); + if(result != HasReturnvaluesIF::RETURN_OK) { + sif::warning << "Could not get prefered SD card information from the scratch buffer" << std::endl; } + sd::SdCard otherSdc = sd::SdCard::SLOT_0; + std::string printoutString; + std::string otherString; + if(preferredSdCard == sd::SdCard::SLOT_0) { + printoutString = "0"; + otherSdc = sd::SdCard::SLOT_1; + otherString = "1"; + } else { - sif::info << "SD card " << printoutString << " was switched on and mounted" << std::endl; + printoutString = "1"; + otherSdc = sd::SdCard::SLOT_0; + otherString = "0"; + } + + sd::SdStatus targetStatus = sd::SdStatus::OFF; + if(preferredSdCard == sd::SdCard::SLOT_0) { + targetStatus = sdStatus.first; + } + else if(preferredSdCard == sd::SdCard::SLOT_1) { + targetStatus = sdStatus.second; + } + + if(targetStatus == sd::SdStatus::MOUNTED) { + sif::info << "SD card " << printoutString << " is already switched on and mounted" << + std::endl; + result = HasReturnvaluesIF::RETURN_OK; + } + else if(targetStatus == sd::SdStatus::ON) { + sif::info << "Mounting SD card " << printoutString << std::endl; + result = sdcMan->mountSdCard(preferredSdCard); + if(result != HasReturnvaluesIF::RETURN_OK) { + sif::warning << "Mounting SD card failed" << std::endl; + } + } + else if(targetStatus == sd::SdStatus::OFF) { + sif::info << "Switching on and mounting SD card " << printoutString << std::endl; + result = sdcMan->switchOnSdCard(preferredSdCard, true); + if(result != HasReturnvaluesIF::RETURN_OK) { + sif::warning << "Switching on and mounting SD card failed" << std::endl; + } + } + + if(result != HasReturnvaluesIF::RETURN_OK) { + // This should not happen.. Switch on other SD card for now + sdcMan->switchOnSdCard(otherSdc, true); + return HasReturnvaluesIF::RETURN_FAILED; + } + + sif::info << "Switching off SD card " << otherString << std::endl; + // Switch off other SD card in cold-redundant mode + result = sdcMan->switchOffSdCard(otherSdc, true); + if(result != HasReturnvaluesIF::RETURN_OK) { + sif::warning << "Switching off SD card " << otherString << " failed" << std::endl; } return HasReturnvaluesIF::RETURN_OK; -} +#elif Q7S_SD_CARD_CONFIG == Q7S_SD_HOT_REDUNDANT + sif::info << "Hot redundant SD card configuration" << std::endl; -ReturnValue_t CoreController::checkModeCommand(Mode_t mode, Submode_t submode, - uint32_t *msToReachTheMode) { + // Use a lambda to avoid duplicate code + auto setUpSdCard = [sdcMan](sd::SdCard sdCard, sd::SdStatus status, std::string sdString) { + if(status == sd::SdStatus::OFF) { + sif::info << "Switching on and mounting SD card " << sdString << std::endl; + sdcMan->switchOnSdCard(sdCard, true); + } + else if(status == sd::SdStatus::ON) { + sif::info << "Mounting SD card " << sdString << std::endl; + sdcMan->mountSdCard(sdCard); + } + else { + sif::info << "SD card " << sdString << " already on and mounted" << std::endl; + } + }; + + setUpSdCard(sd::SdCard::SLOT_0, sdStatus.first, "0"); + setUpSdCard(sd::SdCard::SLOT_1, sdStatus.second, "1"); return HasReturnvaluesIF::RETURN_OK; +#endif + +#endif /* Q7S_SD_CARD_CONFIG != Q7S_SD_NONE */ + } diff --git a/bsp_q7s/core/CoreController.h b/bsp_q7s/core/CoreController.h index 674ed073..940a9097 100644 --- a/bsp_q7s/core/CoreController.h +++ b/bsp_q7s/core/CoreController.h @@ -17,6 +17,8 @@ private: LocalPoolDataSetBase* getDataSetHandle(sid_t sid) override; ReturnValue_t checkModeCommand(Mode_t mode, Submode_t submode, uint32_t *msToReachTheMode); + + ReturnValue_t sdCardInit(); }; diff --git a/bsp_q7s/memory/SdCardManager.cpp b/bsp_q7s/memory/SdCardManager.cpp index 232000a3..1e9968b5 100644 --- a/bsp_q7s/memory/SdCardManager.cpp +++ b/bsp_q7s/memory/SdCardManager.cpp @@ -1,4 +1,6 @@ #include "SdCardManager.h" +#include "scratchApi.h" + #include "linux/utility/utility.h" #include "fsfw/ipc/MutexFactory.h" @@ -28,7 +30,7 @@ SdCardManager* SdCardManager::instance() { ReturnValue_t SdCardManager::switchOnSdCard(sd::SdCard sdCard, bool doMountSdCard) { std::pair active; - ReturnValue_t result = sdCardActive(active); + ReturnValue_t result = getSdCardActiveStatus(active); // Not allowed, this function turns on one SD card if(sdCard == sd::SdCard::BOTH) { sif::warning << "SdCardManager::switchOffSdCard: API does not allow sd::SdStatus::BOTH" @@ -67,7 +69,7 @@ ReturnValue_t SdCardManager::switchOnSdCard(sd::SdCard sdCard, bool doMountSdCar ReturnValue_t SdCardManager::switchOffSdCard(sd::SdCard sdCard, bool doUnmountSdCard) { std::pair active; - ReturnValue_t result = sdCardActive(active); + ReturnValue_t result = getSdCardActiveStatus(active); if(result != HasReturnvaluesIF::RETURN_OK) { return result; } @@ -99,8 +101,9 @@ ReturnValue_t SdCardManager::switchOffSdCard(sd::SdCard sdCard, bool doUnmountSd } ReturnValue_t SdCardManager::setSdCardState(sd::SdCard sdCard, bool on) { - std::string sdstring = ""; - std::string statestring = ""; + using namespace std; + string sdstring = ""; + string statestring = ""; if(sdCard == sd::SdCard::SLOT_0) { sdstring = "0"; } @@ -113,9 +116,9 @@ ReturnValue_t SdCardManager::setSdCardState(sd::SdCard sdCard, bool on) { else { statestring = "off"; } - std::ostringstream command; + ostringstream command; command << "q7hw sd set " << sdstring << " " << statestring; - int result = std::system(command.str().c_str()); + int result = system(command.str().c_str()); if(result == 0) { return HasReturnvaluesIF::RETURN_OK; } @@ -124,7 +127,7 @@ ReturnValue_t SdCardManager::setSdCardState(sd::SdCard sdCard, bool on) { return SYSTEM_CALL_ERROR; } -ReturnValue_t SdCardManager::sdCardActive(std::pair& active) { +ReturnValue_t SdCardManager::getSdCardActiveStatus(std::pair& active) { using namespace std; if(not filesystem::exists(SD_STATE_FILE)) { return STATUS_FILE_NEXISTS; @@ -152,8 +155,8 @@ ReturnValue_t SdCardManager::mountSdCard(sd::SdCard sdCard) { << std::endl; return HasReturnvaluesIF::RETURN_FAILED; } - std::string mountDev; - std::string mountPoint; + string mountDev; + string mountPoint; if(sdCard == sd::SdCard::SLOT_0) { mountDev = SD_0_DEV_NAME; mountPoint = SD_0_MOUNT_POINT; @@ -162,7 +165,7 @@ ReturnValue_t SdCardManager::mountSdCard(sd::SdCard sdCard) { mountDev = SD_0_DEV_NAME; mountPoint = SD_1_MOUNT_POINT; } - if(not std::filesystem::exists(mountDev)) { + if(not filesystem::exists(mountDev)) { sif::warning << "SdCardManager::mountSdCard: Device file does not exists. Make sure to" " turn on the SD card" << std::endl; return MOUNT_ERROR; @@ -197,6 +200,7 @@ ReturnValue_t SdCardManager::unmountSdCard(sd::SdCard sdCard) { sif::warning << "SdCardManager::unmountSdCard: Mount point is empty!" << std::endl; } string sdUnmountCommand = "umount " + mountPoint; + sif::debug << sdUnmountCommand << std::endl; int result = system(sdUnmountCommand.c_str()); if (result != 0) { utility::handleSystemError(result, "SdCardManager::unmountSdCard"); @@ -260,13 +264,21 @@ void SdCardManager::processSdStatusLine(std::pair &a idx++; } -sd::SdCard SdCardManager::getPreferredSdCard() const { - //int result = std::system("xsc_scratch read PREFSD > /tmp/pref_sd.txt"); - return preferredSdCard; +ReturnValue_t SdCardManager::getPreferredSdCard(sd::SdCard& sdCard) const { + uint8_t prefSdCard = 0; + ReturnValue_t result = scratch::readNumber(scratch::PREFERED_SDC_KEY, prefSdCard); + if(result != HasReturnvaluesIF::RETURN_OK) { + return result; + } + sdCard = static_cast(prefSdCard); + return HasReturnvaluesIF::RETURN_OK; } -void SdCardManager::setPreferredSdCard(sd::SdCard sdCard) { - preferredSdCard = sdCard; +ReturnValue_t SdCardManager::setPreferredSdCard(sd::SdCard sdCard) { + if(sdCard == sd::SdCard::BOTH) { + return HasReturnvaluesIF::RETURN_FAILED; + } + return scratch::writeNumber(scratch::PREFERED_SDC_KEY, static_cast(sdCard)); } ReturnValue_t SdCardManager::updateSdCardStateFile() { diff --git a/bsp_q7s/memory/SdCardManager.h b/bsp_q7s/memory/SdCardManager.h index b3a33d42..35ba1654 100644 --- a/bsp_q7s/memory/SdCardManager.h +++ b/bsp_q7s/memory/SdCardManager.h @@ -54,9 +54,9 @@ public: */ static SdCardManager* instance(); - void setPreferredSdCard(sd::SdCard sdCard); + ReturnValue_t setPreferredSdCard(sd::SdCard sdCard); - sd::SdCard getPreferredSdCard() const; + ReturnValue_t getPreferredSdCard(sd::SdCard& sdCard) const; /** * Switch on the specified SD card. @@ -97,7 +97,7 @@ public: * should call #updateSdCardStateFile again in that case * - STATUS_FILE_NEXISTS if the status file does not exist */ - ReturnValue_t sdCardActive(std::pair& active); + ReturnValue_t getSdCardActiveStatus(std::pair& active); /** * Mount the specified SD card. This is necessary to use it. @@ -113,8 +113,6 @@ public: */ ReturnValue_t unmountSdCard(sd::SdCard sdCard); - sd::SdCard getPreferedSdCard() const; - private: SdCardManager(); diff --git a/bsp_q7s/memory/definitions.h b/bsp_q7s/memory/definitions.h index a2d29d9b..546a6585 100644 --- a/bsp_q7s/memory/definitions.h +++ b/bsp_q7s/memory/definitions.h @@ -12,7 +12,7 @@ enum SdStatus: uint8_t { MOUNTED = 2 }; -enum SdCard { +enum SdCard: uint8_t { SLOT_0, SLOT_1, BOTH diff --git a/bsp_q7s/memory/scratchApi.h b/bsp_q7s/memory/scratchApi.h index 09bf6bab..eceda11a 100644 --- a/bsp_q7s/memory/scratchApi.h +++ b/bsp_q7s/memory/scratchApi.h @@ -16,6 +16,8 @@ */ namespace scratch { +static constexpr char PREFERED_SDC_KEY[] = "PREFSD"; + namespace { static uint8_t counter = 0; } From e0cf333a7d7fe5d56fdffefa9bb434660017ed84 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Mon, 12 Jul 2021 15:19:06 +0200 Subject: [PATCH 103/111] more bugfixes --- bsp_q7s/boardconfig/q7sConfig.h.in | 2 +- bsp_q7s/core/CoreController.cpp | 16 ++++++--- bsp_q7s/memory/SdCardManager.cpp | 57 +++++++++++++++++++----------- bsp_q7s/memory/SdCardManager.h | 16 ++++++--- 4 files changed, 60 insertions(+), 31 deletions(-) diff --git a/bsp_q7s/boardconfig/q7sConfig.h.in b/bsp_q7s/boardconfig/q7sConfig.h.in index 92c47994..11dec25c 100644 --- a/bsp_q7s/boardconfig/q7sConfig.h.in +++ b/bsp_q7s/boardconfig/q7sConfig.h.in @@ -13,7 +13,7 @@ // Set to Q7S_COLD_REDUNDANT: On startup, get the prefered SD card, turn it on and mount it, and // turn off the second SD card if it is on // Set to Q7S_HOT_REDUNDANT: On startup, turn on both SD cards and mount them -#define Q7S_SD_CARD_CONFIG 1 +#define Q7S_SD_CARD_CONFIG Q7S_SD_COLD_REDUNDANT #define Q7S_ADD_RTD_DEVICES 0 diff --git a/bsp_q7s/core/CoreController.cpp b/bsp_q7s/core/CoreController.cpp index f7f907d0..2dcd204c 100644 --- a/bsp_q7s/core/CoreController.cpp +++ b/bsp_q7s/core/CoreController.cpp @@ -37,14 +37,16 @@ ReturnValue_t CoreController::sdCardInit() { sif::info << "No SD card initialization will be performed" << std::endl; return HasReturnvaluesIF::RETURN_OK; #else - // Creator or update status file - ReturnValue_t result = SdCardManager::instance()->updateSdCardStateFile(); + SdCardManager* sdcMan = SdCardManager::instance(); + + // Create update status file + ReturnValue_t result = sdcMan->updateSdCardStateFile(); if(result != HasReturnvaluesIF::RETURN_OK) { sif::warning << "CoreController::initialize: Updating SD card state file failed" << std::endl; } - SdCardManager* sdcMan = SdCardManager::instance(); + auto sdStatus = std::pair(sd::SdStatus::OFF, sd::SdStatus::OFF); result = sdcMan->getSdCardActiveStatus(sdStatus); if(result != HasReturnvaluesIF::RETURN_OK) { @@ -113,15 +115,17 @@ ReturnValue_t CoreController::sdCardInit() { if(result != HasReturnvaluesIF::RETURN_OK) { sif::warning << "Switching off SD card " << otherString << " failed" << std::endl; } + // Update status file + sdcMan->updateSdCardStateFile(); return HasReturnvaluesIF::RETURN_OK; #elif Q7S_SD_CARD_CONFIG == Q7S_SD_HOT_REDUNDANT sif::info << "Hot redundant SD card configuration" << std::endl; // Use a lambda to avoid duplicate code - auto setUpSdCard = [sdcMan](sd::SdCard sdCard, sd::SdStatus status, std::string sdString) { + auto setUpSdCard = [&](sd::SdCard sdCard, sd::SdStatus status, std::string sdString) { if(status == sd::SdStatus::OFF) { sif::info << "Switching on and mounting SD card " << sdString << std::endl; - sdcMan->switchOnSdCard(sdCard, true); + sdcMan->switchOnSdCard(sdCard, true, &sdStatus); } else if(status == sd::SdStatus::ON) { sif::info << "Mounting SD card " << sdString << std::endl; @@ -134,6 +138,8 @@ ReturnValue_t CoreController::sdCardInit() { setUpSdCard(sd::SdCard::SLOT_0, sdStatus.first, "0"); setUpSdCard(sd::SdCard::SLOT_1, sdStatus.second, "1"); + // Update status file + sdcMan->updateSdCardStateFile(); return HasReturnvaluesIF::RETURN_OK; #endif diff --git a/bsp_q7s/memory/SdCardManager.cpp b/bsp_q7s/memory/SdCardManager.cpp index 1e9968b5..537d3e77 100644 --- a/bsp_q7s/memory/SdCardManager.cpp +++ b/bsp_q7s/memory/SdCardManager.cpp @@ -28,23 +28,34 @@ SdCardManager* SdCardManager::instance() { return SdCardManager::factoryInstance; } -ReturnValue_t SdCardManager::switchOnSdCard(sd::SdCard sdCard, bool doMountSdCard) { - std::pair active; - ReturnValue_t result = getSdCardActiveStatus(active); +ReturnValue_t SdCardManager::switchOnSdCard(sd::SdCard sdCard, bool doMountSdCard, + SdStatusPair* statusPair) { + ReturnValue_t result = HasReturnvaluesIF::RETURN_OK; + if(statusPair == nullptr) { + statusPair = std::make_unique().get(); + result = getSdCardActiveStatus(*statusPair); + if(result != HasReturnvaluesIF::RETURN_OK) { + return result; + } + } + // Not allowed, this function turns on one SD card if(sdCard == sd::SdCard::BOTH) { sif::warning << "SdCardManager::switchOffSdCard: API does not allow sd::SdStatus::BOTH" << std::endl; return HasReturnvaluesIF::RETURN_FAILED; } - if(result != HasReturnvaluesIF::RETURN_OK) { - return result; - } + + sd::SdStatus targetStatus; if(sdCard == sd::SdCard::SLOT_0) { - if(active.first == sd::SdStatus::MOUNTED) { - return ALREADY_MOUNTED; - } - else if(active.first == sd::SdStatus::ON) { + targetStatus = statusPair->first; + } + else if(sdCard == sd::SdCard::SLOT_1) { + targetStatus = statusPair->second; + } + + auto switchCall = [&]() { + if(targetStatus == sd::SdStatus::ON) { if(not doMountSdCard) { return ALREADY_ON; } @@ -52,14 +63,19 @@ ReturnValue_t SdCardManager::switchOnSdCard(sd::SdCard sdCard, bool doMountSdCar return mountSdCard(sdCard); } } - - } - else if(sdCard == sd::SdCard::SLOT_1) { - if(active.second == sd::SdStatus::ON or active.second == sd::SdStatus::MOUNTED) { - return ALREADY_ON; + else if(targetStatus == sd::SdStatus::MOUNTED) { + return ALREADY_MOUNTED; } - } - result = setSdCardState(sdCard, true); + else if(targetStatus == sd::SdStatus::OFF) { + return setSdCardState(sdCard, true); + } + else { + return HasReturnvaluesIF::RETURN_FAILED; + } + }; + + result = switchCall(); + if(result != HasReturnvaluesIF::RETURN_OK or not doMountSdCard) { return result; } @@ -67,7 +83,8 @@ ReturnValue_t SdCardManager::switchOnSdCard(sd::SdCard sdCard, bool doMountSdCar return mountSdCard(sdCard); } -ReturnValue_t SdCardManager::switchOffSdCard(sd::SdCard sdCard, bool doUnmountSdCard) { +ReturnValue_t SdCardManager::switchOffSdCard(sd::SdCard sdCard, bool doUnmountSdCard, + SdStatusPair* statusPair) { std::pair active; ReturnValue_t result = getSdCardActiveStatus(active); if(result != HasReturnvaluesIF::RETURN_OK) { @@ -127,7 +144,7 @@ ReturnValue_t SdCardManager::setSdCardState(sd::SdCard sdCard, bool on) { return SYSTEM_CALL_ERROR; } -ReturnValue_t SdCardManager::getSdCardActiveStatus(std::pair& active) { +ReturnValue_t SdCardManager::getSdCardActiveStatus(SdStatusPair& active) { using namespace std; if(not filesystem::exists(SD_STATE_FILE)) { return STATUS_FILE_NEXISTS; @@ -162,7 +179,7 @@ ReturnValue_t SdCardManager::mountSdCard(sd::SdCard sdCard) { mountPoint = SD_0_MOUNT_POINT; } else if(sdCard == sd::SdCard::SLOT_1) { - mountDev = SD_0_DEV_NAME; + mountDev = SD_1_DEV_NAME; mountPoint = SD_1_MOUNT_POINT; } if(not filesystem::exists(mountDev)) { diff --git a/bsp_q7s/memory/SdCardManager.h b/bsp_q7s/memory/SdCardManager.h index 35ba1654..9a4dcbc5 100644 --- a/bsp_q7s/memory/SdCardManager.h +++ b/bsp_q7s/memory/SdCardManager.h @@ -19,6 +19,8 @@ class MutexIF; class SdCardManager { friend class SdCardAccess; public: + using SdStatusPair = std::pair; + static constexpr uint8_t INTERFACE_ID = CLASS_ID::SD_CARD_MANAGER; static constexpr ReturnValue_t ALREADY_ON = @@ -63,20 +65,24 @@ public: * @param sdCard * @param doMountSdCard Mount the SD card after switching it on, which is necessary * to use it + * @param statusPair If the status pair is already available, it can be passed here * @return - RETURN_OK on success, ALREADY_ON if it is already on, * SYSTEM_CALL_ERROR on system error */ - ReturnValue_t switchOnSdCard(sd::SdCard sdCard, bool doMountSdCard = true); + ReturnValue_t switchOnSdCard(sd::SdCard sdCard, bool doMountSdCard = true, + SdStatusPair* statusPair = nullptr); /** * Switch off the specified SD card. * @param sdCard * @param doUnmountSdCard Unmount the SD card before switching the card off, which makes * the operation safer + * @param statusPair If the status pair is already available, it can be passed here * @return - RETURN_OK on success, ALREADY_ON if it is already on, * SYSTEM_CALL_ERROR on system error */ - ReturnValue_t switchOffSdCard(sd::SdCard sdCard, bool doUnmountSdCard = true); + ReturnValue_t switchOffSdCard(sd::SdCard sdCard, bool doUnmountSdCard = true, + SdStatusPair* statusPair = nullptr); /** * Update the state file or creates one if it does not exist. You need to call this @@ -97,7 +103,7 @@ public: * should call #updateSdCardStateFile again in that case * - STATUS_FILE_NEXISTS if the status file does not exist */ - ReturnValue_t getSdCardActiveStatus(std::pair& active); + ReturnValue_t getSdCardActiveStatus(SdStatusPair& active); /** * Mount the specified SD card. This is necessary to use it. @@ -120,8 +126,8 @@ private: sd::SdCard preferredSdCard = sd::SdCard::SLOT_0; - void processSdStatusLine(std::pair& active, - std::string& line, uint8_t& idx, sd::SdCard& currentSd); + void processSdStatusLine(SdStatusPair& active, std::string& line, uint8_t& idx, + sd::SdCard& currentSd); static SdCardManager* factoryInstance; }; From ec2f15cf54f26fc6017c2d327188b69335743a7a Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Mon, 12 Jul 2021 15:52:13 +0200 Subject: [PATCH 104/111] some refactoring --- bsp_q7s/core/CoreController.cpp | 112 +++++++++++++++---------------- bsp_q7s/memory/SdCardManager.cpp | 1 - 2 files changed, 56 insertions(+), 57 deletions(-) diff --git a/bsp_q7s/core/CoreController.cpp b/bsp_q7s/core/CoreController.cpp index 2dcd204c..93df63a7 100644 --- a/bsp_q7s/core/CoreController.cpp +++ b/bsp_q7s/core/CoreController.cpp @@ -46,96 +46,96 @@ ReturnValue_t CoreController::sdCardInit() { << std::endl; } - auto sdStatus = std::pair(sd::SdStatus::OFF, sd::SdStatus::OFF); result = sdcMan->getSdCardActiveStatus(sdStatus); if(result != HasReturnvaluesIF::RETURN_OK) { sif::warning << "Getting SD card activity status failed" << std::endl; } + // Use a lambda to avoid duplicate code + auto setUpSdCard = [&](sd::SdCard sdCard, sd::SdStatus status, std::string sdString) { + std::string mountString; + if(sdCard == sd::SdCard::SLOT_0) { + mountString = SdCardManager::SD_0_MOUNT_POINT; + } + else { + mountString = SdCardManager::SD_1_MOUNT_POINT; + } + + if(status == sd::SdStatus::OFF) { + sif::info << "Switching on and mounting SD card " << sdString << " at " << + mountString << std::endl; + return sdcMan->switchOnSdCard(sdCard, true, &sdStatus); + } + else if(status == sd::SdStatus::ON) { + sif::info << "Mounting SD card " << sdString << " at " << mountString << std::endl; + return sdcMan->mountSdCard(sdCard); + } + else { + sif::info << "SD card " << sdString << " already on and mounted at " << + mountString << std::endl; + return SdCardManager::ALREADY_MOUNTED; + } + }; + #if Q7S_SD_CARD_CONFIG == Q7S_SD_COLD_REDUNDANT - sif::info << "Cold redundant SD card configuration" << std::endl; sd::SdCard preferredSdCard = sd::SdCard::SLOT_0; result = sdcMan->getPreferredSdCard(preferredSdCard); if(result != HasReturnvaluesIF::RETURN_OK) { sif::warning << "Could not get prefered SD card information from the scratch buffer" << std::endl; } - sd::SdCard otherSdc = sd::SdCard::SLOT_0; - std::string printoutString; + std::string preferredString; + sd::SdStatus preferredStatus = sd::SdStatus::OFF; + + sd::SdStatus otherStatus = sd::SdStatus::OFF; std::string otherString; + sd::SdCard otherSdc = sd::SdCard::SLOT_0; + + sif::info << "Cold redundant SD card configuration, preferred SD card " << + preferredString << std::endl; + if(preferredSdCard == sd::SdCard::SLOT_0) { - printoutString = "0"; + preferredStatus = sdStatus.first; + preferredString = "0"; otherSdc = sd::SdCard::SLOT_1; + otherStatus = sdStatus.second; otherString = "1"; } else { - printoutString = "1"; + preferredString = "1"; + preferredStatus = sdStatus.second; + otherStatus = sdStatus.first; otherSdc = sd::SdCard::SLOT_0; otherString = "0"; } - sd::SdStatus targetStatus = sd::SdStatus::OFF; - if(preferredSdCard == sd::SdCard::SLOT_0) { - targetStatus = sdStatus.first; - } - else if(preferredSdCard == sd::SdCard::SLOT_1) { - targetStatus = sdStatus.second; + result = setUpSdCard(preferredSdCard, preferredStatus, preferredString); + if(result != SdCardManager::ALREADY_MOUNTED and result != HasReturnvaluesIF::RETURN_OK) { + sif::warning << "Setting up preferred card " << otherString << + " in cold redundant mode failed" << std::endl; + // Try other SD card and mark set up operation as failed + setUpSdCard(otherSdc, otherStatus, otherString); + result = HasReturnvaluesIF::RETURN_FAILED; } - if(targetStatus == sd::SdStatus::MOUNTED) { - sif::info << "SD card " << printoutString << " is already switched on and mounted" << - std::endl; - result = HasReturnvaluesIF::RETURN_OK; - } - else if(targetStatus == sd::SdStatus::ON) { - sif::info << "Mounting SD card " << printoutString << std::endl; - result = sdcMan->mountSdCard(preferredSdCard); - if(result != HasReturnvaluesIF::RETURN_OK) { - sif::warning << "Mounting SD card failed" << std::endl; - } - } - else if(targetStatus == sd::SdStatus::OFF) { - sif::info << "Switching on and mounting SD card " << printoutString << std::endl; - result = sdcMan->switchOnSdCard(preferredSdCard, true); - if(result != HasReturnvaluesIF::RETURN_OK) { - sif::warning << "Switching on and mounting SD card failed" << std::endl; + if(result != HasReturnvaluesIF::RETURN_FAILED and otherStatus != sd::SdStatus::OFF) { + sif::info << "Switching off secondary SD card " << otherString << std::endl; + // Switch off other SD card in cold redundant mode if setting up preferred one walked + // without issues + result = sdcMan->switchOffSdCard(otherSdc, otherStatus, &sdStatus); + if(result != HasReturnvaluesIF::RETURN_OK and result != SdCardManager::ALREADY_OFF) { + sif::warning << "Switching off secondary SD card " << otherString << + " in cold redundant mode failed" << std::endl; } } - if(result != HasReturnvaluesIF::RETURN_OK) { - // This should not happen.. Switch on other SD card for now - sdcMan->switchOnSdCard(otherSdc, true); - return HasReturnvaluesIF::RETURN_FAILED; - } - - sif::info << "Switching off SD card " << otherString << std::endl; - // Switch off other SD card in cold-redundant mode - result = sdcMan->switchOffSdCard(otherSdc, true); - if(result != HasReturnvaluesIF::RETURN_OK) { - sif::warning << "Switching off SD card " << otherString << " failed" << std::endl; - } // Update status file sdcMan->updateSdCardStateFile(); return HasReturnvaluesIF::RETURN_OK; #elif Q7S_SD_CARD_CONFIG == Q7S_SD_HOT_REDUNDANT sif::info << "Hot redundant SD card configuration" << std::endl; - // Use a lambda to avoid duplicate code - auto setUpSdCard = [&](sd::SdCard sdCard, sd::SdStatus status, std::string sdString) { - if(status == sd::SdStatus::OFF) { - sif::info << "Switching on and mounting SD card " << sdString << std::endl; - sdcMan->switchOnSdCard(sdCard, true, &sdStatus); - } - else if(status == sd::SdStatus::ON) { - sif::info << "Mounting SD card " << sdString << std::endl; - sdcMan->mountSdCard(sdCard); - } - else { - sif::info << "SD card " << sdString << " already on and mounted" << std::endl; - } - }; - setUpSdCard(sd::SdCard::SLOT_0, sdStatus.first, "0"); setUpSdCard(sd::SdCard::SLOT_1, sdStatus.second, "1"); // Update status file diff --git a/bsp_q7s/memory/SdCardManager.cpp b/bsp_q7s/memory/SdCardManager.cpp index 537d3e77..b37f1195 100644 --- a/bsp_q7s/memory/SdCardManager.cpp +++ b/bsp_q7s/memory/SdCardManager.cpp @@ -217,7 +217,6 @@ ReturnValue_t SdCardManager::unmountSdCard(sd::SdCard sdCard) { sif::warning << "SdCardManager::unmountSdCard: Mount point is empty!" << std::endl; } string sdUnmountCommand = "umount " + mountPoint; - sif::debug << sdUnmountCommand << std::endl; int result = system(sdUnmountCommand.c_str()); if (result != 0) { utility::handleSystemError(result, "SdCardManager::unmountSdCard"); From 89b6eb8943140b15e31d63440565fc75a9fd4f4d Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Mon, 12 Jul 2021 15:58:43 +0200 Subject: [PATCH 105/111] some more fixes --- bsp_q7s/core/CoreController.cpp | 10 +++++----- bsp_q7s/memory/SdCardAccess.cpp | 2 +- bsp_q7s/memory/SdCardAccess.h | 2 +- bsp_q7s/memory/SdCardManager.cpp | 2 +- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/bsp_q7s/core/CoreController.cpp b/bsp_q7s/core/CoreController.cpp index 93df63a7..c4863260 100644 --- a/bsp_q7s/core/CoreController.cpp +++ b/bsp_q7s/core/CoreController.cpp @@ -4,7 +4,7 @@ #include "../memory/SdCardManager.h" CoreController::CoreController(object_id_t objectId): -ExtendedControllerBase(objectId, objects::NO_OBJECT, 5) { + ExtendedControllerBase(objectId, objects::NO_OBJECT, 5) { } ReturnValue_t CoreController::handleCommandMessage(CommandMessage *message) { @@ -82,7 +82,7 @@ ReturnValue_t CoreController::sdCardInit() { sd::SdCard preferredSdCard = sd::SdCard::SLOT_0; result = sdcMan->getPreferredSdCard(preferredSdCard); if(result != HasReturnvaluesIF::RETURN_OK) { - sif::warning << "Could not get prefered SD card information from the scratch buffer" + sif::warning << "Could not get preferred SD card information from the scratch buffer" << std::endl; } std::string preferredString; @@ -92,9 +92,6 @@ ReturnValue_t CoreController::sdCardInit() { std::string otherString; sd::SdCard otherSdc = sd::SdCard::SLOT_0; - sif::info << "Cold redundant SD card configuration, preferred SD card " << - preferredString << std::endl; - if(preferredSdCard == sd::SdCard::SLOT_0) { preferredStatus = sdStatus.first; preferredString = "0"; @@ -110,6 +107,9 @@ ReturnValue_t CoreController::sdCardInit() { otherString = "0"; } + sif::info << "Cold redundant SD card configuration, preferred SD card " << + preferredString << std::endl; + result = setUpSdCard(preferredSdCard, preferredStatus, preferredString); if(result != SdCardManager::ALREADY_MOUNTED and result != HasReturnvaluesIF::RETURN_OK) { sif::warning << "Setting up preferred card " << otherString << diff --git a/bsp_q7s/memory/SdCardAccess.cpp b/bsp_q7s/memory/SdCardAccess.cpp index 92837787..55efde98 100644 --- a/bsp_q7s/memory/SdCardAccess.cpp +++ b/bsp_q7s/memory/SdCardAccess.cpp @@ -2,6 +2,6 @@ #include "fsfw/ipc/MutexGuard.h" -SdCardAccess::SdCardAccess(sd::SdCard sdCard) { +SdCardAccess::SdCardAccess() { } diff --git a/bsp_q7s/memory/SdCardAccess.h b/bsp_q7s/memory/SdCardAccess.h index 8128b122..38dc3336 100644 --- a/bsp_q7s/memory/SdCardAccess.h +++ b/bsp_q7s/memory/SdCardAccess.h @@ -5,7 +5,7 @@ class SdCardAccess { public: - SdCardAccess(sd::SdCard sdCard); + SdCardAccess(); private: }; diff --git a/bsp_q7s/memory/SdCardManager.cpp b/bsp_q7s/memory/SdCardManager.cpp index b37f1195..36d8f67b 100644 --- a/bsp_q7s/memory/SdCardManager.cpp +++ b/bsp_q7s/memory/SdCardManager.cpp @@ -90,7 +90,7 @@ ReturnValue_t SdCardManager::switchOffSdCard(sd::SdCard sdCard, bool doUnmountSd if(result != HasReturnvaluesIF::RETURN_OK) { return result; } - // Not allowed, this function turns on off SD card + // Not allowed, this function turns off one SD card if(sdCard == sd::SdCard::BOTH) { sif::warning << "SdCardManager::switchOffSdCard: API does not allow sd::SdStatus::BOTH" << std::endl; From 91ff9f3f684871f276808ba61141870509c17298 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Mon, 12 Jul 2021 16:32:14 +0200 Subject: [PATCH 106/111] FS queue size configurable --- bsp_q7s/memory/CMakeLists.txt | 1 - bsp_q7s/memory/FileSystemHandler.cpp | 2 +- bsp_q7s/memory/FileSystemHandler.h | 6 ++++++ bsp_q7s/memory/SdCardAccess.cpp | 7 ------- bsp_q7s/memory/SdCardAccess.h | 13 ------------- bsp_q7s/memory/SdCardManager.h | 15 +++++++++++++-- linux/fsfwconfig/OBSWConfig.h.in | 2 ++ 7 files changed, 22 insertions(+), 24 deletions(-) delete mode 100644 bsp_q7s/memory/SdCardAccess.cpp delete mode 100644 bsp_q7s/memory/SdCardAccess.h diff --git a/bsp_q7s/memory/CMakeLists.txt b/bsp_q7s/memory/CMakeLists.txt index ada948fb..6c7d0a94 100644 --- a/bsp_q7s/memory/CMakeLists.txt +++ b/bsp_q7s/memory/CMakeLists.txt @@ -1,6 +1,5 @@ target_sources(${TARGET_NAME} PRIVATE FileSystemHandler.cpp - SdCardAccess.cpp SdCardManager.cpp scratchApi.cpp ) \ No newline at end of file diff --git a/bsp_q7s/memory/FileSystemHandler.cpp b/bsp_q7s/memory/FileSystemHandler.cpp index 5f7e0435..473a5167 100644 --- a/bsp_q7s/memory/FileSystemHandler.cpp +++ b/bsp_q7s/memory/FileSystemHandler.cpp @@ -6,7 +6,7 @@ FileSystemHandler::FileSystemHandler(object_id_t fileSystemHandler): SystemObject(fileSystemHandler) { - mq = QueueFactory::instance()->createMessageQueue(50); + mq = QueueFactory::instance()->createMessageQueue(FS_MAX_QUEUE_SIZE); } FileSystemHandler::~FileSystemHandler() { diff --git a/bsp_q7s/memory/FileSystemHandler.h b/bsp_q7s/memory/FileSystemHandler.h index 04cea3dc..803e52b7 100644 --- a/bsp_q7s/memory/FileSystemHandler.h +++ b/bsp_q7s/memory/FileSystemHandler.h @@ -1,11 +1,15 @@ #ifndef BSP_Q7S_MEMORY_FILESYSTEMHANDLER_H_ #define BSP_Q7S_MEMORY_FILESYSTEMHANDLER_H_ +#include "OBSWConfig.h" + #include "fsfw/ipc/MessageQueueIF.h" #include "fsfw/tasks/ExecutableObjectIF.h" #include "fsfw/objectmanager/SystemObject.h" #include "fsfw/memory/HasFileSystemIF.h" +#include + class FileSystemHandler: public SystemObject, public ExecutableObjectIF, public HasFileSystemIF { @@ -23,6 +27,8 @@ public: private: MessageQueueIF* mq = nullptr; + std::string currentMountPrefix; + static constexpr uint32_t FS_MAX_QUEUE_SIZE = config::OBSW_FILESYSTEM_HANDLER_QUEUE_SIZE; ReturnValue_t appendToFile(const char* repositoryPath, const char* filename, const uint8_t* data, size_t size, diff --git a/bsp_q7s/memory/SdCardAccess.cpp b/bsp_q7s/memory/SdCardAccess.cpp deleted file mode 100644 index 55efde98..00000000 --- a/bsp_q7s/memory/SdCardAccess.cpp +++ /dev/null @@ -1,7 +0,0 @@ -#include "SdCardAccess.h" - -#include "fsfw/ipc/MutexGuard.h" - -SdCardAccess::SdCardAccess() { - -} diff --git a/bsp_q7s/memory/SdCardAccess.h b/bsp_q7s/memory/SdCardAccess.h deleted file mode 100644 index 38dc3336..00000000 --- a/bsp_q7s/memory/SdCardAccess.h +++ /dev/null @@ -1,13 +0,0 @@ -#ifndef BSP_Q7S_MEMORY_SDCARDACCESS_H_ -#define BSP_Q7S_MEMORY_SDCARDACCESS_H_ - -#include "definitions.h" - -class SdCardAccess { -public: - SdCardAccess(); -private: -}; - - -#endif /* BSP_Q7S_MEMORY_SDCARDACCESS_H_ */ diff --git a/bsp_q7s/memory/SdCardManager.h b/bsp_q7s/memory/SdCardManager.h index 9a4dcbc5..d47b5322 100644 --- a/bsp_q7s/memory/SdCardManager.h +++ b/bsp_q7s/memory/SdCardManager.h @@ -56,8 +56,21 @@ public: */ static SdCardManager* instance(); + /** + * Set the preferred SD card which will determine which SD card will be used as the primary + * SD card in hot redundant and cold redundant mode. This function will not switch the + * SD cards which are currently on and mounted, this needs to be implemented by + * an upper layer by using #switchOffSdCard , #switchOnSdCard and #updateSdCardStateFile + * @param sdCard + * @return + */ ReturnValue_t setPreferredSdCard(sd::SdCard sdCard); + /** + * Get the currently configured preferred SD card + * @param sdCard + * @return + */ ReturnValue_t getPreferredSdCard(sd::SdCard& sdCard) const; /** @@ -124,8 +137,6 @@ private: ReturnValue_t setSdCardState(sd::SdCard sdCard, bool on); - sd::SdCard preferredSdCard = sd::SdCard::SLOT_0; - void processSdStatusLine(SdStatusPair& active, std::string& line, uint8_t& idx, sd::SdCard& currentSd); diff --git a/linux/fsfwconfig/OBSWConfig.h.in b/linux/fsfwconfig/OBSWConfig.h.in index a5a439ab..ef6b419d 100644 --- a/linux/fsfwconfig/OBSWConfig.h.in +++ b/linux/fsfwconfig/OBSWConfig.h.in @@ -14,6 +14,8 @@ #include "commonConfig.h" #include "OBSWVersion.h" +#define OBSW_FILESYSTEM_HANDLER_QUEUE_SIZE 50 + /* These defines should be disabled for mission code but are useful for debugging. */ #define OBSW_VERBOSE_LEVEL 1 From 74fdd90c073f2ad7ee273868008b430d841ae892 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Mon, 12 Jul 2021 17:23:32 +0200 Subject: [PATCH 107/111] starting file system handler --- bsp_q7s/memory/FileSystemHandler.cpp | 126 +++++++++++++++++++++------ bsp_q7s/memory/FileSystemHandler.h | 12 ++- bsp_q7s/memory/SdCardManager.cpp | 23 +++++ bsp_q7s/memory/SdCardManager.h | 13 +++ fsfw | 2 +- 5 files changed, 149 insertions(+), 27 deletions(-) diff --git a/bsp_q7s/memory/FileSystemHandler.cpp b/bsp_q7s/memory/FileSystemHandler.cpp index 473a5167..ba64a991 100644 --- a/bsp_q7s/memory/FileSystemHandler.cpp +++ b/bsp_q7s/memory/FileSystemHandler.cpp @@ -15,33 +15,85 @@ FileSystemHandler::~FileSystemHandler() { ReturnValue_t FileSystemHandler::performOperation(uint8_t unsignedChar) { while(true) { - CommandMessage filemsg; - ReturnValue_t result = HasReturnvaluesIF::RETURN_OK; - while(true) { - result = mq->receiveMessage(&filemsg); - if(result == MessageQueueIF::EMPTY) { - break; - } - else if(result != HasReturnvaluesIF::RETURN_FAILED) { - sif::warning << "FileSystemHandler::performOperation: Message reception failed!" - << std::endl; - break; - } - Command_t command = filemsg.getCommand(); - switch(command) { - case(GenericFileSystemMessage::CMD_CREATE_DIRECTORY): { - break; - } - case(GenericFileSystemMessage::CMD_CREATE_FILE): { - break; - } - } + try { + fileSystemHandlerLoop(); } + catch(std::bad_alloc& e) { + // Restart OBSW, hints at a memory leak + sif::error << "Allocation error in FileSystemHandler::performOperation" + << e.what() << std::endl; + // TODO: If we trigger an event, it might not get sent because were restarting + // Set up an error file or a special flag in the scratch buffer. + // TODO: CoreController: Implement function to restart OBC + } + } +} - // This task will have a low priority and will run permanently in the background - // so we will just run in a permanent loop here and check file system - // messages permanently - TaskFactory::instance()->delayTask(1000); + +void FileSystemHandler::fileSystemHandlerLoop() { + CommandMessage filemsg; + ReturnValue_t result = HasReturnvaluesIF::RETURN_OK; + while(true) { + if(opCounter % 5 == 0) { + fileSystemCheckup(); + } + result = mq->receiveMessage(&filemsg); + if(result == MessageQueueIF::EMPTY) { + break; + } + else if(result != HasReturnvaluesIF::RETURN_FAILED) { + sif::warning << "FileSystemHandler::performOperation: Message reception failed!" + << std::endl; + break; + } + Command_t command = filemsg.getCommand(); + switch(command) { + case(GenericFileSystemMessage::CMD_CREATE_DIRECTORY): { + break; + } + case(GenericFileSystemMessage::CMD_CREATE_FILE): { + break; + } + } + opCounter++; + } + + // This task will have a low priority and will run permanently in the background + // so we will just run in a permanent loop here and check file system + // messages permanently + TaskFactory::instance()->delayTask(1000); +} + +void FileSystemHandler::fileSystemCheckup() { + SdCardManager::SdStatusPair statusPair; + sdcMan->getSdCardActiveStatus(statusPair); + sd::SdCard preferredSdCard; + sdcMan->getPreferredSdCard(preferredSdCard); + if((preferredSdCard == sd::SdCard::SLOT_0) and + (statusPair.first == sd::SdStatus::MOUNTED)) { + currentMountPrefix = SdCardManager::SD_0_MOUNT_POINT; + } + if((preferredSdCard == sd::SdCard::SLOT_1) and + (statusPair.second == sd::SdStatus::MOUNTED)) { + currentMountPrefix = SdCardManager::SD_1_MOUNT_POINT; + } + else { + std::string sdString; + if(preferredSdCard == sd::SdCard::SLOT_0) { + sdString = "0"; + } + else { + sdString = "1"; + } + sif::warning << "FileSystemHandler::performOperation: Inconsistent" << + " state detected. Preferred SD card is " << sdString << + " but does not appear to be mounted. Attempting fix.." << std::endl; + // This function will appear to fix the inconsistent state + ReturnValue_t result = sdcMan->sanitizeState(&preferredSdCard, &statusPair); + if(result != HasReturnvaluesIF::RETURN_OK) { + // Oh no. Trigger medium severity event + sif::error << "Fix failed" << std::endl; + } } } @@ -49,6 +101,22 @@ MessageQueueId_t FileSystemHandler::getCommandQueue() const { return mq->getId(); } +ReturnValue_t FileSystemHandler::initialize() { + sdcMan = SdCardManager::instance(); + sd::SdCard preferredSdCard; + ReturnValue_t result = sdcMan->getPreferredSdCard(preferredSdCard); + if(result != HasReturnvaluesIF::RETURN_OK) { + return result; + } + if(preferredSdCard == sd::SdCard::SLOT_0) { + currentMountPrefix = SdCardManager::SD_0_MOUNT_POINT; + } + else if(preferredSdCard == sd::SdCard::SLOT_1) { + currentMountPrefix = SdCardManager::SD_1_MOUNT_POINT; + } + return HasReturnvaluesIF::RETURN_OK; +} + ReturnValue_t FileSystemHandler::appendToFile(const char *repositoryPath, const char *filename, const uint8_t *data, size_t size, uint16_t packetNumber, void *args) { return HasReturnvaluesIF::RETURN_OK; @@ -63,3 +131,11 @@ ReturnValue_t FileSystemHandler::deleteFile(const char *repositoryPath, const ch void *args) { return HasReturnvaluesIF::RETURN_OK; } + +ReturnValue_t FileSystemHandler::createDirectory(const char *repositoryPath, void *args) { + return HasReturnvaluesIF::RETURN_OK; +} + +ReturnValue_t FileSystemHandler::removeDirectory(const char *repositoryPath, void *args) { + return HasReturnvaluesIF::RETURN_OK; +} diff --git a/bsp_q7s/memory/FileSystemHandler.h b/bsp_q7s/memory/FileSystemHandler.h index 803e52b7..9d3285b1 100644 --- a/bsp_q7s/memory/FileSystemHandler.h +++ b/bsp_q7s/memory/FileSystemHandler.h @@ -1,6 +1,7 @@ #ifndef BSP_Q7S_MEMORY_FILESYSTEMHANDLER_H_ #define BSP_Q7S_MEMORY_FILESYSTEMHANDLER_H_ +#include #include "OBSWConfig.h" #include "fsfw/ipc/MessageQueueIF.h" @@ -19,6 +20,8 @@ public: ReturnValue_t performOperation(uint8_t) override; + ReturnValue_t initialize() override; + /** * Function to get the MessageQueueId_t of the implementing object * @return MessageQueueId_t of the object @@ -27,8 +30,13 @@ public: private: MessageQueueIF* mq = nullptr; - std::string currentMountPrefix; + std::string currentMountPrefix = SdCardManager::SD_0_MOUNT_POINT; static constexpr uint32_t FS_MAX_QUEUE_SIZE = config::OBSW_FILESYSTEM_HANDLER_QUEUE_SIZE; + SdCardManager* sdcMan = nullptr; + uint8_t opCounter = 0; + + void fileSystemHandlerLoop(); + void fileSystemCheckup(); ReturnValue_t appendToFile(const char* repositoryPath, const char* filename, const uint8_t* data, size_t size, @@ -38,6 +46,8 @@ private: size_t size = 0, void* args = nullptr) override; ReturnValue_t deleteFile(const char* repositoryPath, const char* filename, void* args = nullptr) override; + ReturnValue_t createDirectory(const char* repositoryPath, void* args = nullptr) override; + ReturnValue_t removeDirectory(const char* repositoryPath, void* args = nullptr) override; }; diff --git a/bsp_q7s/memory/SdCardManager.cpp b/bsp_q7s/memory/SdCardManager.cpp index 36d8f67b..5a50665b 100644 --- a/bsp_q7s/memory/SdCardManager.cpp +++ b/bsp_q7s/memory/SdCardManager.cpp @@ -7,6 +7,7 @@ #include "fsfw/serviceinterface/ServiceInterface.h" #include +#include #include SdCardManager* SdCardManager::factoryInstance = nullptr; @@ -225,6 +226,28 @@ ReturnValue_t SdCardManager::unmountSdCard(sd::SdCard sdCard) { return HasReturnvaluesIF::RETURN_OK; } +ReturnValue_t SdCardManager::sanitizeState(sd::SdCard* prefSdCard, SdStatusPair* statusPair) { + if(prefSdCard == nullptr) { + prefSdCard = std::make_unique(sd::SdCard::SLOT_0).get(); + getPreferredSdCard(*prefSdCard); + } + if(statusPair == nullptr) { + statusPair = std::make_unique().get(); + getSdCardActiveStatus(*statusPair); + } + + auto sanitizerFunc = [&](sd::SdCard prefSdCard) { + if(statusPair->first == sd::SdStatus::ON) { + return mountSdCard(prefSdCard); + } + else { + return switchOnSdCard(prefSdCard, true, statusPair); + } + }; + + return sanitizerFunc(*prefSdCard); +} + void SdCardManager::processSdStatusLine(std::pair &active, std::string& line, uint8_t& idx, sd::SdCard& currentSd) { using namespace std; diff --git a/bsp_q7s/memory/SdCardManager.h b/bsp_q7s/memory/SdCardManager.h index d47b5322..966e6e2a 100644 --- a/bsp_q7s/memory/SdCardManager.h +++ b/bsp_q7s/memory/SdCardManager.h @@ -132,6 +132,19 @@ public: */ ReturnValue_t unmountSdCard(sd::SdCard sdCard); + /** + * In case that there is a discrepancy between the preferred SD card and the currently + * mounted one, this function will sanitize the state by attempting to mount the + * currently preferred SD card. If the caller already has state information, it can be + * passed into the function. + * @param prefSdCard Preferred SD card captured with #getPreferredSdCard + * @param statusPair Current SD card status capture with #getSdCardActiveStatus + * @throws std::bad_alloc if one of the two arguments was a nullptr and an allocation failed + * @return + */ + ReturnValue_t sanitizeState(sd::SdCard* prefSdCard = nullptr, + SdStatusPair* statusPair = nullptr); + private: SdCardManager(); diff --git a/fsfw b/fsfw index eef2fd3b..323577cd 160000 --- a/fsfw +++ b/fsfw @@ -1 +1 @@ -Subproject commit eef2fd3b7ac764f06ed5d9a3c97c894d92a515fa +Subproject commit 323577cdc69ee2d863e6e61cebd71a8aa75c6d2b From 64aadf5e1e7224e87ec9981d62e37a024c44f9ac Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Mon, 12 Jul 2021 17:39:36 +0200 Subject: [PATCH 108/111] continued functions to create/delete dir --- bsp_q7s/memory/FileSystemHandler.cpp | 37 ++++++++++++++++++++++++++-- bsp_q7s/memory/FileSystemHandler.h | 3 ++- fsfw | 2 +- 3 files changed, 38 insertions(+), 4 deletions(-) diff --git a/bsp_q7s/memory/FileSystemHandler.cpp b/bsp_q7s/memory/FileSystemHandler.cpp index ba64a991..12c3a20b 100644 --- a/bsp_q7s/memory/FileSystemHandler.cpp +++ b/bsp_q7s/memory/FileSystemHandler.cpp @@ -4,6 +4,8 @@ #include "fsfw/memory/GenericFileSystemMessage.h" #include "fsfw/ipc/QueueFactory.h" +#include + FileSystemHandler::FileSystemHandler(object_id_t fileSystemHandler): SystemObject(fileSystemHandler) { mq = QueueFactory::instance()->createMessageQueue(FS_MAX_QUEUE_SIZE); @@ -133,9 +135,40 @@ ReturnValue_t FileSystemHandler::deleteFile(const char *repositoryPath, const ch } ReturnValue_t FileSystemHandler::createDirectory(const char *repositoryPath, void *args) { - return HasReturnvaluesIF::RETURN_OK; + std::string fullPath = currentMountPrefix + std::string(repositoryPath); + if(std::filesystem::exists(fullPath)) { + return DIRECTORY_ALREADY_EXISTS; + } + if(std::filesystem::create_directory(fullPath)) { + return HasReturnvaluesIF::RETURN_OK; + } + sif::warning << "Creating directory " << fullPath << " failed" << std::endl; + return GENERIC_FILE_ERROR; } -ReturnValue_t FileSystemHandler::removeDirectory(const char *repositoryPath, void *args) { +ReturnValue_t FileSystemHandler::removeDirectory(const char *repositoryPath, + bool deleteRecurively, void *args) { + std::string fullPath = currentMountPrefix + std::string(repositoryPath); + if(not std::filesystem::exists(fullPath)) { + return DIRECTORY_DOES_NOT_EXIST; + } + std::error_code err; + if(not deleteRecurively) { + if(std::filesystem::remove(fullPath, err)) { + return HasReturnvaluesIF::RETURN_OK; + } + else { + // Check error code. Most probably denied permissions because folder is not empty + } + } + else { + if(std::filesystem::remove_all(fullPath, err)) { + return HasReturnvaluesIF::RETURN_OK; + } + else { + // Check error code + } + } + return HasReturnvaluesIF::RETURN_OK; } diff --git a/bsp_q7s/memory/FileSystemHandler.h b/bsp_q7s/memory/FileSystemHandler.h index 9d3285b1..4f82566d 100644 --- a/bsp_q7s/memory/FileSystemHandler.h +++ b/bsp_q7s/memory/FileSystemHandler.h @@ -47,7 +47,8 @@ private: ReturnValue_t deleteFile(const char* repositoryPath, const char* filename, void* args = nullptr) override; ReturnValue_t createDirectory(const char* repositoryPath, void* args = nullptr) override; - ReturnValue_t removeDirectory(const char* repositoryPath, void* args = nullptr) override; + ReturnValue_t removeDirectory(const char* repositoryPath, bool deleteRecurively = false, + void* args = nullptr) override; }; diff --git a/fsfw b/fsfw index 323577cd..da8a4470 160000 --- a/fsfw +++ b/fsfw @@ -1 +1 @@ -Subproject commit 323577cdc69ee2d863e6e61cebd71a8aa75c6d2b +Subproject commit da8a4470734808bed4d872e47c192af694382c41 From d903da109eca66bab2849ad5be1e7a89504c2544 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Mon, 12 Jul 2021 17:41:13 +0200 Subject: [PATCH 109/111] added builder functions for full paths --- bsp_q7s/memory/FileSystemHandler.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/bsp_q7s/memory/FileSystemHandler.cpp b/bsp_q7s/memory/FileSystemHandler.cpp index 12c3a20b..02788b81 100644 --- a/bsp_q7s/memory/FileSystemHandler.cpp +++ b/bsp_q7s/memory/FileSystemHandler.cpp @@ -121,16 +121,25 @@ ReturnValue_t FileSystemHandler::initialize() { ReturnValue_t FileSystemHandler::appendToFile(const char *repositoryPath, const char *filename, const uint8_t *data, size_t size, uint16_t packetNumber, void *args) { + // A double slash between repo and filename should not be an issue, so add it in any case + std::string fullPath = currentMountPrefix + std::string(repositoryPath) + "/" + + std::string(filename); return HasReturnvaluesIF::RETURN_OK; } ReturnValue_t FileSystemHandler::createFile(const char *repositoryPath, const char *filename, const uint8_t *data, size_t size, void *args) { + // A double slash between repo and filename should not be an issue, so add it in any case + std::string fullPath = currentMountPrefix + std::string(repositoryPath) + "/" + + std::string(filename); return HasReturnvaluesIF::RETURN_OK; } ReturnValue_t FileSystemHandler::deleteFile(const char *repositoryPath, const char *filename, void *args) { + // A double slash between repo and filename should not be an issue, so add it in any case + std::string fullPath = currentMountPrefix + std::string(repositoryPath) + "/" + + std::string(filename); return HasReturnvaluesIF::RETURN_OK; } From 6c2c1e6552bdd6531d099bd5d19c450a9d317577 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Mon, 12 Jul 2021 17:50:01 +0200 Subject: [PATCH 110/111] minor changes --- bsp_q7s/memory/FileSystemHandler.cpp | 3 ++- bsp_q7s/memory/FileSystemHandler.h | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/bsp_q7s/memory/FileSystemHandler.cpp b/bsp_q7s/memory/FileSystemHandler.cpp index 02788b81..1519b92b 100644 --- a/bsp_q7s/memory/FileSystemHandler.cpp +++ b/bsp_q7s/memory/FileSystemHandler.cpp @@ -93,7 +93,8 @@ void FileSystemHandler::fileSystemCheckup() { // This function will appear to fix the inconsistent state ReturnValue_t result = sdcMan->sanitizeState(&preferredSdCard, &statusPair); if(result != HasReturnvaluesIF::RETURN_OK) { - // Oh no. Trigger medium severity event + // Oh no. + // TODO: Trigger medium severity event sif::error << "Fix failed" << std::endl; } } diff --git a/bsp_q7s/memory/FileSystemHandler.h b/bsp_q7s/memory/FileSystemHandler.h index 4f82566d..886fa574 100644 --- a/bsp_q7s/memory/FileSystemHandler.h +++ b/bsp_q7s/memory/FileSystemHandler.h @@ -1,7 +1,7 @@ #ifndef BSP_Q7S_MEMORY_FILESYSTEMHANDLER_H_ #define BSP_Q7S_MEMORY_FILESYSTEMHANDLER_H_ -#include +#include "SdCardManager.h" #include "OBSWConfig.h" #include "fsfw/ipc/MessageQueueIF.h" From 385eb6a7e5640ac1e8bad7ed816310e2571e2c20 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Thu, 22 Jul 2021 11:51:58 +0200 Subject: [PATCH 111/111] config option needs to be in config namespace --- linux/fsfwconfig/OBSWConfig.h.in | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/linux/fsfwconfig/OBSWConfig.h.in b/linux/fsfwconfig/OBSWConfig.h.in index ef6b419d..30b01491 100644 --- a/linux/fsfwconfig/OBSWConfig.h.in +++ b/linux/fsfwconfig/OBSWConfig.h.in @@ -14,8 +14,6 @@ #include "commonConfig.h" #include "OBSWVersion.h" -#define OBSW_FILESYSTEM_HANDLER_QUEUE_SIZE 50 - /* These defines should be disabled for mission code but are useful for debugging. */ #define OBSW_VERBOSE_LEVEL 1 @@ -66,6 +64,7 @@ namespace config { #endif /* Add mission configuration flags here */ +static constexpr uint32_t OBSW_FILESYSTEM_HANDLER_QUEUE_SIZE = 50; #ifdef __cplusplus }