I've got a few RPi's (0W's) running GPS. All have worked with the same install steps and code except the latest I just assembled yesterday. Now when I run my GPS code, I get the following prints and then nothing else. It looks like it's hanging in report = gps_sensor.next() ?
Thoughts? Did something change in a recent Raspbian update?
I can cat the device and see the following NMEA data. Should I be worried about those weird symbols? Is that expected? Maybe that's the issue?:
pi@raspberrypi:~/data-logger/src $ cat /dev/ttyS0 $GPGGA,184909.085,,,,,0,00,,,M,,M,,*78
$GPGSA,A,1,,,,,,,,,,,,,,,*1E
$GPRMC,184909.085,V,,,,,0.00,0.00,220718,,,N*43
$GPVTG,0.00,T,,M,0.00,N,0.00,K,N*32
$GPGSA,A,1,,,,,,,,,,,,,,,*1E
,,,M,,M,,*78
����$GPRMC,184909.085,V,,,,,0.00,0.00,220718,,,N*43
����$GPVTG,0.00,T,,M,0.00,N,0.00,K,N*32
0718,,,N*43
����$GPGSA,A,1,,,,,,,,,,,,,,,*1E
K,N*32
0718,,,N*43
����$GPGSA,A,1,,,,,,,,,,,,,,,*1E
0.00,220718,,,^C^Z^A^X^O^_^L ����$GPVTG,0.00,T,,M,0.00,N,0.00,K,N*32
$GPGSA,A,1,,,,,,,,,,,,,,,*1E
0.00,220718,,,^C^Z^A^X^O^_^L ����$GPVTG,0.00,T,,M,0.00,N,0.00,K,N*32
$GPVTG,0.00,T,,M,0.00,N,0.00,K,N*32
0718,,,^C^Z^A^X^O^_^L ����$GPVTG,0.00,T,,M,0.00,N,0.00,K,N*32
$GPGSA,A,1,,,,,,,,,,,,,,,*1E
K,N*32
0718,,,^C^Z^A^X^O^_^L ����$GPVTG,0.00,T,,M,0.00,N,0.00,K,N*32
Prints from Python script:
wow
wowwwww
wwwwwow
<dictwrapper: {u'release': u'3.16', u'proto_major': 3, u'rev': u'3.16-4', u'class': u'VERSION', u'proto_minor': 11}>
wow
wowwwww
wwwwwow
<dictwrapper: {u'class': u'DEVICES', u'devices': []}>
wow
wowwwww
wwwwwow
<dictwrapper: {u'pps': False, u'enable': True, u'scaled': False, u'raw': 0, u'json': True, u'nmea': False, u'timing': False, u'class': u'WATCH', u'split24': False}>
wow
wowwwww
Python script:
#!/usr/bin/python
'''
data_logger.py
This program is intended to record data from
GPS
'''
#import modules
import gps
from datetime import datetime
import os
import csv
import time
import sys
def log_gps_data(init_time):
#init vars
VERBOSE = True
TIME_STATS = False
time_interval = 10 #sec
glat =[]
glon =[]
galt =[]
gspeed =[]
gtime =[]
gmode =[]
start= time.time()
#create sensor objects
os.system('sudo killall gpsd')
os.system('sudo gpsd /dev/ttyS0 -F /var/run/gpsd.sock')
gps_sensor =gps.gps("localhost","2947")
gps_sensor.stream(gps.WATCH_ENABLE | gps.WATCH_NEWSTYLE)
data_dir = os.path.dirname(os.path.dirname(os.path.realpath(__file__))) + '/data'
#do stuff 4ever
while True:
end = time.time()
#read data
time1 = time.time()
try:
report = gps_sensor.next()
if VERBOSE== True:
print(report)
if report['class'] == 'TPV':
if hasattr(report,'time'):
gtime+=[report.time]
else:
now = str(datetime.now())
now = now.split('.')
now = now[0]
gtime+=[now]
gmode+=[report.mode]
#protect for slow acquisition
if report.mode < 2:
if VERBOSE== True:
print('still acquiring...')
glat+=[-99999999]
glon+=[-99999999]
galt+=[-99999999]
gspeed+=[-99999999]
else:
if hasattr(report,'lat'):
glat+=[report.lat]
else:
glat+=[-99999999]
if hasattr(report,'lon'):
glon+=[report.lon]
else:
glon+=[-99999999]
if hasattr(report,'alt'):
galt+=[report.alt]
else:
galt+=[-99999999]
if hasattr(report,'speed'):
gspeed+=[report.speed]
else:
gspeed+=[-99999999]
if VERBOSE== True:
print(gtime[-1])
print(gmode[-1])
print(glat[-1])
print(glon[-1])
print(galt[-1])
print(gspeed[-1])
except KeyError:
print('GPS Key Error')
pass
except KeyboardInterrupt:
print('GPS Keyboard Interrupt')
quit()
except StopIteration:
gps_sensor = None
print("GPSD has terminated")