J'ai des problèmes avec la sortie GPS. Quand je tape :
$ cat /dev/ttyUSB0
J'ai des phrases NMEA qui sortent (c'est ce que je veux).
$GPGGA,134131.000,4548.0018,N,01557.1026,E,1,06,1.5,123.8,M,42.4,M,,0000*56
$GPGSA,A,3,12,15,24,17,22,18,,,,,,,2.3,1.5,1.8*30
$GPGSV,3,1,12,24,76,320,29,12,49,254,44,15,42,195,17,17,38,057,15*7A
$GPGSV,3,2,12,25,15,249,,09,12,112,,26,11,162,,18,09,267,19*75
$GPGSV,3,3,12,22,08,297,23,14,08,323,,04,06,114,,28,03,061,*78
$GPRMC,134131.000,A,4548.0018,N,01557.1026,E,1.71,291.64,210513,,,A*67
Mais, quand j'essaie de voir la sortie avec python (ceci est un code de base) :
import gps
session=gps.gps('localhost','2947')
session.stream()
print session
Je m'en occupe :
Time: (nan)
Lat/Lon: 0.000000 0.000000
Altitude: ?
Speed: ?
Track: ?
Status: STATUS_NO_FIX
Mode: MODE_NO_FIX
Quality: 0 p=0.00 h=0.00 v=0.00 t=0.00 g=0.00
Y: 0 satellites in view:
J'ai essayé le code de quelqu'un d'autre mais il dit toujours NaN ou 0 :
#! /usr/bin/python
# Written by Dan Mandle http://dan.mandle.me September 2012
# License: GPL 2.0
import os
from gps import *
from time import *
import time
import threading
gpsd = None #seting the global variable
os.system('clear') #clear the terminal (optional)
class GpsPoller(threading.Thread):
def __init__(self):
threading.Thread.__init__(self)
global gpsd #bring it in scope
gpsd = gps(mode=WATCH_ENABLE) #starting the stream of info
self.current_value = None
self.running = True #setting the thread running to true
def run(self):
global gpsd
while gpsp.running:
gpsd.next() #this will continue to loop and grab EACH set of gpsd info to$
if __name__ == '__main__':
gpsp = GpsPoller() # create the thread
try:
gpsp.start() # start it up
while True:
#It may take a second or two to get good data
#print gpsd.fix.latitude,', ',gpsd.fix.longitude,' Time: ',gpsd.utc
os.system('clear')
print
print ' GPS reading'
print '----------------------------------------'
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(5) #set to whatever
Sortie :
GPS reading
----------------------------------------
latitude 0.0
longitude 0.0
time utc + nan
altitude (m) nan
eps nan
epx nan
epv nan
ept nan
speed (m/s) nan
climb nan
track nan
mode 1
sats []
Quelqu'un sait-il pourquoi il n'y a que des zéros et des inconnus ?
Aidez-moi, j'essaie de le réparer depuis une semaine.
Gracias