gpsd-users
[Top][All Lists]
Advanced

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

Re: What is the easiest / best way to build just the Python client libra


From: W. Craig Trader
Subject: Re: What is the easiest / best way to build just the Python client library?
Date: Sun, 13 Feb 2022 22:35:27 -0500

Gary ...

As it happens, packet.py isn't included by the rest of the gps library, so we are both right -- the code I want to use doesn't depend on packet.py, so the code I'm using doesn't depend on libgpsdpacket.a.  

Typical use case would be:

import gps

server = gps.gps()
server.stream(gps.WATCH_ENABLE)

try:
for report in self.server:
print( report )

except Exception as e:
print( e )

server.stream(gps.WATCH_DISABLE)
My code is somewhat more complex, but effectively that's what it's doing. That's fine for JSON reports.

The problem lies when I try to enable RAW mode using this code: instead of getting NMEA messages, I get nothing. When I wrote a straight TCP client (in Python), I get the correct messages, so the problem isn't with my receiver or GPSD, it's with the Python library (but still not using the packet module).

And yes, I suppose I'll just have to copy the pieces I need by hand, since I don't have time to put together a 32-bit ARM environment for building all of GPSD that doesn't already have GPSD installed.

- Craig -

On Sun, Feb 13, 2022 at 7:25 PM Gary E. Miller <gem@rellim.com> wrote:
Yo W.!

On Sun, 13 Feb 2022 18:22:22 -0500
"W. Craig Trader" <craig.trader@gmail.com> wrote:

> The chunk of Python code in
> https://gitlab.com/gpsd/gpsd/-/tree/master/gps IS a pure Python
> client library for GPSD. That code doesn't depend on libgps.a at all
> -- it makes straight TCP calls to the GPSD daemon.

My mistake, it does not depend on on libgpa.a, it depends on
libgpsdpacket.a.  So, not Pure Python.  It does not "depend" on
libgps.a, but it imports libgpsdpacket.a as an FFI.  Check out
gps/packet.py.in (the prereq to gps/packet/py).  Note this line:

    packet_path = ctypes.util.find_library('gpsdpacket')

That is where Python loads libgpsdpacket.a and then makes the functions
in there available to the gpsd python module.

> It's not well
> documented, and I'm pretty sure there's a bug with WATCH_RAW, but the
> code does work, since I've been using it for more than a year.

WATCH_RAW is almsot 20 years.  I use it every day.  It works as documented.
What is it that you think is not working about WATCHRAW?

> All I want to do is easily process the .py.in  files to produce the
> corresponding .py files, without having to do it manually and then
> maintain my own fork.

That is what scons is for.  scons does a lot of @PARAMETER@ substitutions
on the .py.in file to produce hte .py files.  The data used to make the
changes is in the scons files.  So you need to run scons.

scons is Pure Python and will run on anything that runs python.

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

reply via email to

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