Python を使用して GPSD ポーリングを実装しています: ここの Python の例に従ってください: http://www.catb.org/gpsd/client-howto.html#_python_examples
ここでコードを使用できない理由があります: https://gist.github.com/wolfg1969/4653340 システムで約 10 個のプロセスをデーモン化する必要があるため、簡単に実装するには catb を使用します。
次のコードについて質問があります。なぜ 2 サイクル後に停止するのですか? どうすればこれを修正できますか?ありがとう。
def GpsDetection():
global gpsd
gpsd = gps(mode=WATCH_ENABLE)
try:
while 1:
# Do stuff
report = gpsd.next()
# Check report class for 'DEVICE' messages from gpsd. If we're expecting messages from multiple devices we should
# inspect the message to determine which device has just become available. But if we're just listening
# to a single device, this may do.
print report
if report['class'] == 'DEVICE':
# Clean up our current connection.
gpsd.close()
# Tell gpsd we're ready to receive messages.
gpsd = gps(mode=WATCH_ENABLE)
# Do more stuff
print "GPSD Data is showing now!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
print datetime.datetime.now()
print 'latitude ' , gpsd.fix.latitude
print 'longitude ' , gpsd.fix.longitude
print 'time utc ' , gpsd.utc,' + ', gpsd.fix.time
print 'altitude (m)' , gpsd.fix.altitude
print 'eps ' , gpsd.fix.eps
print 'epx ' , gpsd.fix.epx
print 'epv ' , gpsd.fix.epv
print 'ept ' , gpsd.fix.ept
print 'speed (m/s) ' , gpsd.fix.speed
print 'climb ' , gpsd.fix.climb
print 'track ' , gpsd.fix.track
print 'mode ' , gpsd.fix.mode
print
print 'sats ' , gpsd.satellites
time.sleep(1)
except StopIteration:
print "GPSD has terminated"
return