gpsd-users
[Top][All Lists]
Advanced

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

[gpsd-users] Gps application stops transmitting data after some time


From: lokesh kumar Nijalinge
Subject: [gpsd-users] Gps application stops transmitting data after some time
Date: Tue, 15 Sep 2015 17:33:59 +0530

Hi All,

I am trying to write the gps application code using gpsd library. The below code i got after searching internet. This works fine, but after some time the data stops coming.
Can anyone let me know if something is missed in this part of code.
Below is the code


if ((rc = gps_open("localhost", "2947", &gpsdata)) == -1) {
    printf("code: %d, reason: %s\n", rc, gps_errstr(rc));
    return EXIT_FAILURE;
}
gps_stream(&gpsdata, WATCH_ENABLE | WATCH_JSON, NULL);

while (1) {
    /* wait for 2 seconds to receive data */
    if (gps_waiting (&gpsdata, 2000)) {
        /* read data */
        if ((rc = gps_read(&gpsdata)) == -1) {
            printf("error occured reading gps data. code: %d, reason: %s\n", rc, gps_errstr(rc));
        } else {
            /* Display data from the GPS receiver. */
            if ((gpsdata.fix.mode >= MODE_2D) && !isnan(gpsdata.fix.latitude) && !isnan(gpsdata.fix.longitude)) {
                if(!isnan(gpsdata.fix.time))
                        (void)unix_to_iso8601(gpsdata.
fix.time, scr, sizeof(scr));
                    printf("latitude: %f, longitude: %f, speed: %.1f %s, timestamp: %s altitude: %f climb %.1f %s/min \n", gpsdata.fix.latitude, gpsdata.fix.longitude, gpsdata.fix.speed * speedfactor, speedunits, scr, gpsdata.fix.altitude, gpsdata.fix.climb * altfactor * 60, altunits);
            } else {
                printf("no GPS data available\n");
            }
        }
        printf(" Wait ");
    }
    sleep(1);
        printf("status %d \n",gpsdata.status);
}


Thanks,
Lokesh

reply via email to

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