gpsd-users
[Top][All Lists]
Advanced

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

Re: gpsd Example2.py


From: Dirk Beer
Subject: Re: gpsd Example2.py
Date: Thu, 22 Sep 2022 05:10:41 +0000

Gary -
> > > What happened to your time? Did you just start the receiver?
> >
> > I don't know, trying to track this down now. gpscsv does show times,
> > so not sure why example2.py isn't for me.
>
>
> The example reads a JSON message, and checks it is has TIME_SET set, if
> not, the the time is shown as "n/a".
>
> No idea why your JSON does not have TIME_SET, can you provide 30
> seconds of your JSON? This way:
>
> gpspipe -e -x 30 > json.log
Hmm, my gpspipe does not have a -e option. I ran

    gpspipe --json -x 30 > json.log

instead (file attached).

This is making me wonder if I have a problematic version or bad compile. I'm 
using the latest release tarball, and scons and scons check both seemed to run 
fine (no errors):
https://download.savannah.gnu.org/releases/gpsd/gpsd-3.24.tar.gz

    pi@pheromone:~ $ gpsd -V
    gpsd: 3.24 (revision 3.24)

> Until your time works, we are missing something.
So looks like the json file *does* have time in it for the TPV reports.

> 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".

Ah, I think I figured it out. example2.py does work if I change this bitwise 
and to a logical and:

    if gps.TIME_SET and session.valid:

Now I get:
    pi@pheromone:~ $ python3 example2.py
    Mode: 3D(3) Time: 2022-09-22T05:04:40.000Z Lat 32.729165 Lon -116.994065
    Mode: 3D(3) Time: 2022-09-22T05:04:40.000Z Lat 32.729165 Lon -116.994065
    Mode: 3D(3) Time: 2022-09-22T05:04:41.000Z Lat 32.729162 Lon -116.994069
    Mode: 3D(3) Time: 2022-09-22T05:04:41.000Z Lat 32.729162 Lon -116.994069

Cheers,
Dirk

Attachment: json.log
Description: Text document


reply via email to

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