From 2331637350fdde889b170d2e674d7db4075c5231 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Thu, 24 Jun 2021 08:50:46 +0200 Subject: [PATCH] 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;