pyserial for GPS data

Arun p das arunpdasuit at gmail.com
Thu Mar 15 09:19:26 CET 2012


I have a USB GPS dongle using this for getting  position information. I
installed gpsd daemon so that any clients can read data from that. It is
working fine
used xgps, cgps as clients.

*gpsd -n -N -D2 /dev/ttyUSB0 *

import gps, os, time
g = gps.gps(mode=gps.WATCH_NEWSTYLE)
while 1:
os.system('clear')
g.poll()
#if gps.PACKET_SET:
g.stream()
print 'latitude ' , g.fix.latitude
print 'longitude ' , g.fix.longitude
print 'time utc ' , g.utc,' + ', g.fix.time


Used the following program to read gps data but it is not giving accurate
readings as cgps,xgps clients. I tried to read directly from the serial
port using the following program but its giving non printable characters as
output as it should return something like

$GPRMC,199304.973,3248.7780,N,11355.7832,W,1,06,02.2,25722.5,M,,,*00"

*import serial*
*ser = serial.Serial( port='/dev/ttyUSB0', baudrate=4800,timeout=1) *
*while True:*
* line=ser.read()*
* print line,*
*f.close()*
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20120315/5299758a/attachment.html>


More information about the Python-list mailing list