diff --git a/CMakeLists.txt b/CMakeLists.txt index d057de50..9f1c6d05 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -153,8 +153,6 @@ if(ADD_JSON_LIB) add_subdirectory(${LIB_JSON_PATH}) endif() - - if(NOT EIVE_BUILD_WATCHDOG) if(ADD_LINUX_FILES) add_subdirectory(${LINUX_PATH}) @@ -190,8 +188,13 @@ if((NOT BUILD_Q7S_SIMPLE_MODE) AND (NOT EIVE_BUILD_WATCHDOG)) ${LIB_FSFW_NAME} ${LIB_OS_NAME} ${LIB_LWGPS_NAME} - ${LIB_ARCSEC} ) + + if(TGT_BSP MATCHES "arm/q7s") + target_link_libraries(${TARGET_NAME} PRIVATE + ${LIB_ARCSEC} + ) + endif() endif() if(NOT EIVE_BUILD_WATCHDOG) @@ -214,8 +217,6 @@ if(ADD_JSON_LIB) ) endif() - - target_link_libraries(${TARGET_NAME} PRIVATE ${LIB_CXX_FS} ) @@ -228,6 +229,11 @@ target_include_directories(${TARGET_NAME} PRIVATE ${ARCSEC_LIB_PATH} ) +if(TGT_BSP MATCHES "arm/q7s") + target_include_directories(${TARGET_NAME} PRIVATE + ${ARCSEC_LIB_PATH} + ) +endif() if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU") set(WARNING_FLAGS diff --git a/bsp_linux_board/InitMission.cpp b/bsp_linux_board/InitMission.cpp index 68423216..febae2f3 100644 --- a/bsp_linux_board/InitMission.cpp +++ b/bsp_linux_board/InitMission.cpp @@ -134,12 +134,14 @@ void initmission::initTasks() { objects::INTERNAL_ERROR_REPORTER); } + bool startTestPst = true; #if OBSW_ADD_TEST_PST == 1 FixedTimeslotTaskIF* pstTestTask = factory->createFixedTimeslotTask("ACS_PST", 50, PeriodicTaskIF::MINIMUM_STACK_SIZE * 2, 2.0, missedDeadlineFunc); result = pst::pstTest(pstTestTask); if(result != HasReturnvaluesIF::RETURN_OK) { - sif::warning << "initmission::initTasks: ACS PST initialization failed!" << std::endl; + sif::info << "initmission::initTasks: ACS PST empty or invalid" << std::endl; + startTestPst = false; } #endif /* RPI_TEST_ACS_BOARD == 1 */ @@ -186,7 +188,9 @@ void initmission::initTasks() { #endif /* OBSW_ADD_TEST_CODE == 1 */ #if OBSW_ADD_TEST_PST == 1 - pstTestTask->startTask(); + if(startTestPst) { + pstTestTask->startTask(); + } #endif /* RPI_TEST_ACS_BOARD == 1 */ sif::info << "Tasks started.." << std::endl; } diff --git a/bsp_linux_board/ObjectFactory.cpp b/bsp_linux_board/ObjectFactory.cpp index b24b633f..fa5c35dd 100644 --- a/bsp_linux_board/ObjectFactory.cpp +++ b/bsp_linux_board/ObjectFactory.cpp @@ -1,6 +1,3 @@ -#include -#include -#include #include "ObjectFactory.h" #include "objects/systemObjectList.h" @@ -17,6 +14,7 @@ #include "mission/core/GenericFactory.h" #include "mission/utility/TmFunnel.h" +#include #include "mission/devices/MGMHandlerLIS3MDL.h" #include "mission/devices/MGMHandlerRM3100.h" #include "mission/devices/GyroADIS16507Handler.h" @@ -28,8 +26,13 @@ #include "fsfw/tasks/TaskFactory.h" /* UDP server includes */ +#if OBSW_USE_TMTC_TCP_BRIDGE == 1 +#include +#include +#else #include "fsfw/osal/common/UdpTmTcBridge.h" #include "fsfw/osal/common/UdpTcPollingTask.h" +#endif #include "fsfw_hal/devicehandlers/GyroL3GD20Handler.h" #include "fsfw_hal/linux/gpio/LinuxLibgpioIF.h" @@ -37,6 +40,8 @@ #include "fsfw_hal/common/gpio/GpioCookie.h" #include "fsfw_hal/linux/spi/SpiCookie.h" #include "fsfw_hal/linux/spi/SpiComIF.h" +#include +#include void Factory::setStaticFrameworkObjectIds() { PusServiceBase::packetSource = objects::PUS_PACKET_DISTRIBUTOR; @@ -59,12 +64,27 @@ void ObjectFactory::produce(void* args){ Factory::setStaticFrameworkObjectIds(); ObjectFactory::produceGenericObjects(); +#if OBSW_USE_TMTC_TCP_BRIDGE == 1 + new TcpTmTcBridge(objects::TMTC_BRIDGE, objects::CCSDS_PACKET_DISTRIBUTOR); + new TcpTmTcServer(objects::TMTC_POLLING_TASK, objects::TMTC_BRIDGE); +#else new UdpTmTcBridge(objects::TMTC_BRIDGE, objects::CCSDS_PACKET_DISTRIBUTOR); new UdpTcPollingTask(objects::TMTC_POLLING_TASK, objects::TMTC_BRIDGE); +#endif GpioIF* gpioIF = new LinuxLibgpioIF(objects::GPIO_IF); GpioCookie* gpioCookie = nullptr; static_cast(gpioCookie); + + new SpiComIF(objects::SPI_COM_IF, gpioIF); + + std::string spiDev; + SpiCookie* spiCookie = nullptr; + static_cast(spiCookie); + +#if OBSW_ADD_TEST_CODE == 1 + new TestTask(objects::TEST_TASK); + #if RPI_ADD_SPI_TEST == 1 new SpiTestClass(objects::SPI_TEST, gpioIF); #endif @@ -89,12 +109,6 @@ void ObjectFactory::produce(void* args){ new LibgpiodTest(objects::LIBGPIOD_TEST, objects::GPIO_IF, gpioCookieLoopback); #endif /* RPI_LOOPBACK_TEST_GPIO == 1 */ - new SpiComIF(objects::SPI_COM_IF, gpioIF); - - std::string spiDev; - SpiCookie* spiCookie = nullptr; - static_cast(spiCookie); - #if RPI_TEST_ACS_BOARD == 1 if(gpioCookie == nullptr) { gpioCookie = new GpioCookie(); @@ -158,8 +172,9 @@ void ObjectFactory::produce(void* args){ uartCookie->setToFlushInput(true); uartCookie->setReadCycles(6); GPSHyperionHandler* gpsHandler = new GPSHyperionHandler(objects::GPS0_HANDLER, - objects::UART_COM_IF, uartCookie); + objects::UART_COM_IF, uartCookie, false); gpsHandler->setStartUpImmediately(); #endif +#endif /* OBSW_ADD_TEST_CODE == 1 */ } diff --git a/bsp_linux_board/boardconfig/rpiConfig.h.in b/bsp_linux_board/boardconfig/rpiConfig.h.in index 19629465..5198ddb7 100644 --- a/bsp_linux_board/boardconfig/rpiConfig.h.in +++ b/bsp_linux_board/boardconfig/rpiConfig.h.in @@ -15,10 +15,7 @@ #define RPI_TEST_ACS_BOARD 0 #endif -#define RPI_ADD_UART_TEST 1 -#if RPI_ADD_UART_TEST == 1 -#define RPI_TEST_GPS_DEVICE 0 -#endif +#define RPI_ADD_UART_TEST 0 /* Adapt these values accordingly */ namespace gpio { diff --git a/bsp_linux_board/main.cpp b/bsp_linux_board/main.cpp index 2e9ce8a4..a766f2a0 100644 --- a/bsp_linux_board/main.cpp +++ b/bsp_linux_board/main.cpp @@ -1,4 +1,5 @@ #include "InitMission.h" +#include "OBSWConfig.h" #include "OBSWVersion.h" #include "fsfw/FSFWVersion.h" diff --git a/cmake/HardwareOsPostConfig.cmake b/cmake/HardwareOsPostConfig.cmake index 73a8d8b1..2492b9bb 100644 --- a/cmake/HardwareOsPostConfig.cmake +++ b/cmake/HardwareOsPostConfig.cmake @@ -11,17 +11,6 @@ if(LINK_LWIP) endif() endif() -if(LINK_HAL) - message(STATUS "Linking against ${LIB_HAL_NAME} HAL library") - if(LIB_HAL_NAME) - target_link_libraries(${TARGET_NAME} PUBLIC - ${LIB_HAL_NAME} - ) - else() - message(WARNING "HAL library name not set!") - endif() -endif() - if(LINKER_SCRIPT) target_link_options(${TARGET_NAME} PRIVATE -T${LINKER_SCRIPT} @@ -52,11 +41,14 @@ target_compile_options(${TARGET_NAME} PRIVATE $<$:${ASM_FLAGS}> ) +set(STRIPPED_TARGET_NAME ${TARGET_NAME}-stripped) + add_custom_command( TARGET ${TARGET_NAME} POST_BUILD - COMMAND ${CMAKE_OBJCOPY} -O binary ${TARGET_NAME} ${TARGET_NAME}.bin - COMMENT "Generating binary file ${CMAKE_PROJECT_NAME}.bin.." + COMMAND ${CMAKE_STRIP} --strip-all ${TARGET_NAME} -o ${STRIPPED_TARGET_NAME} + BYPRODUCTS ${STRIPPED_TARGET_NAME} + COMMENT "Generating stripped executable ${STRIPPED_TARGET_NAME}.." ) endfunction() \ No newline at end of file diff --git a/cmake/Q7SCrossCompileConfig.cmake b/cmake/Q7SCrossCompileConfig.cmake index 006b2c96..1d23b16d 100644 --- a/cmake/Q7SCrossCompileConfig.cmake +++ b/cmake/Q7SCrossCompileConfig.cmake @@ -42,6 +42,7 @@ find_program (CMAKE_CXX_COMPILER ${CROSS_COMPILE_CXX} REQUIRED) # Useful utilities, not strictly necessary find_program(CMAKE_SIZE ${CROSS_COMPILE_SIZE}) find_program(CMAKE_OBJCOPY ${CROSS_COMPILE_OBJCOPY}) +find_program(CMAKE_STRIP ${CROSS_COMPILE_STRIP}) set(CMAKE_CROSSCOMPILING TRUE) set(CMAKE_SYSROOT "${SYSROOT_PATH}") diff --git a/cmake/scripts/Q7S/make-size-cfg.sh b/cmake/scripts/Q7S/make-size-cfg.sh new file mode 100755 index 00000000..f75edb7f --- /dev/null +++ b/cmake/scripts/Q7S/make-size-cfg.sh @@ -0,0 +1,35 @@ +#!/bin/sh +counter=0 +cfg_script_name="cmake-build-cfg.py" +while [ ${counter} -lt 5 ] +do + cd .. + if [ -f ${cfg_script_name} ];then + break + fi + counter=$((counter=counter + 1)) +done + +if [ "${counter}" -ge 5 ];then + echo "${cfg_script_name} not found in upper directories!" + exit 1 +fi + +os_fsfw="linux" +tgt_bsp="arm/q7s" +build_dir="build-Release-Q7S" +build_generator="" +if [ "${OS}" = "Windows_NT" ]; then + build_generator="MinGW Makefiles" + python="py" +# Could be other OS but this works for now. +else + build_generator="Unix Makefiles" + python="python3" +fi + +echo "Running command (without the leading +):" +set -x # Print command +${python} ${cfg_script_name} -o "${os_fsfw}" -g "${build_generator}" -b "size" -t "${tgt_bsp}" \ + -l"${build_dir}" +# set +x diff --git a/linux/fsfwconfig/OBSWConfig.h.in b/linux/fsfwconfig/OBSWConfig.h.in index 36d1e638..e2693430 100644 --- a/linux/fsfwconfig/OBSWConfig.h.in +++ b/linux/fsfwconfig/OBSWConfig.h.in @@ -6,7 +6,7 @@ #ifndef FSFWCONFIG_OBSWCONFIG_H_ #define FSFWCONFIG_OBSWCONFIG_H_ -#cmakedefine RASPBERRY_Pi +#cmakedefine RASPBERRY_PI #cmakedefine XIPHOS_Q7S #cmakedefine BEAGLEBONEBLACK diff --git a/linux/fsfwconfig/pollingsequence/pollingSequenceFactory.cpp b/linux/fsfwconfig/pollingsequence/pollingSequenceFactory.cpp index a24c5393..7153ac81 100644 --- a/linux/fsfwconfig/pollingsequence/pollingSequenceFactory.cpp +++ b/linux/fsfwconfig/pollingsequence/pollingSequenceFactory.cpp @@ -606,7 +606,9 @@ ReturnValue_t pst::pstGompaceCan(FixedTimeslotTaskIF *thisSequence){ ReturnValue_t pst::pstTest(FixedTimeslotTaskIF* thisSequence) { /* Length of a communication cycle */ uint32_t length = thisSequence->getPeriodMs(); + bool notEmpty = false; #if OBSW_ADD_ACS_BOARD == 1 + notEmpty = true; thisSequence->addSlot(objects::MGM_0_LIS3_HANDLER, length * 0, DeviceHandlerIF::PERFORM_OPERATION); thisSequence->addSlot(objects::MGM_0_LIS3_HANDLER, length * 0.2, @@ -678,6 +680,7 @@ ReturnValue_t pst::pstTest(FixedTimeslotTaskIF* thisSequence) { #endif #if RPI_TEST_ADIS16507 == 1 + notEmpty = true; thisSequence->addSlot(objects::GYRO_0_ADIS_HANDLER, length * 0, DeviceHandlerIF::PERFORM_OPERATION); thisSequence->addSlot(objects::GYRO_0_ADIS_HANDLER, length * 0.2, DeviceHandlerIF::SEND_WRITE); @@ -687,6 +690,7 @@ ReturnValue_t pst::pstTest(FixedTimeslotTaskIF* thisSequence) { #endif #if RPI_TEST_GPS_HANDLER == 1 + notEmpty = true; thisSequence->addSlot(objects::GPS0_HANDLER, length * 0, DeviceHandlerIF::PERFORM_OPERATION); thisSequence->addSlot(objects::GPS0_HANDLER, length * 0, DeviceHandlerIF::SEND_READ); @@ -696,6 +700,9 @@ ReturnValue_t pst::pstTest(FixedTimeslotTaskIF* thisSequence) { thisSequence->addSlot(objects::GPS0_HANDLER, length * 0.5, DeviceHandlerIF::GET_READ); #endif static_cast(length); + if(not notEmpty) { + return HasReturnvaluesIF::RETURN_FAILED; + } if (thisSequence->checkSequence() != HasReturnvaluesIF::RETURN_OK) { sif::error << "Test PST initialization failed" << std::endl; return HasReturnvaluesIF::RETURN_FAILED; diff --git a/mission/devices/GPSHyperionHandler.cpp b/mission/devices/GPSHyperionHandler.cpp index c3b71882..34fdd47d 100644 --- a/mission/devices/GPSHyperionHandler.cpp +++ b/mission/devices/GPSHyperionHandler.cpp @@ -7,8 +7,9 @@ #include "lwgps/lwgps.h" GPSHyperionHandler::GPSHyperionHandler(object_id_t objectId, object_id_t deviceCommunication, - CookieIF *comCookie): - DeviceHandlerBase(objectId, deviceCommunication, comCookie), gpsSet(this) { + CookieIF *comCookie, bool debugHyperionGps): + DeviceHandlerBase(objectId, deviceCommunication, comCookie), gpsSet(this), + debugHyperionGps(debugHyperionGps) { lwgps_init(&gpsData); } @@ -36,21 +37,21 @@ void GPSHyperionHandler::doShutDown() { } ReturnValue_t GPSHyperionHandler::buildTransitionDeviceCommand(DeviceCommandId_t *id) { - return HasReturnvaluesIF::RETURN_OK; + return HasReturnvaluesIF::RETURN_OK; } ReturnValue_t GPSHyperionHandler::buildNormalDeviceCommand(DeviceCommandId_t *id) { - return HasReturnvaluesIF::RETURN_OK; + return HasReturnvaluesIF::RETURN_OK; } ReturnValue_t GPSHyperionHandler::buildCommandFromCommand( - DeviceCommandId_t deviceCommand, const uint8_t *commandData, - size_t commandDataLen) { - return HasReturnvaluesIF::RETURN_OK; + DeviceCommandId_t deviceCommand, const uint8_t *commandData, + size_t commandDataLen) { + return HasReturnvaluesIF::RETURN_OK; } ReturnValue_t GPSHyperionHandler::scanForReply(const uint8_t *start, size_t len, - DeviceCommandId_t *foundId, size_t *foundLen) { + DeviceCommandId_t *foundId, size_t *foundLen) { // Pass data to GPS library if(len > 0) { sif::info << "GPSHandler::scanForReply: Received " << len << " bytes" << std::endl; @@ -100,31 +101,31 @@ ReturnValue_t GPSHyperionHandler::scanForReply(const uint8_t *start, size_t len, gpsSet.hours = gpsData.hours; gpsSet.minutes = gpsData.minutes; gpsSet.seconds = gpsData.seconds; -#if FSFW_HAL_DEBUG_HYPERION_GPS == 1 - sif::info << "GPS Data" << std::endl; - printf("Valid status: %d\n", gpsData.is_valid); - printf("Latitude: %f degrees\n", gpsData.latitude); - printf("Longitude: %f degrees\n", gpsData.longitude); - printf("Altitude: %f meters\n", gpsData.altitude); -#endif + if(debugHyperionGps) { + sif::info << "GPS Data" << std::endl; + printf("Valid status: %d\n", gpsData.is_valid); + printf("Latitude: %f degrees\n", gpsData.latitude); + printf("Longitude: %f degrees\n", gpsData.longitude); + printf("Altitude: %f meters\n", gpsData.altitude); + } } *foundLen = len; } - return HasReturnvaluesIF::RETURN_OK; + return HasReturnvaluesIF::RETURN_OK; } ReturnValue_t GPSHyperionHandler::interpretDeviceReply(DeviceCommandId_t id, - const uint8_t *packet) { - return HasReturnvaluesIF::RETURN_OK; + const uint8_t *packet) { + return HasReturnvaluesIF::RETURN_OK; } uint32_t GPSHyperionHandler::getTransitionDelayMs(Mode_t from, Mode_t to) { - return 5000; + return 5000; } ReturnValue_t GPSHyperionHandler::initializeLocalDataPool( - localpool::DataPool &localDataPoolMap, LocalDataPoolManager &poolManager) { + localpool::DataPool &localDataPoolMap, LocalDataPoolManager &poolManager) { localDataPoolMap.emplace(GpsHyperion::ALTITUDE, new PoolEntry({0.0})); localDataPoolMap.emplace(GpsHyperion::LONGITUDE, new PoolEntry({0.0})); localDataPoolMap.emplace(GpsHyperion::LATITUDE, new PoolEntry({0.0})); @@ -137,12 +138,13 @@ ReturnValue_t GPSHyperionHandler::initializeLocalDataPool( localDataPoolMap.emplace(GpsHyperion::UNIX_SECONDS, new PoolEntry()); localDataPoolMap.emplace(GpsHyperion::SATS_IN_USE, new PoolEntry()); localDataPoolMap.emplace(GpsHyperion::FIX_MODE, new PoolEntry()); - return HasReturnvaluesIF::RETURN_OK; + poolManager.subscribeForPeriodicPacket(gpsSet.getSid(), true, 2.0, false); + return HasReturnvaluesIF::RETURN_OK; } void GPSHyperionHandler::fillCommandAndReplyMap() { // Reply length does not matter, packets should always arrive periodically - insertInReplyMap(GpsHyperion::GPS_REPLY, 4, nullptr, 0, true); + insertInReplyMap(GpsHyperion::GPS_REPLY, 4, &gpsSet, 0, true); } void GPSHyperionHandler::modeChanged() { diff --git a/mission/devices/GPSHyperionHandler.h b/mission/devices/GPSHyperionHandler.h index 5685ac86..49d8f416 100644 --- a/mission/devices/GPSHyperionHandler.h +++ b/mission/devices/GPSHyperionHandler.h @@ -1,13 +1,11 @@ #ifndef MISSION_DEVICES_GPSHYPERIONHANDLER_H_ #define MISSION_DEVICES_GPSHYPERIONHANDLER_H_ +#include "fsfw/FSFW.h" #include "fsfw/devicehandlers/DeviceHandlerBase.h" #include "devicedefinitions/GPSDefinitions.h" #include "lwgps/lwgps.h" -#ifndef FSFW_HAL_DEBUG_HYPERION_GPS -#define FSFW_HAL_DEBUG_HYPERION_GPS 0 -#endif /** * @brief Device handler for the Hyperion HT-GPS200 device @@ -18,10 +16,11 @@ class GPSHyperionHandler: public DeviceHandlerBase { public: GPSHyperionHandler(object_id_t objectId, object_id_t deviceCommunication, - CookieIF* comCookie); + CookieIF* comCookie, bool debugHyperionGps = false); virtual ~GPSHyperionHandler(); protected: + enum class InternalStates { NONE, WAIT_FIRST_MESSAGE, @@ -54,6 +53,7 @@ protected: private: lwgps_t gpsData = {}; GpsPrimaryDataset gpsSet; + bool debugHyperionGps = false; }; #endif /* MISSION_DEVICES_GPSHYPERIONHANDLER_H_ */ diff --git a/tmtc b/tmtc index cc6dbd8e..387a076a 160000 --- a/tmtc +++ b/tmtc @@ -1 +1 @@ -Subproject commit cc6dbd8ef9d5bd028835f37a24a5617224569862 +Subproject commit 387a076a2180c14da8de086d690a2ebb5ad63649