import serial, os, string, math
def run(program, *args):
for path in string.split(os.environ["PATH"], os.pathsep):
file = os.path.join(path, program) + ".exe"
try:
return os.spawnv(os.P_NOWAIT, file, (program,) + args)
except os.error:
pass
raise os.error, "cannot find executable"
def dmmm2dec(degrees,sw):
deg= math.floor(degrees/100.0)
frac= ((degrees/100.0)-deg)/0.6
ret = deg+frac
if ((sw=="S") or (sw=="W")):
ret=ret*(-1)
return ret
ser = serial.Serial(port='COM2',baudrate=4800,bytesize=8, parity='N', stopbits=1,timeout=3)
line = ""
while not(line.startswith("$GPGGA")):
line= ser.readline()
ser.close()
tokens = line.split(",")
lat = dmmm2dec(float(tokens[2]),tokens[3])
lng = dmmm2dec(float(tokens[4]),tokens[5])
query = "sandwiches"
url = r'"http://maps.google.com/maps?f=l&hl=en&q='+query+'&near='+str(lat)+','+str(lng)+'&ie=UTF8&z=12&om=1"';
run("firefox",url)