gpsd-users
[Top][All Lists]
Advanced

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

Re: gpsd Example2.py


From: Gary E. Miller
Subject: Re: gpsd Example2.py
Date: Tue, 20 Sep 2022 20:51:24 -0700

Yo Dirk!

On Tue, 20 Sep 2022 12:46:23 +0000
Dirk Beer <rdbeer@pm.me> wrote:

> I'm learning how to use gpsd in python, and I'm wondering about
> discrepancies in the examples I see.

Not discrepancies, just more than one way to do things.

> Can you point me in the right direction?

You are already there: the gpsd doc and examples.

> Specifically, Example2.py shows something like:
> 
> session = gps.gps(mode=gps.WATCH_ENABLE)
> while 0 == session.read():
> print(session.fix.xxx)

Not for a while.  Check out the current example2.py:

https://gpsd.io/gpsd-client-example-code.html#_example_2python

> But https://gpsd.io/libgps.html shows:
> 
> session = gps.gps(host="localhost", port="2947")
> session.stream(flags=gps.WATCH_JSON)
> for report in session:
> process(report)
> del session

That works too, except for the missing check that the proper message
got read.

> For me, Example2.py doesn't work, it shows repeated identical lat,
> longs (but I suppose this could be a problem on my end).

Try the latest example2.py, that should work.  If it does not
then send a capture of your raw data:  gpspipe -R -w 30 > raw.log

> I'm wondering, which approach is the right way to do things?

Both work, except the later is missing the class check.

> (I'm using 3.24, gpsd started with sudo /usr/local/sbin/gpsd
> /dev/ttyACM0 -F /var/run/gpsd.sock on a raspberry pi zero with
> Bullseye)

gpsd is meant to be run as root, not under sudo:

sudo is evil:

https://gpsd.io/ubxtool-examples.html#_sudo_sudont

Why are you supplying both a device and a socket?

Why are you not using the -n option?

RGDS
GARY
---------------------------------------------------------------------------
Gary E. Miller Rellim 109 NW Wilmington Ave., Suite E, Bend, OR 97703
        gem@rellim.com  Tel:+1 541 382 8588

            Veritas liberabit vos. -- Quid est veritas?
    "If you can't measure it, you can't improve it." - Lord Kelvin

Attachment: pgpAAu85785OK.pgp
Description: OpenPGP digital signature


reply via email to

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