From 1bed87bc202bf2e9780e504f6134ab7ad67ffbe8 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Mon, 10 Jan 2022 10:07:19 +0100 Subject: [PATCH 01/18] README update --- README.md | 21 +-------------------- tmtc | 2 +- 2 files changed, 2 insertions(+), 21 deletions(-) diff --git a/README.md b/README.md index ff2c359d..04249cfa 100644 --- a/README.md +++ b/README.md @@ -1021,26 +1021,7 @@ cat file.bin | hexdump -v -n X ## Preparation of a fresh rootfs and SD card -This section summarizes important changes between a fresh rootfs and the current -EIVE implementation - -### rootfs - -- Mount point `/mnt/sd0` created for SD card 0. Created with `mkdir` -- Mount point `/mnt/sd1` created for SD card 1. Created with `mkdir` -- Folder `scripts` in `/home/root` folder. -- `scripts` folder currently contains a few shell helper scripts -- Folder `profile.d` in `/etc` folder which contains the `path-set.sh` script - which is sourced at software startup -- Library `libwire.so` in `/usr/lib` folder - -### SD Cards - -- Folder `bin` for binaries, for example the OBSW -- Folder `misc` for miscellaneous files. Contains `ls` for directory listings -- Folder `tc` for telecommands -- Folder `tm` for telemetry -- Folder `xdi` for XDI components (e.g. for firmware or device tree updates) +See [q7s-package repository README](https://egit.irs.uni-stuttgart.de/eive/q7s-package) # Running cppcheck on the Software diff --git a/tmtc b/tmtc index 2ecc4de0..77919df9 160000 --- a/tmtc +++ b/tmtc @@ -1 +1 @@ -Subproject commit 2ecc4de0223f3772627a002a6486c356ab6f5cd2 +Subproject commit 77919df9f2f05aede4ad4afd5ea56899ad994d32 From 7201fdf1521649a16442c01b5a1a48fc5b1134a2 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Mon, 10 Jan 2022 14:02:58 +0100 Subject: [PATCH 02/18] justfile update --- Justfile | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Justfile b/Justfile index f9d9504b..278ace99 100644 --- a/Justfile +++ b/Justfile @@ -5,5 +5,8 @@ default: q7s-debug-make q7s-debug-make: {{python_script}} -o linux -g make -b debug -t "arm/q7s" -l build-Debug-Q7S +q7s-release-make: + {{python_script}} -o linux -g make -b release -t "arm/q7s" -l build-Release-Q7S + q7s-debug-ninja: {{python_script}} -o linux -g ninja -b debug -t "arm/q7s" -l build-Debug-Q7S From 1f5553b5712bdbe4720610d8121fdd20cb60a9ce Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Tue, 11 Jan 2022 10:16:26 +0100 Subject: [PATCH 03/18] convert gps handler base class - Is ExtendedControllerBase now --- bsp_q7s/core/ObjectFactory.cpp | 1 - mission/devices/GPSHyperionHandler.cpp | 219 +++++++++---------------- mission/devices/GPSHyperionHandler.h | 43 ++--- 3 files changed, 86 insertions(+), 177 deletions(-) diff --git a/bsp_q7s/core/ObjectFactory.cpp b/bsp_q7s/core/ObjectFactory.cpp index ffc9693b..14f1b34b 100644 --- a/bsp_q7s/core/ObjectFactory.cpp +++ b/bsp_q7s/core/ObjectFactory.cpp @@ -577,7 +577,6 @@ void ObjectFactory::createAcsBoardComponents(LinuxLibgpioIF *gpioComIF, UartComI auto gpsHandler0 = new GPSHyperionHandler(objects::GPS0_HANDLER, objects::UART_COM_IF, uartCookieGps0, debugGps); gpsHandler0->setResetPinTriggerFunction(gps::triggerGpioResetPin, &resetArgsGnss0); - gpsHandler0->setStartUpImmediately(); } void ObjectFactory::createHeaterComponents() { diff --git a/mission/devices/GPSHyperionHandler.cpp b/mission/devices/GPSHyperionHandler.cpp index 8944d17a..58491332 100644 --- a/mission/devices/GPSHyperionHandler.cpp +++ b/mission/devices/GPSHyperionHandler.cpp @@ -4,8 +4,6 @@ #include "fsfw/datapool/PoolReadGuard.h" #include "fsfw/timemanager/Clock.h" -#include "lwgps/lwgps.h" - #if FSFW_DEV_HYPERION_GPS_CREATE_NMEA_CSV == 1 #include #include @@ -13,48 +11,88 @@ GPSHyperionHandler::GPSHyperionHandler(object_id_t objectId, object_id_t deviceCommunication, CookieIF *comCookie, bool debugHyperionGps): - DeviceHandlerBase(objectId, deviceCommunication, comCookie), gpsSet(this), + ExtendedControllerBase(objectId, objects::NO_OBJECT), gpsSet(this), debugHyperionGps(debugHyperionGps) { - lwgps_init(&gpsData); } GPSHyperionHandler::~GPSHyperionHandler() {} -void GPSHyperionHandler::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 GPSHyperionHandler::performControlOperation() { + // The data from the device will generally be read all at once. Therefore, we + // can set all field here +// PoolReadGuard pg(&gpsSet); +// if(pg.getReadResult() != HasReturnvaluesIF::RETURN_OK) { +//#if FSFW_VERBOSE_LEVEL >= 1 +// sif::warning << "GPSHyperionHandler::scanForReply: Reading dataset failed" +// << std::endl; +//#endif +// } +// // Print messages +// if(gpsData.is_valid) { +// // Set all entries valid now, set invalid on case basis if values are sanitized +// gpsSet.setValidity(true, true); +// } +// // Negative latitude -> South direction +// gpsSet.latitude.value = gpsData.latitude; +// // Negative longitude -> West direction +// gpsSet.longitude.value = gpsData.longitude; +// if(gpsData.altitude > 600000.0 or gpsData.altitude < 400000.0) { +// gpsSet.altitude.setValid(false); +// } +// else { +// gpsSet.altitude.setValid(true); +// gpsSet.altitude.value = gpsData.altitude; +// } +// gpsSet.fixMode.value = gpsData.fix_mode; +// gpsSet.satInUse.value = gpsData.sats_in_use; +// Clock::TimeOfDay_t timeStruct = {}; +// timeStruct.day = gpsData.date; +// timeStruct.hour = gpsData.hours; +// timeStruct.minute = gpsData.minutes; +// timeStruct.month = gpsData.month; +// timeStruct.second = gpsData.seconds; +// // Convert two-digit year to full year (AD) +// timeStruct.year = gpsData.year + 2000; +// timeval timeval = {}; +// Clock::convertTimeOfDayToTimeval(&timeStruct, &timeval); +// gpsSet.year = timeStruct.year; +// gpsSet.month = gpsData.month; +// gpsSet.day = gpsData.date; +// gpsSet.hours = gpsData.hours; +// gpsSet.minutes = gpsData.minutes; +// gpsSet.seconds = gpsData.seconds; +// gpsSet.unixSeconds = timeval.tv_sec; +// 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); +// } +//#if FSFW_DEV_HYPERION_GPS_CREATE_NMEA_CSV == 1 +// std::string filename = "/mnt/sd0/gps_log.txt"; +// std::ofstream gpsFile; +// if(not std::filesystem::exists(filename)) { +// gpsFile.open(filename, std::ofstream::out); +// } +// gpsFile.open(filename, std::ofstream::out | std::ofstream::app); +// gpsFile.write("\n", 1); +// gpsFile.write(reinterpret_cast(start), len); +//#endif } -void GPSHyperionHandler::doShutDown() { - internalState = InternalStates::NONE; - commandExecuted = false; - setMode(_MODE_POWER_DOWN); +LocalPoolDataSetBase* GPSHyperionHandler::getDataSetHandle(sid_t sid) { + return nullptr; } -ReturnValue_t GPSHyperionHandler::buildTransitionDeviceCommand(DeviceCommandId_t *id) { - return NOTHING_TO_SEND; +ReturnValue_t GPSHyperionHandler::checkModeCommand(Mode_t mode, Submode_t submode, + uint32_t *msToReachTheMode) { + return HasReturnvaluesIF::RETURN_OK; } -ReturnValue_t GPSHyperionHandler::buildNormalDeviceCommand(DeviceCommandId_t *id) { - return NOTHING_TO_SEND; -} - -ReturnValue_t GPSHyperionHandler::buildCommandFromCommand( - DeviceCommandId_t deviceCommand, const uint8_t *commandData, - size_t commandDataLen) { - // By default, send nothing - rawPacketLen = 0; - switch(deviceCommand) { +ReturnValue_t GPSHyperionHandler::executeAction(ActionId_t actionId, MessageQueueId_t commandedBy, + const uint8_t *data, size_t size) { + switch(actionId) { case(GpsHyperion::TRIGGER_RESET_PIN): { if(resetCallback != nullptr) { PoolReadGuard pg(&gpsSet); @@ -69,99 +107,6 @@ ReturnValue_t GPSHyperionHandler::buildCommandFromCommand( return HasReturnvaluesIF::RETURN_OK; } -ReturnValue_t GPSHyperionHandler::scanForReply(const uint8_t *start, size_t len, - DeviceCommandId_t *foundId, size_t *foundLen) { - // Pass data to GPS library - if(len > 0) { - // sif::debug << "GPSHandler::scanForReply: Received " << len << " bytes" << std::endl; - if (internalState == InternalStates::WAIT_FIRST_MESSAGE) { - // TODO: Check whether data is valid by checking whether NMEA start string is valid? - commandExecuted = true; - } - int result = lwgps_process(&gpsData, start, len); - if(result != 1) { - sif::warning << "GPSHandler::scanForReply: Issue processing GPS data with lwgps" - << std::endl; - } - else { - // The data from the device will generally be read all at once. Therefore, we - // can set all field here - PoolReadGuard pg(&gpsSet); - if(pg.getReadResult() != HasReturnvaluesIF::RETURN_OK) { -#if FSFW_VERBOSE_LEVEL >= 1 - sif::warning << "GPSHyperionHandler::scanForReply: Reading dataset failed" - << std::endl; -#endif - } - // Print messages - if(gpsData.is_valid) { - // Set all entries valid now, set invalid on case basis if values are sanitized - gpsSet.setValidity(true, true); - } - // Negative latitude -> South direction - gpsSet.latitude.value = gpsData.latitude; - // Negative longitude -> West direction - gpsSet.longitude.value = gpsData.longitude; - if(gpsData.altitude > 600000.0 or gpsData.altitude < 400000.0) { - gpsSet.altitude.setValid(false); - } - else { - gpsSet.altitude.setValid(true); - gpsSet.altitude.value = gpsData.altitude; - } - gpsSet.fixMode.value = gpsData.fix_mode; - gpsSet.satInUse.value = gpsData.sats_in_use; - Clock::TimeOfDay_t timeStruct = {}; - timeStruct.day = gpsData.date; - timeStruct.hour = gpsData.hours; - timeStruct.minute = gpsData.minutes; - timeStruct.month = gpsData.month; - timeStruct.second = gpsData.seconds; - // Convert two-digit year to full year (AD) - timeStruct.year = gpsData.year + 2000; - timeval timeval = {}; - Clock::convertTimeOfDayToTimeval(&timeStruct, &timeval); - gpsSet.year = timeStruct.year; - gpsSet.month = gpsData.month; - gpsSet.day = gpsData.date; - gpsSet.hours = gpsData.hours; - gpsSet.minutes = gpsData.minutes; - gpsSet.seconds = gpsData.seconds; - gpsSet.unixSeconds = timeval.tv_sec; - 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); - } -#if FSFW_DEV_HYPERION_GPS_CREATE_NMEA_CSV == 1 - std::string filename = "/mnt/sd0/gps_log.txt"; - std::ofstream gpsFile; - if(not std::filesystem::exists(filename)) { - gpsFile.open(filename, std::ofstream::out); - } - gpsFile.open(filename, std::ofstream::out | std::ofstream::app); - gpsFile.write("\n", 1); - gpsFile.write(reinterpret_cast(start), len); -#endif - } - *foundLen = len; - *foundId = GpsHyperion::GPS_REPLY; - } - return HasReturnvaluesIF::RETURN_OK; - -} - -ReturnValue_t GPSHyperionHandler::interpretDeviceReply(DeviceCommandId_t id, - const uint8_t *packet) { - return HasReturnvaluesIF::RETURN_OK; -} - -uint32_t GPSHyperionHandler::getTransitionDelayMs(Mode_t from, Mode_t to) { - return 5000; -} - ReturnValue_t GPSHyperionHandler::initializeLocalDataPool( localpool::DataPool &localDataPoolMap, LocalDataPoolManager &poolManager) { localDataPoolMap.emplace(GpsHyperion::ALTITUDE, new PoolEntry({0.0})); @@ -180,35 +125,21 @@ ReturnValue_t GPSHyperionHandler::initializeLocalDataPool( return HasReturnvaluesIF::RETURN_OK; } -void GPSHyperionHandler::fillCommandAndReplyMap() { - // Reply length does not matter, packets should always arrive periodically - insertInReplyMap(GpsHyperion::GPS_REPLY, 4, &gpsSet, 0, true); - insertInCommandMap(GpsHyperion::TRIGGER_RESET_PIN); -} - -void GPSHyperionHandler::modeChanged() { - internalState = InternalStates::NONE; -} - void GPSHyperionHandler::setResetPinTriggerFunction(gpioResetFunction_t resetCallback, void *args) { this->resetCallback = resetCallback; resetCallbackArgs = args; } -void GPSHyperionHandler::debugInterface(uint8_t positionTracker, object_id_t objectId, - uint32_t parameter) { -} ReturnValue_t GPSHyperionHandler::initialize() { - ReturnValue_t result = DeviceHandlerBase::initialize(); + ReturnValue_t result = ExtendedControllerBase::initialize(); if(result != HasReturnvaluesIF::RETURN_OK) { return result; } - // Enable reply immediately for now - return updatePeriodicReply(true, GpsHyperion::GPS_REPLY); + return result; } -ReturnValue_t GPSHyperionHandler::acceptExternalDeviceCommands() { - return DeviceHandlerBase::acceptExternalDeviceCommands(); +ReturnValue_t GPSHyperionHandler::handleCommandMessage(CommandMessage *message) { + return ExtendedControllerBase::handleCommandMessage(message); } diff --git a/mission/devices/GPSHyperionHandler.h b/mission/devices/GPSHyperionHandler.h index e7c925be..62ec4d01 100644 --- a/mission/devices/GPSHyperionHandler.h +++ b/mission/devices/GPSHyperionHandler.h @@ -3,6 +3,7 @@ #include "fsfw/FSFW.h" #include "fsfw/devicehandlers/DeviceHandlerBase.h" +#include "fsfw/controller/ExtendedControllerBase.h" #include "devicedefinitions/GPSDefinitions.h" #include "lwgps/lwgps.h" @@ -12,7 +13,7 @@ * Flight manual: * https://egit.irs.uni-stuttgart.de/redmine/projects/eive-flight-manual/wiki/Hyperion_HT-GPS200 */ -class GPSHyperionHandler: public DeviceHandlerBase { +class GPSHyperionHandler: public ExtendedControllerBase { public: GPSHyperionHandler(object_id_t objectId, object_id_t deviceCommunication, @@ -22,46 +23,24 @@ public: using gpioResetFunction_t = ReturnValue_t (*) (void* args); void setResetPinTriggerFunction(gpioResetFunction_t resetCallback, void*args); - ReturnValue_t acceptExternalDeviceCommands() override; - + ReturnValue_t handleCommandMessage(CommandMessage *message) override; + void performControlOperation() override; + LocalPoolDataSetBase* getDataSetHandle(sid_t sid) override; + ReturnValue_t checkModeCommand(Mode_t mode, Submode_t submode, + uint32_t *msToReachTheMode) override; + ReturnValue_t executeAction(ActionId_t actionId, + MessageQueueId_t commandedBy, const uint8_t* data, + size_t size) override; ReturnValue_t initialize() override; protected: gpioResetFunction_t resetCallback = nullptr; void* resetCallbackArgs = nullptr; - enum class InternalStates { - NONE, - WAIT_FIRST_MESSAGE, - IDLE - }; - InternalStates internalState = InternalStates::NONE; - bool commandExecuted = false; - - /* DeviceHandlerBase overrides */ - ReturnValue_t buildTransitionDeviceCommand( - DeviceCommandId_t *id) override; - void doStartUp() override; - void doShutDown() override; - ReturnValue_t buildNormalDeviceCommand( - DeviceCommandId_t *id) override; - ReturnValue_t buildCommandFromCommand( - DeviceCommandId_t deviceCommand, const uint8_t *commandData, - size_t commandDataLen) override; - ReturnValue_t scanForReply(const uint8_t *start, size_t len, - DeviceCommandId_t *foundId, size_t *foundLen) override; - ReturnValue_t interpretDeviceReply(DeviceCommandId_t id, - const uint8_t *packet) override; - - void fillCommandAndReplyMap() override; - void modeChanged() override; - uint32_t getTransitionDelayMs(Mode_t from, Mode_t to) override; ReturnValue_t initializeLocalDataPool(localpool::DataPool &localDataPoolMap, LocalDataPoolManager &poolManager) override; - virtual void debugInterface(uint8_t positionTracker = 0, - object_id_t objectId = 0, uint32_t parameter = 0) override; + private: - lwgps_t gpsData = {}; GpsPrimaryDataset gpsSet; bool debugHyperionGps = false; }; From d8ec051e13aecc6d29bbc7c8b857662f3dbcbc1a Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Tue, 11 Jan 2022 10:55:26 +0100 Subject: [PATCH 04/18] stuff --- bsp_q7s/core/ObjectFactory.cpp | 8 ++------ linux/fsfwconfig/OBSWConfig.h.in | 2 +- mission/devices/GPSHyperionHandler.cpp | 4 ++-- mission/devices/GPSHyperionHandler.h | 4 ++-- 4 files changed, 7 insertions(+), 11 deletions(-) diff --git a/bsp_q7s/core/ObjectFactory.cpp b/bsp_q7s/core/ObjectFactory.cpp index 14f1b34b..42665293 100644 --- a/bsp_q7s/core/ObjectFactory.cpp +++ b/bsp_q7s/core/ObjectFactory.cpp @@ -570,12 +570,8 @@ void ObjectFactory::createAcsBoardComponents(LinuxLibgpioIF *gpioComIF, UartComI resetArgsGnss0.gnss1 = false; resetArgsGnss0.gpioComIF = gpioComIF; resetArgsGnss0.waitPeriodMs = 100; - auto uartCookieGps0 = new UartCookie(objects::GPS0_HANDLER, q7s::UART_GNSS_DEV, - UartModes::CANONICAL, uart::GNSS_BAUD, uart::HYPERION_GPS_REPLY_MAX_BUFFER); - uartCookieGps0->setToFlushInput(true); - uartCookieGps0->setReadCycles(6); - auto gpsHandler0 = new GPSHyperionHandler(objects::GPS0_HANDLER, objects::UART_COM_IF, - uartCookieGps0, debugGps); + auto gpsHandler0 = new GPSHyperionHandler(objects::GPS0_HANDLER, objects::NO_OBJECT, + debugGps); gpsHandler0->setResetPinTriggerFunction(gps::triggerGpioResetPin, &resetArgsGnss0); } diff --git a/linux/fsfwconfig/OBSWConfig.h.in b/linux/fsfwconfig/OBSWConfig.h.in index 4a7bca35..51a04e16 100644 --- a/linux/fsfwconfig/OBSWConfig.h.in +++ b/linux/fsfwconfig/OBSWConfig.h.in @@ -109,7 +109,7 @@ debugging. */ #define OBSW_DEBUG_STARTRACKER 0 #define OBSW_DEBUG_PLOC_MPSOC 0 #define OBSW_DEBUG_PLOC_SUPERVISOR 0 -#define OBSW_DEBUG_PDEC_HANDLER 1 +#define OBSW_DEBUG_PDEC_HANDLER 0 /*******************************************************************/ /** Hardcoded */ diff --git a/mission/devices/GPSHyperionHandler.cpp b/mission/devices/GPSHyperionHandler.cpp index 58491332..3a2253e6 100644 --- a/mission/devices/GPSHyperionHandler.cpp +++ b/mission/devices/GPSHyperionHandler.cpp @@ -9,8 +9,8 @@ #include #endif -GPSHyperionHandler::GPSHyperionHandler(object_id_t objectId, object_id_t deviceCommunication, - CookieIF *comCookie, bool debugHyperionGps): +GPSHyperionHandler::GPSHyperionHandler(object_id_t objectId, object_id_t parentId, + bool debugHyperionGps): ExtendedControllerBase(objectId, objects::NO_OBJECT), gpsSet(this), debugHyperionGps(debugHyperionGps) { } diff --git a/mission/devices/GPSHyperionHandler.h b/mission/devices/GPSHyperionHandler.h index 62ec4d01..240fe480 100644 --- a/mission/devices/GPSHyperionHandler.h +++ b/mission/devices/GPSHyperionHandler.h @@ -16,8 +16,8 @@ class GPSHyperionHandler: public ExtendedControllerBase { public: - GPSHyperionHandler(object_id_t objectId, object_id_t deviceCommunication, - CookieIF* comCookie, bool debugHyperionGps = false); + GPSHyperionHandler(object_id_t objectId, object_id_t parentId, + bool debugHyperionGps = false); virtual ~GPSHyperionHandler(); using gpioResetFunction_t = ReturnValue_t (*) (void* args); From 64ac41d1feedc34916259a2645e040338d13b362 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Tue, 11 Jan 2022 11:04:23 +0100 Subject: [PATCH 05/18] initialize variable --- bsp_q7s/devices/startracker/StrHelper.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bsp_q7s/devices/startracker/StrHelper.cpp b/bsp_q7s/devices/startracker/StrHelper.cpp index 0be38ad7..59587317 100644 --- a/bsp_q7s/devices/startracker/StrHelper.cpp +++ b/bsp_q7s/devices/startracker/StrHelper.cpp @@ -634,7 +634,7 @@ ReturnValue_t StrHelper::checkFlashActionReply(uint8_t region_, uint32_t address << std::endl; return result; } - uint16_t length; + uint16_t length = 0; size = sizeof(length); const uint8_t* lengthData = data + LENGTH_OFFSET; result = SerializeAdapter::deSerialize(&length, lengthData, &size, From 9d48438faee734968f6179608b501b5db5852066 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Tue, 11 Jan 2022 14:45:16 +0100 Subject: [PATCH 06/18] fixes for RPi --- bsp_linux_board/ObjectFactory.cpp | 2 +- fsfw | 2 +- linux/boardtest/SpiTestClass.cpp | 14 +++++++------- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/bsp_linux_board/ObjectFactory.cpp b/bsp_linux_board/ObjectFactory.cpp index 5cd52c91..bb86ecce 100644 --- a/bsp_linux_board/ObjectFactory.cpp +++ b/bsp_linux_board/ObjectFactory.cpp @@ -14,7 +14,7 @@ #include "mission/core/GenericFactory.h" #include "mission/utility/TmFunnel.h" #include -#include "mission/devices/GyroADIS16507Handler.h" +#include "mission/devices/GyroADIS1650XHandler.h" #include "fsfw/datapoollocal/LocalDataPoolManager.h" #include "fsfw/tmtcservices/CommandingServiceBase.h" diff --git a/fsfw b/fsfw index 2506af27..5214f8a4 160000 --- a/fsfw +++ b/fsfw @@ -1 +1 @@ -Subproject commit 2506af27ed84585c64df2679b0c6a3c969f31941 +Subproject commit 5214f8a449d195ecfa69f978cc0fe001ef76130a diff --git a/linux/boardtest/SpiTestClass.cpp b/linux/boardtest/SpiTestClass.cpp index b043b55d..65f2ca9f 100644 --- a/linux/boardtest/SpiTestClass.cpp +++ b/linux/boardtest/SpiTestClass.cpp @@ -297,31 +297,31 @@ void SpiTestClass::acsInit() { GpiodRegularByChip* gpio = nullptr; std::string rpiGpioName = "gpiochip0"; gpio = new GpiodRegularByChip(rpiGpioName, mgm0Lis3mdlChipSelect, "MGM_0_LIS3", - gpio::DIR_OUT, 1); + gpio::DIR_OUT, gpio::HIGH); gpioCookie->addGpio(gpioIds::MGM_0_LIS3_CS, gpio); gpio = new GpiodRegularByChip(rpiGpioName, mgm1Rm3100ChipSelect, "MGM_1_RM3100", - gpio::DIR_OUT, 1); + gpio::DIR_OUT, gpio::HIGH); gpioCookie->addGpio(gpioIds::MGM_1_RM3100_CS, gpio); gpio = new GpiodRegularByChip(rpiGpioName, gyro0AdisChipSelect, "GYRO_0_ADIS", - gpio::DIR_OUT, 1); + gpio::DIR_OUT, gpio::HIGH); gpioCookie->addGpio(gpioIds::GYRO_0_ADIS_CS, gpio); gpio = new GpiodRegularByChip(rpiGpioName, gyro1L3gd20ChipSelect, "GYRO_1_L3G", - gpio::DIR_OUT, 1); + gpio::DIR_OUT, gpio::HIGH); gpioCookie->addGpio(gpioIds::GYRO_1_L3G_CS, gpio); gpio = new GpiodRegularByChip(rpiGpioName, gyro3L3gd20ChipSelect, "GYRO_2_L3G", - gpio::DIR_OUT, 1); + gpio::DIR_OUT, gpio::HIGH); gpioCookie->addGpio(gpioIds::GYRO_3_L3G_CS, gpio); gpio = new GpiodRegularByChip(rpiGpioName, mgm2Lis3mdlChipSelect, "MGM_2_LIS3", - gpio::DIR_OUT, 1); + gpio::DIR_OUT, gpio::HIGH); gpioCookie->addGpio(gpioIds::MGM_2_LIS3_CS, gpio); gpio = new GpiodRegularByChip(rpiGpioName, mgm3Rm3100ChipSelect, "MGM_3_RM3100", - gpio::DIR_OUT, 1); + gpio::DIR_OUT, gpio::HIGH); gpioCookie->addGpio(gpioIds::MGM_3_RM3100_CS, gpio); #elif defined(XIPHOS_Q7S) GpiodRegularByLineName* gpio = nullptr; From 2323fd0506f8064866335d453734fe36fc949faf Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Tue, 11 Jan 2022 14:50:39 +0100 Subject: [PATCH 07/18] added rpi port script --- scripts/rpi-port.sh | 8 ++++++++ 1 file changed, 8 insertions(+) create mode 100755 scripts/rpi-port.sh diff --git a/scripts/rpi-port.sh b/scripts/rpi-port.sh new file mode 100755 index 00000000..5801fb50 --- /dev/null +++ b/scripts/rpi-port.sh @@ -0,0 +1,8 @@ +#!/bin/bash +echo "-L 1538:raspberrypi.local:1538 for Raspberry Pi connect with TCF agent" +echo "-L 1539:raspberrypi.local:22 for Raspberry Pi file transfers" + +ssh -L 1538:raspberrypi.local:1534 \ + -L 1539:raspberrypi.local:22 \ + eive@2001:7c0:2018:1099:babe:0:e1fe:f1a5 \ + -t 'CONSOLE_PREFIX="[RPi Tunnel]" /bin/bash' From e73dc2f19176db39923aa355685ea1592c32802d Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Sat, 15 Jan 2022 13:05:11 +0100 Subject: [PATCH 08/18] gps test worked --- CMakeLists.txt | 2 ++ bsp_q7s/boardtest/Q7STestTask.cpp | 29 +++++++++++++++++++++++++++++ bsp_q7s/boardtest/Q7STestTask.h | 3 +++ fsfw | 2 +- 4 files changed, 35 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 59d9d32d..17796924 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -66,6 +66,7 @@ set(LIB_ARCSEC wire) set(THIRD_PARTY_FOLDER thirdparty) set(LIB_CXX_FS -lstdc++fs) set(LIB_CATCH2 Catch2) +set(LIB_GPS gps) set(LIB_JSON_NAME nlohmann_json::nlohmann_json) # Set path names @@ -221,6 +222,7 @@ if((NOT BUILD_Q7S_SIMPLE_MODE) AND (NOT EIVE_BUILD_WATCHDOG)) if(TGT_BSP MATCHES "arm/q7s") target_link_libraries(${TARGET_NAME} PRIVATE ${LIB_ARCSEC} + ${LIB_GPS} ) endif() endif() diff --git a/bsp_q7s/boardtest/Q7STestTask.cpp b/bsp_q7s/boardtest/Q7STestTask.cpp index 5cead3d5..77bd7e13 100644 --- a/bsp_q7s/boardtest/Q7STestTask.cpp +++ b/bsp_q7s/boardtest/Q7STestTask.cpp @@ -12,8 +12,12 @@ #include "test/DummyParameter.h" #include +#include +#include +#include #include +#include #include #include @@ -31,6 +35,11 @@ ReturnValue_t Q7STestTask::performOneShotAction() { return TestTask::performOneShotAction(); } +ReturnValue_t Q7STestTask::performPeriodicAction() { + testGpsDaemon(); + return TestTask::performPeriodicAction(); +} + void Q7STestTask::testSdCard() { using namespace std; Stopwatch stopwatch; @@ -224,6 +233,26 @@ void Q7STestTask::testProtHandler() { } } +void Q7STestTask::testGpsDaemon() { + gpsmm gpsmm(GPSD_SHARED_MEMORY, 0); + gps_data_t* gps; + gps = gpsmm.read(); + if(gps == nullptr) { + sif::warning << "Q7STestTask: Reading GPS data failed" << std::endl; + } + sif::info << "-- Q7STestTask: GPS shared memory read test --" << std::endl; + time_t timeRaw = gps->fix.time.tv_sec; + std::tm* time = gmtime(&timeRaw); + sif::info << "Time: " << std::put_time(time, "%c %Z") << std::endl; + sif::info << "Visible satellites: " << gps->satellites_visible << std::endl; + sif::info << "Satellites used: " << gps->satellites_used << std::endl; + sif::info << "Fix (0:Not Seen|1:No Fix|2:2D|3:3D): " << gps->fix.mode << std::endl; + sif::info << "Latitude: " << gps->fix.latitude << std::endl; + sif::info << "Longitude: " << gps->fix.longitude << std::endl; + sif::info << "Altitude(MSL): " << gps->fix.altMSL << std::endl; + sif::info << "Speed(m/s): " << gps->fix.speed << std::endl; +} + void Q7STestTask::testFileSystemHandlerDirect(FsOpCodes opCode) { auto fsHandler = ObjectManager::instance()-> get(objects::FILE_SYSTEM_HANDLER); diff --git a/bsp_q7s/boardtest/Q7STestTask.h b/bsp_q7s/boardtest/Q7STestTask.h index 5e11b374..f6da9b7a 100644 --- a/bsp_q7s/boardtest/Q7STestTask.h +++ b/bsp_q7s/boardtest/Q7STestTask.h @@ -11,6 +11,9 @@ public: private: CoreController* coreController = nullptr; ReturnValue_t performOneShotAction() override; + ReturnValue_t performPeriodicAction() override; + + void testGpsDaemon(); void testSdCard(); void fileTests(); diff --git a/fsfw b/fsfw index 5214f8a4..c1e0bcee 160000 --- a/fsfw +++ b/fsfw @@ -1 +1 @@ -Subproject commit 5214f8a449d195ecfa69f978cc0fe001ef76130a +Subproject commit c1e0bcee6db652d6c474c87a4099e61ecf86b694 From a706f6d9bd382acf372d5c6cb90c62fc6571c139 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Sat, 15 Jan 2022 13:09:33 +0100 Subject: [PATCH 09/18] using test booleans --- bsp_q7s/boardtest/Q7STestTask.cpp | 15 ++++++++++++--- bsp_q7s/boardtest/Q7STestTask.h | 4 ++++ 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/bsp_q7s/boardtest/Q7STestTask.cpp b/bsp_q7s/boardtest/Q7STestTask.cpp index 77bd7e13..dc87cd3b 100644 --- a/bsp_q7s/boardtest/Q7STestTask.cpp +++ b/bsp_q7s/boardtest/Q7STestTask.cpp @@ -22,11 +22,18 @@ #include Q7STestTask::Q7STestTask(object_id_t objectId): TestTask(objectId) { + doTestSdCard = false; + doTestScratchApi = false; + doTestGps = false; } ReturnValue_t Q7STestTask::performOneShotAction() { - //testSdCard(); - //testScratchApi(); + if (doTestSdCard) { + testSdCard(); + } + if (doTestScratchApi) { + testScratchApi(); + } //testJsonLibDirect(); //testDummyParams(); //testProtHandler(); @@ -36,7 +43,9 @@ ReturnValue_t Q7STestTask::performOneShotAction() { } ReturnValue_t Q7STestTask::performPeriodicAction() { - testGpsDaemon(); + if(doTestGps) { + testGpsDaemon(); + } return TestTask::performPeriodicAction(); } diff --git a/bsp_q7s/boardtest/Q7STestTask.h b/bsp_q7s/boardtest/Q7STestTask.h index f6da9b7a..91e8c3d6 100644 --- a/bsp_q7s/boardtest/Q7STestTask.h +++ b/bsp_q7s/boardtest/Q7STestTask.h @@ -9,6 +9,10 @@ public: ReturnValue_t initialize() override; private: + bool doTestSdCard = false; + bool doTestScratchApi = false; + bool doTestGps = false; + CoreController* coreController = nullptr; ReturnValue_t performOneShotAction() override; ReturnValue_t performPeriodicAction() override; From 806280ee4aee42f712a381179d45b95afc198bec Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Sat, 15 Jan 2022 13:18:52 +0100 Subject: [PATCH 10/18] fsfw update --- fsfw | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fsfw b/fsfw index c1e0bcee..2c871af7 160000 --- a/fsfw +++ b/fsfw @@ -1 +1 @@ -Subproject commit c1e0bcee6db652d6c474c87a4099e61ecf86b694 +Subproject commit 2c871af7b98abc794cdf6072fae174c9dc3ac63b From 9b0906c06819899184114a3fdc078f581bb7002d Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Sat, 15 Jan 2022 13:19:21 +0100 Subject: [PATCH 11/18] repoint fsfw --- fsfw | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fsfw b/fsfw index 2c871af7..c1e0bcee 160000 --- a/fsfw +++ b/fsfw @@ -1 +1 @@ -Subproject commit 2c871af7b98abc794cdf6072fae174c9dc3ac63b +Subproject commit c1e0bcee6db652d6c474c87a4099e61ecf86b694 From 1aa8befe50f64794a0b579cd018f96a9b832b785 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Sat, 15 Jan 2022 13:21:46 +0100 Subject: [PATCH 12/18] tmtc update --- tmtc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tmtc b/tmtc index 77919df9..8ed7a4e9 160000 --- a/tmtc +++ b/tmtc @@ -1 +1 @@ -Subproject commit 77919df9f2f05aede4ad4afd5ea56899ad994d32 +Subproject commit 8ed7a4e90f392f4f60e63659fa0115a2fe6765e1 From 2fa8de41032853b2c41fce0b1152319f9833657f Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Sat, 15 Jan 2022 13:39:49 +0100 Subject: [PATCH 13/18] tmtc update --- tmtc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tmtc b/tmtc index 77919df9..c86cd187 160000 --- a/tmtc +++ b/tmtc @@ -1 +1 @@ -Subproject commit 77919df9f2f05aede4ad4afd5ea56899ad994d32 +Subproject commit c86cd1874f605a89277e1b8fcf4496f9302c941e From 70ab48608130f48a568147bbd0eb73f42a828494 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Sat, 15 Jan 2022 13:50:21 +0100 Subject: [PATCH 14/18] removed GPS flags --- linux/fsfwconfig/OBSWConfig.h.in | 2 -- 1 file changed, 2 deletions(-) diff --git a/linux/fsfwconfig/OBSWConfig.h.in b/linux/fsfwconfig/OBSWConfig.h.in index 51a04e16..ea26425b 100644 --- a/linux/fsfwconfig/OBSWConfig.h.in +++ b/linux/fsfwconfig/OBSWConfig.h.in @@ -47,8 +47,6 @@ debugging. */ #define OBSW_ADD_PLOC_MPSOC 0 #define OBSW_ADD_SUN_SENSORS 0 #define OBSW_ADD_ACS_BOARD 0 -#define OBSW_ADD_GPS_0 0 -#define OBSW_ADD_GPS_1 0 #define OBSW_ADD_RW 0 #define OBSW_ADD_RTD_DEVICES 0 #define OBSW_ADD_TMP_DEVICES 0 From 3b9959b8b39e068a981cfc9ac743de20309d68a8 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Sat, 15 Jan 2022 13:51:27 +0100 Subject: [PATCH 15/18] removed gps from pst --- .../pollingSequenceFactory.cpp | 32 ------------------- 1 file changed, 32 deletions(-) diff --git a/linux/fsfwconfig/pollingsequence/pollingSequenceFactory.cpp b/linux/fsfwconfig/pollingsequence/pollingSequenceFactory.cpp index 07bc4a8f..82748821 100644 --- a/linux/fsfwconfig/pollingsequence/pollingSequenceFactory.cpp +++ b/linux/fsfwconfig/pollingsequence/pollingSequenceFactory.cpp @@ -614,38 +614,6 @@ ReturnValue_t pst::pstUart(FixedTimeslotTaskIF *thisSequence) { DeviceHandlerIF::GET_READ); #endif -#if OBSW_ADD_ACS_BOARD == 1 - -#if OBSW_ADD_GPS_0 == 1 - uartPstEmpty = false; - thisSequence->addSlot(objects::GPS0_HANDLER, length * 0, - DeviceHandlerIF::PERFORM_OPERATION); - thisSequence->addSlot(objects::GPS0_HANDLER, length * 0.2, - DeviceHandlerIF::SEND_WRITE); - thisSequence->addSlot(objects::GPS0_HANDLER, length * 0.4, - DeviceHandlerIF::GET_WRITE); - thisSequence->addSlot(objects::GPS0_HANDLER, length * 0.6, - DeviceHandlerIF::SEND_READ); - thisSequence->addSlot(objects::GPS0_HANDLER, length * 0.8, - DeviceHandlerIF::GET_READ); -#endif /* OBSW_ADD_GPS_0 == 1 */ - -#if OBSW_ADD_GPS_1 == 1 - uartPstEmpty = false; - thisSequence->addSlot(objects::GPS1_HANDLER, length * 0, - DeviceHandlerIF::PERFORM_OPERATION); - thisSequence->addSlot(objects::GPS1_HANDLER, length * 0.2, - DeviceHandlerIF::SEND_WRITE); - thisSequence->addSlot(objects::GPS1_HANDLER, length * 0.4, - DeviceHandlerIF::GET_WRITE); - thisSequence->addSlot(objects::GPS1_HANDLER, length * 0.6, - DeviceHandlerIF::SEND_READ); - thisSequence->addSlot(objects::GPS1_HANDLER, length * 0.8, - DeviceHandlerIF::GET_READ); -#endif /* OBSW_ADD_GPS_1 == 1 */ - -#endif /* OBSW_ADD_ACS_BOARD == 1 */ - #if OBSW_ADD_STAR_TRACKER == 1 uartPstEmpty = false; thisSequence->addSlot(objects::STAR_TRACKER, length * 0, DeviceHandlerIF::PERFORM_OPERATION); From 37ae508af5090be7d0baaa494be035214c75978b Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Mon, 17 Jan 2022 11:31:50 +0100 Subject: [PATCH 16/18] finished GPS handler refactoring --- mission/devices/GPSHyperionHandler.cpp | 151 +++++++++++------- mission/devices/GPSHyperionHandler.h | 3 +- .../devicedefinitions/GPSDefinitions.h | 22 +-- tmtc | 2 +- 4 files changed, 106 insertions(+), 72 deletions(-) diff --git a/mission/devices/GPSHyperionHandler.cpp b/mission/devices/GPSHyperionHandler.cpp index 3a2253e6..d42421a0 100644 --- a/mission/devices/GPSHyperionHandler.cpp +++ b/mission/devices/GPSHyperionHandler.cpp @@ -4,6 +4,10 @@ #include "fsfw/datapool/PoolReadGuard.h" #include "fsfw/timemanager/Clock.h" +#include +#include +#include + #if FSFW_DEV_HYPERION_GPS_CREATE_NMEA_CSV == 1 #include #include @@ -18,67 +22,7 @@ GPSHyperionHandler::GPSHyperionHandler(object_id_t objectId, object_id_t parentI GPSHyperionHandler::~GPSHyperionHandler() {} void GPSHyperionHandler::performControlOperation() { - // The data from the device will generally be read all at once. Therefore, we - // can set all field here -// PoolReadGuard pg(&gpsSet); -// if(pg.getReadResult() != HasReturnvaluesIF::RETURN_OK) { -//#if FSFW_VERBOSE_LEVEL >= 1 -// sif::warning << "GPSHyperionHandler::scanForReply: Reading dataset failed" -// << std::endl; -//#endif -// } -// // Print messages -// if(gpsData.is_valid) { -// // Set all entries valid now, set invalid on case basis if values are sanitized -// gpsSet.setValidity(true, true); -// } -// // Negative latitude -> South direction -// gpsSet.latitude.value = gpsData.latitude; -// // Negative longitude -> West direction -// gpsSet.longitude.value = gpsData.longitude; -// if(gpsData.altitude > 600000.0 or gpsData.altitude < 400000.0) { -// gpsSet.altitude.setValid(false); -// } -// else { -// gpsSet.altitude.setValid(true); -// gpsSet.altitude.value = gpsData.altitude; -// } -// gpsSet.fixMode.value = gpsData.fix_mode; -// gpsSet.satInUse.value = gpsData.sats_in_use; -// Clock::TimeOfDay_t timeStruct = {}; -// timeStruct.day = gpsData.date; -// timeStruct.hour = gpsData.hours; -// timeStruct.minute = gpsData.minutes; -// timeStruct.month = gpsData.month; -// timeStruct.second = gpsData.seconds; -// // Convert two-digit year to full year (AD) -// timeStruct.year = gpsData.year + 2000; -// timeval timeval = {}; -// Clock::convertTimeOfDayToTimeval(&timeStruct, &timeval); -// gpsSet.year = timeStruct.year; -// gpsSet.month = gpsData.month; -// gpsSet.day = gpsData.date; -// gpsSet.hours = gpsData.hours; -// gpsSet.minutes = gpsData.minutes; -// gpsSet.seconds = gpsData.seconds; -// gpsSet.unixSeconds = timeval.tv_sec; -// 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); -// } -//#if FSFW_DEV_HYPERION_GPS_CREATE_NMEA_CSV == 1 -// std::string filename = "/mnt/sd0/gps_log.txt"; -// std::ofstream gpsFile; -// if(not std::filesystem::exists(filename)) { -// gpsFile.open(filename, std::ofstream::out); -// } -// gpsFile.open(filename, std::ofstream::out | std::ofstream::app); -// gpsFile.write("\n", 1); -// gpsFile.write(reinterpret_cast(start), len); -//#endif + readGpsDataFromGpsd(); } LocalPoolDataSetBase* GPSHyperionHandler::getDataSetHandle(sid_t sid) { @@ -143,3 +87,88 @@ ReturnValue_t GPSHyperionHandler::initialize() { ReturnValue_t GPSHyperionHandler::handleCommandMessage(CommandMessage *message) { return ExtendedControllerBase::handleCommandMessage(message); } + +void GPSHyperionHandler::readGpsDataFromGpsd() { + // The data from the device will generally be read all at once. Therefore, we + // can set all field here + gpsmm gpsmm(GPSD_SHARED_MEMORY, 0); + gps_data_t* gps; + gps = gpsmm.read(); + if(gps == nullptr) { + sif::warning << "Q7STestTask: Reading GPS data failed" << std::endl; + } + PoolReadGuard pg(&gpsSet); + if(pg.getReadResult() != HasReturnvaluesIF::RETURN_OK) { +#if FSFW_VERBOSE_LEVEL >= 1 + sif::warning << "GPSHyperionHandler::scanForReply: Reading dataset failed" + << std::endl; +#endif + } + // Print messages + if((gps->set & MODE_SET) != MODE_SET) { + // Could not even set mode + gpsSet.setValidity(false, true); + return; + } + + if(gps->satellites_used > 0) { + gpsSet.setValidity(true, true); + } + + gpsSet.satInUse.value = gps->satellites_used; + gpsSet.satInView.value = gps->satellites_visible; + + // 0: Not seen, 1: No fix, 2: 2D-Fix, 3: 3D-Fix + gpsSet.fixMode = gps->fix.mode; + if(std::isfinite(gps->fix.latitude)) { + // Negative latitude -> South direction + gpsSet.latitude.value = gps->fix.latitude; + } else { + gpsSet.latitude.setValid(false); + } + + if(std::isfinite(gps->fix.longitude)) { + // Negative longitude -> West direction + gpsSet.longitude.value = gps->fix.longitude; + } else { + gpsSet.longitude.setValid(false); + } + + if(std::isfinite(gps->fix.altitude)) { + gpsSet.altitude.value = gps->fix.altitude; + } else { + gpsSet.altitude.setValid(false); + } + + if(std::isfinite(gps->fix.speed)) { + gpsSet.speed.value = gps->fix.speed; + } else { + gpsSet.speed.setValid(false); + } + + gpsSet.unixSeconds.value = gps->fix.time.tv_sec; + timeval time = {}; + time.tv_sec = gpsSet.unixSeconds.value; + time.tv_usec = gps->fix.time.tv_nsec / 1000; + Clock::TimeOfDay_t timeOfDay = {}; + Clock::convertTimevalToTimeOfDay(&time, &timeOfDay); + gpsSet.year = timeOfDay.year; + gpsSet.month = timeOfDay.month; + gpsSet.day = timeOfDay.day; + gpsSet.hours = timeOfDay.hour; + gpsSet.minutes = timeOfDay.minute; + gpsSet.seconds = timeOfDay.second; + if(debugHyperionGps) { + sif::info << "-- Hyperion GPS Data --" << std::endl; + time_t timeRaw = gps->fix.time.tv_sec; + std::tm* time = gmtime(&timeRaw); + std::cout << "Time: " << std::put_time(time, "%c %Z") << std::endl; + std::cout << "Visible satellites: " << gps->satellites_visible << std::endl; + std::cout << "Satellites used: " << gps->satellites_used << std::endl; + std::cout << "Fix (0:Not Seen|1:No Fix|2:2D|3:3D): " << gps->fix.mode << std::endl; + std::cout << "Latitude: " << gps->fix.latitude << std::endl; + std::cout << "Longitude: " << gps->fix.longitude << std::endl; + std::cout << "Altitude(MSL): " << gps->fix.altMSL << std::endl; + std::cout << "Speed(m/s): " << gps->fix.speed << std::endl; + } +} diff --git a/mission/devices/GPSHyperionHandler.h b/mission/devices/GPSHyperionHandler.h index 240fe480..96d6089e 100644 --- a/mission/devices/GPSHyperionHandler.h +++ b/mission/devices/GPSHyperionHandler.h @@ -5,7 +5,6 @@ #include "fsfw/devicehandlers/DeviceHandlerBase.h" #include "fsfw/controller/ExtendedControllerBase.h" #include "devicedefinitions/GPSDefinitions.h" -#include "lwgps/lwgps.h" /** * @brief Device handler for the Hyperion HT-GPS200 device @@ -43,6 +42,8 @@ protected: private: GpsPrimaryDataset gpsSet; bool debugHyperionGps = false; + + void readGpsDataFromGpsd(); }; #endif /* MISSION_DEVICES_GPSHYPERIONHANDLER_H_ */ diff --git a/mission/devices/devicedefinitions/GPSDefinitions.h b/mission/devices/devicedefinitions/GPSDefinitions.h index 90fdb123..aea442a2 100644 --- a/mission/devices/devicedefinitions/GPSDefinitions.h +++ b/mission/devices/devicedefinitions/GPSDefinitions.h @@ -15,15 +15,17 @@ enum GpsPoolIds: lp_id_t { LATITUDE = 0, LONGITUDE = 1, ALTITUDE = 2, - FIX_MODE = 3, - SATS_IN_USE = 4, - UNIX_SECONDS = 5, - YEAR = 6, - MONTH = 7, - DAY = 8, - HOURS = 9, - MINUTES = 10, - SECONDS = 11 + SPEED = 3, + FIX_MODE = 4, + SATS_IN_USE = 5, + SATS_IN_VIEW = 6, + UNIX_SECONDS = 7, + YEAR = 8, + MONTH = 9, + DAY = 10, + HOURS = 11, + MINUTES = 12, + SECONDS = 13 }; enum GpsFixModes: uint8_t { @@ -47,8 +49,10 @@ public: lp_var_t longitude = lp_var_t(sid.objectId, GpsHyperion::LONGITUDE, this); lp_var_t altitude = lp_var_t(sid.objectId, GpsHyperion::ALTITUDE, this); + lp_var_t speed = lp_var_t(sid.objectId, GpsHyperion::SPEED, this); lp_var_t fixMode = lp_var_t(sid.objectId, GpsHyperion::FIX_MODE, this); lp_var_t satInUse = lp_var_t(sid.objectId, GpsHyperion::SATS_IN_USE, this); + lp_var_t satInView = lp_var_t(sid.objectId, GpsHyperion::SATS_IN_VIEW, this); lp_var_t year = lp_var_t(sid.objectId, GpsHyperion::YEAR, this); lp_var_t month = lp_var_t(sid.objectId, GpsHyperion::MONTH, this); lp_var_t day = lp_var_t(sid.objectId, GpsHyperion::DAY, this); diff --git a/tmtc b/tmtc index 8ed7a4e9..c86cd187 160000 --- a/tmtc +++ b/tmtc @@ -1 +1 @@ -Subproject commit 8ed7a4e90f392f4f60e63659fa0115a2fe6765e1 +Subproject commit c86cd1874f605a89277e1b8fcf4496f9302c941e From 969251d9fa637362db0e9c476c6aea875fbd422b Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Mon, 17 Jan 2022 11:38:21 +0100 Subject: [PATCH 17/18] new ACS ctrl task --- bsp_q7s/core/InitMission.cpp | 9 +++++++++ bsp_q7s/core/ObjectFactory.cpp | 10 +++++----- common/config/commonObjects.h | 3 +-- 3 files changed, 15 insertions(+), 7 deletions(-) diff --git a/bsp_q7s/core/InitMission.cpp b/bsp_q7s/core/InitMission.cpp index 7977deed..df857d59 100644 --- a/bsp_q7s/core/InitMission.cpp +++ b/bsp_q7s/core/InitMission.cpp @@ -117,6 +117,13 @@ void initmission::initTasks() { } #endif /* OBSW_USE_CCSDS_IP_CORE == 1 */ + PeriodicTaskIF* acsCtrl = factory->createPeriodicTask( + "ACS_CTRL", 40, PeriodicTaskIF::MINIMUM_STACK_SIZE, 0.4, missedDeadlineFunc); + result = acsCtrl->addComponent(objects::GPS_CONTROLLER); + if(result != HasReturnvaluesIF::RETURN_OK) { + initmission::printAddObjectError("ACS_CTRL", objects::GPS_CONTROLLER); + } + # if BOARD_TE0720 == 0 // FS task, task interval does not matter because it runs in permanent loop, priority low // because it is a non-essential background task @@ -202,6 +209,8 @@ void initmission::initTasks() { #endif /* OBSW_ADD_STAR_TRACKER == 1 */ #endif + acsCtrl->startTask(); + sif::info << "Tasks started.." << std::endl; } diff --git a/bsp_q7s/core/ObjectFactory.cpp b/bsp_q7s/core/ObjectFactory.cpp index 42665293..c93ed507 100644 --- a/bsp_q7s/core/ObjectFactory.cpp +++ b/bsp_q7s/core/ObjectFactory.cpp @@ -449,14 +449,14 @@ void ObjectFactory::createAcsBoardComponents(LinuxLibgpioIF *gpioComIF, UartComI gpioCookieAcsBoard->addGpio(gpioIds::MGM_3_RM3100_CS, gpio); consumer.str(""); - consumer << "0x" << std::hex << objects::GPS0_HANDLER; + consumer << "0x" << std::hex << objects::GPS_CONTROLLER; // GNSS reset pins are active low gpio = new GpiodRegularByLineName(q7s::gpioNames::RESET_GNSS_0, consumer.str(), gpio::DIR_OUT, gpio::HIGH); gpioCookieAcsBoard->addGpio(gpioIds::GNSS_0_NRESET, gpio); consumer.str(""); - consumer << "0x" << std::hex << objects::GPS1_HANDLER; + consumer << "0x" << std::hex << objects::GPS_CONTROLLER; gpio = new GpiodRegularByLineName(q7s::gpioNames::RESET_GNSS_1, consumer.str(), gpio::DIR_OUT, gpio::HIGH); gpioCookieAcsBoard->addGpio(gpioIds::GNSS_1_NRESET, gpio); @@ -476,13 +476,13 @@ void ObjectFactory::createAcsBoardComponents(LinuxLibgpioIF *gpioComIF, UartComI // Enable pins for GNSS consumer.str(""); - consumer << "0x" << std::hex << objects::GPS0_HANDLER; + consumer << "0x" << std::hex << objects::GPS_CONTROLLER; gpio = new GpiodRegularByLineName(q7s::gpioNames::GNSS_0_ENABLE, consumer.str(), gpio::DIR_OUT, gpio::LOW); gpioCookieAcsBoard->addGpio(gpioIds::GNSS_0_ENABLE, gpio); consumer.str(""); - consumer << "0x" << std::hex << objects::GPS1_HANDLER; + consumer << "0x" << std::hex << objects::GPS_CONTROLLER; gpio = new GpiodRegularByLineName(q7s::gpioNames::GNSS_1_ENABLE, consumer.str(), gpio::DIR_OUT, gpio::LOW); gpioCookieAcsBoard->addGpio(gpioIds::GNSS_1_ENABLE, gpio); @@ -570,7 +570,7 @@ void ObjectFactory::createAcsBoardComponents(LinuxLibgpioIF *gpioComIF, UartComI resetArgsGnss0.gnss1 = false; resetArgsGnss0.gpioComIF = gpioComIF; resetArgsGnss0.waitPeriodMs = 100; - auto gpsHandler0 = new GPSHyperionHandler(objects::GPS0_HANDLER, objects::NO_OBJECT, + auto gpsHandler0 = new GPSHyperionHandler(objects::GPS_CONTROLLER, objects::NO_OBJECT, debugGps); gpsHandler0->setResetPinTriggerFunction(gps::triggerGpioResetPin, &resetArgsGnss0); } diff --git a/common/config/commonObjects.h b/common/config/commonObjects.h index cce3616f..135259d6 100644 --- a/common/config/commonObjects.h +++ b/common/config/commonObjects.h @@ -79,8 +79,7 @@ enum commonObjects: uint32_t { SUS_12 = 0x44120043, SUS_13 = 0x44120044, - GPS0_HANDLER = 0x44130045, - GPS1_HANDLER = 0x44130146, + GPS_CONTROLLER = 0x44130045, RW1 = 0x44120047, RW2 = 0x44120148, From c657264832fdc68607f0cb920e5c212b8dbed875 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Mon, 17 Jan 2022 15:41:22 +0100 Subject: [PATCH 18/18] small fix --- mission/devices/GPSHyperionHandler.cpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/mission/devices/GPSHyperionHandler.cpp b/mission/devices/GPSHyperionHandler.cpp index d42421a0..a0036867 100644 --- a/mission/devices/GPSHyperionHandler.cpp +++ b/mission/devices/GPSHyperionHandler.cpp @@ -4,8 +4,11 @@ #include "fsfw/datapool/PoolReadGuard.h" #include "fsfw/timemanager/Clock.h" +#ifdef FSFW_OSAL_LINUX #include #include +#endif + #include #if FSFW_DEV_HYPERION_GPS_CREATE_NMEA_CSV == 1 @@ -22,7 +25,9 @@ GPSHyperionHandler::GPSHyperionHandler(object_id_t objectId, object_id_t parentI GPSHyperionHandler::~GPSHyperionHandler() {} void GPSHyperionHandler::performControlOperation() { +#ifdef FSFW_OSAL_LINUX readGpsDataFromGpsd(); +#endif } LocalPoolDataSetBase* GPSHyperionHandler::getDataSetHandle(sid_t sid) { @@ -88,6 +93,7 @@ ReturnValue_t GPSHyperionHandler::handleCommandMessage(CommandMessage *message) return ExtendedControllerBase::handleCommandMessage(message); } +#ifdef FSFW_OSAL_LINUX void GPSHyperionHandler::readGpsDataFromGpsd() { // The data from the device will generally be read all at once. Therefore, we // can set all field here @@ -172,3 +178,4 @@ void GPSHyperionHandler::readGpsDataFromGpsd() { std::cout << "Speed(m/s): " << gps->fix.speed << std::endl; } } +#endif