From 9d7291eea2ceb8f93c33a9b2bd783c6c5c403437 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Mon, 6 Feb 2023 18:12:41 +0100 Subject: [PATCH] this works now --- linux/devices/GpsHyperionLinuxController.cpp | 20 ++++++++------------ 1 file changed, 8 insertions(+), 12 deletions(-) diff --git a/linux/devices/GpsHyperionLinuxController.cpp b/linux/devices/GpsHyperionLinuxController.cpp index 44038a09..6bbbcfb7 100644 --- a/linux/devices/GpsHyperionLinuxController.cpp +++ b/linux/devices/GpsHyperionLinuxController.cpp @@ -1,5 +1,6 @@ #include "GpsHyperionLinuxController.h" +#include #include #include "OBSWConfig.h" @@ -96,8 +97,8 @@ ReturnValue_t GpsHyperionLinuxController::performOperation(uint8_t opCode) { handleQueue(); poolManager.performHkOperation(); while (true) { - bool callAgain = readGpsDataFromGpsd(); - if (not callAgain) { + bool callAgainImmediately = readGpsDataFromGpsd(); + if (not callAgainImmediately) { handleQueue(); poolManager.performHkOperation(); } @@ -126,6 +127,7 @@ ReturnValue_t GpsHyperionLinuxController::initialize() { if (retval != 0) { openError("Socket", retval); } + gps_stream(&gps, WATCH_ENABLE | WATCH_JSON, nullptr); } else if (readMode == ReadModes::SHM) { int retval = gps_open(GPSD_SHARED_MEMORY, "", &gps); if (retval != 0) { @@ -142,25 +144,19 @@ ReturnValue_t GpsHyperionLinuxController::handleCommandMessage(CommandMessage *m void GpsHyperionLinuxController::performControlOperation() {} bool GpsHyperionLinuxController::readGpsDataFromGpsd() { - auto readError = [&](int error) { + auto readError = [&]() { if (gpsReadFailedSwitch) { gpsReadFailedSwitch = false; sif::warning << "GPSHyperionHandler::readGpsDataFromGpsd: Reading GPS data failed | " "Error " - << error << " | " << gps_errstr(error) << std::endl; + << errno << " | " << gps_errstr(errno) << std::endl; } }; - currentClientBuf = gps_data(&gps); if (readMode == ReadModes::SOCKET) { - gps_stream(&gps, WATCH_ENABLE | WATCH_JSON, nullptr); // Perform other necessary handling if not data seen for 0.2 seconds. if (gps_waiting(&gps, 200000)) { - int result = gps_read(&gps); - while (result > 0) { - result = gps_read(&gps); - } - if (result == -1) { - readError(result); + if (-1 == gps_read(&gps)) { + readError(); return false; } if (MODE_SET != (MODE_SET & gps.set)) {