|
|
@ -172,20 +172,10 @@ bool GpsHyperionLinuxController::readGpsDataFromGpsd() {
|
|
|
|
return false;
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
oneShotSwitches.gpsReadFailedSwitch = true;
|
|
|
|
oneShotSwitches.gpsReadFailedSwitch = true;
|
|
|
|
// did not event get mode, nothing to see.
|
|
|
|
ReturnValue_t result = handleGpsReadData();
|
|
|
|
if (MODE_SET != (MODE_SET & gps.set)) {
|
|
|
|
if (result == returnvalue::OK) {
|
|
|
|
if (mode != MODE_OFF) {
|
|
|
|
|
|
|
|
if (maxTimeToReachFix.hasTimedOut() and oneShotSwitches.cantGetFixSwitch) {
|
|
|
|
|
|
|
|
sif::warning
|
|
|
|
|
|
|
|
<< "GPSHyperionHandler::readGpsDataFromGpsd: No mode could be set in allowed "
|
|
|
|
|
|
|
|
<< maxTimeToReachFix.timeout / 1000 << " seconds" << std::endl;
|
|
|
|
|
|
|
|
triggerEvent(GpsHyperion::CANT_GET_FIX, maxTimeToReachFix.timeout);
|
|
|
|
|
|
|
|
oneShotSwitches.cantGetFixSwitch = false;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
// Mode is on, so do next read immediately
|
|
|
|
|
|
|
|
return true;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
// GPS device is off anyway, so do other handling
|
|
|
|
|
|
|
|
return false;
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
noModeSetCntr = 0;
|
|
|
|
noModeSetCntr = 0;
|
|
|
@ -197,11 +187,26 @@ bool GpsHyperionLinuxController::readGpsDataFromGpsd() {
|
|
|
|
"SHM read not implemented"
|
|
|
|
"SHM read not implemented"
|
|
|
|
<< std::endl;
|
|
|
|
<< std::endl;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
handleGpsReadData();
|
|
|
|
|
|
|
|
return true;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
ReturnValue_t GpsHyperionLinuxController::handleGpsReadData() {
|
|
|
|
ReturnValue_t GpsHyperionLinuxController::handleGpsReadData() {
|
|
|
|
|
|
|
|
bool modeIsSet = true;
|
|
|
|
|
|
|
|
if (MODE_SET != (MODE_SET & gps.set)) {
|
|
|
|
|
|
|
|
if (mode != MODE_OFF) {
|
|
|
|
|
|
|
|
if (maxTimeToReachFix.hasTimedOut() and oneShotSwitches.cantGetFixSwitch) {
|
|
|
|
|
|
|
|
sif::warning << "GpsHyperionLinuxController: No mode could be set in allowed "
|
|
|
|
|
|
|
|
<< maxTimeToReachFix.timeout / 1000 << " seconds" << std::endl;
|
|
|
|
|
|
|
|
triggerEvent(GpsHyperion::CANT_GET_FIX, maxTimeToReachFix.timeout);
|
|
|
|
|
|
|
|
oneShotSwitches.cantGetFixSwitch = false;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
modeIsSet = false;
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
// GPS device is off anyway, so do other handling
|
|
|
|
|
|
|
|
return returnvalue::FAILED;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
PoolReadGuard pg(&gpsSet);
|
|
|
|
PoolReadGuard pg(&gpsSet);
|
|
|
|
if (pg.getReadResult() != returnvalue::OK) {
|
|
|
|
if (pg.getReadResult() != returnvalue::OK) {
|
|
|
|
#if FSFW_VERBOSE_LEVEL >= 1
|
|
|
|
#if FSFW_VERBOSE_LEVEL >= 1
|
|
|
@ -211,6 +216,7 @@ ReturnValue_t GpsHyperionLinuxController::handleGpsReadData() {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bool validFix = false;
|
|
|
|
bool validFix = false;
|
|
|
|
|
|
|
|
if (modeIsSet) {
|
|
|
|
// 0: Not seen, 1: No fix, 2: 2D-Fix, 3: 3D-Fix
|
|
|
|
// 0: Not seen, 1: No fix, 2: 2D-Fix, 3: 3D-Fix
|
|
|
|
if (gps.fix.mode == 2 or gps.fix.mode == 3) {
|
|
|
|
if (gps.fix.mode == 2 or gps.fix.mode == 3) {
|
|
|
|
validFix = true;
|
|
|
|
validFix = true;
|
|
|
@ -227,50 +233,76 @@ ReturnValue_t GpsHyperionLinuxController::handleGpsReadData() {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
modeCommanded = false;
|
|
|
|
modeCommanded = false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
gpsSet.setValidity(false, true);
|
|
|
|
|
|
|
|
} else if (gps.satellites_used > 0 && validFix && mode != MODE_OFF) {
|
|
|
|
|
|
|
|
gpsSet.setValidity(true, true);
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
gpsSet.fixMode.setValid(modeIsSet);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Only set on specific messages, so only set a valid flag to invalid
|
|
|
|
|
|
|
|
// if not set for more than a full message set (10 messages here)
|
|
|
|
|
|
|
|
if (SATELLITE_SET == (SATELLITE_SET & gps.set)) {
|
|
|
|
gpsSet.satInUse.value = gps.satellites_used;
|
|
|
|
gpsSet.satInUse.value = gps.satellites_used;
|
|
|
|
gpsSet.satInView.value = gps.satellites_visible;
|
|
|
|
gpsSet.satInView.value = gps.satellites_visible;
|
|
|
|
|
|
|
|
if (not gpsSet.satInUse.isValid()) {
|
|
|
|
|
|
|
|
gpsSet.satInUse.setValid(true);
|
|
|
|
|
|
|
|
gpsSet.satInView.setValid(true);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
satNotSetCounter = 0;
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
satNotSetCounter++;
|
|
|
|
|
|
|
|
if (gpsSet.satInUse.isValid() and satNotSetCounter >= 10) {
|
|
|
|
|
|
|
|
gpsSet.satInUse.setValid(false);
|
|
|
|
|
|
|
|
gpsSet.satInView.setValid(false);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// LATLON is set for every message, no need for a counter
|
|
|
|
bool latValid = false;
|
|
|
|
bool latValid = false;
|
|
|
|
|
|
|
|
bool longValid = false;
|
|
|
|
|
|
|
|
if (LATLON_SET == (LATLON_SET & gps.set)) {
|
|
|
|
if (std::isfinite(gps.fix.latitude)) {
|
|
|
|
if (std::isfinite(gps.fix.latitude)) {
|
|
|
|
// Negative latitude -> South direction
|
|
|
|
// Negative latitude -> South direction
|
|
|
|
gpsSet.latitude.value = gps.fix.latitude;
|
|
|
|
gpsSet.latitude.value = gps.fix.latitude;
|
|
|
|
|
|
|
|
// As specified in gps.h: Only valid if mode >= 2
|
|
|
|
if (gps.fix.mode >= 2) {
|
|
|
|
if (gps.fix.mode >= 2) {
|
|
|
|
latValid = true;
|
|
|
|
latValid = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
gpsSet.latitude.setValid(latValid);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
bool longValid = false;
|
|
|
|
|
|
|
|
if (std::isfinite(gps.fix.longitude)) {
|
|
|
|
if (std::isfinite(gps.fix.longitude)) {
|
|
|
|
// Negative longitude -> West direction
|
|
|
|
// Negative longitude -> West direction
|
|
|
|
gpsSet.longitude.value = gps.fix.longitude;
|
|
|
|
gpsSet.longitude.value = gps.fix.longitude;
|
|
|
|
|
|
|
|
// As specified in gps.h: Only valid if mode >= 2
|
|
|
|
if (gps.fix.mode >= 2) {
|
|
|
|
if (gps.fix.mode >= 2) {
|
|
|
|
longValid = true;
|
|
|
|
longValid = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
gpsSet.latitude.setValid(longValid);
|
|
|
|
}
|
|
|
|
|
|
|
|
gpsSet.latitude.setValid(latValid);
|
|
|
|
|
|
|
|
gpsSet.longitude.setValid(longValid);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// ALTITUDE is set for every message, no need for a counter
|
|
|
|
bool altitudeValid = false;
|
|
|
|
bool altitudeValid = false;
|
|
|
|
if (std::isfinite(gps.fix.altitude)) {
|
|
|
|
if (ALTITUDE_SET == (ALTITUDE_SET & gps.set) && std::isfinite(gps.fix.altitude)) {
|
|
|
|
gpsSet.altitude.value = gps.fix.altitude;
|
|
|
|
gpsSet.altitude.value = gps.fix.altitude;
|
|
|
|
|
|
|
|
// As specified in gps.h: Only valid if mode == 3
|
|
|
|
if (gps.fix.mode == 3) {
|
|
|
|
if (gps.fix.mode == 3) {
|
|
|
|
altitudeValid = true;
|
|
|
|
altitudeValid = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
gpsSet.altitude.setValid(altitudeValid);
|
|
|
|
gpsSet.altitude.setValid(altitudeValid);
|
|
|
|
|
|
|
|
|
|
|
|
if (std::isfinite(gps.fix.speed)) {
|
|
|
|
// SPEED is set for every message, no need for a counter
|
|
|
|
|
|
|
|
bool speedValid = false;
|
|
|
|
|
|
|
|
if (SPEED_SET == (SPEED_SET & gps.set) && std::isfinite(gps.fix.speed)) {
|
|
|
|
gpsSet.speed.value = gps.fix.speed;
|
|
|
|
gpsSet.speed.value = gps.fix.speed;
|
|
|
|
} else {
|
|
|
|
speedValid = true;
|
|
|
|
gpsSet.speed.setValid(false);
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
gpsSet.speed.setValid(speedValid);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// TIME is set for every message, no need for a counter
|
|
|
|
|
|
|
|
bool timeValid = false;
|
|
|
|
if (TIME_SET == (TIME_SET & gps.set)) {
|
|
|
|
if (TIME_SET == (TIME_SET & gps.set)) {
|
|
|
|
|
|
|
|
timeValid = true;
|
|
|
|
timeval time = {};
|
|
|
|
timeval time = {};
|
|
|
|
#if LIBGPS_VERSION_MINOR <= 17
|
|
|
|
#if LIBGPS_VERSION_MINOR <= 17
|
|
|
|
gpsSet.unixSeconds.value = std::floor(gps.fix.time);
|
|
|
|
gpsSet.unixSeconds.value = std::floor(gps.fix.time);
|
|
|
@ -294,15 +326,14 @@ ReturnValue_t GpsHyperionLinuxController::handleGpsReadData() {
|
|
|
|
gpsSet.hours = timeOfDay.hour;
|
|
|
|
gpsSet.hours = timeOfDay.hour;
|
|
|
|
gpsSet.minutes = timeOfDay.minute;
|
|
|
|
gpsSet.minutes = timeOfDay.minute;
|
|
|
|
gpsSet.seconds = timeOfDay.second;
|
|
|
|
gpsSet.seconds = timeOfDay.second;
|
|
|
|
} else {
|
|
|
|
|
|
|
|
gpsSet.unixSeconds.setValid(false);
|
|
|
|
|
|
|
|
gpsSet.year.setValid(false);
|
|
|
|
|
|
|
|
gpsSet.month.setValid(false);
|
|
|
|
|
|
|
|
gpsSet.day.setValid(false);
|
|
|
|
|
|
|
|
gpsSet.hours.setValid(false);
|
|
|
|
|
|
|
|
gpsSet.minutes.setValid(false);
|
|
|
|
|
|
|
|
gpsSet.seconds.setValid(false);
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
gpsSet.unixSeconds.setValid(timeValid);
|
|
|
|
|
|
|
|
gpsSet.year.setValid(timeValid);
|
|
|
|
|
|
|
|
gpsSet.month.setValid(timeValid);
|
|
|
|
|
|
|
|
gpsSet.day.setValid(timeValid);
|
|
|
|
|
|
|
|
gpsSet.hours.setValid(timeValid);
|
|
|
|
|
|
|
|
gpsSet.minutes.setValid(timeValid);
|
|
|
|
|
|
|
|
gpsSet.seconds.setValid(timeValid);
|
|
|
|
|
|
|
|
|
|
|
|
if (debugHyperionGps) {
|
|
|
|
if (debugHyperionGps) {
|
|
|
|
sif::info << "-- Hyperion GPS Data --" << std::endl;
|
|
|
|
sif::info << "-- Hyperion GPS Data --" << std::endl;
|
|
|
|