[Top][All Lists]

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

Re: need help: have issues with gpsd-client under python

From: Gary E. Miller
Subject: Re: need help: have issues with gpsd-client under python
Date: Thu, 30 Jun 2022 10:20:45 -0700

Yo Beta!

On Thu, 30 Jun 2022 06:52:56 +0200
Beta Tester <> wrote:

> hi, i have several issues with gpsd under python.
> i have two Raspberry Pi Zero W (rev.1.3) acting as gpsd-server (via
> WiFi, HOST_1: & HOST_2: with an GPS device on
> each connected via serial port on GPIO. and i have a Raspberry Pi 4
> acting as gpsd-client (via LAN-cable, IP: to collect and
> store gps data from both gpsd-servers.

You neglect to mention your distribution, your gps decive,
versions of gpsd and python.

> the gpsd-client is made in python:
> two threads are running `gps.gpd(host=HOST_1)`,
> `gps.gpd(host=HOST_2)` to collect gps data of interest (`TPV`,`SKY`)

Python sucks at threading, so I hope you dont really mean threading.

The python gpsd module is not tested for threading either.

> and make a copy of it (with transforming nested dictwrapper to dict)
> and put the data to a queue. another thread is taking the data from
> the queue and store them to a in-memory database first and every 10
> minutes it store the data from the in-memory database to a file and
> clean the in-memory database and it starts a script that uses the
> data from the database file to publish the data for a local webpage.


> everything works well except:
> 1. `` seems to get crazy from time to time in two ways.
>    case 1: `` blocks forever and never returns.
>    case 2: `` returns the same gps record repeatly over and
> over.

I think you said later that you had a bad conenction, causing that?

> 2. because `` or `` blocks the thread, is there a
> way to set a timeout to get back control to the loop?

Yeah, don't do that!  That is whay gps_waiting() is for.

> 3. when starting with `gps.gps(reconnect=True)`, when does a
> reconnect happen? i cannot see any difference between reconnect
> enabled or disabled. e.g., the gpsd-servers powers off and powers on
> again, gps.gps(reconnect=True) does not come back receiving gps data.

Souds like a missing "-n", but later you says you use "-n"

> 4. not every time i get a `StopIteration` exception, then the
> gpsd-server goes down while ``. is not from us.

> on the gpsd-server on the RPi ZeroW i run `gpsd -D 5 -G -N -n -s
> 115200 /dev/ttyAMA0 2>&1 | tee /tmp/test-gpsd.txt` as root

The hard way....

> do i something wrong in the two gpsd-client threads?

You are on your own with Python threads.

> maybe the RPi Zero W with its single core CPU is too weak to handle a
> gpsd-client?


> the link to the python source code i use, in case someone will watch
> the code to point me, what i am doing wrong there:

what is IFNULL()???

You are not always checking that items are set before trying to save
them to your DB.

You are not collecting data per epoch, instead you are over writing data.

Here you are forgetting the PRN:
    INSERT INTO data_gps_sky_map (host, el, az, ss)

Never, ever, sleep, Use gps_waiting():

No one ever, ever, said the timestamps would be unique!
    # DEBUG: detect running crazy (then receiving same timestamp over and over)

They are no epmpty, just not what you expected:
    # gpsd 3.24+ send lots of empty SKY records

> PS.: i know `gpsplot` exists. i just want to know what is going wrong
> in my application.

A lot is wrong.

Gary E. Miller Rellim 109 NW Wilmington Ave., Suite E, Bend, OR 97703  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: pgpMi1x5zotac.pgp
Description: OpenPGP digital signature

reply via email to

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