gpsd-dev
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[gpsd-dev] Problems with C++ gpsd client


From: ldimauro
Subject: [gpsd-dev] Problems with C++ gpsd client
Date: Fri, 19 Jan 2018 08:13:34 +0000
User-agent: Internet Messaging Program (IMP) H5 (6.1.7)

Hello,
I have a gps transceiver and I'm trying to read its coordinates with this C++ program using "libgpsmm" library:

#include <iostream>
#include <libgpsmm.h>
#include <cmath>

using namespace std;

int main(void)
{
    gpsmm gpsClient("localhost", DEFAULT_GPSD_PORT);

    if (gpsClient.stream(WATCH_ENABLE|WATCH_JSON) == NULL) {
        cerr << "No GPSD running.\n";
        return 1;
    }

    for (;;) {
        struct gps_data_t* data;

        if (!gpsClient.waiting(50000000))
          continue;

        if ((data = gpsClient.read()) == NULL) {
            cerr << "Read error.\n";
        }
        else {
if ((data->status == STATUS_FIX) && (data->fix.mode == MODE_2D || data->fix.mode == MODE_3D)) cout << "latitude: " << data->fix.latitude << ", longitude: " << data->fix.latitude << ", speed: " << data->fix.speed << ", timestamp: " << data->fix.time;
            else
                printf("no GPS data available\n");
        }
    }

    return 0;
}

Unfortunately it doesn't work (it prints "no data GPS available", despite the program "gpsmon" receives coordinates correctly and reading directly from serial port gives the NMEA sentences.

How can I fix this problem? I'm using debian 8 OS and the user belong to group "tty".

Thanks to all!
Luca




reply via email to

[Prev in Thread] Current Thread [Next in Thread]