#!/usr/bin/env python2.1 import os import string import cPickle pickle = cPickle import select import time #gps = open('/dev/ttyS0', 'r') gps = open('gps_data', 'r') log = open('trip.log', 'w') logp = pickle.Pickler(log) count = 0 gpscheck = select.poll() gpscheck.register(gps, select.POLLIN) photo_period = 4 photo_time_prev = 0 while (1): # Did the GPS say anything? while len(gpscheck.poll(0)) > 0: line = gps.readline() if line[0] != '$': continue components = string.split(line[:-1], ',') logp.dump(components) print 'GPS' #: %s' % (components) print '-' now = time.time() # if now > photo_time_prev + photo_period: if 0: photo_time_prev = now #image = os.popen('vgrabbj -i vga', 'r').read() image = open('image.jpeg', 'r').read() logp.dump(['$photo', '0', image]) print 'photo' # time.sleep(1)