#!/usr/bin/env python import struct from math import pow EXAMPLE_MSG = b"<\xff\x01HB9EGM-7>APLRT1,WIDE1-1:!/7%=6P\')8[I#Q" def decodeEncodedGPS(packet): """Returns a string with decoded latitude and longitude, or raises ValueError""" ix = packet.index(b":!/") gps_packet = packet[ix+3:] encoded_latitude = gps_packet[:4] encoded_longitude = gps_packet[4:8] (y1, y2, y3, y4) = struct.unpack("