在NMEA GPS receiver中,GPGGA is not the only one to read GPS position, with all receivers, since not all receiver use it.
Should be able decode at least :
GPGGA
GPRMC
GPGLL
(注: 那些含有lon&lat的 sentence应该都可以)
Download and review Python for Series 60 Documentation bundle at http://forum.nokia.com/main/0,6566,040,00.html?fsrParam=1-3-/main/0,,034-821,00.html&fileID=6534
At "Programming with Python for Series 60 Platform" there is section dedicated to the topic - Bluetooth Sockets. There is example of services discovery and reference to Python's Bluetooth console and Bluetooth socket stdio.
Here is a sample BT program that reads a position from a BT GPS and displays it.
import socket
class BTReader:
def connect(self):
self.sock=socket.socket(socket.AF_BT,socket.SOCK_STREAM)
address,services=socket.bt_discover()
print "Discovered: %s, %s"%(address,services)
target=(address,services.values()[0])
print "Connecting to "+str(target)
self.sock.connect(target)
def readposition(self):
try:
while 1:
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"):
(GPGGA,hhmmssss,l1ddmmmmmm,l1,l2dddmmmmmm,l2,q,xx,pp,ab,M,cd,M,xx,nnnn)=buffer.split(",")
return (l1+l1ddmmmmmm, l2+l2dddmmmmmm)
except Error:
return None
def close(self):
self.sock.close()
bt=BTReader()
bt.connect()
print bt.readposition()
print bt.readposition()
print bt.readposition()
bt.close()
没有评论:
发表评论