def terminate(): print 'Interrupted' try: com.stopGun(sock) except: logging.error('could not shut down laser gun properly, connection failed'); sync.qLock.acquire() sync.queue.put( (command.TRG_OFF, None) ) sync.qLock.release() sync.terminate.set() sync.queueEvent.set() scheduler.join() listener.join() alsain.join() sys.exit(0)
def terminate(): print 'Interrupted' try: com.stopGun(sock) except: logging.error( 'could not shut down laser gun properly, connection failed') sync.qLock.acquire() sync.queue.put((command.TRG_OFF, None)) sync.qLock.release() sync.terminate.set() sync.queueEvent.set() scheduler.join() listener.join() alsain.join() sys.exit(0)
# connect to bluetooth device sock = com.connect(params.btMAC) if not sock: logging.error('connection to laser gun failed') exit(2) listener = Listener(sock) scheduler = Scheduler(params) alsain = alsaInput() scheduler.start() listener.start() alsain.start() time.sleep(1) com.stopGun(sock) if not com.resetGun(sock): terminate() if not com.calibrateGun(sock): terminate() if not com.startGun(sock): terminate() try: while True: time.sleep(0.5) if sync.disconnect.isSet(): print "disconnected :-(" sock.close() terminate() break