DEFAULT_PORT = serial_port_best_guess(prompt=True) PORT = input('PORT=? (default={}):'.format(DEFAULT_PORT)).strip() # empty input, use default if '' == PORT: PORT = DEFAULT_PORT with Serial(PORT, 115200, timeout=1) as ser: save_default_port(PORT) if is_logging(ser): r = input( 'Cannot rename logger while it is running. Stop it? (yes/no; default=no)' ) if 'yes' == r.strip(): stop_logging(ser) else: print('Terminating.') sys.exit() try: name = get_logger_name(ser) flash_id = get_flash_id(ser) print('Current logger name: {} (ID={})'.format(name, flash_id)) except UnicodeDecodeError: pass name = '' while True: newname = input('Enter new name (max. 15 characters): ')
r = input( 'Found existing config file. Overwrite? (yes/no; default=yes)' ).strip() if r.lower() not in ['yes', '']: print('No change made. Terminating.') sys.exit() # Stop logging if necessary logging.debug('Stop ongoing logging if necessary...') try: if is_logging(ser): r = input( 'Logger is still logging. Stop it first? (yes/no; default=yes)' ) if r.strip().lower() in ['yes', '']: if not stop_logging(ser, maxretry=20): logging.error( 'Logger is still logging and is not responding to stop_logging. Terminating.' ) sys.exit() else: logging.error( 'Logger must be stopped before it can be restarted. Terminating.' ) sys.exit() except InvalidResponseException: logging.error('Cannot verify logger status. Terminating.') sys.exit() # Verify that it is indeed not logging assert not is_logging(ser)
def stop_plotting(self): common.stop_logging() self.plot = False
# empty input, use default if '' == PORT: PORT = DEFAULT_PORT with Serial(PORT, 115200, timeout=2) as ser: ser.reset_input_buffer() ser.reset_output_buffer() ser.write(b'\n\n\n') stop_logging_time = None if is_logging(ser): r = input('Logger is still logging. Stop logging? (yes/no; default=no)') if r.strip().lower() == 'yes': if not stop_logging(ser): print('Could not stop logger. Terminating.') sys.exit() stop_logging_time = time.time() else: print('No change made. Terminating.') sys.exit() save_default_port(PORT) try: logger_name = get_logger_name(ser) print('Name: {}'.format(logger_name)) flash_id = get_flash_id(ser) print('ID: {}'.format(flash_id))