From 8441c49fe67616512882bd73300eb0baa48d08da Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Wed, 2 Aug 2023 16:00:27 +0200 Subject: [PATCH] big gps victory --- linux/acs/GpsHyperionLinuxController.cpp | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/linux/acs/GpsHyperionLinuxController.cpp b/linux/acs/GpsHyperionLinuxController.cpp index afa73f77..b451c112 100644 --- a/linux/acs/GpsHyperionLinuxController.cpp +++ b/linux/acs/GpsHyperionLinuxController.cpp @@ -166,29 +166,32 @@ bool GpsHyperionLinuxController::readGpsDataFromGpsd() { if (mode == MODE_OFF) { return false; } + unsigned int readIdx = 0; if (readMode == ReadModes::SOCKET) { // Poll the GPS. - if (gps_waiting(&gps, 0)) { + while (gps_waiting(&gps, 0)) { int retval = gps_read(&gps); if (retval < 0) { readError(); return false; - } else if (retval == 0) { - oneShotSwitches.gpsReadFailedSwitch = true; - ReturnValue_t result = handleGpsReadData(); - if (result != returnvalue::OK) { - return false; - } } - } else { - return false; + readIdx++; + if (readIdx >= 40) { + sif::warning << "GpsHyperionLinuxController: Received " << readIdx + << " GPSD message consecutively" << std::endl; + break; + } + } + if (readIdx > 0) { + oneShotSwitches.gpsReadFailedSwitch = true; + handleGpsReadData(); } } else if (readMode == ReadModes::SHM) { sif::error << "GpsHyperionLinuxController::readGpsDataFromGpsdPermanentLoop: " "SHM read not implemented" << std::endl; } - return true; + return false; } ReturnValue_t GpsHyperionLinuxController::handleGpsReadData() {