@@ -0,0 +1,2070 @@
+#!/usr/bin/env python%0A%0Aimport time%0Aimport json%0Aimport smbus%0Aimport logging %0A%0ABUS = None%0Aaddress = 0x42%0AgpsReadInterval = 0.1%0ALOG = logging.getLogger()%0A%0A# GUIDE%0A# http://ava.upuaut.net/?p=768%0A%0AGPSDAT = %7B%0A    'strType': None,%0A    'fixTime': None,%0A    'lat': None,%0A    'latDir': None,%0A    'lon': None,%0A    'lonDir': None,%0A    'fixQual': None,%0A    'numSat': None,%0A    'horDil': None,%0A    'alt': None,%0A    'altUnit': None,%0A    'galt': None,%0A    'galtUnit': None,%0A    'DPGS_updt': None,%0A    'DPGS_ID': None%0A%7D%0A%0Adef connectBus():%0A    global BUS%0A    BUS = smbus.SMBus(1)%0A%0Adef parseResponse(gpsLine):%0A    global lastLocation%0A    gpsChars = ''.join(chr(c) for c in gpsLine)%0A    print(%22LINE: %25s%22 %25 gpsChars)%0A    if %22*%22 not in gpsChars:%0A        return False%0A%0A    #gpsStr, chkSum = gpsChars.split('*')%0A    star_split = gpsChars.split('*')%0A    if len(star_split) != 2:%0A        emsg = %22too many stars: %25s%22  %25gpsChars%0A        raise Exception(emsg)%0A        return%0A    gpsStr, chkSum = star_split%0A    gpsComponents = gpsStr.split(',')%0A    gpsStart = gpsComponents%5B0%5D%0A    if (gpsStart == %22$GNGGA%22):%0A        chkVal = 0%0A        for ch in gpsStr%5B1:%5D: # Remove the $%0A            chkVal %5E= ord(ch)%0A        if (chkVal == int(chkSum, 16)):%0A            for i, k in enumerate(%0A                %5B'strType', 'fixTime', %0A                'lat', 'latDir', 'lon', 'lonDir',%0A                'fixQual', 'numSat', 'horDil', %0A                'alt', 'altUnit', 'galt', 'galtUnit',%0A                'DPGS_updt', 'DPGS_ID'%5D):%0A                GPSDAT%5Bk%5D = gpsComponents%5Bi%5D%0A            print json.dumps(GPSDAT, indent=2)%0A        else:%0A            print %22Invalid chksum: %25s%22 %25 gpsChars%0A%0Adef readGPS():%0A    c = None%0A    response = %5B%5D%0A    while True: # Newline, or bad char.%0A        c = BUS.read_byte(address)%0A        if c == 255:%0A            return False%0A        elif c %3E126:%0A            print %22special char: %25s, c=%25d%22 %25 (chr(c), c)%0A        elif c == 10:%0A            break%0A        else:%0A            response.append(c)%0A    parseResponse(response)%0A%0AconnectBus()%0Awhile True:%0A    readGPS()%0A    #time.sleep(gpsReadInterval)%0A

add ubx.py from live hacking environment