From d8185c0611f89db24d57f0ee04d05a2e5312c053 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Tue, 29 Dec 2020 13:59:31 +0100 Subject: [PATCH] added cmake support for csp lib --- CMakeLists.txt | 22 ++- Makefile | 2 +- bsp_hosted/InitMission.cpp | 5 +- {bsp_linux => bsp_q7s}/CMakeLists.txt | 0 {bsp_linux => bsp_q7s}/InitMission.cpp | 11 +- bsp_q7s/InitMission.h | 9 + bsp_q7s/ObjectFactory.cpp | 77 +++++++++ bsp_q7s/ObjectFactory.h | 10 ++ .../boardconfig/CMakeLists.txt | 0 .../boardconfig/etl_profile.h | 0 {bsp_linux => bsp_q7s}/boardconfig/gcov.h | 0 {bsp_linux => bsp_q7s}/boardconfig/print.c | 2 +- {bsp_linux => bsp_q7s}/boardconfig/print.h | 0 bsp_linux/bsp_linux.mk => bsp_q7s/bsp_q7s.mk | 0 {bsp_linux => bsp_q7s}/comIF/CspComIF.cpp | 3 +- {bsp_linux => bsp_q7s}/comIF/CspComIF.h | 0 .../comIF/cookies/CspCookie.cpp | 0 .../comIF/cookies/CspCookie.h | 8 +- bsp_q7s/main.cpp | 29 ++++ bsp_rpi/CMakeLists.txt | 7 +- bsp_rpi/InitMission.cpp | 158 ++++++++++++++++++ {bsp_linux => bsp_rpi}/InitMission.h | 0 {bsp_linux => bsp_rpi}/ObjectFactory.cpp | 0 {bsp_linux => bsp_rpi}/ObjectFactory.h | 0 bsp_rpi/boardconfig/CMakeLists.txt | 10 ++ bsp_rpi/boardconfig/etl_profile.h | 38 +++++ bsp_rpi/boardconfig/gcov.h | 14 ++ bsp_rpi/boardconfig/print.c | 14 ++ bsp_rpi/boardconfig/print.h | 8 + {bsp_linux => bsp_rpi}/main.cpp | 0 buildsystem/cmake/HardwareOsPreConfig.cmake | 7 +- libcsp/CMakeLists.txt | 12 ++ libcsp/include/CMakeLists.txt | 7 + libcsp/src/CMakeLists.txt | 25 +++ libcsp/src/arch/posix/CMakeLists.txt | 9 + libcsp/src/crypto/CMakeLists.txt | 5 + libcsp/src/drivers/CMakeLists.txt | 1 + libcsp/src/drivers/can/CMakeLists.txt | 3 + libcsp/src/interfaces/CMakeLists.txt | 7 + libcsp/src/rtable/CMakeLists.txt | 3 + libcsp/src/transport/CMakeLists.txt | 4 + mission/core/GenericFactory.cpp | 47 +----- 42 files changed, 490 insertions(+), 67 deletions(-) rename {bsp_linux => bsp_q7s}/CMakeLists.txt (100%) rename {bsp_linux => bsp_q7s}/InitMission.cpp (96%) create mode 100644 bsp_q7s/InitMission.h create mode 100644 bsp_q7s/ObjectFactory.cpp create mode 100644 bsp_q7s/ObjectFactory.h rename {bsp_linux => bsp_q7s}/boardconfig/CMakeLists.txt (100%) rename {bsp_linux => bsp_q7s}/boardconfig/etl_profile.h (100%) rename {bsp_linux => bsp_q7s}/boardconfig/gcov.h (100%) rename {bsp_linux => bsp_q7s}/boardconfig/print.c (81%) rename {bsp_linux => bsp_q7s}/boardconfig/print.h (100%) rename bsp_linux/bsp_linux.mk => bsp_q7s/bsp_q7s.mk (100%) rename {bsp_linux => bsp_q7s}/comIF/CspComIF.cpp (99%) rename {bsp_linux => bsp_q7s}/comIF/CspComIF.h (100%) rename {bsp_linux => bsp_q7s}/comIF/cookies/CspCookie.cpp (100%) rename {bsp_linux => bsp_q7s}/comIF/cookies/CspCookie.h (71%) create mode 100644 bsp_q7s/main.cpp create mode 100644 bsp_rpi/InitMission.cpp rename {bsp_linux => bsp_rpi}/InitMission.h (100%) rename {bsp_linux => bsp_rpi}/ObjectFactory.cpp (100%) rename {bsp_linux => bsp_rpi}/ObjectFactory.h (100%) create mode 100644 bsp_rpi/boardconfig/CMakeLists.txt create mode 100644 bsp_rpi/boardconfig/etl_profile.h create mode 100644 bsp_rpi/boardconfig/gcov.h create mode 100644 bsp_rpi/boardconfig/print.c create mode 100644 bsp_rpi/boardconfig/print.h rename {bsp_linux => bsp_rpi}/main.cpp (100%) create mode 100644 libcsp/CMakeLists.txt create mode 100644 libcsp/include/CMakeLists.txt create mode 100644 libcsp/src/CMakeLists.txt create mode 100644 libcsp/src/arch/posix/CMakeLists.txt create mode 100644 libcsp/src/crypto/CMakeLists.txt create mode 100644 libcsp/src/drivers/CMakeLists.txt create mode 100644 libcsp/src/drivers/can/CMakeLists.txt create mode 100644 libcsp/src/interfaces/CMakeLists.txt create mode 100644 libcsp/src/rtable/CMakeLists.txt create mode 100644 libcsp/src/transport/CMakeLists.txt diff --git a/CMakeLists.txt b/CMakeLists.txt index cd91447c..9a27a5cc 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -41,20 +41,26 @@ set(LIB_FSFW_NAME fsfw) # Set path names set(FSFW_PATH fsfw) set(MISSION_PATH mission) +set(CSPLIB_PATH libcsp) # Analyse different OS and architecture/target options, determine BSP_PATH, # display information about compiler etc. include (${CMAKE_SCRIPT_PATH}/HardwareOsPreConfig.cmake) pre_source_hw_os_config() -if(${OS_FSFW} MATCHES linux) -set(FSFW_CONFIG_PATH "fsfwconfig") +if(TGT_BSP) + if(${TGT_BSP} MATCHES "arm/q7s" OR ${TGT_BSP} MATCHES "arm/raspberrypi") + set(ROOT_CONFIG_FOLDER TRUE) + set(FSFW_CONFIG_PATH "fsfwconfig") + endif() + + if(${TGT_BSP} MATCHES "arm/q7s") + set(ADD_CSP_LIB TRUE) + endif() else() -set(FSFW_CONFIG_PATH "${BSP_PATH}/fsfwconfig") + set(FSFW_CONFIG_PATH "${BSP_PATH}/fsfwconfig") endif() -set(RPI_BSP_PATH "bsp_rpi") - ################################################################################ # Executable and Sources ################################################################################ @@ -63,12 +69,12 @@ set(RPI_BSP_PATH "bsp_rpi") add_executable(${TARGET_NAME}) # Add subdirectories -if(${OS_FSFW} MATCHES linux) +if(ROOT_CONFIG_FOLDER) add_subdirectory(${FSFW_CONFIG_PATH}) endif() -if(${TGT_BSP} MATCHES "arm/raspberrypi") - add_subdirectory(${RPI_BSP_PATH}) +if(ADD_CSP_LIB) + add_subdirectory(${CSPLIB_PATH}) endif() add_subdirectory(${BSP_PATH}) diff --git a/Makefile b/Makefile index 3956d5f1..b1ccd741 100644 --- a/Makefile +++ b/Makefile @@ -13,7 +13,7 @@ SHELL = /bin/sh # Chip & board used for compilation # (can be overriden by adding CHIP=chip and BOARD=board to the command-line) -BOARD_FILE_ROOT = bsp_linux +BOARD_FILE_ROOT = bsp_q7s BOARD = linux OS_FSFW = linux CUSTOM_DEFINES += -D$(OS_FSFW) diff --git a/bsp_hosted/InitMission.cpp b/bsp_hosted/InitMission.cpp index cfc33db9..d4e58b99 100644 --- a/bsp_hosted/InitMission.cpp +++ b/bsp_hosted/InitMission.cpp @@ -1,6 +1,5 @@ -#include -#include - +#include +#include #include #include #include diff --git a/bsp_linux/CMakeLists.txt b/bsp_q7s/CMakeLists.txt similarity index 100% rename from bsp_linux/CMakeLists.txt rename to bsp_q7s/CMakeLists.txt diff --git a/bsp_linux/InitMission.cpp b/bsp_q7s/InitMission.cpp similarity index 96% rename from bsp_linux/InitMission.cpp rename to bsp_q7s/InitMission.cpp index c50a1d38..94892adf 100644 --- a/bsp_linux/InitMission.cpp +++ b/bsp_q7s/InitMission.cpp @@ -1,5 +1,6 @@ -#include -#include +#include "InitMission.h" +#include "ObjectFactory.h" +#include #include #include @@ -8,8 +9,6 @@ #include #include #include -#include -#include #include #include @@ -144,7 +143,7 @@ void InitMission::initTasks(){ } -#if ADD_TEST_CODE == 1 +#if OBSW_ADD_TEST_CODE == 1 // FixedTimeslotTaskIF* TestTimeslotTask = TaskFactory::instance()-> // createFixedTimeslotTask("PST_TEST_TASK", 10, // PeriodicTaskIF::MINIMUM_STACK_SIZE, 1.0, nullptr); @@ -172,7 +171,7 @@ void InitMission::initTasks(){ // P60DockTask->startTask(); -#if ADD_TEST_CODE == 1 +#if OBSW_ADD_TEST_CODE == 1 // TestTimeslotTask->startTask(); #endif sif::info << "Tasks started.." << std::endl; diff --git a/bsp_q7s/InitMission.h b/bsp_q7s/InitMission.h new file mode 100644 index 00000000..89d65ada --- /dev/null +++ b/bsp_q7s/InitMission.h @@ -0,0 +1,9 @@ +#ifndef BSP_Q7S_INITMISSION_H_ +#define BSP_Q7S_INITMISSION_H_ + +namespace InitMission { +void initMission(); +void initTasks(); +}; + +#endif /* BSP_Q7S_INITMISSION_H_ */ diff --git a/bsp_q7s/ObjectFactory.cpp b/bsp_q7s/ObjectFactory.cpp new file mode 100644 index 00000000..86c0f068 --- /dev/null +++ b/bsp_q7s/ObjectFactory.cpp @@ -0,0 +1,77 @@ +#include "ObjectFactory.h" +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include + +#include +#include + +void Factory::setStaticFrameworkObjectIds() { + PusServiceBase::packetSource = objects::PUS_PACKET_DISTRIBUTOR; + PusServiceBase::packetDestination = objects::TM_FUNNEL; + + CommandingServiceBase::defaultPacketSource = objects::PUS_PACKET_DISTRIBUTOR; + CommandingServiceBase::defaultPacketDestination = objects::TM_FUNNEL; + + TmFunnel::downlinkDestination = objects::UDP_BRIDGE; + // No storage object for now. + TmFunnel::storageDestination = objects::NO_OBJECT; + + LocalDataPoolManager::defaultHkDestination = objects::NO_OBJECT; + + VerificationReporter::messageReceiver = objects::PUS_SERVICE_1_VERIFICATION; + TmPacketStored::timeStamperId = objects::TIME_STAMPER; +} + + + +void ObjectFactory::produce(){ + Factory::setStaticFrameworkObjectIds(); + ObjectFactory::produceGenericObjects(); + + /* Cookies */ + CspCookie* p60DockCspCookie = new CspCookie(P60Dock::MAX_REPLY_LENGTH, + addresses::P60DOCK); + CspCookie* pdu1CspCookie = new CspCookie(PDU::MAX_REPLY_LENGTH, + addresses::PDU1); + CspCookie* pdu2CspCookie = new CspCookie(PDU::MAX_REPLY_LENGTH, + addresses::PDU2); + CspCookie* acuCspCookie = new CspCookie(ACU::MAX_REPLY_LENGTH, + addresses::ACU); + + /* Communication interfaces */ + new CspComIF(objects::CSP_COM_IF); + + /* Device Handler */ + new GomspaceDeviceHandler(objects::P60DOCK_HANDLER, objects::CSP_COM_IF, + p60DockCspCookie, P60Dock::MAX_CONFIGTABLE_ADDRESS, + P60Dock::MAX_HKTABLE_ADDRESS); + new GomspaceDeviceHandler(objects::PDU1_HANDLER, objects::CSP_COM_IF, + pdu1CspCookie, PDU::MAX_CONFIGTABLE_ADDRESS, + PDU::MAX_HKTABLE_ADDRESS); + new GomspaceDeviceHandler(objects::PDU2_HANDLER, objects::CSP_COM_IF, + pdu2CspCookie, PDU::MAX_CONFIGTABLE_ADDRESS, + PDU::MAX_HKTABLE_ADDRESS); + new GomspaceDeviceHandler(objects::ACU_HANDLER, objects::CSP_COM_IF, + acuCspCookie, ACU::MAX_CONFIGTABLE_ADDRESS, + ACU::MAX_HKTABLE_ADDRESS); + + new TmTcUnixUdpBridge(objects::UDP_BRIDGE, + objects::CCSDS_PACKET_DISTRIBUTOR, + objects::TM_STORE, objects::TC_STORE); + new TcUnixUdpPollingTask(objects::UDP_POLLING_TASK, objects::UDP_BRIDGE); +} diff --git a/bsp_q7s/ObjectFactory.h b/bsp_q7s/ObjectFactory.h new file mode 100644 index 00000000..5e3358ae --- /dev/null +++ b/bsp_q7s/ObjectFactory.h @@ -0,0 +1,10 @@ +#ifndef BSP_Q7S_OBJECTFACTORY_H_ +#define BSP_Q7S_OBJECTFACTORY_H_ + + +namespace ObjectFactory { + void setStatics(); + void produce(); +}; + +#endif /* BSP_Q7S_OBJECTFACTORY_H_ */ diff --git a/bsp_linux/boardconfig/CMakeLists.txt b/bsp_q7s/boardconfig/CMakeLists.txt similarity index 100% rename from bsp_linux/boardconfig/CMakeLists.txt rename to bsp_q7s/boardconfig/CMakeLists.txt diff --git a/bsp_linux/boardconfig/etl_profile.h b/bsp_q7s/boardconfig/etl_profile.h similarity index 100% rename from bsp_linux/boardconfig/etl_profile.h rename to bsp_q7s/boardconfig/etl_profile.h diff --git a/bsp_linux/boardconfig/gcov.h b/bsp_q7s/boardconfig/gcov.h similarity index 100% rename from bsp_linux/boardconfig/gcov.h rename to bsp_q7s/boardconfig/gcov.h diff --git a/bsp_linux/boardconfig/print.c b/bsp_q7s/boardconfig/print.c similarity index 81% rename from bsp_linux/boardconfig/print.c rename to bsp_q7s/boardconfig/print.c index f409ee1b..c501e0b7 100644 --- a/bsp_linux/boardconfig/print.c +++ b/bsp_q7s/boardconfig/print.c @@ -1,4 +1,4 @@ -#include "print.h" +#include #include void printChar(const char* character, bool errStream) { diff --git a/bsp_linux/boardconfig/print.h b/bsp_q7s/boardconfig/print.h similarity index 100% rename from bsp_linux/boardconfig/print.h rename to bsp_q7s/boardconfig/print.h diff --git a/bsp_linux/bsp_linux.mk b/bsp_q7s/bsp_q7s.mk similarity index 100% rename from bsp_linux/bsp_linux.mk rename to bsp_q7s/bsp_q7s.mk diff --git a/bsp_linux/comIF/CspComIF.cpp b/bsp_q7s/comIF/CspComIF.cpp similarity index 99% rename from bsp_linux/comIF/CspComIF.cpp rename to bsp_q7s/comIF/CspComIF.cpp index 83be2864..cf72be94 100644 --- a/bsp_linux/comIF/CspComIF.cpp +++ b/bsp_q7s/comIF/CspComIF.cpp @@ -1,5 +1,6 @@ #include "CspComIF.h" -#include +#include "cookies/CspCookie.h" + #include #include #include diff --git a/bsp_linux/comIF/CspComIF.h b/bsp_q7s/comIF/CspComIF.h similarity index 100% rename from bsp_linux/comIF/CspComIF.h rename to bsp_q7s/comIF/CspComIF.h diff --git a/bsp_linux/comIF/cookies/CspCookie.cpp b/bsp_q7s/comIF/cookies/CspCookie.cpp similarity index 100% rename from bsp_linux/comIF/cookies/CspCookie.cpp rename to bsp_q7s/comIF/cookies/CspCookie.cpp diff --git a/bsp_linux/comIF/cookies/CspCookie.h b/bsp_q7s/comIF/cookies/CspCookie.h similarity index 71% rename from bsp_linux/comIF/cookies/CspCookie.h rename to bsp_q7s/comIF/cookies/CspCookie.h index 128926e5..e877761d 100644 --- a/bsp_linux/comIF/cookies/CspCookie.h +++ b/bsp_q7s/comIF/cookies/CspCookie.h @@ -1,8 +1,8 @@ -#ifndef BSP_LINUX_COMIF_COOKIES_CSPCOOKIE_H_ -#define BSP_LINUX_COMIF_COOKIES_CSPCOOKIE_H_ +#ifndef BSP_Q7S_COMIF_COOKIES_CSPCOOKIE_H_ +#define BSP_Q7S_COMIF_COOKIES_CSPCOOKIE_H_ #include -#include +#include /** * @brief This is the cookie for devices supporting the CSP (CubeSat Space @@ -24,4 +24,4 @@ private: uint8_t cspAddress; }; -#endif /* BSP_LINUX_COMIF_COOKIES_CSPCOOKIE_H_ */ +#endif /* BSP_Q7S_COMIF_COOKIES_CSPCOOKIE_H_ */ diff --git a/bsp_q7s/main.cpp b/bsp_q7s/main.cpp new file mode 100644 index 00000000..49416ae2 --- /dev/null +++ b/bsp_q7s/main.cpp @@ -0,0 +1,29 @@ +#include "InitMission.h" +#include +#include + +#include + +#include + +/** + * @brief This is the main program for the target hardware. + * @return + */ +int main(void) +{ + std::cout << "-- EIVE OBSW --" << std::endl; + std::cout << "-- Compiled for Linux " << " --" << std::endl; + 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_rpi/CMakeLists.txt b/bsp_rpi/CMakeLists.txt index e2ad16aa..8dd8e6f1 100644 --- a/bsp_rpi/CMakeLists.txt +++ b/bsp_rpi/CMakeLists.txt @@ -1,6 +1,11 @@ target_sources(${TARGET_NAME} PUBLIC - + InitMission.cpp + main.cpp + ObjectFactory.cpp ) +add_subdirectory(boardconfig) + + diff --git a/bsp_rpi/InitMission.cpp b/bsp_rpi/InitMission.cpp new file mode 100644 index 00000000..76918716 --- /dev/null +++ b/bsp_rpi/InitMission.cpp @@ -0,0 +1,158 @@ +#include "InitMission.h" +#include "ObjectFactory.h" + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +// This is configured for linux without \cr +#ifdef LINUX +ServiceInterfaceStream sif::debug("DEBUG"); +ServiceInterfaceStream sif::info("INFO"); +ServiceInterfaceStream sif::warning("WARNING"); +ServiceInterfaceStream sif::error("ERROR", false, false, true); +#else +ServiceInterfaceStream sif::debug("DEBUG", true); +ServiceInterfaceStream sif::info("INFO", true); +ServiceInterfaceStream sif::warning("WARNING", true); +ServiceInterfaceStream sif::error("ERROR", true, false, true); +#endif + +ObjectManagerIF *objectManager = nullptr; + +void InitMission::initMission() { + 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(); + + /* This function creates and starts all tasks */ + 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); + if(result != HasReturnvaluesIF::RETURN_OK) { + 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); + if(result != HasReturnvaluesIF::RETURN_OK) { + 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); + if(result != HasReturnvaluesIF::RETURN_OK) { + 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; + } + + 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* 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* 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* 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; + } + + +#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 + + //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; +} diff --git a/bsp_linux/InitMission.h b/bsp_rpi/InitMission.h similarity index 100% rename from bsp_linux/InitMission.h rename to bsp_rpi/InitMission.h diff --git a/bsp_linux/ObjectFactory.cpp b/bsp_rpi/ObjectFactory.cpp similarity index 100% rename from bsp_linux/ObjectFactory.cpp rename to bsp_rpi/ObjectFactory.cpp diff --git a/bsp_linux/ObjectFactory.h b/bsp_rpi/ObjectFactory.h similarity index 100% rename from bsp_linux/ObjectFactory.h rename to bsp_rpi/ObjectFactory.h diff --git a/bsp_rpi/boardconfig/CMakeLists.txt b/bsp_rpi/boardconfig/CMakeLists.txt new file mode 100644 index 00000000..c32b326d --- /dev/null +++ b/bsp_rpi/boardconfig/CMakeLists.txt @@ -0,0 +1,10 @@ +target_sources(${TARGET_NAME} PRIVATE + print.c +) + +target_include_directories(${TARGET_NAME} PUBLIC + ${CMAKE_CURRENT_SOURCE_DIR} +) + + + diff --git a/bsp_rpi/boardconfig/etl_profile.h b/bsp_rpi/boardconfig/etl_profile.h new file mode 100644 index 00000000..c35ffb46 --- /dev/null +++ b/bsp_rpi/boardconfig/etl_profile.h @@ -0,0 +1,38 @@ +///\file + +/****************************************************************************** +The MIT License(MIT) + +Embedded Template Library. +https://github.com/ETLCPP/etl +https://www.etlcpp.com + +Copyright(c) 2019 jwellbelove + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files(the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and / or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions : + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. +******************************************************************************/ +#ifndef __ETL_PROFILE_H__ +#define __ETL_PROFILE_H__ + +#define ETL_CHECK_PUSH_POP + +#define ETL_CPP11_SUPPORTED 1 +#define ETL_NO_NULLPTR_SUPPORT 0 + +#endif diff --git a/bsp_rpi/boardconfig/gcov.h b/bsp_rpi/boardconfig/gcov.h new file mode 100644 index 00000000..491d24c6 --- /dev/null +++ b/bsp_rpi/boardconfig/gcov.h @@ -0,0 +1,14 @@ +#ifndef LINUX_GCOV_H_ +#define LINUX_GCOV_H_ +#include + +#ifdef GCOV +extern "C" void __gcov_flush(); +#else +void __gcov_flush() { + sif::info << "GCC GCOV: Please supply GCOV=1 in Makefile if " + "coverage information is desired.\n" << std::flush; +} +#endif + +#endif /* LINUX_GCOV_H_ */ diff --git a/bsp_rpi/boardconfig/print.c b/bsp_rpi/boardconfig/print.c new file mode 100644 index 00000000..c501e0b7 --- /dev/null +++ b/bsp_rpi/boardconfig/print.c @@ -0,0 +1,14 @@ +#include +#include + +void printChar(const char* character, bool errStream) { + if(errStream) { + putc(*character, stderr); + return; + } + putc(*character, stdout); +} + + + + diff --git a/bsp_rpi/boardconfig/print.h b/bsp_rpi/boardconfig/print.h new file mode 100644 index 00000000..8e7e2e5d --- /dev/null +++ b/bsp_rpi/boardconfig/print.h @@ -0,0 +1,8 @@ +#ifndef HOSTED_BOARDCONFIG_PRINT_H_ +#define HOSTED_BOARDCONFIG_PRINT_H_ + +#include + +void printChar(const char* character, bool errStream); + +#endif /* HOSTED_BOARDCONFIG_PRINT_H_ */ diff --git a/bsp_linux/main.cpp b/bsp_rpi/main.cpp similarity index 100% rename from bsp_linux/main.cpp rename to bsp_rpi/main.cpp diff --git a/buildsystem/cmake/HardwareOsPreConfig.cmake b/buildsystem/cmake/HardwareOsPreConfig.cmake index b8a11f97..4ead6540 100644 --- a/buildsystem/cmake/HardwareOsPreConfig.cmake +++ b/buildsystem/cmake/HardwareOsPreConfig.cmake @@ -10,7 +10,6 @@ elseif(${OS_FSFW} STREQUAL rtems) elseif(${OS_FSFW} STREQUAL linux) add_definitions(-DUNIX -DLINUX) find_package(Threads REQUIRED) - set(BSP_PATH "bsp_linux") # Hosted else() set(BSP_PATH "bsp_hosted") @@ -54,8 +53,10 @@ endif() if(TGT_BSP) - if (${TGT_BSP} MATCHES "arm/raspberrypi" OR ${TGT_BSP} MATCHES "arm/q7s") - # set(BSP_PATH "bsp_linux") + if (${TGT_BSP} MATCHES "arm/raspberrypi") + set(BSP_PATH "bsp_rpi") + elseif(${TGT_BSP} MATCHES "arm/q7s") + set(BSP_PATH "bsp_q7s") else() message(WARNING "CMake not configured for this target!") message(FATAL_ERROR "Target: ${TGT_BSP}!") diff --git a/libcsp/CMakeLists.txt b/libcsp/CMakeLists.txt new file mode 100644 index 00000000..5c9f7677 --- /dev/null +++ b/libcsp/CMakeLists.txt @@ -0,0 +1,12 @@ +cmake_minimum_required(VERSION 3.13) + +set(LIB_CSP_NAME libcsp) + +add_library(${LIB_CSP_NAME}) + +add_subdirectory(src) +add_subdirectory(include) + +target_include_directories(${LIB_CSP_NAME} PRIVATE + ${CMAKE_CURRENT_SOURCE_DIR} +) \ No newline at end of file diff --git a/libcsp/include/CMakeLists.txt b/libcsp/include/CMakeLists.txt new file mode 100644 index 00000000..94fee196 --- /dev/null +++ b/libcsp/include/CMakeLists.txt @@ -0,0 +1,7 @@ +target_include_directories(${LIB_CSP_NAME} PRIVATE + ${CMAKE_CURRENT_SOURCE_DIR} + ${CMAKE_CURRENT_SOURCE_DIR}/csp + ${CMAKE_CURRENT_SOURCE_DIR}/csp/crypto +) + + diff --git a/libcsp/src/CMakeLists.txt b/libcsp/src/CMakeLists.txt new file mode 100644 index 00000000..5d1bfbf5 --- /dev/null +++ b/libcsp/src/CMakeLists.txt @@ -0,0 +1,25 @@ +target_sources(${LIB_CSP_NAME} PRIVATE + csp_bridge.c + csp_buffer.c + csp_conn.c + csp_crc32.c + csp_debug.c + csp_dedup.c + csp_endian.c + csp_hex_dump.c + csp_pflist.c + csp_io.c + csp_port.c + csp_promisc.c + csp_qfifo.c + csp_route.c + csp_service_handler.c + csp_services.c + csp_sfp.c +) + +add_subdirectory(drivers) +add_subdirectory(crypto) +add_subdirectory(interfaces) +add_subdirectory(rtable) + diff --git a/libcsp/src/arch/posix/CMakeLists.txt b/libcsp/src/arch/posix/CMakeLists.txt new file mode 100644 index 00000000..856040bc --- /dev/null +++ b/libcsp/src/arch/posix/CMakeLists.txt @@ -0,0 +1,9 @@ +target_sources(${LIB_CSP_NAME} PRIVATE + csp_malloc.c + csp_queue.c + csp_sempahore.c + csp_system.c + csp_thread.c + csp_time.c + pthread_queue.c +) diff --git a/libcsp/src/crypto/CMakeLists.txt b/libcsp/src/crypto/CMakeLists.txt new file mode 100644 index 00000000..19cb878a --- /dev/null +++ b/libcsp/src/crypto/CMakeLists.txt @@ -0,0 +1,5 @@ +target_sources(${LIB_CSP_NAME} PRIVATE + csp_hmac.c + csp_sha1.c + csp_xtea.c +) diff --git a/libcsp/src/drivers/CMakeLists.txt b/libcsp/src/drivers/CMakeLists.txt new file mode 100644 index 00000000..e2dd440b --- /dev/null +++ b/libcsp/src/drivers/CMakeLists.txt @@ -0,0 +1 @@ +add_subdirectory(can) diff --git a/libcsp/src/drivers/can/CMakeLists.txt b/libcsp/src/drivers/can/CMakeLists.txt new file mode 100644 index 00000000..d291fccc --- /dev/null +++ b/libcsp/src/drivers/can/CMakeLists.txt @@ -0,0 +1,3 @@ +target_sources(${LIB_CSP_NAME} PRIVATE + can_socketcan.c +) diff --git a/libcsp/src/interfaces/CMakeLists.txt b/libcsp/src/interfaces/CMakeLists.txt new file mode 100644 index 00000000..33f779e3 --- /dev/null +++ b/libcsp/src/interfaces/CMakeLists.txt @@ -0,0 +1,7 @@ +target_sources(${LIB_CSP_NAME} PRIVATE + csp_if_can_pbuf.c + csp_if_can.c + csp_if_i2c.c + csp_if_kiss.c + csp_if_lo.c +) diff --git a/libcsp/src/rtable/CMakeLists.txt b/libcsp/src/rtable/CMakeLists.txt new file mode 100644 index 00000000..101f4fb9 --- /dev/null +++ b/libcsp/src/rtable/CMakeLists.txt @@ -0,0 +1,3 @@ +target_sources(${LIB_CSP_NAME} PRIVATE + csp_rtable_cidr.c +) diff --git a/libcsp/src/transport/CMakeLists.txt b/libcsp/src/transport/CMakeLists.txt new file mode 100644 index 00000000..c509b755 --- /dev/null +++ b/libcsp/src/transport/CMakeLists.txt @@ -0,0 +1,4 @@ +target_sources(${LIB_CSP_NAME} PRIVATE + csp_rdp.c + csp_udp.c +) diff --git a/mission/core/GenericFactory.cpp b/mission/core/GenericFactory.cpp index 24572218..b708f964 100644 --- a/mission/core/GenericFactory.cpp +++ b/mission/core/GenericFactory.cpp @@ -1,9 +1,9 @@ #include "GenericFactory.h" -#include -#include -#include + #include -#include + +#include +#include #include #include @@ -21,13 +21,9 @@ #include #include #include -#include -#include -#include "mission/devices/GomspaceDeviceHandler.h" -#include "mission/devices/devicedefinitions/GomspaceDefinitions.h" -#if ADD_TEST_CODE == 1 -//#include +#if OBSW_ADD_TEST_CODE == 1 + #include #endif void ObjectFactory::produceGenericObjects() { @@ -84,35 +80,8 @@ void ObjectFactory::produceGenericObjects() { new CService200ModeCommanding(objects::PUS_SERVICE_200_MODE_MGMT, apid::EIVE_OBSW, pus::PUS_SERVICE_200); - /* Cookies */ - CspCookie* p60DockCspCookie = new CspCookie(P60Dock::MAX_REPLY_LENGTH, - addresses::P60DOCK); - CspCookie* pdu1CspCookie = new CspCookie(PDU::MAX_REPLY_LENGTH, - addresses::PDU1); - CspCookie* pdu2CspCookie = new CspCookie(PDU::MAX_REPLY_LENGTH, - addresses::PDU2); - CspCookie* acuCspCookie = new CspCookie(ACU::MAX_REPLY_LENGTH, - addresses::ACU); - - /* Communication interfaces */ - new CspComIF(objects::CSP_COM_IF); - - /* Device Handler */ - new GomspaceDeviceHandler(objects::P60DOCK_HANDLER, objects::CSP_COM_IF, - p60DockCspCookie, P60Dock::MAX_CONFIGTABLE_ADDRESS, - P60Dock::MAX_HKTABLE_ADDRESS); - new GomspaceDeviceHandler(objects::PDU1_HANDLER, objects::CSP_COM_IF, - pdu1CspCookie, PDU::MAX_CONFIGTABLE_ADDRESS, - PDU::MAX_HKTABLE_ADDRESS); - new GomspaceDeviceHandler(objects::PDU2_HANDLER, objects::CSP_COM_IF, - pdu2CspCookie, PDU::MAX_CONFIGTABLE_ADDRESS, - PDU::MAX_HKTABLE_ADDRESS); - new GomspaceDeviceHandler(objects::ACU_HANDLER, objects::CSP_COM_IF, - acuCspCookie, ACU::MAX_CONFIGTABLE_ADDRESS, - ACU::MAX_HKTABLE_ADDRESS); - /* Test Device Handler */ -#if ADD_TEST_CODE == 1 -// new TestTask(objects::TEST_TASK); +#if OBSW_ADD_TEST_CODE == 1 + new TestTask(objects::TEST_TASK); #endif }