Note that there are some explanatory texts on larger screens.

plurals
  1. POWhy is output of GPS using python zero or Nan?
    primarykey
    data
    text
    <p>I'm having troubles with GPS output. When i type:</p> <pre><code>$ cat /dev/ttyUSB0 </code></pre> <p>i have NMEA sentences coming out (it's what i want)</p> <pre><code>$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 </code></pre> <p>But, when i try to see output with python (this is basic code):</p> <pre><code>import gps session=gps.gps('localhost','2947') session.stream() print session </code></pre> <p>i got this:</p> <pre><code>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: </code></pre> <p>I tried someone else's code but it always say NaN or 0:</p> <pre><code> #! /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 </code></pre> <p>Output:</p> <pre><code> 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 [] </code></pre> <p>So does somebody know why is this all zeros and unknown?</p> <p>Please help, i'm trying to fix it for a week now.</p> <p>Thanks</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload