Exemplo n.º 1
0
    save_default_port(PORT)

    # Prepare config file
    makedirs(join('data', flash_id), exist_ok=True)
    if exists(join('data', flash_id, flash_id + '.config')):
        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:
Exemplo n.º 2
0
# find the serial port to use from user, from history, or make a guess
# if on Windows, print the list of COM ports
from common import serial_port_best_guess, save_default_port

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:
Exemplo n.º 3
0
DEFAULT_PORT = serial_port_best_guess(prompt=True)
print('- - -')
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)

    while True:
        try:
            name = get_logger_name(ser)
            flash_id = get_flash_id(ser)
            running = is_logging(ser)
            vbatt = read_vbatt(ser)
            rtc = read_rtc(ser)
            r = get_logging_config(ser)
            logging_start_time = r['logging_start_time']
            logging_stop_time = r['logging_stop_time']

            running = 'Logging' if running else 'Not logging'

            if logging_start_time > 0:
                if logging_stop_time > logging_start_time:
                    r = 'Contains data from {} to {}'.format(
                        ts2dt(logging_start_time), ts2dt(logging_stop_time))
                else:
                    r = 'Contains data from {} (no stop record)'.format(
                        ts2dt(logging_start_time))