From f8b9ce1d426f29c7dd74f23aae55004cc3b5fc1f Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Sat, 27 Feb 2021 21:39:32 +0100 Subject: [PATCH] updated init mission of hosted bsp and executed lwGPS test --- bsp_hosted/InitMission.cpp | 200 +++++++++--------- bsp_hosted/fsfwconfig/OBSWConfig.h | 4 +- common/config/CMakeLists.txt | 3 + common/config/commonConfig.h | 7 + fsfwconfig/OBSWConfig.h | 1 + .../Host/eive-mingw-debug-cmake.launch | 4 +- test/testtasks/TestTask.cpp | 47 +++- test/testtasks/TestTask.h | 2 + thirdparty/lwgps | 2 +- 9 files changed, 163 insertions(+), 107 deletions(-) create mode 100644 common/config/commonConfig.h diff --git a/bsp_hosted/InitMission.cpp b/bsp_hosted/InitMission.cpp index 5ed5775d..06bc5646 100644 --- a/bsp_hosted/InitMission.cpp +++ b/bsp_hosted/InitMission.cpp @@ -15,7 +15,6 @@ #include -// This is configured for linux without \cr #ifdef LINUX ServiceInterfaceStream sif::debug("DEBUG"); ServiceInterfaceStream sif::info("INFO"); @@ -31,8 +30,8 @@ ServiceInterfaceStream sif::error("ERROR", true, false, true); ObjectManagerIF *objectManager = nullptr; void initmission::initMission() { - sif::info << "Building global objects.." << std::endl; - /* Instantiate global object manager and also create all objects */ + sif::info << "Building global objects.." << std::endl; + /* Instantiate global object manager and also create all objects */ objectManager = new ObjectManager(ObjectFactory::produce); sif::info << "Initializing all objects.." << std::endl; objectManager->initialize(); @@ -41,117 +40,120 @@ void initmission::initMission() { initTasks(); } -void initmission::initTasks(){ - /* TMTC Distribution */ - PeriodicTaskIF* TmTcDistributor = TaskFactory::instance()-> - createPeriodicTask("DIST", 40, PeriodicTaskIF::MINIMUM_STACK_SIZE, - 0.100, nullptr); - ReturnValue_t result = TmTcDistributor->addComponent( - objects::CCSDS_PACKET_DISTRIBUTOR); - if(result!=HasReturnvaluesIF::RETURN_OK){ - sif::error << "Object add component failed" << std::endl; - } - result = TmTcDistributor->addComponent(objects::PUS_PACKET_DISTRIBUTOR); - if(result!=HasReturnvaluesIF::RETURN_OK){ - sif::error << "Object add component failed" << std::endl; - } - result = TmTcDistributor->addComponent(objects::TM_FUNNEL); +void initmission::initTasks() { + TaskFactory* factory = TaskFactory::instance(); + if(factory == nullptr) { + /* Should never happen ! */ + return; + } +#if OBSW_PRINT_MISSED_DEADLINES == 1 + void (*missedDeadlineFunc) (void) = TaskFactory::printMissedDeadline; +#else + void (*missedDeadlineFunc) (void) = nullptr; +#endif + + /* TMTC Distribution */ + PeriodicTaskIF* tmTcDistributor = factory->createPeriodicTask( + "DIST", 40, PeriodicTaskIF::MINIMUM_STACK_SIZE, 0.2, missedDeadlineFunc); + ReturnValue_t result = tmTcDistributor->addComponent( + objects::CCSDS_PACKET_DISTRIBUTOR); + if(result != HasReturnvaluesIF::RETURN_OK){ + sif::error << "Object add component failed" << std::endl; + } + result = tmTcDistributor->addComponent(objects::PUS_PACKET_DISTRIBUTOR); + if(result != HasReturnvaluesIF::RETURN_OK){ + sif::error << "Object add component failed" << std::endl; + } + result = tmTcDistributor->addComponent(objects::TM_FUNNEL); if(result != HasReturnvaluesIF::RETURN_OK) { - sif::error << "Object add component failed" << std::endl; + sif::error << "Object add component failed" << std::endl; } /* UDP bridge */ - PeriodicTaskIF* UdpBridgeTask = TaskFactory::instance()->createPeriodicTask( - "UDP_UNIX_BRIDGE", 50, PeriodicTaskIF::MINIMUM_STACK_SIZE, - 0.2, nullptr); - result = UdpBridgeTask->addComponent(objects::UDP_BRIDGE); + PeriodicTaskIF* udpBridgeTask = factory->createPeriodicTask( + "UDP_UNIX_BRIDGE", 50, PeriodicTaskIF::MINIMUM_STACK_SIZE, 0.2, missedDeadlineFunc); + result = udpBridgeTask->addComponent(objects::UDP_BRIDGE); if(result != HasReturnvaluesIF::RETURN_OK) { - sif::error << "Add component UDP Unix Bridge failed" << std::endl; + sif::error << "Add component UDP Unix Bridge failed" << std::endl; } - PeriodicTaskIF* UdpPollingTask = TaskFactory::instance()-> - createPeriodicTask("UDP_POLLING", 80, - PeriodicTaskIF::MINIMUM_STACK_SIZE, 2.0, nullptr); - result = UdpPollingTask->addComponent(objects::UDP_POLLING_TASK); + PeriodicTaskIF* udpPollingTask = factory->createPeriodicTask( + "UDP_POLLING", 80, PeriodicTaskIF::MINIMUM_STACK_SIZE, 2.0, missedDeadlineFunc); + result = udpPollingTask->addComponent(objects::UDP_POLLING_TASK); if(result != HasReturnvaluesIF::RETURN_OK) { - sif::error << "Add component UDP Polling failed" << std::endl; + sif::error << "Add component UDP Polling failed" << std::endl; } - /* PUS Services */ - PeriodicTaskIF* PusVerification = TaskFactory::instance()-> - createPeriodicTask("PUS_VERIF_1", 40, - PeriodicTaskIF::MINIMUM_STACK_SIZE, 0.200, nullptr); - result = PusVerification->addComponent(objects::PUS_SERVICE_1_VERIFICATION); - if(result != HasReturnvaluesIF::RETURN_OK){ - sif::error << "Object add component failed" << std::endl; - } + /* PUS Services */ + PeriodicTaskIF* pusVerification = factory->createPeriodicTask( + "PUS_VERIF", 40, PeriodicTaskIF::MINIMUM_STACK_SIZE, 0.200, missedDeadlineFunc); + result = pusVerification->addComponent(objects::PUS_SERVICE_1_VERIFICATION); + if(result != HasReturnvaluesIF::RETURN_OK){ + sif::error << "Object add component failed" << std::endl; + } - PeriodicTaskIF* PusEvents = TaskFactory::instance()-> - createPeriodicTask("PUS_VERIF_1", 60, - PeriodicTaskIF::MINIMUM_STACK_SIZE, 0.200, nullptr); - result = PusVerification->addComponent(objects::PUS_SERVICE_5_EVENT_REPORTING); - if(result != HasReturnvaluesIF::RETURN_OK){ - sif::error << "Object add component failed" << std::endl; - } + PeriodicTaskIF* pusEvents = factory->createPeriodicTask( + "PUS_EVENTS", 60, PeriodicTaskIF::MINIMUM_STACK_SIZE, 0.200, missedDeadlineFunc); + result = pusVerification->addComponent(objects::PUS_SERVICE_5_EVENT_REPORTING); + if(result != HasReturnvaluesIF::RETURN_OK){ + initmission::printAddObjectError("PUS5", objects::PUS_SERVICE_5_EVENT_REPORTING); + } - PeriodicTaskIF* PusHighPrio = TaskFactory::instance()-> - createPeriodicTask("PUS_HIGH_PRIO", 50, - PeriodicTaskIF::MINIMUM_STACK_SIZE, - 0.200, nullptr); - result = PusHighPrio->addComponent(objects::PUS_SERVICE_2_DEVICE_ACCESS); - if(result!=HasReturnvaluesIF::RETURN_OK){ - sif::error << "Object add component failed" << std::endl; - } - result = PusHighPrio->addComponent(objects::PUS_SERVICE_9_TIME_MGMT); - if(result!=HasReturnvaluesIF::RETURN_OK){ - sif::error << "Object add component failed" << std::endl; - } + PeriodicTaskIF* pusHighPrio = factory->createPeriodicTask( + "PUS_HIGH_PRIO", 50, PeriodicTaskIF::MINIMUM_STACK_SIZE, 0.200, missedDeadlineFunc); + result = pusHighPrio->addComponent(objects::PUS_SERVICE_2_DEVICE_ACCESS); + if(result != HasReturnvaluesIF::RETURN_OK) { + initmission::printAddObjectError("PUS2", objects::PUS_SERVICE_2_DEVICE_ACCESS); + } + result = pusHighPrio->addComponent(objects::PUS_SERVICE_9_TIME_MGMT); + if(result != HasReturnvaluesIF::RETURN_OK) { + initmission::printAddObjectError("PUS9", objects::PUS_SERVICE_9_TIME_MGMT); + } - PeriodicTaskIF* PusMedPrio = TaskFactory::instance()-> - createPeriodicTask("PUS_HIGH_PRIO", 40, - PeriodicTaskIF::MINIMUM_STACK_SIZE, - 0.8, nullptr); - result = PusMedPrio->addComponent(objects::PUS_SERVICE_8_FUNCTION_MGMT); - if(result!=HasReturnvaluesIF::RETURN_OK){ - sif::error << "Object add component failed" << std::endl; - } - result = PusMedPrio->addComponent(objects::PUS_SERVICE_200_MODE_MGMT); - if(result!=HasReturnvaluesIF::RETURN_OK){ - sif::error << "Object add component failed" << std::endl; - } + PeriodicTaskIF* pusMedPrio = factory->createPeriodicTask( + "PUS_MED_PRIO", 40, PeriodicTaskIF::MINIMUM_STACK_SIZE, 0.8, missedDeadlineFunc); + result = pusMedPrio->addComponent(objects::PUS_SERVICE_8_FUNCTION_MGMT); + if(result != HasReturnvaluesIF::RETURN_OK) { + initmission::printAddObjectError("PUS8", objects::PUS_SERVICE_8_FUNCTION_MGMT); + } + result = pusMedPrio->addComponent(objects::PUS_SERVICE_200_MODE_MGMT); + if(result != HasReturnvaluesIF::RETURN_OK) { + initmission::printAddObjectError("PUS200", objects::PUS_SERVICE_200_MODE_MGMT); + } + result = pusMedPrio->addComponent(objects::PUS_SERVICE_20_PARAMETERS); + if(result != HasReturnvaluesIF::RETURN_OK) { + initmission::printAddObjectError("PUS20", objects::PUS_SERVICE_20_PARAMETERS); + } - PeriodicTaskIF* PusLowPrio = TaskFactory::instance()-> - createPeriodicTask("PUSB", 30, PeriodicTaskIF::MINIMUM_STACK_SIZE, - 1.6, nullptr); - result = PusLowPrio->addComponent(objects::PUS_SERVICE_17_TEST); - if(result!=HasReturnvaluesIF::RETURN_OK){ - sif::error << "Object add component failed" << std::endl; - } + PeriodicTaskIF* pusLowPrio = factory->createPeriodicTask( + "PUS_LOW_PRIO", 30, PeriodicTaskIF::MINIMUM_STACK_SIZE, 1.6, missedDeadlineFunc); + result = pusLowPrio->addComponent(objects::PUS_SERVICE_17_TEST); + if(result != HasReturnvaluesIF::RETURN_OK) { + initmission::printAddObjectError("PUS17", objects::PUS_SERVICE_17_TEST); + } + PeriodicTaskIF* testTask = factory->createPeriodicTask( + "TEST_TASK", 40, PeriodicTaskIF::MINIMUM_STACK_SIZE, 2.0, missedDeadlineFunc); +#if OBSW_ADD_TEST_CODE == 1 + result = testTask->addComponent(objects::TEST_TASK); + if(result != HasReturnvaluesIF::RETURN_OK) { + initmission::printAddObjectError("TEST_TASK", objects::TEST_TASK); + } +#endif /* OBSW_ADD_TEST_CODE == 1 */ + + sif::info << "Starting tasks.." << std::endl; + tmTcDistributor->startTask(); + udpBridgeTask->startTask(); + udpPollingTask->startTask(); + + pusVerification->startTask(); + pusEvents->startTask(); + pusHighPrio->startTask(); + pusMedPrio->startTask(); + pusLowPrio->startTask(); #if OBSW_ADD_TEST_CODE == 1 - FixedTimeslotTaskIF* TestTimeslotTask = TaskFactory::instance()-> - createFixedTimeslotTask("PST_TEST_TASK", 10, - PeriodicTaskIF::MINIMUM_STACK_SIZE, 1.0, nullptr); - result = pst::pollingSequenceTestFunction(TestTimeslotTask); - if(result != HasReturnvaluesIF::RETURN_OK) { - sif::error << "InitMission::createTasks: Test PST initialization " - << "failed!" << std::endl; - } -#endif + testTask->startTask(); +#endif /* OBSW_ADD_TEST_CODE == 1 */ - //Main thread sleep - sif::info << "Starting tasks.." << std::endl; - TmTcDistributor->startTask(); - UdpBridgeTask->startTask(); - UdpPollingTask->startTask(); - - PusVerification->startTask(); - PusEvents->startTask(); - PusHighPrio->startTask(); - PusMedPrio->startTask(); - PusLowPrio->startTask(); -#if OBSW_ADD_TEST_CODE == 1 - TestTimeslotTask->startTask(); -#endif - sif::info << "Tasks started.." << std::endl; + sif::info << "Tasks started.." << std::endl; } diff --git a/bsp_hosted/fsfwconfig/OBSWConfig.h b/bsp_hosted/fsfwconfig/OBSWConfig.h index b784cd03..5996e3a2 100644 --- a/bsp_hosted/fsfwconfig/OBSWConfig.h +++ b/bsp_hosted/fsfwconfig/OBSWConfig.h @@ -6,7 +6,9 @@ #ifndef CONFIG_OBSWCONFIG_H_ #define CONFIG_OBSWCONFIG_H_ -#define OBSW_ADD_TEST_CODE 0 +#include "commonConfig.h" + +#define OBSW_ADD_TEST_CODE 1 /* These defines should be disabled for mission code but are useful for debugging. */ diff --git a/common/config/CMakeLists.txt b/common/config/CMakeLists.txt index e69de29b..f38f2c50 100644 --- a/common/config/CMakeLists.txt +++ b/common/config/CMakeLists.txt @@ -0,0 +1,3 @@ +target_include_directories(${TARGET_NAME} PRIVATE + ${CMAKE_CURRENT_SOURCE_DIR} +) \ No newline at end of file diff --git a/common/config/commonConfig.h b/common/config/commonConfig.h new file mode 100644 index 00000000..6c5cb4c4 --- /dev/null +++ b/common/config/commonConfig.h @@ -0,0 +1,7 @@ +#ifndef COMMON_CONFIG_COMMONCONFIG_H_ +#define COMMON_CONFIG_COMMONCONFIG_H_ + +#define OBSW_ADD_LWGPS_TEST 0 + + +#endif /* COMMON_CONFIG_COMMONCONFIG_H_ */ diff --git a/fsfwconfig/OBSWConfig.h b/fsfwconfig/OBSWConfig.h index d4220b9e..f40fbec3 100644 --- a/fsfwconfig/OBSWConfig.h +++ b/fsfwconfig/OBSWConfig.h @@ -9,6 +9,7 @@ #ifdef RASPBERRY_PI #include #endif +#include "commonConfig.h" #include "OBSWVersion.h" /* These defines should be disabled for mission code but are useful for diff --git a/misc/eclipse/Host/eive-mingw-debug-cmake.launch b/misc/eclipse/Host/eive-mingw-debug-cmake.launch index 3552a26b..d31b97e9 100644 --- a/misc/eclipse/Host/eive-mingw-debug-cmake.launch +++ b/misc/eclipse/Host/eive-mingw-debug-cmake.launch @@ -4,7 +4,7 @@ - + @@ -18,7 +18,7 @@ - + diff --git a/test/testtasks/TestTask.cpp b/test/testtasks/TestTask.cpp index 4b80c127..b413a7cc 100644 --- a/test/testtasks/TestTask.cpp +++ b/test/testtasks/TestTask.cpp @@ -1,4 +1,6 @@ -#include +#include "TestTask.h" +#include + #include #include #include @@ -42,11 +44,32 @@ ReturnValue_t TestTask::performOperation(uint8_t operationCode) { } #include +#include + +/** + * @brief Dummy data from GPS receiver. Will be replaced witgh hyperion data later. + */ +const char +gps_rx_data[] = "" + "$GPRMC,183729,A,3907.356,N,12102.482,W,000.0,360.0,080301,015.5,E*6F\r\n" + "$GPRMB,A,,,,,,,,,,,,V*71\r\n" + "$GPGGA,183730,3907.356,N,12102.482,W,1,05,1.6,646.4,M,-24.1,M,,*75\r\n" + "$GPGSA,A,3,02,,,07,,09,24,26,,,,,1.6,1.6,1.0*3D\r\n" + "$GPGSV,2,1,08,02,43,088,38,04,42,145,00,05,11,291,00,07,60,043,35*71\r\n" + "$GPGSV,2,2,08,08,02,145,00,09,46,303,47,24,16,178,32,26,18,231,43*77\r\n" + "$PGRME,22.0,M,52.9,M,51.0,M*14\r\n" + "$GPGLL,3907.360,N,12102.481,W,183730,A*33\r\n" + "$PGRMZ,2062,f,3*2D\r\n" + "$PGRMM,WGS84*06\r\n" + "$GPBOD,,T,,M,,*47\r\n" + "$GPRTE,1,1,c,0*07\r\n" + "$GPRMC,183731,A,3907.482,N,12102.436,W,000.0,360.0,080301,015.5,E*67\r\n" + "$GPRMB,A,,,,,,,,,,,,V*71\r\n"; ReturnValue_t TestTask::performOneShotAction() { - /* Everything here will only be performed once. */ - etl::vector testVec; - +#if OBSW_ADD_TEST_CODE == 1 + performLwgpsTest(); +#endif return HasReturnvaluesIF::RETURN_OK; } @@ -67,3 +90,19 @@ ReturnValue_t TestTask::performActionB() { /* Add periodically executed code here */ return result; } + +void TestTask::performLwgpsTest() { + /* Everything here will only be performed once. */ + etl::vector testVec; + + lwgps_t gpsStruct; + + /* Process all input data */ + lwgps_process(&gpsStruct, gps_rx_data, strlen(gps_rx_data)); + + /* Print messages */ + printf("Valid status: %d\r\n", gpsStruct.is_valid); + printf("Latitude: %f degrees\r\n", gpsStruct.latitude); + printf("Longitude: %f degrees\r\n", gpsStruct.longitude); + printf("Altitude: %f meters\r\n", gpsStruct.altitude); +} diff --git a/test/testtasks/TestTask.h b/test/testtasks/TestTask.h index fef1ff0e..e2e8db48 100644 --- a/test/testtasks/TestTask.h +++ b/test/testtasks/TestTask.h @@ -50,6 +50,8 @@ private: // Let's keep it simple for now. bool oneShotAction = true; StorageManagerIF* IPCStore; + + void performLwgpsTest(); }; diff --git a/thirdparty/lwgps b/thirdparty/lwgps index adce7a20..ceba10e5 160000 --- a/thirdparty/lwgps +++ b/thirdparty/lwgps @@ -1 +1 @@ -Subproject commit adce7a203268ca809fa61e6e286e62ff25edeb34 +Subproject commit ceba10e5616b6419a3b61ea2d608ad345d49b1e2