gpsd-users
[Top][All Lists]
Advanced

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

Re: [gpsd-users] Getting fixes without polling


From: Lisandro Damián Nicanor Pérez Meyer
Subject: Re: [gpsd-users] Getting fixes without polling
Date: Thu, 02 Feb 2017 14:34:56 -0300
User-agent: KMail/5.2.3 (Linux/4.9.0-1-amd64; KDE/5.28.0; x86_64; ; )

On miércoles, 1 de febrero de 2017 10:23:17 ART Gary E. Miller wrote:
> Yo Lisandro!

Yo Gary!

> On Wed, 01 Feb 2017 10:57:31 -0300
[snip]
> > > Lisandro Damián Nicanor Pérez Meyer <address@hidden> wrote:
> > > > Is there any way to get fixes without the need to poll? I guess
> > > > dbus might help here, but...
> > > 
> > > Open the gpsd port, 2947, and tell it to stream JSON at you.
> > 
> > I think that's what I'm doing:
> > 
> > result = gps_open("localhost", 37455, &mGPSData);
> > [check result...]
> > result = gps_stream(&mGPSData,WATCH_ENABLE|WATCH_JSON, NULL);
> > [check result...]
> 
> No, you are using libgps, a big layer of complexity.  I'm saying just
> use fopen() and then wait on a select().

Ah, you mean handling the connection myself. If I'm right I have to somehow 
send the right JSON to gpsd and then get the data and use gps_unpack to parse 
it into the struct gps_data_t, right?

If I'm right: is there an API to create the right JSON to correctly connect to 
gpsd? Or I need to manually craft it?

> > But then I need a timer to poll using gps_read(). Is there a way to
> > have a callback in order to avoid the timer?
> 
> Have you looked at gps_waiting() or gps_stream().  Have you read the example
> on the libgps man page?

Yes, yes and yes (doesn't means I fully grasped it ;) ), and to be sure this 
is the example code:

    struct gps_data_t gps_data;

    ret = gps_open(hostName, hostPort, &gps_data);

    (void) gps_stream(&gps_data, WATCH_ENABLE | WATCH_JSON, NULL);

    /* Put this in a loop with a call to a high resolution sleep () in it. */
    if (gps_waiting (&gps_data, 500)) {
        errno = 0;
        if (gps_read (&gps_data) == -1) {
            ...
        } else {
            /* Display data from the GPS receiver. */
            if (gps_data.set & ...
        }
    }

And this is what I'm currently doing: asking gpsd each 80 millisenconds to to 
the gps_waiting code block.

I'll try to look at libgps code to see what I can get from there.

Thanks!

-- 
3: Que ocurre en el escritorio de Windows cuando se abre una ventana
    * Se cierra una puerta
    Damian Nadales
    http://mx.grulic.org.ar/lurker/message/20080307.141449.a70fb2fc.es.html

Lisandro Damián Nicanor Pérez Meyer
http://perezmeyer.com.ar/
http://perezmeyer.blogspot.com/

Attachment: signature.asc
Description: This is a digitally signed message part.


reply via email to

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