#---------------------------------------------------------------------- # SABVABAA Hovercraft Seismic Profiling Gun Control Program # # University of Bergen, Norway # Dept. of Earth Science # # Rev Date By Description # --------------------------------------------------------------------- # 0.2 Apr 11, 2010 OM Small modification for use with # USB/Serial adapter. # 0.1 Jun 08, 2008 OM Initial version. #---------------------------------------------------------------------- import time import serial import winsound from sys import exit #-------------------------------------------------------------------------- # C O N S T A N T S #-------------------------------------------------------------------------- VERSION = "Ver. 0.2 Date: 11 April 2010" COM_PORT = 4 # '1' = COM1 -> On the rear of the DELL Latitude D630 # '4' = COM4 -> USB/SERIAL adapter (check in Control Panel -> System -> Hardware -> .. #------------------------------------------------------------ # Subroutine: Fire GUNCO #------------------------------------------------------------ def FireAirGun(): for k in range(1): winsound.Beep(2000, 20) winsound.Beep(2200, 10) print "Fire!", time.strftime("%a, %d %b %Y %H:%M:%S", time.gmtime()) ser.setDTR(level=1) time.sleep(0.01) ser.setDTR(level=0) #------------------------------------------------------------ # M A I N P R O G R A M #------------------------------------------------------------ print ''' ============================================================== S A B V A B A A H O V E R C R A F T Seismic Profiling Gun & Recording Trigger Program ============================================================== Terminate program by CTRL-C (may have to wait a bit) ''' print "Serial port specified: COM%d" % int(COM_PORT) print print VERSION print ''' Dept. of Earth Science - University of Bergen, Norway ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ''' #--- Open COM port for GUN control #--- DTR -> GUN1 -> fire from 0 to 1 state #--- RTS -> GUN2 -> ---"--- try: ser = serial.Serial(COM_PORT-1) # Subtract one as parameter starts from zero. except: print print "++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++" print "+++++++++++++++++ E R R O R +++++++++++++++++++++++++++" print "++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++" print "Could not open COM%d" % int(COM_PORT) print "Check in:" print " Control Panel -> System -> Hardware -> Devices -> Ports" print "for correct COM port assignment." print "Edit COM_PORT constant in this program accordingly." print "++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++" exit() ser.setDTR(level=0) ShotInterval = int(raw_input("Shot interval [s]: ")) print "Shot interval = ", ShotInterval, "s" print "Shooting in 5 seconds ..." t = 4 while t > 0: print t t -= 1 time.sleep(1) print FireAirGun() #-------------- Loop eternally. Interrupt by CTRL-C while 1: time.sleep(ShotInterval) FireAirGun() ser.close() exit()