From 2fd46871088a5913c4c7c9834d0eb2247ffd54d5 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Mon, 27 Sep 2021 11:20:00 +0200 Subject: [PATCH 01/18] fsfw update --- fsfw | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fsfw b/fsfw index a84c770d..98deac1e 160000 --- a/fsfw +++ b/fsfw @@ -1 +1 @@ -Subproject commit a84c770dfb8447325c263da42d5cecd99b38d1f0 +Subproject commit 98deac1ef1a5d100e9a29adc8bc9552a88e5dc62 -- 2.43.0 From 55a274a6e317f861d98c59a8fd043844f404711f Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Tue, 28 Sep 2021 10:59:09 +0200 Subject: [PATCH 02/18] fsfw and tmtc update --- fsfw | 2 +- tmtc | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/fsfw b/fsfw index 98deac1e..254aac51 160000 --- a/fsfw +++ b/fsfw @@ -1 +1 @@ -Subproject commit 98deac1ef1a5d100e9a29adc8bc9552a88e5dc62 +Subproject commit 254aac51ec1234b44eefafd7425b62e54f348958 diff --git a/tmtc b/tmtc index 53bf6508..82495ad7 160000 --- a/tmtc +++ b/tmtc @@ -1 +1 @@ -Subproject commit 53bf65083889af10f77c3899972b1153ea835f3c +Subproject commit 82495ad785c83440ee90846bce70be1659b66209 -- 2.43.0 From 8acb0c3c0218d569f29c870a5ae980c34e85111f Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Tue, 28 Sep 2021 11:34:43 +0200 Subject: [PATCH 03/18] fsfw update --- fsfw | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fsfw b/fsfw index 254aac51..5fd7a8c9 160000 --- a/fsfw +++ b/fsfw @@ -1 +1 @@ -Subproject commit 254aac51ec1234b44eefafd7425b62e54f348958 +Subproject commit 5fd7a8c9b76bae2d7d019e0175b481083e7ba460 -- 2.43.0 From e5d0dac65e14d60c278f1bfd47a3f9f05be44f0e Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Tue, 28 Sep 2021 14:58:12 +0200 Subject: [PATCH 04/18] tcpip components refactoring --- bsp_q7s/core/InitMission.cpp | 12 +++++++--- bsp_q7s/core/ObjectFactory.cpp | 24 +------------------- common/config/CMakeLists.txt | 4 ++++ common/config/commonConfig.cpp | 5 +++++ common/config/commonConfig.h.in | 10 ++++++++- fsfw | 2 +- mission/core/GenericFactory.cpp | 39 +++++++++++++++++++++++++++++---- 7 files changed, 64 insertions(+), 32 deletions(-) create mode 100644 common/config/commonConfig.cpp diff --git a/bsp_q7s/core/InitMission.cpp b/bsp_q7s/core/InitMission.cpp index bc9139fb..deda0ed8 100644 --- a/bsp_q7s/core/InitMission.cpp +++ b/bsp_q7s/core/InitMission.cpp @@ -82,19 +82,21 @@ void initmission::initTasks() { initmission::printAddObjectError("TM_FUNNEL", objects::TM_FUNNEL); } - /* UDP bridge */ +#if OBSW_ADD_TCPIP_BRIDGE == 1 + // TMTC bridge PeriodicTaskIF* tmtcBridgeTask = factory->createPeriodicTask( - "UDP_UNIX_BRIDGE", 50, PeriodicTaskIF::MINIMUM_STACK_SIZE, 0.2, missedDeadlineFunc); + "TCPIP_TMTC_BRIDGE", 50, PeriodicTaskIF::MINIMUM_STACK_SIZE, 0.2, missedDeadlineFunc); result = tmtcBridgeTask->addComponent(objects::TMTC_BRIDGE); if(result != HasReturnvaluesIF::RETURN_OK) { initmission::printAddObjectError("UDP_BRIDGE", objects::TMTC_BRIDGE); } PeriodicTaskIF* tmtcPollingTask = factory->createPeriodicTask( - "UDP_POLLING", 80, PeriodicTaskIF::MINIMUM_STACK_SIZE, 2.0, missedDeadlineFunc); + "TMTC_POLLING", 80, PeriodicTaskIF::MINIMUM_STACK_SIZE, 2.0, missedDeadlineFunc); result = tmtcPollingTask->addComponent(objects::TMTC_POLLING_TASK); if(result != HasReturnvaluesIF::RETURN_OK) { initmission::printAddObjectError("UDP_POLLING", objects::TMTC_POLLING_TASK); } +#endif # if BOARD_TE0720 == 0 // FS task, task interval does not matter because it runs in permanent loop, priority low @@ -139,8 +141,12 @@ void initmission::initTasks() { sif::info << "Starting tasks.." << std::endl; tmTcDistributor->startTask(); + +#if OBSW_ADD_TCPIP_BRIDGE == 1 tmtcBridgeTask->startTask(); tmtcPollingTask->startTask(); +#endif + #if BOARD_TE0720 == 0 coreController->startTask(); #endif diff --git a/bsp_q7s/core/ObjectFactory.cpp b/bsp_q7s/core/ObjectFactory.cpp index e0cc084d..b916977a 100644 --- a/bsp_q7s/core/ObjectFactory.cpp +++ b/bsp_q7s/core/ObjectFactory.cpp @@ -69,16 +69,6 @@ #include "fsfw/tmtcservices/PusServiceBase.h" #include "fsfw/tmtcpacket/pus/tm.h" -#if OBSW_USE_TMTC_TCP_BRIDGE == 0 -// UDP server includes -#include "fsfw/osal/common/UdpTmTcBridge.h" -#include "fsfw/osal/common/UdpTcPollingTask.h" -#else -// TCP server includes -#include "fsfw/osal/common/TcpTmTcBridge.h" -#include "fsfw/osal/common/TcpTmTcServer.h" -#endif - #include "linux/boardtest/SpiTestClass.h" #if OBSW_TEST_LIBGPIOD == 1 @@ -114,6 +104,7 @@ void Factory::setStaticFrameworkObjectIds() { void ObjectFactory::produce(void* args) { ObjectFactory::setStatics(); ObjectFactory::produceGenericObjects(); + LinuxLibgpioIF* gpioComIF = nullptr; UartComIF* uartComIF = nullptr; SpiComIF* spiComIF = nullptr; @@ -173,19 +164,6 @@ void ObjectFactory::produce(void* args) { #endif /* TE7020 != 0 */ -#if OBSW_USE_TMTC_TCP_BRIDGE == 0 - auto udpBridge = new UdpTmTcBridge(objects::TMTC_BRIDGE, objects::CCSDS_PACKET_DISTRIBUTOR); - new UdpTcPollingTask(objects::TMTC_POLLING_TASK, objects::TMTC_BRIDGE); - sif::info << "Created UDP server for TMTC commanding with listener port " << - udpBridge->getUdpPort() << std::endl; -#else - auto tmtcBridge = new TcpTmTcBridge(objects::TMTC_BRIDGE, objects::CCSDS_PACKET_DISTRIBUTOR); - tmtcBridge->setMaxNumberOfPacketsStored(50); - auto tcpServer = new TcpTmTcServer(objects::TMTC_POLLING_TASK, objects::TMTC_BRIDGE); - sif::info << "Created TCP server for TMTC commanding with listener port " - << tcpServer->getTcpPort() << std::endl; -#endif /* OBSW_USE_TMTC_TCP_BRIDGE == 0 */ - /* Test Task */ #if OBSW_ADD_TEST_CODE == 1 createTestComponents(gpioComIF); diff --git a/common/config/CMakeLists.txt b/common/config/CMakeLists.txt index f38f2c50..5c4b4942 100644 --- a/common/config/CMakeLists.txt +++ b/common/config/CMakeLists.txt @@ -1,3 +1,7 @@ target_include_directories(${TARGET_NAME} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} +) + +target_sources(${TARGET_NAME} PRIVATE + commonConfig.cpp ) \ No newline at end of file diff --git a/common/config/commonConfig.cpp b/common/config/commonConfig.cpp new file mode 100644 index 00000000..b15a14c5 --- /dev/null +++ b/common/config/commonConfig.cpp @@ -0,0 +1,5 @@ +#include "commonConfig.h" +#include "tmtc/apid.h" +#include "fsfw/tmtcpacket/SpacePacket.h" + +const uint16_t common::TC_PACKET_ID = SpacePacket::getTcSpacePacketIdFromApid(apid::EIVE_OBSW); diff --git a/common/config/commonConfig.h.in b/common/config/commonConfig.h.in index 52b5dd45..055f86aa 100644 --- a/common/config/commonConfig.h.in +++ b/common/config/commonConfig.h.in @@ -1,10 +1,18 @@ #ifndef COMMON_CONFIG_COMMONCONFIG_H_ #define COMMON_CONFIG_COMMONCONFIG_H_ +#include + #define OBSW_ADD_LWGPS_TEST 0 +// Disable this for mission code. It allows exchanging TMTC packets via the Ethernet port +#define OBSW_ADD_TCPIP_BRIDGE 1 // Use TCP instead of UDP for the TMTC bridge. This allows using the TMTC client locally // because UDP packets are not allowed in the VPN -#define OBSW_USE_TMTC_TCP_BRIDGE 1 +#define OBSW_USE_TCP_BRIDGE 1 + +namespace common { +extern const uint16_t TC_PACKET_ID; +} #endif /* COMMON_CONFIG_COMMONCONFIG_H_ */ diff --git a/fsfw b/fsfw index 5fd7a8c9..c7ce568a 160000 --- a/fsfw +++ b/fsfw @@ -1 +1 @@ -Subproject commit 5fd7a8c9b76bae2d7d019e0175b481083e7ba460 +Subproject commit c7ce568a302538ef98e308add1bcae632563c48e diff --git a/mission/core/GenericFactory.cpp b/mission/core/GenericFactory.cpp index 4ee1ff70..df15025b 100644 --- a/mission/core/GenericFactory.cpp +++ b/mission/core/GenericFactory.cpp @@ -23,12 +23,24 @@ #include #include +#if OBSW_ADD_TCPIP_BRIDGE == 1 +#if OBSW_USE_TCP_BRIDGE == 0 +// UDP server includes +#include "fsfw/osal/common/UdpTmTcBridge.h" +#include "fsfw/osal/common/UdpTcPollingTask.h" +#else +// TCP server includes +#include "fsfw/osal/common/TcpTmTcBridge.h" +#include "fsfw/osal/common/TcpTmTcServer.h" +#endif +#endif + #if OBSW_ADD_TEST_CODE == 1 - #include +#include #endif void ObjectFactory::produceGenericObjects() { - /* Framework objects */ + // Framework objects new EventManager(objects::EVENT_MANAGER); new HealthTable(objects::HEALTH_TABLE); new InternalErrorReporter(objects::INTERNAL_ERROR_REPORTER); @@ -61,10 +73,10 @@ void ObjectFactory::produceGenericObjects() { objects::CCSDS_PACKET_DISTRIBUTOR); - /* TMTC Reception via UDP socket */ + // Every TM packet goes through this funnel new TmFunnel(objects::TM_FUNNEL); - /* PUS stack */ + // PUS service stack new Service1TelecommandVerification(objects::PUS_SERVICE_1_VERIFICATION, apid::EIVE_OBSW, pus::PUS_SERVICE_1, objects::TM_FUNNEL, 20); new Service2DeviceAccess(objects::PUS_SERVICE_2_DEVICE_ACCESS, @@ -83,4 +95,23 @@ void ObjectFactory::produceGenericObjects() { pus::PUS_SERVICE_20); new CService200ModeCommanding(objects::PUS_SERVICE_200_MODE_MGMT, apid::EIVE_OBSW, pus::PUS_SERVICE_200); + + +#if OBSW_ADD_TCPIP_BRIDGE == 1 +#if OBSW_USE_TCP_BRIDGE == 0 + auto tmtcBridge = new UdpTmTcBridge(objects::TMTC_BRIDGE, objects::CCSDS_PACKET_DISTRIBUTOR); + tmtcBridge->setMaxNumberOfPacketsStored(50); + new UdpTcPollingTask(objects::TMTC_POLLING_TASK, objects::TMTC_BRIDGE); + sif::info << "Created UDP server for TMTC commanding with listener port " << + udpBridge->getUdpPort() << std::endl; +#else + auto tmtcBridge = new TcpTmTcBridge(objects::TMTC_BRIDGE, objects::CCSDS_PACKET_DISTRIBUTOR); + tmtcBridge->setMaxNumberOfPacketsStored(50); + auto tcpServer = new TcpTmTcServer(objects::TMTC_POLLING_TASK, objects::TMTC_BRIDGE); + // TCP is stream based. Use packet ID as start marker when parsing for space packets + tcpServer->setSpacePacketParsingOptions({common::TC_PACKET_ID}); + sif::info << "Created TCP server for TMTC commanding with listener port " + << tcpServer->getTcpPort() << std::endl; +#endif /* OBSW_USE_TMTC_TCP_BRIDGE == 0 */ +#endif /* OBSW_ADD_TCPIP_BRIDGE == 1 */ } -- 2.43.0 From 14dcd9eb5ffdb5c59939f90817306b603f1ff546 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Tue, 28 Sep 2021 15:13:05 +0200 Subject: [PATCH 05/18] fsfw update --- fsfw | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fsfw b/fsfw index c7ce568a..f2020b24 160000 --- a/fsfw +++ b/fsfw @@ -1 +1 @@ -Subproject commit c7ce568a302538ef98e308add1bcae632563c48e +Subproject commit f2020b24923b77390ff5234e579a5aa9fc492f4e -- 2.43.0 From 699ffd75df47b1aceb430a38413cfb932f6d8513 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Tue, 28 Sep 2021 15:33:46 +0200 Subject: [PATCH 06/18] fsfw update --- fsfw | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fsfw b/fsfw index f2020b24..be8623a4 160000 --- a/fsfw +++ b/fsfw @@ -1 +1 @@ -Subproject commit f2020b24923b77390ff5234e579a5aa9fc492f4e +Subproject commit be8623a4f85d4445b218873bddd6bcf0ed24fb5f -- 2.43.0 From 4db5944514feca6ccf8ea3230cb215ade08d4f41 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Tue, 28 Sep 2021 16:46:07 +0200 Subject: [PATCH 07/18] fsfw update --- fsfw | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fsfw b/fsfw index be8623a4..6881c6b6 160000 --- a/fsfw +++ b/fsfw @@ -1 +1 @@ -Subproject commit be8623a4f85d4445b218873bddd6bcf0ed24fb5f +Subproject commit 6881c6b66a5a3d11756485f8f845928aea9a705e -- 2.43.0 From 6a00fd309929e2dbee9c7f9d9169004b05503cc4 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Tue, 28 Sep 2021 17:41:02 +0200 Subject: [PATCH 08/18] fsfw update and call fix --- common/config/commonConfig.cpp | 2 +- fsfw | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/common/config/commonConfig.cpp b/common/config/commonConfig.cpp index b15a14c5..b578f23b 100644 --- a/common/config/commonConfig.cpp +++ b/common/config/commonConfig.cpp @@ -2,4 +2,4 @@ #include "tmtc/apid.h" #include "fsfw/tmtcpacket/SpacePacket.h" -const uint16_t common::TC_PACKET_ID = SpacePacket::getTcSpacePacketIdFromApid(apid::EIVE_OBSW); +const uint16_t common::TC_PACKET_ID = getTcSpacePacketIdFromApid(apid::EIVE_OBSW); diff --git a/fsfw b/fsfw index 6881c6b6..69922e77 160000 --- a/fsfw +++ b/fsfw @@ -1 +1 @@ -Subproject commit 6881c6b66a5a3d11756485f8f845928aea9a705e +Subproject commit 69922e77c501ddaef84481c96e25801dc1889c11 -- 2.43.0 From d903df55ceafafe4e182ccdd6a5c1eb0ed31ad48 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Tue, 28 Sep 2021 17:43:02 +0200 Subject: [PATCH 09/18] fsfw update --- fsfw | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fsfw b/fsfw index 69922e77..5ee315f8 160000 --- a/fsfw +++ b/fsfw @@ -1 +1 @@ -Subproject commit 69922e77c501ddaef84481c96e25801dc1889c11 +Subproject commit 5ee315f8ca3b0bb27d5a368948ecd115c6a055c9 -- 2.43.0 From 5b6f09185975abe962b101149970b488b5eb7a5b Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Tue, 28 Sep 2021 17:43:18 +0200 Subject: [PATCH 10/18] function in namespace now --- common/config/commonConfig.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/common/config/commonConfig.cpp b/common/config/commonConfig.cpp index b578f23b..1c9ece8b 100644 --- a/common/config/commonConfig.cpp +++ b/common/config/commonConfig.cpp @@ -2,4 +2,4 @@ #include "tmtc/apid.h" #include "fsfw/tmtcpacket/SpacePacket.h" -const uint16_t common::TC_PACKET_ID = getTcSpacePacketIdFromApid(apid::EIVE_OBSW); +const uint16_t common::TC_PACKET_ID = spacepacket::getTcSpacePacketIdFromApid(apid::EIVE_OBSW); -- 2.43.0 From c1fe5325eda4d05e7271b71df0938ae0f4df76f9 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Wed, 29 Sep 2021 09:12:57 +0200 Subject: [PATCH 11/18] renaming options --- CMakeLists.txt | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index e9b1b68c..c8e345e2 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -18,7 +18,8 @@ if(TGT_BSP MATCHES "arm/q7s") option(BUILD_Q7S_SIMPLE_MODE OFF "Simple mode with a minimal main function") endif() -option(ADD_ETL_LIB "Add ETL library" ON) +option(EIVE_BUILD_UNITTESTS "Build Catch2 unittests" OFF) +option(EIVE_ADD_ETL_LIB "Add ETL library" ON) option(ADD_JSON_LIB "Add JSON library" ON) option(EIVE_SYSROOT_MAGIC "Perform sysroot magic which might not be necessary" OFF) @@ -143,7 +144,7 @@ set(FSFW_ADDITIONAL_INC_PATHS # Add executable add_executable(${TARGET_NAME}) -if(ADD_ETL_LIB) +if(EIVE_ADD_ETL_LIB) add_subdirectory(${ETL_LIB_PATH}) endif() @@ -203,7 +204,7 @@ if(NOT EIVE_BUILD_WATCHDOG) endif() endif() -if(ADD_ETL_LIB) +if(EIVE_ADD_ETL_LIB) target_link_libraries(${TARGET_NAME} PRIVATE ${LIB_ETL_NAME} ) -- 2.43.0 From cf04b83cdf743b588b015fac73a4cd3c8d726c90 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Wed, 29 Sep 2021 09:14:17 +0200 Subject: [PATCH 12/18] EIVE prefixes added --- CMakeLists.txt | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index c8e345e2..ed5c5409 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -20,7 +20,7 @@ endif() option(EIVE_BUILD_UNITTESTS "Build Catch2 unittests" OFF) option(EIVE_ADD_ETL_LIB "Add ETL library" ON) -option(ADD_JSON_LIB "Add JSON library" ON) +option(EIVE_ADD_JSON_LIB "Add JSON library" ON) option(EIVE_SYSROOT_MAGIC "Perform sysroot magic which might not be necessary" OFF) if(NOT FSFW_OSAL) @@ -148,7 +148,7 @@ if(EIVE_ADD_ETL_LIB) add_subdirectory(${ETL_LIB_PATH}) endif() -if(ADD_JSON_LIB) +if(EIVE_ADD_JSON_LIB) add_subdirectory(${LIB_JSON_PATH}) endif() @@ -210,7 +210,7 @@ if(EIVE_ADD_ETL_LIB) ) endif() -if(ADD_JSON_LIB) +if(EIVE_ADD_JSON_LIB) target_link_libraries(${TARGET_NAME} PRIVATE ${LIB_JSON_NAME} ) -- 2.43.0 From 74fa4835e2e0a86b26794f52f14bf4210c4c1369 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Wed, 29 Sep 2021 09:15:02 +0200 Subject: [PATCH 13/18] added Catch2 repo --- .gitmodules | 3 +++ thirdparty/Catch2 | 1 + 2 files changed, 4 insertions(+) create mode 160000 thirdparty/Catch2 diff --git a/.gitmodules b/.gitmodules index 1f3dc6ec..1ca8bec5 100644 --- a/.gitmodules +++ b/.gitmodules @@ -22,3 +22,6 @@ [submodule "thirdparty/json"] path = thirdparty/json url = https://github.com/nlohmann/json.git +[submodule "thirdparty/Catch2"] + path = thirdparty/Catch2 + url = https://github.com/catchorg/Catch2.git diff --git a/thirdparty/Catch2 b/thirdparty/Catch2 new file mode 160000 index 00000000..42695403 --- /dev/null +++ b/thirdparty/Catch2 @@ -0,0 +1 @@ +Subproject commit 426954032f263754d2fff4cffce8552e7371965e -- 2.43.0 From ababb5c06220ffe60a94aaf2466a9b92b8fbbe2d Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Wed, 29 Sep 2021 09:30:58 +0200 Subject: [PATCH 14/18] adding unittests for EIVE --- CMakeLists.txt | 45 +++++++---- fsfw | 2 +- unittest/CMakeLists.txt | 1 + unittest/testcfg/CMakeLists.txt | 9 +++ unittest/testcfg/FSFWConfig.h.in | 78 +++++++++++++++++++ unittest/testcfg/OBSWConfig.h.in | 8 ++ unittest/testcfg/TestsConfig.h.in | 21 +++++ unittest/testcfg/devices/logicalAddresses.cpp | 5 ++ unittest/testcfg/devices/logicalAddresses.h | 15 ++++ .../testcfg/devices/powerSwitcherList.cpp | 4 + unittest/testcfg/devices/powerSwitcherList.h | 12 +++ unittest/testcfg/events/subsystemIdRanges.h | 18 +++++ unittest/testcfg/ipc/MissionMessageTypes.cpp | 12 +++ unittest/testcfg/ipc/MissionMessageTypes.h | 22 ++++++ unittest/testcfg/objects/systemObjectList.h | 32 ++++++++ .../PollingSequenceFactory.cpp | 39 ++++++++++ .../pollingsequence/PollingSequenceFactory.h | 32 ++++++++ unittest/testcfg/returnvalues/classIds.h | 16 ++++ unittest/testcfg/tmtc/apid.h | 18 +++++ unittest/testcfg/tmtc/pusIds.h | 25 ++++++ unittest/unittest.mk | 0 21 files changed, 400 insertions(+), 14 deletions(-) create mode 100644 unittest/CMakeLists.txt create mode 100644 unittest/testcfg/CMakeLists.txt create mode 100644 unittest/testcfg/FSFWConfig.h.in create mode 100644 unittest/testcfg/OBSWConfig.h.in create mode 100644 unittest/testcfg/TestsConfig.h.in create mode 100644 unittest/testcfg/devices/logicalAddresses.cpp create mode 100644 unittest/testcfg/devices/logicalAddresses.h create mode 100644 unittest/testcfg/devices/powerSwitcherList.cpp create mode 100644 unittest/testcfg/devices/powerSwitcherList.h create mode 100644 unittest/testcfg/events/subsystemIdRanges.h create mode 100644 unittest/testcfg/ipc/MissionMessageTypes.cpp create mode 100644 unittest/testcfg/ipc/MissionMessageTypes.h create mode 100644 unittest/testcfg/objects/systemObjectList.h create mode 100644 unittest/testcfg/pollingsequence/PollingSequenceFactory.cpp create mode 100644 unittest/testcfg/pollingsequence/PollingSequenceFactory.h create mode 100644 unittest/testcfg/returnvalues/classIds.h create mode 100644 unittest/testcfg/tmtc/apid.h create mode 100644 unittest/testcfg/tmtc/pusIds.h delete mode 100644 unittest/unittest.mk diff --git a/CMakeLists.txt b/CMakeLists.txt index ed5c5409..54915f2c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -60,26 +60,34 @@ set(LIB_LWGPS_NAME lwgps) set(LIB_ARCSEC wire) set(THIRD_PARTY_FOLDER thirdparty) set(LIB_CXX_FS -lstdc++fs) +set(LIB_CATCH2 Catch2) set(LIB_JSON_NAME nlohmann_json::nlohmann_json) # Set path names set(FSFW_PATH fsfw) set(MISSION_PATH mission) set(TEST_PATH test/testtasks) +set(UNITTEST_PATH unittest) set(LINUX_PATH linux) set(COMMON_PATH common) set(WATCHDOG_PATH watchdog) set(COMMON_CONFIG_PATH ${COMMON_PATH}/config) -set(FSFW_HAL_LIB_PATH fsfw_hal) -set(CSP_LIB_PATH ${THIRD_PARTY_FOLDER}/libcsp) -set(ETL_LIB_PATH ${THIRD_PARTY_FOLDER}/etl) -set(LWGPS_LIB_PATH ${THIRD_PARTY_FOLDER}/lwgps) -set(ARCSEC_LIB_PATH ${THIRD_PARTY_FOLDER}/arcsec_star_tracker) +set(LIB_CSP_PATH ${THIRD_PARTY_FOLDER}/libcsp) +set(LIB_ETL_PATH ${THIRD_PARTY_FOLDER}/etl) +set(LIB_CATCH2_PATH ${THIRD_PARTY_FOLDER}/Catch2) +set(LIB_LWGPS_PATH ${THIRD_PARTY_FOLDER}/lwgps) +set(LIB_ARCSEC_PATH ${THIRD_PARTY_FOLDER}/arcsec_star_tracker) set(LIB_JSON_PATH ${THIRD_PARTY_FOLDER}/json) set(FSFW_WARNING_SHADOW_LOCAL_GCC OFF) -set(ADD_LINUX_FILES False) +set(EIVE_ADD_LINUX_FILES False) + +if(FSFW_CUSTOM_UNITTEST_RUNNER OR FSFW_ADD_UNITTESTS) + set(CATCH2_TARGET Catch2) +else() + set(CATCH2_TARGET Catch2WithMain) +endif() # Analyse different OS and architecture/target options, determine BSP_PATH, # display information about compiler etc. @@ -92,7 +100,7 @@ if(TGT_BSP) ) set(FSFW_CONFIG_PATH "linux/fsfwconfig") if(NOT BUILD_Q7S_SIMPLE_MODE) - set(ADD_LINUX_FILES TRUE) + set(EIVE_ADD_LINUX_FILES TRUE) set(ADD_CSP_LIB TRUE) set(FSFW_HAL_ADD_LINUX ON) endif() @@ -145,7 +153,7 @@ set(FSFW_ADDITIONAL_INC_PATHS add_executable(${TARGET_NAME}) if(EIVE_ADD_ETL_LIB) - add_subdirectory(${ETL_LIB_PATH}) + add_subdirectory(${LIB_ETL_PATH}) endif() if(EIVE_ADD_JSON_LIB) @@ -153,22 +161,26 @@ if(EIVE_ADD_JSON_LIB) endif() if(NOT EIVE_BUILD_WATCHDOG) - if(ADD_LINUX_FILES) + if(EIVE_ADD_LINUX_FILES) add_subdirectory(${LINUX_PATH}) endif() add_subdirectory(${BSP_PATH}) add_subdirectory(${COMMON_PATH}) if(ADD_CSP_LIB) - add_subdirectory(${CSP_LIB_PATH}) + add_subdirectory(${LIB_CSP_PATH}) endif() endif() if((NOT BUILD_Q7S_SIMPLE_MODE) AND (NOT EIVE_BUILD_WATCHDOG)) - add_subdirectory(${LWGPS_LIB_PATH}) + add_subdirectory(${LIB_LWGPS_PATH}) add_subdirectory(${FSFW_PATH}) add_subdirectory(${MISSION_PATH}) add_subdirectory(${TEST_PATH}) - add_subdirectory(${ARCSEC_LIB_PATH}) + add_subdirectory(${LIB_ARCSEC_PATH}) +endif() + +if(EIVE_BUILD_UNITTEST) + add_subdirectory(${UNITTEST_PATH}) endif() if(EIVE_BUILD_WATCHDOG) @@ -196,6 +208,7 @@ if((NOT BUILD_Q7S_SIMPLE_MODE) AND (NOT EIVE_BUILD_WATCHDOG)) endif() endif() + if(NOT EIVE_BUILD_WATCHDOG) if(ADD_CSP_LIB) target_link_libraries(${TARGET_NAME} PRIVATE @@ -216,6 +229,12 @@ if(EIVE_ADD_JSON_LIB) ) endif() +if(EIVE_BUILD_UNITTEST) + target_link_libraries(${TARGET_NAME} PRIVATE + ${CATCH2_TARGET} + ) +endif() + target_link_libraries(${TARGET_NAME} PRIVATE ${LIB_CXX_FS} ) @@ -225,7 +244,7 @@ target_include_directories(${TARGET_NAME} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} ${FSFW_CONFIG_PATH} ${CMAKE_CURRENT_BINARY_DIR} - ${ARCSEC_LIB_PATH} + ${LIB_ARCSEC_PATH} ) if(TGT_BSP MATCHES "arm/q7s") diff --git a/fsfw b/fsfw index 5ee315f8..354e158c 160000 --- a/fsfw +++ b/fsfw @@ -1 +1 @@ -Subproject commit 5ee315f8ca3b0bb27d5a368948ecd115c6a055c9 +Subproject commit 354e158cc196d7deaf7de24ebcc96f5f6f5f20eb diff --git a/unittest/CMakeLists.txt b/unittest/CMakeLists.txt new file mode 100644 index 00000000..ce562b28 --- /dev/null +++ b/unittest/CMakeLists.txt @@ -0,0 +1 @@ +add_subdirectory(testcfg) diff --git a/unittest/testcfg/CMakeLists.txt b/unittest/testcfg/CMakeLists.txt new file mode 100644 index 00000000..50d13663 --- /dev/null +++ b/unittest/testcfg/CMakeLists.txt @@ -0,0 +1,9 @@ +target_sources(${TARGET_NAME} PRIVATE + ipc/MissionMessageTypes.cpp + pollingsequence/PollingSequenceFactory.cpp +) + +# Add include paths for the executable +target_include_directories(${TARGET_NAME} PUBLIC + ${CMAKE_CURRENT_SOURCE_DIR} +) diff --git a/unittest/testcfg/FSFWConfig.h.in b/unittest/testcfg/FSFWConfig.h.in new file mode 100644 index 00000000..d38f0648 --- /dev/null +++ b/unittest/testcfg/FSFWConfig.h.in @@ -0,0 +1,78 @@ +#ifndef CONFIG_FSFWCONFIG_H_ +#define CONFIG_FSFWCONFIG_H_ + +#include +#include + +//! Used to determine whether C++ ostreams are used which can increase +//! the binary size significantly. If this is disabled, +//! the C stdio functions can be used alternatively +#define FSFW_CPP_OSTREAM_ENABLED 0 + +//! More FSFW related printouts. Useful for development. +#define FSFW_ENHANCED_PRINTOUT 0 + +//! Can be used to completely disable printouts, even the C stdio ones. +//! By default, printouts will be disabled for the unit tests. +#if FSFW_CPP_OSTREAM_ENABLED == 0 && FSFW_ENHANCED_PRINTOUT == 0 + #ifndef FSFW_DISABLE_PRINTOUT + #define FSFW_DISABLE_PRINTOUT 1 + #endif +#endif + +//! Can be used to enable additional debugging printouts for developing the FSFW +#define FSFW_PRINT_VERBOSITY_LEVEL 0 + +//! Can be used to disable the ANSI color sequences for C stdio. +#define FSFW_COLORED_OUTPUT 0 + +//! If FSFW_OBJ_EVENT_TRANSLATION is set to one, +//! additional output which requires the translation files translateObjects +//! and translateEvents (and their compiled source files) +#define FSFW_OBJ_EVENT_TRANSLATION 0 + +#if FSFW_OBJ_EVENT_TRANSLATION == 1 +//! Specify whether info events are printed too. +#define FSFW_DEBUG_INFO 1 +#include "objects/translateObjects.h" +#include "events/translateEvents.h" +#else +#endif + +//! When using the newlib nano library, C99 support for stdio facilities +//! will not be provided. This define should be set to 1 if this is the case. +#define FSFW_NO_C99_IO 1 + +//! Specify whether a special mode store is used for Subsystem components. +#define FSFW_USE_MODESTORE 0 + +//! Defines if the real time scheduler for linux should be used. +//! If set to 0, this will also disable priority settings for linux +//! as most systems will not allow to set nice values without privileges +//! For embedded linux system set this to 1. +//! If set to 1 the binary needs "cap_sys_nice=eip" privileges to run +#define FSFW_USE_REALTIME_FOR_LINUX 1 + +namespace fsfwconfig { +//! Default timestamp size. The default timestamp will be an eight byte CDC +//! short timestamp. +static constexpr uint8_t FSFW_MISSION_TIMESTAMP_SIZE = 8; + +//! Configure the allocated pool sizes for the event manager. +static constexpr size_t FSFW_EVENTMGMR_MATCHTREE_NODES = 240; +static constexpr size_t FSFW_EVENTMGMT_EVENTIDMATCHERS = 120; +static constexpr size_t FSFW_EVENTMGMR_RANGEMATCHERS = 120; + +//! Defines the FIFO depth of each commanding service base which +//! also determines how many commands a CSB service can handle in one cycle +//! simulataneously. This will increase the required RAM for +//! each CSB service ! +static constexpr uint8_t FSFW_CSB_FIFO_DEPTH = 6; + +static constexpr size_t FSFW_PRINT_BUFFER_SIZE = 124; + +static constexpr size_t FSFW_MAX_TM_PACKET_SIZE = 1500; + +} + +#endif /* CONFIG_FSFWCONFIG_H_ */ diff --git a/unittest/testcfg/OBSWConfig.h.in b/unittest/testcfg/OBSWConfig.h.in new file mode 100644 index 00000000..34eda31f --- /dev/null +++ b/unittest/testcfg/OBSWConfig.h.in @@ -0,0 +1,8 @@ +#ifndef TESTCFG_OBSWCONFIG_H_ +#define TESTCFG_OBSWCONFIG_H_ + + + + + +#endif /* TESTCFG_OBSWCONFIG_H_ */ diff --git a/unittest/testcfg/TestsConfig.h.in b/unittest/testcfg/TestsConfig.h.in new file mode 100644 index 00000000..7d950070 --- /dev/null +++ b/unittest/testcfg/TestsConfig.h.in @@ -0,0 +1,21 @@ +#ifndef FSFW_UNITTEST_CONFIG_TESTSCONFIG_H_ +#define FSFW_UNITTEST_CONFIG_TESTSCONFIG_H_ + +#define FSFW_ADD_DEFAULT_FACTORY_FUNCTIONS 1 + +#ifdef __cplusplus + +#include "objects/systemObjectList.h" +#include "events/subsystemIdRanges.h" +#include "returnvalues/classIds.h" + +namespace config { +#endif + +/* Add mission configuration flags here */ + +#ifdef __cplusplus +} +#endif + +#endif /* FSFW_UNITTEST_CONFIG_TESTSCONFIG_H_ */ diff --git a/unittest/testcfg/devices/logicalAddresses.cpp b/unittest/testcfg/devices/logicalAddresses.cpp new file mode 100644 index 00000000..c7ce314d --- /dev/null +++ b/unittest/testcfg/devices/logicalAddresses.cpp @@ -0,0 +1,5 @@ +#include "logicalAddresses.h" + + + + diff --git a/unittest/testcfg/devices/logicalAddresses.h b/unittest/testcfg/devices/logicalAddresses.h new file mode 100644 index 00000000..cdf87025 --- /dev/null +++ b/unittest/testcfg/devices/logicalAddresses.h @@ -0,0 +1,15 @@ +#ifndef CONFIG_DEVICES_LOGICALADDRESSES_H_ +#define CONFIG_DEVICES_LOGICALADDRESSES_H_ + +#include +#include +#include + +namespace addresses { + /* Logical addresses have uint32_t datatype */ + enum logicalAddresses: address_t { + }; +} + + +#endif /* CONFIG_DEVICES_LOGICALADDRESSES_H_ */ diff --git a/unittest/testcfg/devices/powerSwitcherList.cpp b/unittest/testcfg/devices/powerSwitcherList.cpp new file mode 100644 index 00000000..343f78d0 --- /dev/null +++ b/unittest/testcfg/devices/powerSwitcherList.cpp @@ -0,0 +1,4 @@ +#include "powerSwitcherList.h" + + + diff --git a/unittest/testcfg/devices/powerSwitcherList.h b/unittest/testcfg/devices/powerSwitcherList.h new file mode 100644 index 00000000..86ddea57 --- /dev/null +++ b/unittest/testcfg/devices/powerSwitcherList.h @@ -0,0 +1,12 @@ +#ifndef CONFIG_DEVICES_POWERSWITCHERLIST_H_ +#define CONFIG_DEVICES_POWERSWITCHERLIST_H_ + +namespace switches { + /* Switches are uint8_t datatype and go from 0 to 255 */ + enum switcherList { + }; + +} + + +#endif /* CONFIG_DEVICES_POWERSWITCHERLIST_H_ */ diff --git a/unittest/testcfg/events/subsystemIdRanges.h b/unittest/testcfg/events/subsystemIdRanges.h new file mode 100644 index 00000000..24eee819 --- /dev/null +++ b/unittest/testcfg/events/subsystemIdRanges.h @@ -0,0 +1,18 @@ +#ifndef CONFIG_EVENTS_SUBSYSTEMIDRANGES_H_ +#define CONFIG_EVENTS_SUBSYSTEMIDRANGES_H_ + +#include +#include + +/** + * @brief Custom subsystem IDs can be added here + * @details + * Subsystem IDs are used to create unique events. + */ +namespace SUBSYSTEM_ID { +enum: uint8_t { + SUBSYSTEM_ID_START = FW_SUBSYSTEM_ID_RANGE, +}; +} + +#endif /* CONFIG_EVENTS_SUBSYSTEMIDRANGES_H_ */ diff --git a/unittest/testcfg/ipc/MissionMessageTypes.cpp b/unittest/testcfg/ipc/MissionMessageTypes.cpp new file mode 100644 index 00000000..d68cb58c --- /dev/null +++ b/unittest/testcfg/ipc/MissionMessageTypes.cpp @@ -0,0 +1,12 @@ +#include "MissionMessageTypes.h" + +#include + +void messagetypes::clearMissionMessage(CommandMessage* message) { + switch(message->getMessageType()) { + default: + break; + } +} + + diff --git a/unittest/testcfg/ipc/MissionMessageTypes.h b/unittest/testcfg/ipc/MissionMessageTypes.h new file mode 100644 index 00000000..832d8e58 --- /dev/null +++ b/unittest/testcfg/ipc/MissionMessageTypes.h @@ -0,0 +1,22 @@ +#ifndef CONFIG_IPC_MISSIONMESSAGETYPES_H_ +#define CONFIG_IPC_MISSIONMESSAGETYPES_H_ + +#include + +class CommandMessage; + +/** + * Custom command messages are specified here. + * Most messages needed to use FSFW are already located in + * + * @param message Generic Command Message + */ +namespace messagetypes{ +enum MESSAGE_TYPE { + MISSION_MESSAGE_TYPE_START = FW_MESSAGES_COUNT, +}; + +void clearMissionMessage(CommandMessage* message); +} + +#endif /* CONFIG_IPC_MISSIONMESSAGETYPES_H_ */ diff --git a/unittest/testcfg/objects/systemObjectList.h b/unittest/testcfg/objects/systemObjectList.h new file mode 100644 index 00000000..efd21e0d --- /dev/null +++ b/unittest/testcfg/objects/systemObjectList.h @@ -0,0 +1,32 @@ +#ifndef HOSTED_CONFIG_OBJECTS_SYSTEMOBJECTLIST_H_ +#define HOSTED_CONFIG_OBJECTS_SYSTEMOBJECTLIST_H_ + +#include +#include + +// The objects will be instantiated in the ID order +namespace objects { + enum sourceObjects: uint32_t { + /* All addresses between start and end are reserved for the FSFW */ + FSFW_CONFIG_RESERVED_START = PUS_SERVICE_1_VERIFICATION, + FSFW_CONFIG_RESERVED_END = TM_STORE, + + CCSDS_DISTRIBUTOR = 10, + PUS_DISTRIBUTOR = 11, + TM_FUNNEL = 12, + + UDP_BRIDGE = 15, + UDP_POLLING_TASK = 16, + + TEST_ECHO_COM_IF = 20, + TEST_DEVICE = 21, + + HK_RECEIVER_MOCK = 22, + TEST_LOCAL_POOL_OWNER_BASE = 25, + + SHARED_SET_ID = 26 + + }; +} + +#endif /* BSP_CONFIG_OBJECTS_SYSTEMOBJECTLIST_H_ */ diff --git a/unittest/testcfg/pollingsequence/PollingSequenceFactory.cpp b/unittest/testcfg/pollingsequence/PollingSequenceFactory.cpp new file mode 100644 index 00000000..e3ee874a --- /dev/null +++ b/unittest/testcfg/pollingsequence/PollingSequenceFactory.cpp @@ -0,0 +1,39 @@ +#include "PollingSequenceFactory.h" + +#include + +#include +#include +#include + +ReturnValue_t pst::pollingSequenceInitDefault( + FixedTimeslotTaskIF *thisSequence) { + /* Length of a communication cycle */ + uint32_t length = thisSequence->getPeriodMs(); + + /* Add polling sequence table here */ + thisSequence->addSlot(objects::TEST_DEVICE, 0, + DeviceHandlerIF::PERFORM_OPERATION); + thisSequence->addSlot(objects::TEST_DEVICE, 0.3, + DeviceHandlerIF::SEND_WRITE); + thisSequence->addSlot(objects::TEST_DEVICE, 0.45 * length, + DeviceHandlerIF::GET_WRITE); + thisSequence->addSlot(objects::TEST_DEVICE, 0.6 * length, + DeviceHandlerIF::SEND_READ); + thisSequence->addSlot(objects::TEST_DEVICE, 0.8 * length, + DeviceHandlerIF::GET_READ); + + if (thisSequence->checkSequence() == HasReturnvaluesIF::RETURN_OK) { + return HasReturnvaluesIF::RETURN_OK; + } + else { +#if FSFW_CPP_OSTREAM_ENABLED + sif::error << "pst::pollingSequenceInitDefault: Sequence invalid!" + << std::endl; +#else + sif::printError("pst::pollingSequenceInitDefault: Sequence invalid!"); +#endif + return HasReturnvaluesIF::RETURN_FAILED; + } +} + diff --git a/unittest/testcfg/pollingsequence/PollingSequenceFactory.h b/unittest/testcfg/pollingsequence/PollingSequenceFactory.h new file mode 100644 index 00000000..c5d41b7d --- /dev/null +++ b/unittest/testcfg/pollingsequence/PollingSequenceFactory.h @@ -0,0 +1,32 @@ +#ifndef POLLINGSEQUENCEFACTORY_H_ +#define POLLINGSEQUENCEFACTORY_H_ + +#include + +class FixedTimeslotTaskIF; + +/** + * All device handlers are scheduled by adding them into Polling Sequence Tables (PST) + * to satisfy stricter timing requirements of device communication, + * A device handler has four different communication steps: + * 1. DeviceHandlerIF::SEND_WRITE -> Send write via interface + * 2. DeviceHandlerIF::GET_WRITE -> Get confirmation for write + * 3. DeviceHandlerIF::SEND_READ -> Send read request + * 4. DeviceHandlerIF::GET_READ -> Read from interface + * The PST specifies precisely when the respective ComIF functions are called + * during the communication cycle time. + * The task is created using the FixedTimeslotTaskIF, + * which utilises the underlying Operating System Abstraction Layer (OSAL) + * + * @param thisSequence FixedTimeslotTaskIF * object is passed inside the Factory class when creating the PST + * @return + */ +namespace pst { + +/* Default PST */ +ReturnValue_t pollingSequenceInitDefault(FixedTimeslotTaskIF *thisSequence); + + +} + +#endif /* POLLINGSEQUENCEINIT_H_ */ diff --git a/unittest/testcfg/returnvalues/classIds.h b/unittest/testcfg/returnvalues/classIds.h new file mode 100644 index 00000000..606cc60b --- /dev/null +++ b/unittest/testcfg/returnvalues/classIds.h @@ -0,0 +1,16 @@ +#ifndef CONFIG_RETURNVALUES_CLASSIDS_H_ +#define CONFIG_RETURNVALUES_CLASSIDS_H_ + +#include + +/** + * @brief CLASS_ID defintions which are required for custom returnvalues. + */ +namespace CLASS_ID { +enum { + MISSION_CLASS_ID_START = FW_CLASS_ID_COUNT, +}; +} + + +#endif /* CONFIG_RETURNVALUES_CLASSIDS_H_ */ diff --git a/unittest/testcfg/tmtc/apid.h b/unittest/testcfg/tmtc/apid.h new file mode 100644 index 00000000..c0231bca --- /dev/null +++ b/unittest/testcfg/tmtc/apid.h @@ -0,0 +1,18 @@ +#ifndef CONFIG_TMTC_APID_H_ +#define CONFIG_TMTC_APID_H_ + +#include + +/** + * Application Process Definition: entity, uniquely identified by an + * application process ID (APID), capable of generating telemetry source + * packets and receiving telecommand packets. + * + * Chose APID(s) for mission and define it here. + */ +namespace apid { + static const uint16_t DEFAULT_APID = 0x00; +} + + +#endif /* CONFIG_TMTC_APID_H_ */ diff --git a/unittest/testcfg/tmtc/pusIds.h b/unittest/testcfg/tmtc/pusIds.h new file mode 100644 index 00000000..821a9982 --- /dev/null +++ b/unittest/testcfg/tmtc/pusIds.h @@ -0,0 +1,25 @@ +#ifndef CONFIG_TMTC_PUSIDS_HPP_ +#define CONFIG_TMTC_PUSIDS_HPP_ + +#include + +namespace pus { +enum Ids: uint8_t { + PUS_SERVICE_1 = 1, + PUS_SERVICE_2 = 2, + PUS_SERVICE_3 = 3, + PUS_SERVICE_5 = 5, + PUS_SERVICE_6 = 6, + PUS_SERVICE_8 = 8, + PUS_SERVICE_9 = 9, + PUS_SERVICE_11 = 11, + PUS_SERVICE_17 = 17, + PUS_SERVICE_19 = 19, + PUS_SERVICE_20 = 20, + PUS_SERVICE_23 = 23, + PUS_SERVICE_200 = 200, + PUS_SERVICE_201 = 201, +}; +}; + +#endif /* CONFIG_TMTC_PUSIDS_HPP_ */ diff --git a/unittest/unittest.mk b/unittest/unittest.mk deleted file mode 100644 index e69de29b..00000000 -- 2.43.0 From e4286d18d4289e2426a7096cf45813338609510b Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Wed, 29 Sep 2021 09:37:29 +0200 Subject: [PATCH 15/18] only use unique name for EIVE OBSW --- CMakeLists.txt | 7 ++++++- bsp_hosted/ObjectFactory.cpp | 13 ------------- .../eclipse/Host/eive-linux-host-debug-cmake.launch | 2 +- 3 files changed, 7 insertions(+), 15 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 54915f2c..2381568d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -35,7 +35,12 @@ endif() include(${CMAKE_SCRIPT_PATH}/PreProjectConfig.cmake) pre_project_config() -set(PROJECT_NAME_TO_SET eive-obsw-$ENV{USERNAME}) +if(TGT_BSP MATCHES "arm/q7s") + set(PROJECT_NAME_TO_SET eive-obsw-$ENV{USERNAME}) +else() + set(PROJECT_NAME_TO_SET eive-obsw) +endif() + if(EIVE_BUILD_WATCHDOG) set(PROJECT_NAME_TO_SET eive-watchdog) endif() diff --git a/bsp_hosted/ObjectFactory.cpp b/bsp_hosted/ObjectFactory.cpp index d7878e46..6803ace4 100644 --- a/bsp_hosted/ObjectFactory.cpp +++ b/bsp_hosted/ObjectFactory.cpp @@ -44,18 +44,5 @@ void ObjectFactory::produce(void* args){ Factory::setStaticFrameworkObjectIds(); ObjectFactory::produceGenericObjects(); -#if OBSW_USE_TMTC_TCP_BRIDGE == 0 - sif::info << "Setting up UDP TMTC bridge with listener port " << - UdpTmTcBridge::DEFAULT_SERVER_PORT << std::endl; - new UdpTmTcBridge(objects::TMTC_BRIDGE, objects::CCSDS_PACKET_DISTRIBUTOR); - new UdpTcPollingTask(objects::TMTC_POLLING_TASK, objects::TMTC_BRIDGE); -#else - sif::info << "Setting up TCP TMTC bridge with listener port " << - TcpTmTcServer::DEFAULT_SERVER_PORT << std::endl; - new TcpTmTcBridge(objects::TMTC_BRIDGE, objects::CCSDS_PACKET_DISTRIBUTOR); - new TcpTmTcServer(objects::TMTC_POLLING_TASK, objects::TMTC_BRIDGE); -#endif - new TestTask(objects::TEST_TASK); - } diff --git a/misc/eclipse/Host/eive-linux-host-debug-cmake.launch b/misc/eclipse/Host/eive-linux-host-debug-cmake.launch index 294772d8..d8cfc8c1 100644 --- a/misc/eclipse/Host/eive-linux-host-debug-cmake.launch +++ b/misc/eclipse/Host/eive-linux-host-debug-cmake.launch @@ -18,7 +18,7 @@ - + -- 2.43.0 From f61d0e83f05b10ab178c63d8f0f9ad78a6131ab9 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Wed, 29 Sep 2021 10:52:36 +0200 Subject: [PATCH 16/18] refactoring for added unittests --- CMakeLists.txt | 42 +++++++++---- common/config/devices/powerSwitcherList.h | 60 +++++++++++++++++++ .../fsfwconfig => common/config}/tmtc/apid.h | 0 fsfw | 2 +- .../Host/eive-linux-host-unittest.launch | 33 ++++++++++ mission/core/GenericFactory.cpp | 1 + unittest/CMakeLists.txt | 4 ++ unittest/main.cpp | 6 ++ unittest/testcfg/FSFWConfig.h.in | 5 +- unittest/testcfg/events/subsystemIdRanges.h | 1 + unittest/testcfg/objects/systemObjectList.h | 1 + unittest/testcfg/returnvalues/classIds.h | 1 + unittest/testcfg/tmtc/apid.h | 2 +- 13 files changed, 142 insertions(+), 16 deletions(-) create mode 100644 common/config/devices/powerSwitcherList.h rename {linux/fsfwconfig => common/config}/tmtc/apid.h (100%) create mode 100644 misc/eclipse/Host/eive-linux-host-unittest.launch create mode 100644 unittest/main.cpp diff --git a/CMakeLists.txt b/CMakeLists.txt index 2381568d..f57031cf 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -35,16 +35,16 @@ endif() include(${CMAKE_SCRIPT_PATH}/PreProjectConfig.cmake) pre_project_config() -if(TGT_BSP MATCHES "arm/q7s") +if(EIVE_BUILD_WATCHDOG) + set(PROJECT_NAME_TO_SET eive-watchdog) +elseif(EIVE_BUILD_UNITTESTS) + set(PROJECT_NAME_TO_SET eive-unittest) +elseif(TGT_BSP MATCHES "arm/q7s") set(PROJECT_NAME_TO_SET eive-obsw-$ENV{USERNAME}) else() set(PROJECT_NAME_TO_SET eive-obsw) endif() -if(EIVE_BUILD_WATCHDOG) - set(PROJECT_NAME_TO_SET eive-watchdog) -endif() - # Project Name project(${PROJECT_NAME_TO_SET} ASM C CXX) @@ -77,6 +77,7 @@ set(LINUX_PATH linux) set(COMMON_PATH common) set(WATCHDOG_PATH watchdog) set(COMMON_CONFIG_PATH ${COMMON_PATH}/config) +set(UNITTEST_CFG_PATH ${UNITTEST_PATH}/testcfg) set(LIB_CSP_PATH ${THIRD_PARTY_FOLDER}/libcsp) set(LIB_ETL_PATH ${THIRD_PARTY_FOLDER}/etl) @@ -88,6 +89,10 @@ set(LIB_JSON_PATH ${THIRD_PARTY_FOLDER}/json) set(FSFW_WARNING_SHADOW_LOCAL_GCC OFF) set(EIVE_ADD_LINUX_FILES False) +if(EIVE_BUILD_UNITTESTS) + option(FSFW_ADD_UNITTESTS "Build the FSFW unittests as well" ON) +endif() + if(FSFW_CUSTOM_UNITTEST_RUNNER OR FSFW_ADD_UNITTESTS) set(CATCH2_TARGET Catch2) else() @@ -131,6 +136,11 @@ else() set(FSFW_CONFIG_PATH "${BSP_PATH}/fsfwconfig") endif() +if(EIVE_BUILD_UNITTESTS) + configure_file(${UNITTEST_CFG_PATH}/TestsConfig.h.in TestsConfig.h) + set(FSFW_CONFIG_PATH ${UNITTEST_CFG_PATH}) +endif() + # Configuration files if(NOT EIVE_BUILD_WATCHDOG) configure_file(${COMMON_CONFIG_PATH}/commonConfig.h.in commonConfig.h) @@ -142,6 +152,9 @@ if(NOT EIVE_BUILD_WATCHDOG) configure_file(${BSP_PATH}/boardconfig/rpiConfig.h.in rpiConfig.h) endif() endif() + + + configure_file(${WATCHDOG_PATH}/watchdogConf.h.in watchdogConf.h) # Set common config path for FSFW @@ -166,14 +179,16 @@ if(EIVE_ADD_JSON_LIB) endif() if(NOT EIVE_BUILD_WATCHDOG) - if(EIVE_ADD_LINUX_FILES) - add_subdirectory(${LINUX_PATH}) + if(NOT EIVE_BUILD_UNITTESTS) + if(EIVE_ADD_LINUX_FILES) + add_subdirectory(${LINUX_PATH}) + endif() + add_subdirectory(${BSP_PATH}) + if(ADD_CSP_LIB) + add_subdirectory(${LIB_CSP_PATH}) + endif() endif() - add_subdirectory(${BSP_PATH}) add_subdirectory(${COMMON_PATH}) - if(ADD_CSP_LIB) - add_subdirectory(${LIB_CSP_PATH}) - endif() endif() if((NOT BUILD_Q7S_SIMPLE_MODE) AND (NOT EIVE_BUILD_WATCHDOG)) @@ -184,7 +199,8 @@ if((NOT BUILD_Q7S_SIMPLE_MODE) AND (NOT EIVE_BUILD_WATCHDOG)) add_subdirectory(${LIB_ARCSEC_PATH}) endif() -if(EIVE_BUILD_UNITTEST) +if(EIVE_BUILD_UNITTESTS) + add_subdirectory(${LIB_CATCH2_PATH}) add_subdirectory(${UNITTEST_PATH}) endif() @@ -234,7 +250,7 @@ if(EIVE_ADD_JSON_LIB) ) endif() -if(EIVE_BUILD_UNITTEST) +if(EIVE_BUILD_UNITTESTS) target_link_libraries(${TARGET_NAME} PRIVATE ${CATCH2_TARGET} ) diff --git a/common/config/devices/powerSwitcherList.h b/common/config/devices/powerSwitcherList.h new file mode 100644 index 00000000..45428a2e --- /dev/null +++ b/common/config/devices/powerSwitcherList.h @@ -0,0 +1,60 @@ +#ifndef FSFWCONFIG_DEVICES_POWERSWITCHERLIST_H_ +#define FSFWCONFIG_DEVICES_POWERSWITCHERLIST_H_ + +#include "OBSWConfig.h" + +#include + +namespace pcduSwitches { + /* Switches are uint8_t datatype and go from 0 to 255 */ + enum SwitcherList: uint8_t { + Q7S, + PAYLOAD_PCDU_CH1, + RW, + TCS_BOARD_8V_HEATER_IN, + SUS_REDUNDANT, + DEPLOYMENT_MECHANISM, + PAYLOAD_PCDU_CH6, + ACS_BOARD_SIDE_B, + PAYLOAD_CAMERA, + TCS_BOARD_3V3, + SYRLINKS, + STAR_TRACKER, + MGT, + SUS_NOMINAL, + SOLAR_CELL_EXP, + PLOC, + ACS_BOARD_SIDE_A, + NUMBER_OF_SWITCHES + }; + + static const uint8_t ON = 1; + static const uint8_t OFF = 0; + + /* Output states after reboot of the PDUs */ + static const uint8_t INIT_STATE_Q7S = ON; + static const uint8_t INIT_STATE_PAYLOAD_PCDU_CH1 = OFF; + static const uint8_t INIT_STATE_RW = OFF; +#if BOARD_TE0720 == 1 + /* Because the TE0720 is not connected to the PCDU, this switch is always on */ + static const uint8_t INIT_STATE_TCS_BOARD_8V_HEATER_IN = ON; +#else + static const uint8_t INIT_STATE_TCS_BOARD_8V_HEATER_IN = OFF; +#endif + static const uint8_t INIT_STATE_SUS_REDUNDANT = OFF; + static const uint8_t INIT_STATE_DEPLOYMENT_MECHANISM = OFF; + static const uint8_t INIT_STATE_PAYLOAD_PCDU_CH6 = OFF; + static const uint8_t INIT_STATE_ACS_BOARD_SIDE_B = OFF; + static const uint8_t INIT_STATE_PAYLOAD_CAMERA = OFF; + static const uint8_t INIT_STATE_TCS_BOARD_3V3 = OFF; + static const uint8_t INIT_STATE_SYRLINKS = OFF; + static const uint8_t INIT_STATE_STAR_TRACKER = OFF; + static const uint8_t INIT_STATE_MGT = OFF; + static const uint8_t INIT_STATE_SUS_NOMINAL = OFF; + static const uint8_t INIT_STATE_SOLAR_CELL_EXP = OFF; + static const uint8_t INIT_STATE_PLOC = OFF; + static const uint8_t INIT_STATE_ACS_BOARD_SIDE_A = OFF; +} + + +#endif /* FSFWCONFIG_DEVICES_POWERSWITCHERLIST_H_ */ diff --git a/linux/fsfwconfig/tmtc/apid.h b/common/config/tmtc/apid.h similarity index 100% rename from linux/fsfwconfig/tmtc/apid.h rename to common/config/tmtc/apid.h diff --git a/fsfw b/fsfw index 354e158c..04cb8e82 160000 --- a/fsfw +++ b/fsfw @@ -1 +1 @@ -Subproject commit 354e158cc196d7deaf7de24ebcc96f5f6f5f20eb +Subproject commit 04cb8e82f1aaae89e20985539c74c1e36bb85ae3 diff --git a/misc/eclipse/Host/eive-linux-host-unittest.launch b/misc/eclipse/Host/eive-linux-host-unittest.launch new file mode 100644 index 00000000..048b7f3d --- /dev/null +++ b/misc/eclipse/Host/eive-linux-host-unittest.launch @@ -0,0 +1,33 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/mission/core/GenericFactory.cpp b/mission/core/GenericFactory.cpp index df15025b..a0939f1c 100644 --- a/mission/core/GenericFactory.cpp +++ b/mission/core/GenericFactory.cpp @@ -4,6 +4,7 @@ #include #include +#include "objects/systemObjectList.h" #include #include diff --git a/unittest/CMakeLists.txt b/unittest/CMakeLists.txt index ce562b28..0c799d45 100644 --- a/unittest/CMakeLists.txt +++ b/unittest/CMakeLists.txt @@ -1 +1,5 @@ add_subdirectory(testcfg) + +target_sources(${TARGET_NAME} PRIVATE + main.cpp +) \ No newline at end of file diff --git a/unittest/main.cpp b/unittest/main.cpp new file mode 100644 index 00000000..c76e214a --- /dev/null +++ b/unittest/main.cpp @@ -0,0 +1,6 @@ +#include "fsfw_tests/unit/CatchRunner.h" + +int main(int argc, char* argv[]) { + fsfwtest::customMain(argc, argv); +} + diff --git a/unittest/testcfg/FSFWConfig.h.in b/unittest/testcfg/FSFWConfig.h.in index d38f0648..d2ed901d 100644 --- a/unittest/testcfg/FSFWConfig.h.in +++ b/unittest/testcfg/FSFWConfig.h.in @@ -7,7 +7,7 @@ //! Used to determine whether C++ ostreams are used which can increase //! the binary size significantly. If this is disabled, //! the C stdio functions can be used alternatively -#define FSFW_CPP_OSTREAM_ENABLED 0 +#define FSFW_CPP_OSTREAM_ENABLED 1 //! More FSFW related printouts. Useful for development. #define FSFW_ENHANCED_PRINTOUT 0 @@ -20,6 +20,9 @@ #endif #endif +#define FSFW_USE_PUS_C_TELEMETRY 1 +#define FSFW_USE_PUS_C_TELECOMMANDS 1 + //! Can be used to enable additional debugging printouts for developing the FSFW #define FSFW_PRINT_VERBOSITY_LEVEL 0 diff --git a/unittest/testcfg/events/subsystemIdRanges.h b/unittest/testcfg/events/subsystemIdRanges.h index 24eee819..26af041e 100644 --- a/unittest/testcfg/events/subsystemIdRanges.h +++ b/unittest/testcfg/events/subsystemIdRanges.h @@ -2,6 +2,7 @@ #define CONFIG_EVENTS_SUBSYSTEMIDRANGES_H_ #include +#include "commonSubsystemIds.h" #include /** diff --git a/unittest/testcfg/objects/systemObjectList.h b/unittest/testcfg/objects/systemObjectList.h index efd21e0d..9ed43873 100644 --- a/unittest/testcfg/objects/systemObjectList.h +++ b/unittest/testcfg/objects/systemObjectList.h @@ -2,6 +2,7 @@ #define HOSTED_CONFIG_OBJECTS_SYSTEMOBJECTLIST_H_ #include +#include "commonObjects.h" #include // The objects will be instantiated in the ID order diff --git a/unittest/testcfg/returnvalues/classIds.h b/unittest/testcfg/returnvalues/classIds.h index 606cc60b..7a292708 100644 --- a/unittest/testcfg/returnvalues/classIds.h +++ b/unittest/testcfg/returnvalues/classIds.h @@ -1,6 +1,7 @@ #ifndef CONFIG_RETURNVALUES_CLASSIDS_H_ #define CONFIG_RETURNVALUES_CLASSIDS_H_ +#include "commonClassIds.h" #include /** diff --git a/unittest/testcfg/tmtc/apid.h b/unittest/testcfg/tmtc/apid.h index c0231bca..0172f6e3 100644 --- a/unittest/testcfg/tmtc/apid.h +++ b/unittest/testcfg/tmtc/apid.h @@ -11,7 +11,7 @@ * Chose APID(s) for mission and define it here. */ namespace apid { - static const uint16_t DEFAULT_APID = 0x00; + static const uint16_t EIVE_OBSW = 0x65; } -- 2.43.0 From 825682c36d0e9e10e1d8878e8ad5ae7e739a1f62 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Wed, 29 Sep 2021 10:59:37 +0200 Subject: [PATCH 17/18] unittests working --- CMakeLists.txt | 2 + fsfw | 2 +- misc/eclipse/.cproject | 66 +++++++++++++++++++ misc/eclipse/.project | 2 +- .../Host/eive-linux-host-unittest.launch | 4 +- unittest/main.cpp | 1 + 6 files changed, 73 insertions(+), 4 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index f57031cf..656ee3ee 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -91,6 +91,8 @@ set(EIVE_ADD_LINUX_FILES False) if(EIVE_BUILD_UNITTESTS) option(FSFW_ADD_UNITTESTS "Build the FSFW unittests as well" ON) + # Use FSFW custom main for unittests + set(FSFW_CUSTOM_UNITTEST_RUNNER ON) endif() if(FSFW_CUSTOM_UNITTEST_RUNNER OR FSFW_ADD_UNITTESTS) diff --git a/fsfw b/fsfw index 04cb8e82..3d0ce199 160000 --- a/fsfw +++ b/fsfw @@ -1 +1 @@ -Subproject commit 04cb8e82f1aaae89e20985539c74c1e36bb85ae3 +Subproject commit 3d0ce1998114c5d7a43034233ee03a800c8821b0 diff --git a/misc/eclipse/.cproject b/misc/eclipse/.cproject index fe0208b8..7d7c4c09 100644 --- a/misc/eclipse/.cproject +++ b/misc/eclipse/.cproject @@ -1357,6 +1357,68 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -1374,6 +1436,7 @@ + @@ -1385,6 +1448,9 @@ + + + diff --git a/misc/eclipse/.project b/misc/eclipse/.project index 86d98589..62145ff4 100644 --- a/misc/eclipse/.project +++ b/misc/eclipse/.project @@ -7,7 +7,7 @@ org.eclipse.cdt.managedbuilder.core.genmakebuilder - full,incremental, + clean,full,incremental, diff --git a/misc/eclipse/Host/eive-linux-host-unittest.launch b/misc/eclipse/Host/eive-linux-host-unittest.launch index 048b7f3d..85d54281 100644 --- a/misc/eclipse/Host/eive-linux-host-unittest.launch +++ b/misc/eclipse/Host/eive-linux-host-unittest.launch @@ -18,10 +18,10 @@ - + - + diff --git a/unittest/main.cpp b/unittest/main.cpp index c76e214a..cd4f4b77 100644 --- a/unittest/main.cpp +++ b/unittest/main.cpp @@ -1,3 +1,4 @@ +#include "fsfw/serviceinterface/ServiceInterfaceStream.h" #include "fsfw_tests/unit/CatchRunner.h" int main(int argc, char* argv[]) { -- 2.43.0 From 8e23be665bcba8e53bf777d9f5b3ebb364615d5a Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Wed, 29 Sep 2021 11:02:41 +0200 Subject: [PATCH 18/18] updated README --- README.md | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/README.md b/README.md index b12400e9..b6a18947 100644 --- a/README.md +++ b/README.md @@ -171,6 +171,26 @@ cmake -DTGT_BSP=arm/q7s -DFSFW_OSAL=linux -DEIVE_BUILD_WATCHDOG=ON -DCMAKE_BUILD cmake --build . -j ``` +### Hosted + +You can also replace `linux` by `host` for this command to build on Windows or for generic OSes + +```sh +mkdir build-Debug-Host && cd build-Debug-Host +cmake -DFSFW_OSAL=linux -DCMAKE_BUILD_TYPE=Debug .. +cmake --build . -j +``` + +### Unittests + +You can also replace `linux` by `host` for this command to build on Windows + +```sh +mkdir build-Debug-Unittest && cd build-Debug-Unittest +cmake -DFSFW_OSAL=linux -DEIVE_BUILD_UNITTESTS=ON .. +cmake --build . -j +``` + ## Connect to EIVE flatsat ### DNS -- 2.43.0