gpsd-users
[Top][All Lists]
Advanced

[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 <alpha-beta-release@gmx.net> 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:192.168.1.7 & HOST_2:192.168.1.8) 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:192.168.1.2) 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.

Weird.

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

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

> 2. because `gps.next()` or `gps.read()` 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 `gps.next()`.

gps.next() 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?

Nope.

> 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:
> https://github.com/beta-tester/python-gpsd-client/blob/main/gps_issue.py


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():
                sleep(SLEEP_LOOP)

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.

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


reply via email to

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