log_datefmt = '%d.%m.%Y %I:%M:%S' logging.basicConfig(stream=log_out, level=logging.INFO, format=log_format, datefmt=log_datefmt) log = logging.getLogger(__name__) # Our own stuff log.info("Starting up.") p = Protocol(args.device) time.sleep(2) p.setMotor(0, 2, 0) p.setMotor(1, 2, 0) p.setServo(0, 450) p.setServo(1, 450) p.getCS() p.getEN() # Run while not ctrl-c'd run = True while run: try: p.handle() k = p.read() if k != None: print k except KeyboardInterrupt: run = False print "Caught CTRL+C, stopping ..."