def _MainLoop(self): try: ping_message = kegboard.PingCommand() print('Waiting for a kegboard ...') board = kegboard.wait_for_kegboard() print('Found: %s' % board) print('Listening to board ...') board.open() try: while not self._do_quit: for relay in range(4): for mode in (1, 0): cmd = kegboard.SetOutputCommand() cmd.SetValue('output_id', relay) cmd.SetValue('output_mode', mode) self._logger.info('Sending relay command: %s' % cmd) board.write_message(cmd) for m in board.drain_messages(): self._logger.info(m) time.sleep(1.0) except IOError as e: print('Error, closing board: %s' % e) print('') finally: board.close_quietly() except KeyboardInterrupt: return
def _MainLoop(self): try: ping_message = kegboard.PingCommand() print 'Waiting for a kegboard ...' board = kegboard.wait_for_kegboard() print 'Found: %s' % board print 'Listening to board ...' board.open() try: while not self._do_quit: for relay in range(4): for mode in (1, 0): cmd = kegboard.SetOutputCommand() cmd.SetValue('output_id', relay) cmd.SetValue('output_mode', mode) self._logger.info('Sending relay command: %s' % cmd) board.write_message(cmd) for m in board.drain_messages(): self._logger.info(m) time.sleep(1.0) except IOError, e: print 'Error, closing board: %s' % e print '' finally: board.close_quietly()
def _MainLoop(self): try: while True: print 'Waiting for a kegboard ...' board = kegboard.wait_for_kegboard() print 'Found: %s' % board print 'Listening to board ...' board.open() try: while True: print board.read_message() except IOError, e: print 'Error, closing board: %s' % e print '' finally: board.close_quietly()
def _MainLoop(self): try: while True: print('Waiting for a kegboard ...') board = kegboard.wait_for_kegboard() print('Found: %s' % board) print('Listening to board ...') board.open() try: while True: print(board.read_message()) except IOError as e: print('Error, closing board: %s' % e) print('') finally: board.close_quietly() except KeyboardInterrupt: return