0

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")
  • CLARIFICATION: I took another pi0W that was already running the GPS logging script without an issue and updated Stretch. It continued to work after that. I then (foolishly) updated all other software packages and now it's no longer working. So, it's not Stretch, but maybe gpsd or python-gps – Speedy Jul 22 '18 at 22:52
  • CLARIFICATION: NMEA data has those bizarre characters on the working setup, so it's not that either... – Speedy Jul 22 '18 at 22:54
  • If you've read this, and understand the diffs between the mini and primary UARTs, the Bluetooth connections, etc. then I'd have to wonder about your GPS device. Have you tried swapping that? – Seamus Jul 22 '18 at 23:06
  • @Seamus yeah, same result with both devices. Also swapped the device to another pi and it worked there. – Speedy Jul 23 '18 at 0:01
  • 3
    @Speedy You can edit your post to add clarification rather than adding "CLARIFICATION" in comments; that way it'll be clearer to other users finding your question. – Aurora0001 Jul 23 '18 at 8:25
0

I feel like an idiot, I forgot this portion of the instructions:

sudo systemctl stop gpsd.socket
sudo systemctl disable gpsd.socket

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.