gpsd python 客户端
我正在尝试为 Gpsd 编写一个非常简单的 python 客户端,但我有 执行脚本一段时间后出现此错误:
Traceback (most recent call last):
File "gps_cap.py", line 13, in <module>
g.stream()
File "/usr/lib/python2.6/site-packages/gps/gps.py", line 348, in stream
gpsjson.stream(self, flags)
File "/usr/lib/python2.6/site-packages/gps/client.py", line 176, in stream
return self.send(arg + "}")
File "/usr/lib/python2.6/site-packages/gps/client.py", line 111, in send
self.sock.send(commands)
socket.error: [Errno 104] Connection reset by peer
这是我的 python 代码:
import os
from gps import *
from time import *
g = gps(mode=WATCH_ENABLE)
while 1:
os.system('clear')
g.poll()
if PACKET_SET:
g.stream()
print
print ' GPS reading'
print '----------------------------------------'
print 'latitude ' , g.fix.latitude
print 'longitude ' , g.fix.longitude
print 'time utc ' , g.utc,' + ', g.fix.time
print 'altitude ' , g.fix.altitude
print 'epc ' , g.fix.epc
print 'epd ' , g.fix.epd
print 'eps ' , g.fix.eps
print 'epx ' , g.fix.epx
print 'epv ' , g.fix.epv
print 'ept ' , g.fix.ept
print 'speed ' , g.fix.speed
print 'climb ' , g.fix.climb
print 'track ' , g.fix.track
print 'mode ' , g.fix.mode
print
print 'sats ' , g.satellites
sleep(1)
也许有人可以帮助解决这个问题?我在 ArchLinux 盒子里运行 Gpsd 2.95。
谢谢!
I'm trying to write a very simple python client for Gpsd, but I have
this error after some time of execute the script:
Traceback (most recent call last):
File "gps_cap.py", line 13, in <module>
g.stream()
File "/usr/lib/python2.6/site-packages/gps/gps.py", line 348, in stream
gpsjson.stream(self, flags)
File "/usr/lib/python2.6/site-packages/gps/client.py", line 176, in stream
return self.send(arg + "}")
File "/usr/lib/python2.6/site-packages/gps/client.py", line 111, in send
self.sock.send(commands)
socket.error: [Errno 104] Connection reset by peer
and this is my python code:
import os
from gps import *
from time import *
g = gps(mode=WATCH_ENABLE)
while 1:
os.system('clear')
g.poll()
if PACKET_SET:
g.stream()
print
print ' GPS reading'
print '----------------------------------------'
print 'latitude ' , g.fix.latitude
print 'longitude ' , g.fix.longitude
print 'time utc ' , g.utc,' + ', g.fix.time
print 'altitude ' , g.fix.altitude
print 'epc ' , g.fix.epc
print 'epd ' , g.fix.epd
print 'eps ' , g.fix.eps
print 'epx ' , g.fix.epx
print 'epv ' , g.fix.epv
print 'ept ' , g.fix.ept
print 'speed ' , g.fix.speed
print 'climb ' , g.fix.climb
print 'track ' , g.fix.track
print 'mode ' , g.fix.mode
print
print 'sats ' , g.satellites
sleep(1)
Maybe anyone can help with this issue? I'm runnig Gpsd 2.95 in a ArchLinux box.
Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
我知道这个问题已经很老了,但我仍然把我的答案放在这里,以防将来有人需要它:
此代码与线程一起工作,并将在屏幕上给出很好的 gpsd 数据输出。它可以用 Ctrl + C 终止。
所有积分都转到 http ://www.danmandle.com/blog/getting-gpsd-to-work-with-python/
I know this question is pretty old but i still drop my answer here in case someone needs it in the future:
This code work with thread and will give out a nice output of gpsd data to the screen. It can be terminated with Ctrl + C.
All credits go to http://www.danmandle.com/blog/getting-gpsd-to-work-with-python/
我会在 GPSD 如何寻呼的这个片段上投入一些钱;另外,感谢您的引导代码。
http://gpsd.berlios.de/client-howto.html
I would put some money on this snippit from the gpsd how to page; also, thanks for the bootstrap code.
http://gpsd.berlios.de/client-howto.html
为了让老问题继续存在,下面粘贴的是 GPS3(一个 Python 2.7-3.5 gpsd 客户端)的当前状态位于 https://github.com/wadda/gps3。
GPS3 有两个组件; GPSDSocket 类和Fix 类。
GPSD 以许多“类”、TPV、SKY 等形式提供 JSON 数据。连接到 GPSD 后,GPS3 将这些 JSON 对象解压到字典中 (
Fix.TPV['lat']
,Fix.SKY['satellites']
等)通常使用会创建一个实例,例如
fix = gps3.Fix()
,并且所有可用数据都将从本机 JSON 对象的名称(例如,fix.TPV['speed']
、fix.TPV['alt']
等)与 一个演示应用程序 gegps3.py,它创建一个
kml
文件(/tmp/gps3_live.kml
) 可在 Google 地球中查看。To keep an old question alive, pasted below is the current state of GPS3, a Python 2.7-3.5 gpsd client found at https://github.com/wadda/gps3.
GPS3 has two components; the GPSDSocket class, and the Fix class.
GPSD delivers JSON data in a number of 'classes', TPV, SKY, etc. After connecting to the GPSD, GPS3 unpacks those JSON objects into dictionaries (
Fix.TPV['lat']
,Fix.SKY['satellites']
, etc.)Common use would create an instance, e.g.,
fix = gps3.Fix()
, and all available data would be derived from the name of the native JSON object (e.g.,fix.TPV['speed']
,fix.TPV['alt']
, etc.)Confer usage with a demo application gegps3.py which creates a
kml
file (/tmp/gps3_live.kml
) to be viewed in Google Earth.