switch gps ctrl to socket API
All checks were successful
EIVE/eive-obsw/pipeline/pr-develop This commit looks good
EIVE/eive-obsw/pipeline/head This commit looks good

This commit is contained in:
Robin Müller 2022-04-28 10:50:39 +02:00
parent 584700a2ba
commit 234a6b7ac3
No known key found for this signature in database
GPG Key ID: 71B58F8A3CDFA9AC
2 changed files with 37 additions and 9 deletions

View File

@ -1,5 +1,7 @@
#include "GPSHyperionLinuxController.h"
#include <fsfw/timemanager/Stopwatch.h>
#include "OBSWConfig.h"
#include "fsfw/FSFW.h"
#include "fsfw/datapool/PoolReadGuard.h"
@ -106,10 +108,10 @@ ReturnValue_t GPSHyperionLinuxController::handleCommandMessage(CommandMessage *m
#ifdef FSFW_OSAL_LINUX
void GPSHyperionLinuxController::readGpsDataFromGpsd() {
gpsmm myGpsmm("localhost", DEFAULT_GPSD_PORT);
gpsmm gpsmm("localhost", DEFAULT_GPSD_PORT);
// The data from the device will generally be read all at once. Therefore, we
// can set all field here
if (not myGpsmm.is_open()) {
if (not gpsmm.is_open()) {
if (gpsNotOpenSwitch) {
// Opening failed
#if FSFW_VERBOSE_LEVEL >= 1
@ -121,16 +123,41 @@ void GPSHyperionLinuxController::readGpsDataFromGpsd() {
}
return;
}
// Stopwatch watch;
gps_data_t *gps = nullptr;
gps = myGpsmm.read();
gps = gpsmm.stream(WATCH_ENABLE | WATCH_JSON);
if (gps == nullptr) {
if (gpsReadFailedSwitch) {
gpsReadFailedSwitch = false;
sif::warning << "GPSHyperionHandler::readGpsDataFromGpsd: Reading GPS data failed"
<< std::endl;
}
return;
sif::warning << "GPSHyperionHandler::readGpsDataFromGpsd:: Setting GPSD watch "
"policy failed"
<< std::endl;
}
while (gpsmm.waiting(2000)) {
gps = gpsmm.read();
if (gps == nullptr) {
if (gpsReadFailedSwitch) {
gpsReadFailedSwitch = false;
sif::warning << "GPSHyperionHandler::readGpsDataFromGpsd: Reading GPS data failed"
<< std::endl;
}
return;
}
if (MODE_SET != (MODE_SET & gps->set)) {
if (noModeSetCntr >= 0) {
noModeSetCntr++;
}
if (noModeSetCntr == 10) {
// TODO: Trigger event here
sif::warning << "GPSHyperionHandler::readGpsDataFromGpsd: No mode could be "
"read for 10 consecutive reads"
<< std::endl;
noModeSetCntr = -1;
}
return;
} else {
noModeSetCntr = 0;
}
}
gps = gpsmm.stream(WATCH_DISABLE);
PoolReadGuard pg(&gpsSet);
if (pg.getReadResult() != HasReturnvaluesIF::RETURN_OK) {
#if FSFW_VERBOSE_LEVEL >= 1

View File

@ -55,6 +55,7 @@ class GPSHyperionLinuxController : public ExtendedControllerBase {
bool gpsNotOpenSwitch = true;
bool gpsReadFailedSwitch = true;
bool debugHyperionGps = false;
int32_t noModeSetCntr = 0;
uint32_t timeIsConstantCounter = 0;
Countdown timeUpdateCd = Countdown(60);