コード例 #1
0
def read_battery_voltage(ent):
    logging.debug('get_vbatt')
    with Serial(PORT, 115200, timeout=1) as ser:
        ent.config(state='normal')
        ent.delete(0, tk.END)
        ent.insert(0, '{} V'.format(read_vbatt(ser)))
        ent.config(state='readonly')
コード例 #2
0
 def get_vbatt(self):
     logging.debug('get_vbatt')
     with Serial(PORT, 115200, timeout=1) as ser:
         self.label1.set(str(read_vbatt(ser)) + 'V')
コード例 #3
0
        save_default_port(PORT)

        print('Looking for logger...')
        if is_logging(ser):
            r = input('Logger is logging. Stop it? (yes/no; default=no)')
            if r.strip().lower() in ['yes']:
                logging.debug('User wants to stop logging.')
                ser.write(b'stop_logging')
            else:
                print('This script cannot proceed while logger is still running. ABORT.')
                sys.exit()

        logger_name = get_logger_name(ser)
        flash_id = get_flash_id(ser)
        vbatt = read_vbatt(ser)
        rtc = read_rtc(ser)
        config = get_logging_config(ser)
        logging_start_time = config['logging_start_time']
        sample_interval_second = SAMPLE_INTERVAL_CODE_MAP[config['logging_interval_code']]

        print('Logger "{}" (ID={})'.format(logger_name, flash_id))
        print('Battery voltage {:.1f} V, clock {}'.format(vbatt, ts2dt(rtc)))
        print('Scanning logger memory...', end='', flush=True)
        sample_count = get_sample_count(ser)
        if 0 == sample_count:
            print(' Logger is empty. Terminating.')
            sys.exit()

        number_to_read = min(DOWNSAMPLE_N, sample_count)
        STRIDE = int(sample_count // number_to_read)
コード例 #4
0
        config = {}
        if exists(configfilename):
            config = json.loads(open(configfilename).read())
        else:
            logging.warning('No existing config file.')
        config['logger_name'] = logger_name
        config['flash_id'] = flash_id
        config['logging_start_time'] = metadata['logging_start_time']
        config['logging_stop_time'] = metadata['logging_stop_time']
        config['logging_interval_code'] = metadata['logging_interval_code']
        if stop_logging_time is not None:
            config['stop_logging_time'] = stop_logging_time
        else:
            if 'stop_logging_time' in config:
                del config['stop_logging_time']     # remove old record if any
        config['vbatt_post'] = read_vbatt(ser)
        logging.debug(config)
        open(configfilename, 'w').write(json.dumps(config, separators=(',', ':')))

        print('Sample interval = {} second'.format(SAMPLE_INTERVAL_CODE_MAP[config['logging_interval_code']]))

        fn = '{}_{}.bin'.format(flash_id, metadata['logging_start_time'])
        fn = join('data', flash_id, fn)
        if exists(fn):
            r = input(fn + ' already exists. Overwrite? (yes/no; default=no)')
            if r.strip().lower() != 'yes':
                print('No change made. Terminating.')
                sys.exit()

        starttime = time.time()
        with open(fn, 'wb') as fout: