this works now
All checks were successful
EIVE/eive-obsw/pipeline/pr-develop This commit looks good

This commit is contained in:
Robin Müller 2023-02-06 18:12:41 +01:00
parent 5e8eb7151b
commit 9d7291eea2
No known key found for this signature in database
GPG Key ID: 11D4952C8CCEF814

View File

@ -1,5 +1,6 @@
#include "GpsHyperionLinuxController.h"
#include <fsfw/tasks/TaskFactory.h>
#include <fsfw/timemanager/Stopwatch.h>
#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)) {