wadda / gps3 Goto Github PK
View Code? Open in Web Editor NEWPython 2.7 - 3.5 interface to gpsd
License: MIT License
Python 2.7 - 3.5 interface to gpsd
License: MIT License
I'm not exactly a Noob, but only half a notch above.
So far, I've been able to use your tool to get everything I need, BUT, if the GPS Dongle gets partially unplugged, the calls just hang.
I was hoping to at least send it a timeout of 2 seconds for the issue but haven't been successful.
When running pipdeptree -r -p channels
I get:
Warning!! Cyclic dependencies found:
* gps3 => gps3 => gps3
seems like something is misconfigured for gps3.
I have version: gps3 0.33.3
Here I see release 0.33.3: https://pypi.org/project/gps3/0.33.3/
But in this repo I do not find any such tag. What is the difference? Is Is the tag just missing, and can be added, otherwise it is a little bit unclear, how what you download from pypi s related to the source here
It appears gpsd deprecated their alt attribute in favor of altHAE. When gps3 is used with gpsd 3.17, the altitude attribute is fine. When it's used with gpsd 3.19, altitude is always 0. (I suspect it's only reading the now-deprecated alt value that's always set to 0 or NaN).
Hello,
I have been trying to understand the flow of the source a bit lately compared to when I just used it.
Is there a way to write to a file to handle .txt formatting while reading serial data in this lib?
Seth
P.S. I just spent a few hours trying to make a couple of the options available in a .txt file but could not get any output.
I am trying to use lat, lon, and alt in my file so far.
On some installations the "class":"DEVICES" JSON object is not returned or is returned before GPS3 can process it and therefore hangs.
I'll look into this.
I try to close an AGPS3mechanism instance but it raises an error.
from gps3.agps3threaded import AGPS3mechanism
gps = AGPS3mechanism()
gps.stream_data()
gps.run_thread()
print(gps.data_stream.time)
gps.stop()
It raises:
Traceback (most recent call last):
File "/opt/python3.5/lib/python3.5/threading.py", line 914, in _bootstrap_inner
self.run()
File "/opt/python3.5/lib/python3.5/threading.py", line 862, in run
self._target(*self._args, **self._kwargs)
File "/opt/python3.5/lib/python3.5/site-packages/gps3/agps3threaded.py", line 43, in unpack_data
for new_data in self.socket:
File "/opt/python3.5/lib/python3.5/site-packages/gps3/agps3.py", line 115, in next
waitin, _waitout, _waiterror = select.select((self.streamSock,), (), (), timeout)
TypeError: argument must be an int, or have a fileno() method.
How to fix this, please?
how can I make it work with a serial data from an GPS at /dev/ttyUSB2 at , for example 57600 bps ?
and can it take NMEA and/or GPX from such serial interface ?
Thank you.
I have this setup, (agps3 and agps3threaded) and can get lat, long, alt and the demo give ones.
I see hdop in the list, but cannot get it, it just returns n/a
e.g.
agps_thread.data_stream.lat
works fine
agps_thread.data_stream.hdop
returns n/a
cgps, nmea and gpsmon are all giving me hdop in the stream
(ublox mk8030)
The sample code below is currently returned as the top search result for python gps. It's hosted at this URL https://pypi.org/project/gps3/ and the big problem here is that the loop runs out of control, trashing the CPU usage for no reason. I would recommend adding a sleep to the loop. Quite simply a "time.sleep(0.2)" just below the "for new_data in ..." line would save a ton of carbon as N00bs using the sample code don't end up with code that max's out their CPU with useless looping.
from gps3 import gps3
gps_socket = gps3.GPSDSocket()
data_stream = gps3.DataStream()
gps_socket.connect()
gps_socket.watch()
for new_data in gps_socket:
if new_data:
data_stream.unpack(new_data)
print('Altitude = ', data_stream.TPV['alt'])
print('Latitude = ', data_stream.TPV['lat'])
Your README needs some serious cleanup I think.
Can you provide the code snippets as ready-to-copy snippets?
That would be very helpful!
Proper placing of comments (above lines) would also be good there.
Also: One README is enough! ;-)
Please excuse me if I'm misunderstanding how to use the library.
I'm experiencing a problem where the lat and lon values from the GST message (which indicate the standard deviation in meters of the latitude and longitude estimates) are being unpacked as if they are the actual lat/lon. This is because their keys in the GST message are simply 'lat' and 'lon', the same as the actual lat/lon reported in the TPV message.
Is there an intended workaround for this?
Line 48 in 91adcd7
GPSd supports both listening on an address or file socket. Proposing a change here to accept both ways.
I'm working on an integration of GPSD into Home-Assistant.io and using your project.
Have you considered to raise exceptions instead of printing to STDOUT if there is no connection possible or another problem occurs?
What exactly is the difference between agps3.py and gps3.py? diffing both yields pretty much the same thing.
When GPSD is not running, it should throw ConnectionRefusedError: [Errno 111] Connection refused
, however gps3.py, line 70 has a bug:
sys.stderr.write('\nGPSDSocket.connect OSError is-->', error)
TypeError: write() takes exactly 1 argument (2 given)
I am running into an issue with gps3 and the upstream maintainers have requested that this be fixed in the gps3 module. This is a logic issue in processing GPS sentences. You can reference the pull request in Home Assistant - the Proposed Change details the issue. home-assistant/core#83953
Are you still maintaining this project? If not, would you be willing to transfer ownership to either myself or someone else that could make updates.
Thanks
Line 61 in 91adcd7
First of all, thanks for gps3. Really makes using gps with python easier.
I'd like to propose an enhancement: Use logging instead of writing to stdout/stderr.
That way, people can tweak output location, levels etc. It's more configurable and all around a better solution imho.
The pypi version is much ahead of your github version of the code.
Can you use the tags here to get ready for pypi releases?
I'm planning to provide a package for this in Arch Linux AUR.
I'd prefer a "release version" of this code instead of a "git version" there.
Also: Using setuptools for that would be very awesome!
https://github.com/pypa/setuptools
Hi @wadda,
I'm just experimenting with gps3 but I've noticed that the bug on line 162 of gps3.py (key in packages['DEVICE']
as opposed to key in self.packages['DEVICE']
) still persists if I install gps3 via pip install gps3
. I suspect this is because the version number (0.32.0) has not been incremented with the bug fix. Would you mind updating the version number?
Thanks and good work by the way!
Martyn.
Hi,
this library looks grat. However I can't find "Fix Quality" data from the GGA sentence. Am I missing something?
Many thanks!
The socket read is run through the JSON
def refresh(self, gpsd_data_package): """Sets new socket data as Fix attributes Arguments: self: gpsd_data_package (json object): Provides: self attribute dictionaries, e.g., self.TPV['lat'], self.SKY['gdop'] Raises: AttributeError: 'str' object has no attribute 'keys' when the device falls out of the system ValueError, KeyError: most likely extra, or mangled JSON data, should not happen, but that applies to a lot of things. """ try: fresh_data = json.loads(gpsd_data_package) # The reserved word 'class' is popped from JSON object class package_name = fresh_data.pop('class', 'ERROR') # gpsd data package errors are also 'ERROR'. package = getattr(self, package_name, package_name) # packages are named for JSON object class for key in package.keys(): # TODO: Rollover and retry. It fails here when device disappears package[key] = fresh_data.get(key, 'n/a') # Updates and restores 'n/a' if key is absent in the socket # response, present --> 'key: 'n/a'' instead.' except AttributeError: # 'str' object has no attribute 'keys' print('No Data') return except (ValueError, KeyError) as error: sys.stderr.write(str(error)) # Look for extra data in stream return
As you see this last ValueError, KeyError throw a error with extraneous data that is in the JSON object shipped from GPSD
[io@io gps3] :( python3 human.py -host 192.168.0.4
Keyboard interrupt received
Terminated by user
Good Bye.
.
Extra data: line 1 column 2 - line 2 column 1 (char 1 - 15)Extra data: line 1 column 5 - line 2 column 1 (char 4 - 512)Extra data: line 1 column 2 - line 2 column 1 (char 1 - 97)Extra data: line 1 column 2 - line 2 column 1 (char 1 - 113)Expecting value: line 1 column 1 (char 0)Expecting value: line 1 column 1 (char 0)Extra data: line 1 column 2 - line 2 column 1 (char 1 - 159)Expecting value: line 1 column 1 (char 0)[io@io gps3] :(
I'm looking for a way to join this data with the data that is already in the buffer. I'm also open to ideas.
Traceback (most recent call last):
File "/usr/lib/python2.7/threading.py", line 801, in __bootstrap_inner
File "/usr/lib/python2.7/threading.py", line 754, in run
File "433mobile.py", line 213, in gpsThread
File "433mobile.py", line 236, in gpsConnectAndMonitor
File "/root/.local/lib/python2.7/site-packages/gps3/gps3.py", line 116, in next
<type 'exceptions.AttributeError'>: 'NoneType' object has no attribute 'select'
Unclear what conditions led to the situation. The application works fine normally.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.