support both gps versions
Some checks failed
EIVE/eive-obsw/pipeline/pr-develop There was a failure building this commit

This commit is contained in:
2022-04-19 17:47:05 +02:00
parent d12b5958b9
commit 4956161701
4 changed files with 34 additions and 4 deletions

View File

@ -191,11 +191,19 @@ void GPSHyperionLinuxController::readGpsDataFromGpsd() {
gpsSet.speed.setValid(false);
}
#if LIBGPS_VERSION_MINOR <= 17
gpsSet.unixSeconds.value = gps->fix.time;
#else
gpsSet.unixSeconds.value = gps->fix.time.tv_sec;
#endif
timeval time = {};
time.tv_sec = gpsSet.unixSeconds.value;
double fractionalPart = gpsSet.unixSeconds.value - gps->fix.time;
time.tv_usec = fractionalPart * 1000 * 1000;
#if LIBGPS_VERSION_MINOR <= 17
double fractionalPart = gps->fix.time - std::floor(gps->fix.time);
time.tv_usec = fractionalPart * 1000.0 * 1000.0;
#else
time.tv_usec = gps->fix.time.tv_nsec / 1000;
#endif
//time.tv_usec = gps->fix.time.tv_nsec / 1000;
std::time_t t = std::time(nullptr);
if (time.tv_sec == t) {
@ -235,7 +243,11 @@ void GPSHyperionLinuxController::readGpsDataFromGpsd() {
gpsSet.seconds = timeOfDay.second;
if (debugHyperionGps) {
sif::info << "-- Hyperion GPS Data --" << std::endl;
#if LIBGPS_VERSION_MINOR <= 17
time_t timeRaw = gps->fix.time;
#else
time_t timeRaw = gps->fix.time.tv_sec;
#endif
std::tm *time = gmtime(&timeRaw);
std::cout << "Time: " << std::put_time(time, "%c %Z") << std::endl;
std::cout << "Visible satellites: " << gps->satellites_visible << std::endl;
@ -243,7 +255,11 @@ void GPSHyperionLinuxController::readGpsDataFromGpsd() {
std::cout << "Fix (0:Not Seen|1:No Fix|2:2D|3:3D): " << gps->fix.mode << std::endl;
std::cout << "Latitude: " << gps->fix.latitude << std::endl;
std::cout << "Longitude: " << gps->fix.longitude << std::endl;
#if LIBGPS_VERSION_MINOR <= 17
std::cout << "Altitude(MSL): " << gps->fix.altitude << std::endl;
#else
std::cout << "Altitude(MSL): " << gps->fix.altMSL << std::endl;
#endif
std::cout << "Speed(m/s): " << gps->fix.speed << std::endl;
std::time_t t = std::time(nullptr);
std::tm tm = *std::gmtime(&t);

View File

@ -192,6 +192,9 @@ debugging. */
/*******************************************************************/
#cmakedefine EIVE_BUILD_GPSD_GPS_HANDLER
#cmakedefine LIBGPS_VERSION_MAJOR @LIBGPS_VERSION_MAJOR@
#cmakedefine LIBGPS_VERSION_MINOR @LIBGPS_VERSION_MINOR@
#ifdef RASPBERRY_PI
#include "rpiConfig.h"
#elif defined(XIPHOS_Q7S)