atexit.register(clean_up) gps = None try: gps = GPS() gps.openPhidget() gps.waitForAttach(10000) except PhidgetException as e: print("Phidget Exception %i: %s" % (e.code, e.details)) exit(1) print("Date,Time,Lat,Long,Altitude,Velocity,Heading") while True: try: print("{0},{1},{2},{3},{4},{5},{6}".format( gps.getDate().toString(), gps.getTime().toString(), gps.getLatitude(), gps.getLongitude(), gps.getAltitude(), gps.getVelocity(), gps.getHeading(), )) except PhidgetException as e: print("Phidget Exception %i: %s" % (e.code, e.details)) time.sleep(.02)
print("Phidget Exception %i: %s" % (e.code, e.details)) try: gps.closePhidget() except PhidgetException as e: print("Phidget Exception %i: %s" % (e.code, e.details)) print("Exiting....") exit(1) print("Exiting....") exit(1) else: displayDeviceInfo() print("Press Enter to quit....") try: print("GPS Current Time: %s" % (gps.getTime().toString())) print("GPS Current Date: %s" % (gps.getDate().toString())) print("GPS Current Latitude: %F" % (gps.getLatitude())) print("GPS Current Longitude: %F" % (gps.getLongitude())) print("GPS Current Altitude: %F" % (gps.getAltitude())) print("GPS Current Heading: %F" % (gps.getHeading())) print("GPS Current Velocity: %F" % (gps.getVelocity())) except PhidgetException as e: print("Phidget Exception %i: %s" % (e.code, e.details)) chr = sys.stdin.read(1) print("Closing...") try: gps.closePhidget()
print("Phidget Exception %i: %s" % (e.code, e.details)) try: gps.closePhidget() except PhidgetException as e: print("Phidget Exception %i: %s" % (e.code, e.details)) print("Exiting....") exit(1) print("Exiting....") exit(1) else: displayDeviceInfo() print("Press Enter to quit....") try: print("GPS Current Time: %s" % (gps.getTime().toString())) print("GPS Current Date: %s" % (gps.getDate().toString())) print("GPS Current Latitude: %F" % (gps.getLatitude())) print("GPS Current Longitude: %F" % (gps.getLongitude())) print("GPS Current Altitude: %F" % (gps.getAltitude())) print("GPS Current Heading: %F" % (gps.getHeading())) print("GPS Current Velocity: %F" % (gps.getVelocity())) except PhidgetException as e: print("Phidget Exception %i: %s" % (e.code, e.details)) chr = sys.stdin.read(1) print("Closing...") try: gps.closePhidget()
print("Phidget Exception %i: %s" % (e.code, e.details)) try: gps.closePhidget() except PhidgetException as e: print("Phidget Exception %i: %s" % (e.code, e.details)) print("Exiting....") exit(1) print("Exiting....") exit(1) else: displayDeviceInfo() print("Press Enter to quit....") try: print("GPS Current Time: %s" %(gps.getTime().toString())) print("GPS Current Date: %s" %(gps.getDate().toString())) print("GPS Current Latitude: %F" %(gps.getLatitude())) print("GPS Current Longitude: %F" %(gps.getLongitude())) print("GPS Current Altitude: %F" %(gps.getAltitude())) print("GPS Current Heading: %F" %(gps.getHeading())) print("GPS Current Velocity: %F" % (gps.getVelocity())) except PhidgetException as e: print("Phidget Exception %i: %s" % (e.code, e.details)) print("Press Enter to quit....") # DO SOMETHING HERE #
print("Phidget Exception %i: %s" % (e.code, e.details)) try: gps.closePhidget() except PhidgetException as e: print("Phidget Exception %i: %s" % (e.code, e.details)) print("Exiting....") exit(1) print("Exiting....") exit(1) else: displayDeviceInfo() print("Press Enter to quit....") try: print("GPS Current Time: %s" % (gps.getTime().toString())) print("GPS Current Date: %s" % (gps.getDate().toString())) print("GPS Current Latitude: %F" % (gps.getLatitude())) print("GPS Current Longitude: %F" % (gps.getLongitude())) print("GPS Current Altitude: %F" % (gps.getAltitude())) print("GPS Current Heading: %F" % (gps.getHeading())) print("GPS Current Velocity: %F" % (gps.getVelocity())) except PhidgetException as e: print("Phidget Exception %i: %s" % (e.code, e.details)) print("Press Enter to quit....") # DO SOMETHING HERE # # Set digital output port 0 to be on #interfaceKit.setOutputState(0, 1)
import cv, time, datetime, sys from Phidgets.Devices.GPS import GPS saveDir = '/data/tmpImg' logFile = open('/data/tmpImg/runLog.txt', 'w') gps = GPS() gps.openPhidget() gps.waitForAttach(10000) gps_time = gps.getTime().toString() capture = cv.CaptureFromCAM(0) cv.SetCaptureProperty(capture, 3, 1280) cv.SetCaptureProperty(capture, 4, 720) header = 'imgName,curTime,elpTime,gps_time,gps_vel, gps_heading, gps_lon,gps_lat,gps_alt\n' logFile.write(header) for i in range(2000): #print 1 curTime = str(datetime.datetime.now()) imgName = 'testImg' + str(i).zfill(5) + '.jpg' img = cv.QueryFrame(capture) #print 2 #cv.ShowImage("camera", img) cv.SaveImage(saveDir + '/' + imgName, img) #print 3 #gps stuff... gps_time = gps.getTime().toString() gps_lat = gps.getLatitude()
""" simple gps test """ print "starting up!" from Phidgets.Devices.GPS import GPS import datetime, sys gps = GPS() gps.openPhidget() print "waiting for attach" gps.waitForAttach(10000) print "attached!" gps_time = gps.getTime().toString() def gpsChangeHandler1(e): gps_time = gps.getTime().toString() gps_lat = gps.getLatitude() gps_lon = gps.getLongitude() gps_alt = gps.getAltitude() gps_heading = gps.getHeading() gps_vel = gps.getVelocity() time1 = str(datetime.datetime.now()) dataElems = [time1, gps_time, gps_lat, gps_lon] dataElems = [str(x) for x in dataElems] print ','.join(dataElems) print "testing function" gpsChangeHandler1(1)