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: Wed, 21 Sep 2022 17:55:59 -0700

Yo Dirk!

On Wed, 21 Sep 2022 06:34:57 +0000
Dirk Beer <rdbeer@pm.me> wrote:

>     root@pheromone:~# python3 example2.py
>     Mode: 3D(3) Time: n/a Lat 32.729173 Lon -116.993810
>     Mode: 3D(3) Time: n/a Lat 32.729174 Lon -116.993811
>     Mode: 3D(3) Time: n/a Lat 32.729174 Lon -116.993811
>     Mode: 3D(3) Time: n/a Lat 32.729170 Lon -116.993812
>     Mode: 3D(3) Time: n/a Lat 32.729170 Lon -116.993812
>     Mode: 3D(3) Time: n/a Lat 32.729169 Lon -116.993813
>     Mode: 3D(3) Time: n/a Lat 32.729169 Lon -116.993813

FYI, here is what I get from a ZED-F9P:

dilbert ~ # python www/example2.py.txt
Mode: 3D(3) Time: 2022-09-22T00:21:22.000Z Lat 44.068815 Lon -121.314050
Mode: 3D(3) Time: 2022-09-22T00:21:23.000Z Lat 44.068815 Lon -121.314050
Mode: 3D(3) Time: 2022-09-22T00:21:24.000Z Lat 44.068814 Lon -121.314050
Mode: 3D(3) Time: 2022-09-22T00:21:25.000Z Lat 44.068814 Lon -121.314050
Mode: 3D(3) Time: 2022-09-22T00:21:26.000Z Lat 44.068814 Lon -121.314050
Mode: 3D(3) Time: 2022-09-22T00:21:27.000Z Lat 44.068814 Lon -121.314050
Mode: 3D(3) Time: 2022-09-22T00:21:28.000Z Lat 44.068814 Lon -121.314049
Mode: 3D(3) Time: 2022-09-22T00:21:29.000Z Lat 44.068814 Lon -121.314049

Here is the relevant example code:

    while 0 == session.read():
        if not (gps.MODE_SET & session.valid):
            # not useful, probably not a TPV message
            continue

        print('Mode: %s(%d) Time: ' %
              (("Invalid", "NO_FIX", "2D", "3D")[session.fix.mode],
               session.fix.mode), end="")
        # print time, if we have it
        if gps.TIME_SET & session.valid:
            print(session.fix.time, end="")
        else:
            print('n/a', end="")

It reads a JSON message.  Checks that we have a TPV message.  If we
have a TPV, it prints the mode, then if we have time, it prints that or
"n/a".

Simple.

BTW, check that you only have ONE copy of gpsd, and its python modules
installized.  Mixing disto gpsd, and git gpsd, leads to odd failures.

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: pgpML3OzStsuu.pgp
Description: OpenPGP digital signature


reply via email to

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