lsqbank was not the original poster--I think he stumbled into this thread by accident.
The method that reads the position from the BT GPS is as follows--this is adapted from code found on this forum as well as GPSWanderer's gmap.py.
Code:
def readposition(self):
haveFix=0
latitude_in=0
longitude_in=0
while 1:
try:
buffer=""
ch=self.sock.recv(1)
while(ch!='$'):
ch=self.sock.recv(1)
while 1:
if (ch=='\r'):
break
buffer+=ch
ch=self.sock.recv(1)
if (buffer[0:6]=="$GPGGA"):
try:
(GPGGA,utcTime,lat,ns,lon,ew,posfix,sats,hdop,alt,altunits,sep,sepunits,age,sid)=buffer.split(",")
latitude_in=float(lat)
longitude_in=float(lon)
haveFix=int(posfix)
except:
appuifw.note(u'No data from GPS.','info')
haveFix=0
#if (haveFix and (hdop < 4)):
if haveFix:
#fix_message = u'Fix obtained, POSFIX=%s, HDOP=%s.' % (posfix,hdop)
#appuifw.note(fix_message,'info')
if ns == 'S':
latitude_in = -latitude_in
if ew == 'W':
longitude_in = -longitude_in
latitude_degrees = int(latitude_in/100)
latitude_minutes = latitude_in - latitude_degrees*100
longitude_degrees = int(longitude_in/100)
longitude_minutes = longitude_in - longitude_degrees*100
latitude = latitude_degrees + (latitude_minutes/60)
longitude = longitude_degrees + (longitude_minutes/60)
print (latitude, longitude, hdop)
return (latitude, longitude, hdop)
no_fix_message = u'No fix. POSFIX=%s, HDOP=%s.' % (posfix, hdop)
#appuifw.note(no_fix_message,'info')
print no_fix_message
return None
except Exception:
return None