From 80c332355378eef97113f84c9d4634cc66131b4c Mon Sep 17 00:00:00 2001 From: "Robin.Mueller" Date: Tue, 15 Jun 2021 13:32:57 +0200 Subject: [PATCH 01/18] fsfw and fsfw_hal update --- fsfw | 2 +- fsfw_hal | 2 +- linux/fsfwconfig/returnvalues/classIds.h | 2 -- 3 files changed, 2 insertions(+), 4 deletions(-) diff --git a/fsfw b/fsfw index d700fb55..4b248740 160000 --- a/fsfw +++ b/fsfw @@ -1 +1 @@ -Subproject commit d700fb551c85393b58a3ada96fbd3f807217d14b +Subproject commit 4b248740f326b3329c417f3050e0f1cb9c472fd5 diff --git a/fsfw_hal b/fsfw_hal index cd0dfc49..cd9c9647 160000 --- a/fsfw_hal +++ b/fsfw_hal @@ -1 +1 @@ -Subproject commit cd0dfc49d5527755462118445832888572a92169 +Subproject commit cd9c9647ec9de9a4dcd159b6eb08c6f1beaf283f diff --git a/linux/fsfwconfig/returnvalues/classIds.h b/linux/fsfwconfig/returnvalues/classIds.h index 1cda3ace..6282980e 100644 --- a/linux/fsfwconfig/returnvalues/classIds.h +++ b/linux/fsfwconfig/returnvalues/classIds.h @@ -12,8 +12,6 @@ namespace CLASS_ID { enum { CLASS_ID_START = COMMON_CLASS_ID_END, - LINUX_LIBGPIO_IF, //LINUXGPIO - LINUX_SPI_COM_IF, //LINUXSPI SA_DEPL_HANDLER, //SADPL CLASS_ID_END // [EXPORT] : [END] }; From e39d6a8ec972404a07b2618b44a0ff5a3576a56f Mon Sep 17 00:00:00 2001 From: "Robin.Mueller" Date: Tue, 15 Jun 2021 13:40:58 +0200 Subject: [PATCH 02/18] comment block --- mission/devices/GPSHandler.h | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/mission/devices/GPSHandler.h b/mission/devices/GPSHandler.h index 01a13591..ffcbdbc5 100644 --- a/mission/devices/GPSHandler.h +++ b/mission/devices/GPSHandler.h @@ -3,6 +3,11 @@ #include +/** + * @brief Device handler for the Hyperion HT-GPS200 device + * @details + * Flight manual: https://egit.irs.uni-stuttgart.de/redmine/projects/eive-flight-manual/wiki/Hyperion_HT-GPS200 + */ class GPSHandler: public DeviceHandlerBase { public: GPSHandler(object_id_t objectId, object_id_t deviceCommunication, @@ -36,6 +41,4 @@ private: }; - - #endif /* MISSION_DEVICES_GPSHANDLER_H_ */ From 2604876d0eefa62964cbde582a822f6bc800396b Mon Sep 17 00:00:00 2001 From: "Robin.Mueller" Date: Tue, 15 Jun 2021 13:58:19 +0200 Subject: [PATCH 03/18] cross referencing --- mission/devices/GPSHandler.h | 3 ++- mission/devices/GyroADIS16507Handler.h | 6 ++++++ mission/devices/MGMHandlerLIS3MDL.h | 2 ++ mission/devices/MGMHandlerRM3100.h | 2 +- mission/devices/PlocHandler.h | 8 +++++--- 5 files changed, 16 insertions(+), 5 deletions(-) diff --git a/mission/devices/GPSHandler.h b/mission/devices/GPSHandler.h index ffcbdbc5..06362dd6 100644 --- a/mission/devices/GPSHandler.h +++ b/mission/devices/GPSHandler.h @@ -6,7 +6,8 @@ /** * @brief Device handler for the Hyperion HT-GPS200 device * @details - * Flight manual: https://egit.irs.uni-stuttgart.de/redmine/projects/eive-flight-manual/wiki/Hyperion_HT-GPS200 + * Flight manual: + * https://egit.irs.uni-stuttgart.de/redmine/projects/eive-flight-manual/wiki/Hyperion_HT-GPS200 */ class GPSHandler: public DeviceHandlerBase { public: diff --git a/mission/devices/GyroADIS16507Handler.h b/mission/devices/GyroADIS16507Handler.h index 653f56e7..faab3e5d 100644 --- a/mission/devices/GyroADIS16507Handler.h +++ b/mission/devices/GyroADIS16507Handler.h @@ -11,6 +11,12 @@ class SpiComIF; class SpiCookie; #endif +/** + * @brief Device handle for the ADIS16507 Gyroscope by Analog Devices + * @details + * Flight manual: + * https://egit.irs.uni-stuttgart.de/redmine/projects/eive-flight-manual/wiki/ADIS16507_Gyro + */ class GyroADIS16507Handler: public DeviceHandlerBase { public: GyroADIS16507Handler(object_id_t objectId, object_id_t deviceCommunication, diff --git a/mission/devices/MGMHandlerLIS3MDL.h b/mission/devices/MGMHandlerLIS3MDL.h index fc998f46..3cc08a6b 100644 --- a/mission/devices/MGMHandlerLIS3MDL.h +++ b/mission/devices/MGMHandlerLIS3MDL.h @@ -14,6 +14,8 @@ * by STMicroeletronics * @details * Datasheet can be found online by googling LIS3MDL. + * Flight manual: + * https://egit.irs.uni-stuttgart.de/redmine/projects/eive-flight-manual/wiki/LIS3MDL_MGM * @author L. Loidold, R. Mueller */ class MGMHandlerLIS3MDL: public DeviceHandlerBase { diff --git a/mission/devices/MGMHandlerRM3100.h b/mission/devices/MGMHandlerRM3100.h index ce107637..95175b47 100644 --- a/mission/devices/MGMHandlerRM3100.h +++ b/mission/devices/MGMHandlerRM3100.h @@ -14,7 +14,7 @@ * @brief Device Handler for the RM3100 geomagnetic magnetometer sensor * (https://www.pnicorp.com/rm3100/) * @details - * Advanced documentation: + * Flight manual: * https://egit.irs.uni-stuttgart.de/redmine/projects/eive-flight-manual/wiki/RM3100_MGM */ class MGMHandlerRM3100: public DeviceHandlerBase { diff --git a/mission/devices/PlocHandler.h b/mission/devices/PlocHandler.h index c92b3705..d400318e 100644 --- a/mission/devices/PlocHandler.h +++ b/mission/devices/PlocHandler.h @@ -8,9 +8,11 @@ /** * @brief This is the device handler for the PLOC. * - * @details The PLOC uses the space packet protocol for communication. To each command the PLOC - * answers with at least one acknowledgment and one execution report. - * + * @details + * The PLOC uses the space packet protocol for communication. To each command the PLOC + * answers with at least one acknowledgment and one execution report. + * Flight manual: + * https://egit.irs.uni-stuttgart.de/redmine/projects/eive-flight-manual/wiki/PLOC_Commands * @author J. Meier */ class PlocHandler: public DeviceHandlerBase { From 677963a52898bcceabf9953c31a5aaaf9cd42ec7 Mon Sep 17 00:00:00 2001 From: "Robin.Mueller" Date: Tue, 15 Jun 2021 15:37:37 +0200 Subject: [PATCH 04/18] fsfw update and gomspace handler doc crossref --- fsfw | 2 +- mission/devices/GomspaceDeviceHandler.h | 11 +++++++---- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/fsfw b/fsfw index 4b248740..fbbc640f 160000 --- a/fsfw +++ b/fsfw @@ -1 +1 @@ -Subproject commit 4b248740f326b3329c417f3050e0f1cb9c472fd5 +Subproject commit fbbc640f4dfcc17f07e2c5e0e827bf150335226f diff --git a/mission/devices/GomspaceDeviceHandler.h b/mission/devices/GomspaceDeviceHandler.h index 81c62502..8130d8f7 100644 --- a/mission/devices/GomspaceDeviceHandler.h +++ b/mission/devices/GomspaceDeviceHandler.h @@ -7,10 +7,13 @@ /** * @brief This is the device handler class for all gomspace devices. * - * @details All gomspace devices are similar with respect to commanding. Thus - * most of the functionality to command a gomspace device can be - * accommodated in one class. For device specific functions, a new - * class could be created by inheriting from the GomspaceDeviceHandler. + * @details + * All gomspace devices are similar with respect to commanding. Thusmost of the functionality to + * command a gomspace device can be accommodated in one class. For device specific functions, a new + * class could be created by inheriting from the GomspaceDeviceHandler. + * + * Flight manual: + * https://egit.irs.uni-stuttgart.de/redmine/projects/eive-flight-manual/wiki/Gomspace_PCDU_P60_System */ class GomspaceDeviceHandler: public DeviceHandlerBase { public: From 66e1c716156d127e113f4c623c23c4fddb2d59e7 Mon Sep 17 00:00:00 2001 From: "Robin.Mueller" Date: Tue, 15 Jun 2021 16:11:07 +0200 Subject: [PATCH 05/18] updated submodules --- fsfw | 2 +- fsfw_hal | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/fsfw b/fsfw index fbbc640f..cfbdb10a 160000 --- a/fsfw +++ b/fsfw @@ -1 +1 @@ -Subproject commit fbbc640f4dfcc17f07e2c5e0e827bf150335226f +Subproject commit cfbdb10a5570308d4c29bfd7b54ff14b59d47c85 diff --git a/fsfw_hal b/fsfw_hal index cd9c9647..4f825a10 160000 --- a/fsfw_hal +++ b/fsfw_hal @@ -1 +1 @@ -Subproject commit cd9c9647ec9de9a4dcd159b6eb08c6f1beaf283f +Subproject commit 4f825a10cd886dd3b1814bbb952f657da45fd961 From 16066b4cf98ee9336a735bd7bf3b69393ec885af Mon Sep 17 00:00:00 2001 From: "Robin.Mueller" Date: Tue, 15 Jun 2021 16:18:18 +0200 Subject: [PATCH 06/18] fsfw update --- fsfw | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fsfw b/fsfw index cfbdb10a..5f9a6bb1 160000 --- a/fsfw +++ b/fsfw @@ -1 +1 @@ -Subproject commit cfbdb10a5570308d4c29bfd7b54ff14b59d47c85 +Subproject commit 5f9a6bb155eb59981e7ff851b7efaa1ae25e42b4 From 78cb72d12d0937af4f776f567b45d94482a35481 Mon Sep 17 00:00:00 2001 From: "Robin.Mueller" Date: Tue, 15 Jun 2021 16:44:31 +0200 Subject: [PATCH 07/18] added startup and shutdown sequence --- mission/devices/GPSHandler.cpp | 15 ++++++++++++++- mission/devices/GPSHandler.h | 7 +++++++ 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/mission/devices/GPSHandler.cpp b/mission/devices/GPSHandler.cpp index e53ce347..2264a833 100644 --- a/mission/devices/GPSHandler.cpp +++ b/mission/devices/GPSHandler.cpp @@ -8,11 +8,24 @@ GPSHandler::GPSHandler(object_id_t objectId, object_id_t deviceCommunication, GPSHandler::~GPSHandler() {} void GPSHandler::doStartUp() { + if(internalState == InternalStates::NONE) { + commandExecuted = false; + internalState = InternalStates::WAIT_FIRST_MESSAGE; + } + if(internalState == InternalStates::WAIT_FIRST_MESSAGE) { + if(commandExecuted) { + internalState = InternalStates::IDLE; + setMode(MODE_ON); + commandExecuted = false; + } + } } void GPSHandler::doShutDown() { - + internalState = InternalStates::NONE; + commandExecuted = false; + setMode(MODE_OFF); } ReturnValue_t GPSHandler::buildTransitionDeviceCommand(DeviceCommandId_t *id) { diff --git a/mission/devices/GPSHandler.h b/mission/devices/GPSHandler.h index 06362dd6..7ee400e2 100644 --- a/mission/devices/GPSHandler.h +++ b/mission/devices/GPSHandler.h @@ -16,6 +16,13 @@ public: virtual ~GPSHandler(); protected: + enum class InternalStates { + NONE, + WAIT_FIRST_MESSAGE, + IDLE + }; + InternalStates internalState = InternalStates::NONE; + bool commandExecuted = false; /* DeviceHandlerBase overrides */ ReturnValue_t buildTransitionDeviceCommand( From 236244bbb45d4e30ed67d0acfb6a9cf92258a27f Mon Sep 17 00:00:00 2001 From: "Robin.Mueller" Date: Tue, 15 Jun 2021 17:07:47 +0200 Subject: [PATCH 08/18] added gps definitions file --- fsfw_hal | 2 +- mission/devices/GPSHandler.cpp | 6 ++++-- .../devicedefinitions/GPSDefinitions.h | 21 +++++++++++++++++++ 3 files changed, 26 insertions(+), 3 deletions(-) create mode 100644 mission/devices/devicedefinitions/GPSDefinitions.h diff --git a/fsfw_hal b/fsfw_hal index 4f825a10..c0287eb4 160000 --- a/fsfw_hal +++ b/fsfw_hal @@ -1 +1 @@ -Subproject commit 4f825a10cd886dd3b1814bbb952f657da45fd961 +Subproject commit c0287eb4a64ec92a3f068a88c7090d3eae0f5e99 diff --git a/mission/devices/GPSHandler.cpp b/mission/devices/GPSHandler.cpp index 2264a833..da8f4ff3 100644 --- a/mission/devices/GPSHandler.cpp +++ b/mission/devices/GPSHandler.cpp @@ -1,4 +1,5 @@ #include "GPSHandler.h" +#include "devicedefinitions/GPSDefinitions.h" GPSHandler::GPSHandler(object_id_t objectId, object_id_t deviceCommunication, CookieIF *comCookie): @@ -62,9 +63,10 @@ ReturnValue_t GPSHandler::initializeLocalDataPool( } void GPSHandler::fillCommandAndReplyMap() { - + // Reply length does not matter, packets should always arrive periodically + insertInReplyMap(GpsHyperion::GPS_REPLY, 4, nullptr, 0, true); } void GPSHandler::modeChanged() { - + internalState = InternalStates::NONE; } diff --git a/mission/devices/devicedefinitions/GPSDefinitions.h b/mission/devices/devicedefinitions/GPSDefinitions.h new file mode 100644 index 00000000..cb3cfd1a --- /dev/null +++ b/mission/devices/devicedefinitions/GPSDefinitions.h @@ -0,0 +1,21 @@ +#ifndef MISSION_DEVICES_DEVICEDEFINITIONS_GPSDEFINITIONS_H_ +#define MISSION_DEVICES_DEVICEDEFINITIONS_GPSDEFINITIONS_H_ + +#include + +namespace GpsHyperion { + +static constexpr DeviceCommandId_t GPS_REPLY = 0; + +enum GpsPoolIds: lp_id_t { + +}; + +} + +class GpsPrimaryDataset: public StaticLocalDataSet<5> { +public: +private: +}; + +#endif /* MISSION_DEVICES_DEVICEDEFINITIONS_GPSDEFINITIONS_H_ */ From 6d09006f1a35693fdc5e663a03c879e2a54158e7 Mon Sep 17 00:00:00 2001 From: "Robin.Mueller" Date: Wed, 16 Jun 2021 17:19:14 +0200 Subject: [PATCH 09/18] compiling again --- bsp_q7s/ObjectFactory.cpp | 10 +++++----- mission/devices/GPSHandler.cpp | 10 ++++++++++ mission/devices/GPSHandler.h | 3 ++- 3 files changed, 17 insertions(+), 6 deletions(-) diff --git a/bsp_q7s/ObjectFactory.cpp b/bsp_q7s/ObjectFactory.cpp index 33314297..940398e6 100644 --- a/bsp_q7s/ObjectFactory.cpp +++ b/bsp_q7s/ObjectFactory.cpp @@ -29,7 +29,6 @@ #include #include #include -#include #include #include #include @@ -41,6 +40,7 @@ #include "fsfw_hal/linux/uart/UartComIF.h" #include "fsfw_hal/linux/uart/UartCookie.h" +#include "fsfw_hal/devicehandlers/GyroL3GD20Handler.h" #include #include #include @@ -390,8 +390,8 @@ void ObjectFactory::produce(void* args){ solarArrayDeplCookie, objects::PCDU_HANDLER, pcduSwitches::DEPLOYMENT_MECHANISM, gpioIds::DEPLSA1, gpioIds::DEPLSA2, 1000); - UartCookie* syrlinksUartCookie = new UartCookie( - std::string("/dev/ttyUL0"), 38400, SYRLINKS::MAX_REPLY_SIZE); + UartCookie* syrlinksUartCookie = new UartCookie(std::string("/dev/ttyUL0"), + UartModes::NON_CANONICAL, 38400, SYRLINKS::MAX_REPLY_SIZE); syrlinksUartCookie->setParityEven(); SyrlinksHkHandler* syrlinksHkHandler = new SyrlinksHkHandler(objects::SYRLINKS_HK_HANDLER, @@ -546,8 +546,8 @@ void ObjectFactory::produce(void* args){ // imtqHandler->setStartUpImmediately(); (void) imtqHandler; - UartCookie* plocUartCookie = new UartCookie(std::string("/dev/ttyUL3"), 115200, - PLOC::MAX_REPLY_SIZE); + UartCookie* plocUartCookie = new UartCookie(std::string("/dev/ttyUL3"), + UartModes::NON_CANONICAL, 115200, PLOC::MAX_REPLY_SIZE); PlocHandler* plocHandler = new PlocHandler(objects::PLOC_HANDLER, objects::UART_COM_IF, plocUartCookie); // plocHandler->setStartUpImmediately(); diff --git a/mission/devices/GPSHandler.cpp b/mission/devices/GPSHandler.cpp index da8f4ff3..86733794 100644 --- a/mission/devices/GPSHandler.cpp +++ b/mission/devices/GPSHandler.cpp @@ -1,9 +1,12 @@ #include "GPSHandler.h" #include "devicedefinitions/GPSDefinitions.h" +#include "lwgps/lwgps.h" + GPSHandler::GPSHandler(object_id_t objectId, object_id_t deviceCommunication, CookieIF *comCookie): DeviceHandlerBase(objectId, deviceCommunication, comCookie) { + lwgps_init(&gpsData); } GPSHandler::~GPSHandler() {} @@ -45,7 +48,14 @@ ReturnValue_t GPSHandler::buildCommandFromCommand( ReturnValue_t GPSHandler::scanForReply(const uint8_t *start, size_t len, DeviceCommandId_t *foundId, size_t *foundLen) { + // Pass data to GPS library + int result = lwgps_process(&gpsData, start, len); + if(result != 0) { + sif::warning << "GPSHandler::scanForReply: Issue processing GPS data with lwgps" + << std::endl; + } return HasReturnvaluesIF::RETURN_OK; + } ReturnValue_t GPSHandler::interpretDeviceReply(DeviceCommandId_t id, diff --git a/mission/devices/GPSHandler.h b/mission/devices/GPSHandler.h index 7ee400e2..298871e4 100644 --- a/mission/devices/GPSHandler.h +++ b/mission/devices/GPSHandler.h @@ -2,6 +2,7 @@ #define MISSION_DEVICES_GPSHANDLER_H_ #include +#include "lwgps/lwgps.h" /** * @brief Device handler for the Hyperion HT-GPS200 device @@ -46,7 +47,7 @@ protected: LocalDataPoolManager &poolManager) override; private: - + lwgps_t gpsData = {}; }; #endif /* MISSION_DEVICES_GPSHANDLER_H_ */ From 95e625922e450f1f9be618538c93e66dbaf00461 Mon Sep 17 00:00:00 2001 From: "Robin.Mueller" Date: Wed, 16 Jun 2021 18:38:06 +0200 Subject: [PATCH 10/18] gps test complete --- bsp_linux_board/InitMission.cpp | 6 + bsp_linux_board/ObjectFactory.cpp | 48 ++++---- bsp_linux_board/boardconfig/rpiConfig.h.in | 11 +- linux/boardtest/UartTestClass.cpp | 106 +++++++++++++++++- linux/boardtest/UartTestClass.h | 14 ++- linux/fsfwconfig/objects/systemObjectList.h | 1 + .../pollingSequenceFactory.cpp | 2 +- 7 files changed, 161 insertions(+), 27 deletions(-) diff --git a/bsp_linux_board/InitMission.cpp b/bsp_linux_board/InitMission.cpp index a94c2e7d..16dab475 100644 --- a/bsp_linux_board/InitMission.cpp +++ b/bsp_linux_board/InitMission.cpp @@ -163,6 +163,12 @@ void initmission::initTasks() { initmission::printAddObjectError("GPIOD_TEST", objects::LIBGPIOD_TEST); } #endif /* RPI_ADD_GPIO_TEST == 1 */ +#if RPI_ADD_UART_TEST == 1 + result = testTask->addComponent(objects::UART_TEST); + if(result != HasReturnvaluesIF::RETURN_OK) { + initmission::printAddObjectError("UART_TEST", objects::UART_TEST); + } +#endif /* RPI_ADD_GPIO_TEST == 1 */ sif::info << "Starting tasks.." << std::endl; tmTcDistributor->startTask(); diff --git a/bsp_linux_board/ObjectFactory.cpp b/bsp_linux_board/ObjectFactory.cpp index 648d1376..adc50dd0 100644 --- a/bsp_linux_board/ObjectFactory.cpp +++ b/bsp_linux_board/ObjectFactory.cpp @@ -8,32 +8,32 @@ #include "tmtc/pusIds.h" #include "spiConf.h" -#include -#include +#include "linux/boardtest/LibgpiodTest.h" +#include "linux/boardtest/SpiTestClass.h" +#include "linux/boardtest/UartTestClass.h" -//#include -#include -#include -#include -#include -#include "fsfw_hal/devicehandlers/GyroL3GD20Handler.h" -#include +#include "mission/core/GenericFactory.h" +#include "mission/utility/TmFunnel.h" +#include "mission/devices/MGMHandlerLIS3MDL.h" +#include "mission/devices/MGMHandlerRM3100.h" +#include "mission/devices/GyroADIS16507Handler.h" -#include -#include -#include -#include -#include +#include "fsfw/datapoollocal/LocalDataPoolManager.h" +#include "fsfw/tmtcservices/CommandingServiceBase.h" +#include "fsfw/tmtcservices/PusServiceBase.h" +#include "fsfw/tmtcpacket/pus/TmPacketStored.h" +#include "fsfw/tasks/TaskFactory.h" /* UDP server includes */ -#include -#include +#include "fsfw/osal/common/UdpTmTcBridge.h" +#include "fsfw/osal/common/UdpTcPollingTask.h" -#include -#include -#include -#include -#include +#include "fsfw_hal/devicehandlers/GyroL3GD20Handler.h" +#include "fsfw_hal/linux/gpio/LinuxLibgpioIF.h" +#include "fsfw_hal/linux/rpi/GpioRPi.h" +#include "fsfw_hal/common/gpio/GpioCookie.h" +#include "fsfw_hal/linux/spi/SpiCookie.h" +#include "fsfw_hal/linux/spi/SpiComIF.h" void Factory::setStaticFrameworkObjectIds() { PusServiceBase::packetSource = objects::PUS_PACKET_DISTRIBUTOR; @@ -61,10 +61,15 @@ void ObjectFactory::produce(void* args){ GpioIF* gpioIF = new LinuxLibgpioIF(objects::GPIO_IF); GpioCookie* gpioCookie = nullptr; + static_cast(gpioCookie); #if RPI_ADD_SPI_TEST == 1 new SpiTestClass(objects::SPI_TEST, gpioIF); #endif +#if RPI_ADD_UART_TEST == 1 + new UartTestClass(objects::UART_TEST); +#endif + #if RPI_LOOPBACK_TEST_GPIO == 1 GpioCookie* gpioCookieLoopback = new GpioCookie(); /* Loopback pins. Adapt according to setup */ @@ -83,6 +88,7 @@ void ObjectFactory::produce(void* args){ std::string spiDev; SpiCookie* spiCookie = nullptr; + static_cast(spiCookie); #if RPI_TEST_ACS_BOARD == 1 if(gpioCookie == nullptr) { diff --git a/bsp_linux_board/boardconfig/rpiConfig.h.in b/bsp_linux_board/boardconfig/rpiConfig.h.in index 31d6c157..0094903c 100644 --- a/bsp_linux_board/boardconfig/rpiConfig.h.in +++ b/bsp_linux_board/boardconfig/rpiConfig.h.in @@ -6,11 +6,18 @@ #define RPI_ADD_GPIO_TEST 0 #define RPI_LOOPBACK_TEST_GPIO 0 -#define RPI_TEST_ADIS16507 1 +#define RPI_TEST_ADIS16507 0 -/* Only one of those 2 should be enabled! */ +// Only one of those 2 should be enabled! #define RPI_ADD_SPI_TEST 0 +#if RPI_ADD_SPI_TEST == 0 #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 /* Adapt these values accordingly */ namespace gpio { diff --git a/linux/boardtest/UartTestClass.cpp b/linux/boardtest/UartTestClass.cpp index dc9f79c3..9fcff9e9 100644 --- a/linux/boardtest/UartTestClass.cpp +++ b/linux/boardtest/UartTestClass.cpp @@ -1,8 +1,110 @@ -#include +#include "UartTestClass.h" +#include "rpiConfig.h" + +#include "fsfw/serviceinterface/ServiceInterface.h" + +#include "lwgps/lwgps.h" + +#include // Contains file controls like O_RDWR +#include // Error integer and strerror() function +#include // write(), read(), close() + +#define GPS_REPLY_WIRETAPPING 0 UartTestClass::UartTestClass(object_id_t objectId): TestTask(objectId) { } -ReturnValue_t UartTestClass::performPeriodicAction() { +ReturnValue_t UartTestClass::initialize() { +#if RPI_TEST_GPS_DEVICE == 1 + int result = lwgps_init(&gpsData); + if(result == 0) { + sif::warning << "lwgps_init error: " << result << std::endl; + } + + /* Get file descriptor */ + serialPort = open("/dev/serial0", O_RDWR); + if(serialPort < 0) { + sif::warning << "open call failed with error [" << errno << ", " << strerror(errno) + << std::endl; + } + /* Setting up UART parameters */ + tty.c_cflag &= ~PARENB; // Clear parity bit + tty.c_cflag &= ~CSTOPB; // Clear stop field, only one stop bit used in communication + tty.c_cflag &= ~CSIZE; // Clear all the size bits + tty.c_cflag |= CS8; // 8 bits per byte + tty.c_cflag &= ~CRTSCTS; // Disable RTS/CTS hardware flow control + tty.c_cflag |= CREAD | CLOCAL; // Turn on READ & ignore ctrl lines (CLOCAL = 1) + // Use canonical mode for GPS device + tty.c_lflag |= ICANON; + tty.c_lflag &= ~ECHO; // Disable echo + tty.c_lflag &= ~ECHOE; // Disable erasure + tty.c_lflag &= ~ECHONL; // Disable new-line echo + tty.c_lflag &= ~ISIG; // Disable interpretation of INTR, QUIT and SUSP + tty.c_iflag &= ~(IXON | IXOFF | IXANY); // Turn off s/w flow ctrl + tty.c_iflag &= ~(IGNBRK|BRKINT|PARMRK|ISTRIP|INLCR|IGNCR|ICRNL); // Disable any special handling of received bytes + tty.c_oflag &= ~OPOST; // Prevent special interpretation of output bytes (e.g. newline chars) + tty.c_oflag &= ~ONLCR; // Prevent conversion of newline to carriage return/line feed + + // Non-blocking mode + tty.c_cc[VTIME] = 0; + tty.c_cc[VMIN] = 0; + + cfsetispeed(&tty, B9600); + cfsetospeed(&tty, B9600); + if (tcsetattr(serialPort, TCSANOW, &tty) != 0) { + sif::warning << "tcsetattr call failed with error [" << errno << ", " << + strerror(errno) << std::endl;; + } + // Flush received and unread data. Those are old NMEA strings which are not relevant anymore + tcflush(serialPort, TCIFLUSH); +#endif + return HasReturnvaluesIF::RETURN_OK; +} + +ReturnValue_t UartTestClass::performOneShotAction() { +#if RPI_TEST_GPS_DEVICE == 1 +#endif + return HasReturnvaluesIF::RETURN_OK; +} + +ReturnValue_t UartTestClass::performPeriodicAction() { +#if RPI_TEST_GPS_DEVICE == 1 + int bytesRead = 0; + do { + bytesRead = read(serialPort, + reinterpret_cast(recBuf.data()), + static_cast(recBuf.size())); + if(bytesRead < 0) { + sif::warning << "UartTestClass::performPeriodicAction: read call failed with error [" << + errno << ", " << strerror(errno) << "]" << std::endl; + break; + } + else if(bytesRead >= static_cast(recBuf.size())) { + sif::debug << "UartTestClass::performPeriodicAction: " + "recv buffer might not be large enough" << std::endl; + } + else if(bytesRead > 0) { + // pass data to lwgps for processing +#if GPS_REPLY_WIRETAPPING == 1 + sif::info << recBuf.data() << std::endl; +#endif + int result = lwgps_process(&gpsData, recBuf.data(), bytesRead); + if(result == 0) { + sif::warning << "UartTestClass::performPeriodicAction: lwgps_process error" + << std::endl; + } + recvCnt++; + if(recvCnt == 6) { + recvCnt = 0; + sif::info << "GPS Data" << std::endl; + // Print messages + printf("Valid status: %d\n", gpsData.is_valid); + printf("Latitude: %f degrees\n", gpsData.latitude); + printf("Longitude: %f degrees\n", gpsData.longitude); + printf("Altitude: %f meters\n", gpsData.altitude); + } + } + } while(bytesRead > 0); +#endif return HasReturnvaluesIF::RETURN_OK; } diff --git a/linux/boardtest/UartTestClass.h b/linux/boardtest/UartTestClass.h index 406d2af5..aeb2c396 100644 --- a/linux/boardtest/UartTestClass.h +++ b/linux/boardtest/UartTestClass.h @@ -1,15 +1,27 @@ #ifndef LINUX_BOARDTEST_UARTTESTCLASS_H_ #define LINUX_BOARDTEST_UARTTESTCLASS_H_ -#include +#include "test/testtasks/TestTask.h" +#include "lwgps/lwgps.h" + +#include +#include // Contains POSIX terminal control definitions class UartTestClass: public TestTask { public: UartTestClass(object_id_t objectId); + ReturnValue_t initialize() override; + ReturnValue_t performOneShotAction() override; ReturnValue_t performPeriodicAction() override; private: + lwgps_t gpsData = {}; + struct termios tty = {}; + int serialPort = 0; + std::array recBuf; + uint8_t recvCnt = 0; + }; #endif /* LINUX_BOARDTEST_UARTTESTCLASS_H_ */ diff --git a/linux/fsfwconfig/objects/systemObjectList.h b/linux/fsfwconfig/objects/systemObjectList.h index 3f7fddc4..8558e335 100644 --- a/linux/fsfwconfig/objects/systemObjectList.h +++ b/linux/fsfwconfig/objects/systemObjectList.h @@ -60,6 +60,7 @@ namespace objects { TEST_TASK = 0x54694269, LIBGPIOD_TEST = 0x54123456, SPI_TEST = 0x54000010, + UART_TEST = 0x54000020, DUMMY_INTERFACE = 0x5400CAFE, DUMMY_HANDLER = 0x5400AFFE, P60DOCK_TEST_TASK = 0x00005060 diff --git a/linux/fsfwconfig/pollingsequence/pollingSequenceFactory.cpp b/linux/fsfwconfig/pollingsequence/pollingSequenceFactory.cpp index 64ffb4e1..148cef2b 100644 --- a/linux/fsfwconfig/pollingsequence/pollingSequenceFactory.cpp +++ b/linux/fsfwconfig/pollingsequence/pollingSequenceFactory.cpp @@ -560,7 +560,7 @@ ReturnValue_t pst::pollingSequenceTest(FixedTimeslotTaskIF* thisSequence) { thisSequence->addSlot(objects::GYRO_0_ADIS_HANDLER, length * 0.6, DeviceHandlerIF::SEND_READ); thisSequence->addSlot(objects::GYRO_0_ADIS_HANDLER, length * 0.8, DeviceHandlerIF::GET_READ); #endif - + static_cast(length); if (thisSequence->checkSequence() == HasReturnvaluesIF::RETURN_OK) { return HasReturnvaluesIF::RETURN_OK; } From e2ac721432e2e40bc234ffb9dffe0e9655bb7ac5 Mon Sep 17 00:00:00 2001 From: "Robin.Mueller" Date: Mon, 21 Jun 2021 16:20:11 +0200 Subject: [PATCH 11/18] minor tweaks, fsfw_hal update --- fsfw_hal | 2 +- mission/devices/GyroADIS16507Handler.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/fsfw_hal b/fsfw_hal index c0287eb4..34db4bd8 160000 --- a/fsfw_hal +++ b/fsfw_hal @@ -1 +1 @@ -Subproject commit c0287eb4a64ec92a3f068a88c7090d3eae0f5e99 +Subproject commit 34db4bd8e8b3917c6382d2c35564763cbca1975b diff --git a/mission/devices/GyroADIS16507Handler.cpp b/mission/devices/GyroADIS16507Handler.cpp index 2c3ed5a4..ac49a89d 100644 --- a/mission/devices/GyroADIS16507Handler.cpp +++ b/mission/devices/GyroADIS16507Handler.cpp @@ -1,10 +1,10 @@ #include #include -#include #include "GyroADIS16507Handler.h" #if OBSW_ADIS16507_LINUX_COM_IF == 1 +#include "fsfw_hal/linux/utility.h" #include "fsfw_hal/linux/spi/SpiCookie.h" #include "fsfw_hal/linux/spi/SpiComIF.h" #include "fsfw_hal/linux/UnixFileGuard.h" From 2b25b3a6057c10ebafd419c104358d8e213965d6 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Mon, 21 Jun 2021 16:46:49 +0200 Subject: [PATCH 12/18] q7s compiling --- bsp_q7s/ObjectFactory.cpp | 6 +++--- fsfw_hal | 2 +- linux/boardtest/UartTestClass.cpp | 4 ++++ tmtc | 2 +- 4 files changed, 9 insertions(+), 5 deletions(-) diff --git a/bsp_q7s/ObjectFactory.cpp b/bsp_q7s/ObjectFactory.cpp index 940398e6..19bd34d5 100644 --- a/bsp_q7s/ObjectFactory.cpp +++ b/bsp_q7s/ObjectFactory.cpp @@ -390,8 +390,8 @@ void ObjectFactory::produce(void* args){ solarArrayDeplCookie, objects::PCDU_HANDLER, pcduSwitches::DEPLOYMENT_MECHANISM, gpioIds::DEPLSA1, gpioIds::DEPLSA2, 1000); - UartCookie* syrlinksUartCookie = new UartCookie(std::string("/dev/ttyUL0"), - UartModes::NON_CANONICAL, 38400, SYRLINKS::MAX_REPLY_SIZE); + UartCookie* syrlinksUartCookie = new UartCookie(objects::SYRLINKS_HK_HANDLER, + std::string("/dev/ttyUL0"), UartModes::NON_CANONICAL, 38400, SYRLINKS::MAX_REPLY_SIZE); syrlinksUartCookie->setParityEven(); SyrlinksHkHandler* syrlinksHkHandler = new SyrlinksHkHandler(objects::SYRLINKS_HK_HANDLER, @@ -546,7 +546,7 @@ void ObjectFactory::produce(void* args){ // imtqHandler->setStartUpImmediately(); (void) imtqHandler; - UartCookie* plocUartCookie = new UartCookie(std::string("/dev/ttyUL3"), + UartCookie* plocUartCookie = new UartCookie(objects::PLOC_HANDLER, std::string("/dev/ttyUL3"), UartModes::NON_CANONICAL, 115200, PLOC::MAX_REPLY_SIZE); PlocHandler* plocHandler = new PlocHandler(objects::PLOC_HANDLER, objects::UART_COM_IF, plocUartCookie); diff --git a/fsfw_hal b/fsfw_hal index c0287eb4..5cce521f 160000 --- a/fsfw_hal +++ b/fsfw_hal @@ -1 +1 @@ -Subproject commit c0287eb4a64ec92a3f068a88c7090d3eae0f5e99 +Subproject commit 5cce521fb085ce0e285238415b892f8527328173 diff --git a/linux/boardtest/UartTestClass.cpp b/linux/boardtest/UartTestClass.cpp index 9fcff9e9..e69f0e5f 100644 --- a/linux/boardtest/UartTestClass.cpp +++ b/linux/boardtest/UartTestClass.cpp @@ -1,5 +1,9 @@ #include "UartTestClass.h" +#if defined(RASPBERRY_PI) #include "rpiConfig.h" +#elif defined(XIPHOS_Q7S) +#include "q7sConfig.h" +#endif #include "fsfw/serviceinterface/ServiceInterface.h" diff --git a/tmtc b/tmtc index 6debacd9..8fc67c26 160000 --- a/tmtc +++ b/tmtc @@ -1 +1 @@ -Subproject commit 6debacd946cea579d73f7fb63bb8296c606d70aa +Subproject commit 8fc67c26653df03f3352493bd0c744bc79928e1d From 67a1a84615b4558d24ffad97c1f3fc216f684053 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Mon, 21 Jun 2021 16:51:27 +0200 Subject: [PATCH 13/18] fsfw hal update --- fsfw_hal | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fsfw_hal b/fsfw_hal index 5cce521f..ab01c22b 160000 --- a/fsfw_hal +++ b/fsfw_hal @@ -1 +1 @@ -Subproject commit 5cce521fb085ce0e285238415b892f8527328173 +Subproject commit ab01c22b60612d4538baf6cf464b803174ea1fdf From 5bbf0255ef499ffc694d713c9909c9b3b9beb6f9 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Mon, 21 Jun 2021 16:54:33 +0200 Subject: [PATCH 14/18] fixes for updated fsfw --- bsp_linux_board/ObjectFactory.cpp | 2 +- fsfw | 2 +- linux/fsfwconfig/FSFWConfig.h.in | 4 ++++ mission/utility/TmFunnel.cpp | 3 +-- 4 files changed, 7 insertions(+), 4 deletions(-) diff --git a/bsp_linux_board/ObjectFactory.cpp b/bsp_linux_board/ObjectFactory.cpp index adc50dd0..d6dfd623 100644 --- a/bsp_linux_board/ObjectFactory.cpp +++ b/bsp_linux_board/ObjectFactory.cpp @@ -21,7 +21,7 @@ #include "fsfw/datapoollocal/LocalDataPoolManager.h" #include "fsfw/tmtcservices/CommandingServiceBase.h" #include "fsfw/tmtcservices/PusServiceBase.h" -#include "fsfw/tmtcpacket/pus/TmPacketStored.h" +#include "fsfw/tmtcpacket/pus/tm.h" #include "fsfw/tasks/TaskFactory.h" /* UDP server includes */ diff --git a/fsfw b/fsfw index 5f9a6bb1..cae69d54 160000 --- a/fsfw +++ b/fsfw @@ -1 +1 @@ -Subproject commit 5f9a6bb155eb59981e7ff851b7efaa1ae25e42b4 +Subproject commit cae69d540097acba46bffa47fd7afc6a8a19bd15 diff --git a/linux/fsfwconfig/FSFWConfig.h.in b/linux/fsfwconfig/FSFWConfig.h.in index 8ec01cb9..a8519cff 100644 --- a/linux/fsfwconfig/FSFWConfig.h.in +++ b/linux/fsfwconfig/FSFWConfig.h.in @@ -18,6 +18,7 @@ #endif #define FSFW_USE_PUS_C_TELEMETRY 1 +#define FSFW_USE_PUS_C_TELECOMMANDS 1 //! Can be used to disable the ANSI color sequences for C stdio. #define FSFW_COLORED_OUTPUT 1 @@ -66,6 +67,9 @@ static constexpr size_t FSFW_EVENTMGMR_RANGEMATCHERS = 120; 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 = 2048; + } #define FSFW_HAL_LINUX_SPI_WIRETAPPING 0 diff --git a/mission/utility/TmFunnel.cpp b/mission/utility/TmFunnel.cpp index 72c41153..c52fa6f9 100644 --- a/mission/utility/TmFunnel.cpp +++ b/mission/utility/TmFunnel.cpp @@ -1,8 +1,7 @@ #include -#include +#include #include #include -#include #include object_id_t TmFunnel::downlinkDestination = objects::NO_OBJECT; From 85c3300e0b84e2476230243541aa5feafcdf8311 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Mon, 21 Jun 2021 16:57:36 +0200 Subject: [PATCH 15/18] hal update --- fsfw_hal | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fsfw_hal b/fsfw_hal index ab01c22b..fe661fff 160000 --- a/fsfw_hal +++ b/fsfw_hal @@ -1 +1 @@ -Subproject commit ab01c22b60612d4538baf6cf464b803174ea1fdf +Subproject commit fe661fff85e2b8c6149c9603fd68aa3a811bf9bd From 89dc521e04a2ea9996fea08f824acedc66c131a5 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Mon, 21 Jun 2021 17:00:34 +0200 Subject: [PATCH 16/18] small q7s fix --- bsp_q7s/ObjectFactory.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bsp_q7s/ObjectFactory.cpp b/bsp_q7s/ObjectFactory.cpp index 19bd34d5..178a6f97 100644 --- a/bsp_q7s/ObjectFactory.cpp +++ b/bsp_q7s/ObjectFactory.cpp @@ -51,7 +51,7 @@ #include #include #include -#include +#include /* UDP server includes */ #include From 9097438cc2d18d7ae3a8fa4bbec34b53573b5a5e Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Mon, 21 Jun 2021 17:05:20 +0200 Subject: [PATCH 17/18] script correction --- cmake/scripts/Linux/create_cmake_debug_cfg.sh | 2 +- cmake/scripts/Linux/create_cmake_release_cfg.sh | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/cmake/scripts/Linux/create_cmake_debug_cfg.sh b/cmake/scripts/Linux/create_cmake_debug_cfg.sh index 172f890d..1207884e 100755 --- a/cmake/scripts/Linux/create_cmake_debug_cfg.sh +++ b/cmake/scripts/Linux/create_cmake_debug_cfg.sh @@ -16,7 +16,7 @@ fi build_generator="Unix Makefiles" os_fsfw="linux" -builddir="build-Debug-Linux" +builddir="build-Debug-Host" echo "Running command (without the leading +):" set -x # Print command diff --git a/cmake/scripts/Linux/create_cmake_release_cfg.sh b/cmake/scripts/Linux/create_cmake_release_cfg.sh index 019a951d..4412e671 100755 --- a/cmake/scripts/Linux/create_cmake_release_cfg.sh +++ b/cmake/scripts/Linux/create_cmake_release_cfg.sh @@ -16,7 +16,7 @@ fi build_generator="Unix Makefiles" os_fsfw="linux" -builddir="build-Release-Linux" +builddir="build-Release-Host" echo "Running command (without the leading +):" set -x # Print command From ec2f9d243bdf19811003ee498489decb43ff0d45 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Mon, 21 Jun 2021 17:09:49 +0200 Subject: [PATCH 18/18] hosted build fixes --- bsp_hosted/ObjectFactory.cpp | 2 +- bsp_hosted/fsfwconfig/FSFWConfig.h.in | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/bsp_hosted/ObjectFactory.cpp b/bsp_hosted/ObjectFactory.cpp index 743ee03e..acc0be37 100644 --- a/bsp_hosted/ObjectFactory.cpp +++ b/bsp_hosted/ObjectFactory.cpp @@ -14,7 +14,7 @@ #include #include -#include +#include #if OBSW_ADD_TEST_CODE == 1 diff --git a/bsp_hosted/fsfwconfig/FSFWConfig.h.in b/bsp_hosted/fsfwconfig/FSFWConfig.h.in index e48895d9..aa3cefb0 100644 --- a/bsp_hosted/fsfwconfig/FSFWConfig.h.in +++ b/bsp_hosted/fsfwconfig/FSFWConfig.h.in @@ -67,6 +67,8 @@ 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 = 2048; + } #endif /* CONFIG_FSFWCONFIG_H_ */