Marble does not use GPS through gpsd.
https://bugs.kde.org/show_bug.cgi?id=451656
STEPS TO REPRODUCE
- Connect u-blox7 GPS connector ( https://www.robotshop.com/en/dfrobot-usb-gps-receiver-compatible-w-raspberry-pilattepandajetson-nano.html ). Open
cgps
to check it works fine. - Open Marble.
- Select
gpsd
inLocation
>Position Tracking
.
OBSERVED RESULT
Although the cpgs
program shows I have a 2D or 3D FIX and gives me my exact location and GPS-coordinates, Marble keeps on "waiting for current location information...".
EXPECTED RESULT
Marble uses my GPS USB Dongle and detects my position just like the cgps
CLI tool.
SOFTWARE/OS VERSIONS
Linux/KDE Plasma: Fedora 35 KDE (fully updated through the dnf
package manager at 18 March 2022)
KDE Plasma Version: 5.24.3
KDE Frameworks Version: 5.91.0
Qt Version: 5.12.2
ADDITIONAL INFORMATION
Marble is started after cgps
reported a 2D or 3D FIX.
I have created a test file to play with:
// https://gpsd.io/client-howto.html
// https://gpsd.gitlab.io/gpsd/libgps.html
// $ clang++ -lgps -lQt5Core -std=c++20 -Wall -pedantic -g main.cpp && ./a.out
#include <QtCore/QTime>
#include <libgpsmm.h>
#include <iomanip>
#include <iostream>
// Based on https://gpsd.io/client-howto.html#_c_examples_2
void libgpsmm(gpsmm& gps_rec)
{
for (;;)
{
if (!gps_rec.waiting(1000000)) // 1000000 is 1 second
{
continue;
}
struct gps_data_t* gpsd_data;
if ((gpsd_data = gps_rec.read()) == nullptr)
{
std::cerr << "GPSD read error." << std::endl;
}
else
{
const auto latitude{gpsd_data->fix.latitude};
const auto longitude{gpsd_data->fix.longitude};
const auto s_vis{gpsd_data->satellites_visible};
const auto s_used{gpsd_data->satellites_used};
const auto mode{gpsd_data->fix.mode};
std::cout << std::setprecision(8) << std::fixed;
std::cout << "Lat: " << latitude << ", long: " << longitude << ", visible sats: " << s_vis
<< ", used sats: " << s_used << ", mode: " << mode << std::endl;
}
}
}
// Based on Marble source code
void marble(gpsmm& gps_rec)
{
const int gpsWaitTimeout = 200; // ms
QTime watchdog;
watchdog.start();
while (gps_rec.waiting(0) && watchdog.elapsed() < gpsWaitTimeout)
{
gps_data_t* gpsd_data = gps_rec.read();
if (gpsd_data)
{
const auto latitude{gpsd_data->fix.latitude};
const auto longitude{gpsd_data->fix.longitude};
const auto s_vis{gpsd_data->satellites_visible};
const auto s_used{gpsd_data->satellites_used};
const auto mode{gpsd_data->fix.mode};
std::cout << std::setprecision(8) << std::fixed;
std::cout << "Lat: " << latitude << ", long: " << longitude << ", visible sats: " << s_vis
<< ", used sats: " << s_used << ", mode: " << mode << std::endl;
}
else
{
std::cerr << "GPSD read error." << std::endl;
}
}
}
int main()
{
std::cout << "Version " << GPSD_API_MAJOR_VERSION << " - " << GPSD_API_MINOR_VERSION << std::endl;
gpsmm gps_rec("localhost", DEFAULT_GPSD_PORT);
if (gps_rec.stream(WATCH_ENABLE | WATCH_JSON) == nullptr)
{
std::cerr << "No GPSD running." << std::endl;
return 1;
}
// Choose 1:
//
// marble(gps_rec);
// libgpsmm(gps_rec);
return 0;
}
When executing with a 2D FIX I get the following results:
- When uncommenting
marble(gps_rec)
only:
$ clang++ -lgps -lQt5Core -std=c++20 -Wall -pedantic -g main.cpp && ./a.out
Version 12 - 0
Lat: nan, long: nan, visible sats: 0, used sats: 0, mode: 0
Lat: nan, long: nan, visible sats: 0, used sats: 0, mode: 0
Lat: nan, long: nan, visible sats: 0, used sats: 0, mode: 0
$
- When uncommenting
libgpsmm(gps_rec)
only:
$ clang++ -lgps -lQt5Core -std=c++20 -Wall -pedantic -g main.cpp && ./a.out
Version 12 - 0
Lat: nan, long: nan, visible sats: 0, used sats: 0, mode: 0
Lat: nan, long: nan, visible sats: 0, used sats: 0, mode: 0
Lat: nan, long: nan, visible sats: 0, used sats: 0, mode: 0
Lat: 50.12345678, long: 5.12345678, visible sats: 0, used sats: 0, mode: 2
Lat: 50.12345678, long: 5.12345678, visible sats: 10, used sats: 3, mode: 2
Lat: 50.12345678, long: 5.12345678, visible sats: 10, used sats: 3, mode: 2
Lat: 50.12345678, long: 5.12345678, visible sats: 10, used sats: 3, mode: 2
Lat: 50.12345678, long: 5.12345678, visible sats: 10, used sats: 3, mode: 2
Lat: 50.12345678, long: 5.12345678, visible sats: 10, used sats: 3, mode: 2
Lat: 50.12345678, long: 5.12345678, visible sats: 10, used sats: 3, mode: 2
Lat: 50.12345678, long: 5.12345678, visible sats: 10, used sats: 3, mode: 2
Lat: 50.12345678, long: 5.12345678, visible sats: 10, used sats: 3, mode: 2
Lat: 50.12345678, long: 5.12345678, visible sats: 10, used sats: 3, mode: 2
^C
$
Edited by MartenBE MBE