#! /usr/bin/python import os from gps import * from time import * import time import threading gpsd = None class GpsPoller(threading.Thread): def __init__(self): threading.Thread.__init__(self) global gpsd gpsd = gps(mode=WATCH_ENABLE) self.current_value = None self.running = True def run(self): global gpsd while gpsp.running: gpsd.next() if __name__ == '__main__': gpsp = GpsPoller() gpsp.start() time.sleep(15) os.system('clear') print 'latitude ' , .fix.latitude print 'longitude ' , .fix.longitude print 'time utc ' , .fix.time f = open('gpsdata.txt', 'a') coord = str(gpsd.fix.latitude) + '\t' r(gpsd.fix.longitude) t', str(gpsd.fix.time) n' f.write(coord) f.close() gpsp.running = False gpsp.join()