typos and other minor adaptions
This commit is contained in:
parent
07ca738842
commit
d6aa6875cc
@ -199,19 +199,17 @@ ReturnValue_t GpsHyperionLinuxController::handleGpsReadData() {
|
||||
}
|
||||
|
||||
bool validFix = false;
|
||||
static_cast<void>(validFix);
|
||||
// 0: Not seen, 1: No fix, 2: 2D-Fix, 3: 3D-Fix
|
||||
int newFixMode = gps.fix.mode;
|
||||
if (newFixMode == 2 or newFixMode == 3) {
|
||||
if (gps.fix.mode == 2 or gps.fix.mode == 3) {
|
||||
validFix = true;
|
||||
}
|
||||
if (gpsSet.fixMode.value != newFixMode) {
|
||||
triggerEvent(GpsHyperion::GPS_FIX_CHANGE, gpsSet.fixMode.value, newFixMode);
|
||||
if (gpsSet.fixMode.value != gps.fix.mode) {
|
||||
triggerEvent(GpsHyperion::GPS_FIX_CHANGE, gpsSet.fixMode.value, gps.fix.mode);
|
||||
}
|
||||
gpsSet.fixMode.value = newFixMode;
|
||||
gpsSet.fixMode.value = gps.fix.mode;
|
||||
if (gps.fix.mode == 0 or gps.fix.mode == 1) {
|
||||
if (modeCommanded and maxTimeToReachFix.hasTimedOut()) {
|
||||
// We are supposed to be on and functioning, but not fix was found
|
||||
// We are supposed to be on and functioning, but no fix was found
|
||||
if (mode == MODE_ON or mode == MODE_NORMAL) {
|
||||
mode = MODE_OFF;
|
||||
}
|
||||
@ -229,7 +227,7 @@ ReturnValue_t GpsHyperionLinuxController::handleGpsReadData() {
|
||||
if (std::isfinite(gps.fix.latitude)) {
|
||||
// Negative latitude -> South direction
|
||||
gpsSet.latitude.value = gps.fix.latitude;
|
||||
if(gps.fix.mode >= 2) {
|
||||
if (gps.fix.mode >= 2) {
|
||||
latValid = true;
|
||||
}
|
||||
}
|
||||
@ -239,7 +237,7 @@ ReturnValue_t GpsHyperionLinuxController::handleGpsReadData() {
|
||||
if (std::isfinite(gps.fix.longitude)) {
|
||||
// Negative longitude -> West direction
|
||||
gpsSet.longitude.value = gps.fix.longitude;
|
||||
if(gps.fix.mode >= 2) {
|
||||
if (gps.fix.mode >= 2) {
|
||||
longValid = true;
|
||||
}
|
||||
}
|
||||
@ -248,7 +246,7 @@ ReturnValue_t GpsHyperionLinuxController::handleGpsReadData() {
|
||||
bool altitudeValid = false;
|
||||
if (std::isfinite(gps.fix.altitude)) {
|
||||
gpsSet.altitude.value = gps.fix.altitude;
|
||||
if(gps.fix.mode == 3) {
|
||||
if (gps.fix.mode == 3) {
|
||||
altitudeValid = true;
|
||||
}
|
||||
}
|
||||
@ -260,29 +258,40 @@ ReturnValue_t GpsHyperionLinuxController::handleGpsReadData() {
|
||||
gpsSet.speed.setValid(false);
|
||||
}
|
||||
|
||||
timeval time = {};
|
||||
if (TIME_SET != (TIME_SET & gps.set)) {
|
||||
timeval time = {};
|
||||
#if LIBGPS_VERSION_MINOR <= 17
|
||||
gpsSet.unixSeconds.value = std::floor(gps.fix.time);
|
||||
double fractionalPart = gps.fix.time - gpsSet.unixSeconds.value;
|
||||
time.tv_usec = fractionalPart * 1000.0 * 1000.0;
|
||||
gpsSet.unixSeconds.value = std::floor(gps.fix.time);
|
||||
double fractionalPart = gps.fix.time - gpsSet.unixSeconds.value;
|
||||
time.tv_usec = fractionalPart * 1000.0 * 1000.0;
|
||||
#else
|
||||
gpsSet.unixSeconds.value = gps.fix.time.tv_sec;
|
||||
time.tv_usec = gps.fix.time.tv_nsec / 1000;
|
||||
gpsSet.unixSeconds.value = gps.fix.time.tv_sec;
|
||||
time.tv_usec = gps.fix.time.tv_nsec / 1000;
|
||||
#endif
|
||||
time.tv_sec = gpsSet.unixSeconds.value;
|
||||
// If the time is totally wrong (e.g. year 2000 after system reset because we do not have a RTC
|
||||
// and no time file available) we set it with the roughly valid time from the GPS.
|
||||
// NTP might only work if the time difference between sys time and current time is not too large.
|
||||
overwriteTimeIfNotSane(time, validFix);
|
||||
time.tv_sec = gpsSet.unixSeconds.value;
|
||||
// If the time is totally wrong (e.g. year 2000 after system reset because we do not have a RTC
|
||||
// and no time file available) we set it with the roughly valid time from the GPS.
|
||||
// NTP might only work if the time difference between sys time and current time is not too
|
||||
// large.
|
||||
overwriteTimeIfNotSane(time, validFix);
|
||||
Clock::TimeOfDay_t timeOfDay = {};
|
||||
Clock::convertTimevalToTimeOfDay(&time, &timeOfDay);
|
||||
gpsSet.year = timeOfDay.year;
|
||||
gpsSet.month = timeOfDay.month;
|
||||
gpsSet.day = timeOfDay.day;
|
||||
gpsSet.hours = timeOfDay.hour;
|
||||
gpsSet.minutes = timeOfDay.minute;
|
||||
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);
|
||||
}
|
||||
|
||||
Clock::TimeOfDay_t timeOfDay = {};
|
||||
Clock::convertTimevalToTimeOfDay(&time, &timeOfDay);
|
||||
gpsSet.year = timeOfDay.year;
|
||||
gpsSet.month = timeOfDay.month;
|
||||
gpsSet.day = timeOfDay.day;
|
||||
gpsSet.hours = timeOfDay.hour;
|
||||
gpsSet.minutes = timeOfDay.minute;
|
||||
gpsSet.seconds = timeOfDay.second;
|
||||
if (debugHyperionGps) {
|
||||
sif::info << "-- Hyperion GPS Data --" << std::endl;
|
||||
#if LIBGPS_VERSION_MINOR <= 17
|
||||
|
Loading…
Reference in New Issue
Block a user