gpsd-users
[Top][All Lists]
Advanced

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

Re: powering on gps device


From: Gary E. Miller
Subject: Re: powering on gps device
Date: Thu, 24 Jun 2021 11:16:09 -0700

Yo Nachiket!

On Thu, 24 Jun 2021 17:28:06 +0530
Nachiket Gokhale <gokhalen@gmail.com> wrote:

> I want to get latitude and longitude information out of my gps. I
> wrote a small client and tested it with gpsfake. This client was
> based on the one in https://pypi.org/project/gps/

That is an old, 3rd party, copy of old gpsd work.  Much better to
use the exact same files that come as part of gpsd.  That have
patches and updates.

> The input to gpsfake was a nmea file generated via
> nmeagen.org. I can see the following information every half-second

Pretty minimal NMEA.  But valid.  Every device sends different NMEA.

> {'class': 'TPV', 'device': '/dev/pts/9', 'mode': 3, 'time':
> '2021-04-26T09:58:52.573Z', 'ept': 0.005, 'lat': 18.516816667, 'lon':
> 73.834533333, 'alt': 0.0, 'epv': 23.0, 'track': 198.4, 'speed':
> 15.999, 'climb': 0.0, 'epc': 46.0}

Yes.

> Now that I have access to a real physical gps, I'd like to get
> lat/lon out of it using the same (or similar) client I wrote for use
> with gpsfake. Notice that in response to your comments, I have added
> gps.WATCH_NMEA in the client.

Good for debugging.

> Based on your suggestions, here is what I am doing now, in sequence:
> 
> 1) as root, Kill all previous gpsds
> 2) as root, gpsd -n -N -D3  /dev/ttyS0
> 3) as root, run the script to power on

But the script needs /dev/ttyS0 that gpsd now holds?  Right?  Run
the script BEFORE running gpsd.

CAre to share that script?

> 4) as non root-user, start the client
> 
> Detailed output follows
> 
> 1) As root, begin with
>     a) killall -9 gpsd
>     b) service gpsd stop
>     c) rm /run/gpsd.sock
> 
> 2) As root, gpsd -n -N -D3  /dev/ttyS0  which yields
> 
> gpsd:INFO: launching (Version 3.17)

OLD!!!

> gpsd:INFO: listening on port gpsd
> gpsd:INFO: stashing device /dev/ttyS0 at slot 0
> gpsd:INFO: SER: opening GPS data source type 2 at '/dev/ttyS0'
> gpsd:INFO: SER: speed 115200, 8N1
> gpsd:INFO: SER: speed 9600, 8O1
> gpsd:INFO: SER: speed 115200, 8N1
> gpsd:INFO: SER: speed 9600, 8N1
> gpsd:INFO: SER: speed 115200, 8N1
> gpsd:INFO: gpsd_activate(2): activated GPS (fd 6)
> gpsd:INFO: KPPS:/dev/ttyS0 RFC2783 path:/dev/pps0, fd is 7
> gpsd:INFO: KPPS:/dev/ttyS0 pps_caps 0x1133
> gpsd:INFO: KPPS:/dev/ttyS0 have PPS_CANWAIT
> gpsd:INFO: KPPS:/dev/ttyS0 kernel PPS will be used
> gpsd:INFO: PPS:/dev/ttyS0 ntpshm_link_activate: 1
> gpsd:INFO: device /dev/ttyS0 activated
> gpsd:INFO: KPPS:/dev/ttyS0 kernel PPS timeout Interrupted system call

No PPS, I guess that is OK....

> 3) As root, run the power on script in a separate terminal. gpsd
> identifies the gps device and outputs

You could automatically run it as a device-hook.

> gpsd:WARN: can't use GGA time until after ZDA or RMC has supplied a
> year. gpsd:WARN: can't use GGA time until after ZDA or RMC has
> supplied a year. gpsd:INFO: KPPS:/dev/ttyS0 kernel PPS timeout

Did you see that?  VERY important!  Does your device ever send
ZDA or RMC?  If not, there is no way to know the time.

> 4) As non-root user, start the client. gpsd detects that a client has
> connected because it outputs the following

No point.  Until the receiver send ZDA or RMC there will be no progress
to TPV.

> gpsd:CLIENT: <= client(0): ?WATCH={"enable":true,"json":true}\x0a

Note: not watching for NMEA.  Without seeing the NMEA I'm unclear what is
happening.

> Notice there is no TPV information sent to the client, which was
> present when I was faking the gps using gpsfake. I would like TPV
> classes or something else that holds latitude/longitude information.

You have no TPV, because you have no ZDA or RMC.

> Finally, if gpsd is not running, I get sentences like the following
> using cat /dev/ttyS0. If gpsd is running I do not get output from cat
> /dev/ttyS0, presumably because gpsd is reading it.

Yes, only one process can read from a serial device at any one time.

> $GPGGA,112736.947,1829.7791,N,07349.0327,E,1,4,1.64,582.6,M,-64.7,M,,*75
> $GPGGA,112737.947,1829.7837,N,07349.0297,E,1,5,1.50,585.3,M,-64.7,M,,*79
> $GPGGA,112739.000,1829.7767,N,07349.0256,E,1,6,1.14,581.4,M,-64.7,M,,*7A
> $GPGGA,112740.000,1829.7803,N,07349.0281,E,1,7,1.03,585.8,M,-64.7,M,,*7C
> $GPGGA,112741.000,1829.7821,N,07349.0285,E,1,8,0.88,585.6,M,-64.7,M,,*7A

Notice: no ZDA, NO RMC!  So no TPV.

Please confirm port speed, both when cat is running and when gpsd is running.

> ######## Script to power on GPS begins ################
> from time import sleep

Sleeping on serial ports is bad.  It leads to buffer overruns.

> print ("\nGPS output set to GGA (AT+CGPSOUT=2)")
> ser.write(bytes("AT+CGPSOUT=2\n", 'utf-8'))

You also need RMC or ZDA to get the complete time.

> ####### Script to power on GPS ends ###############################
> 
> ####### Client to read data from 127.0.0.1:2947 begins
> ################# import gps

I assume the commented out "import gps" is email corruption?

And dor NOT use the gps from pip.

>         time.sleep(0.5)

Sleeping leads to buffer overruns!

It looks like the main problem is that when you run your power on
script, it takes the serial port away from gpsd.  Run the script FIRST,
then gpsd.

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


reply via email to

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