if plotrange[0] == -1: plotrange = (0, EXPECTED_FREQS) if (plotrange[1] != -1) and (plotrange[1] <= plotrange[0]): raise RuntimeError('Plot range of %s is incorrect.' % str(plotrange)) plotrange = (int(plotrange[0]), int(plotrange[1])) def exit_gracefully(_, __): fpga.disconnect() sys.exit(0) signal.signal(signal.SIGINT, exit_gracefully) # make the FPGA object fpga = FpgaFHost(hostname) time.sleep(0.5) fpga.get_system_information() # set the FFT shift if args.fftshift != -1: fpga.registers.fft_shift.write_int(args.fftshift) current_fft_shift = fpga.registers.fft_shift.read()['data']['fft_shift'] print 'Current FFT shift for %s is %i.' % (fpga.host, current_fft_shift) # check the size of the snapshot blocks snap0 = fpga.snapshots.snap_quant0_ss nsamples = int(snap0.block_info['snap_nsamples']) dwidth = int(snap0.block_info['snap_data_width']) snapshot_bytes = (2**nsamples) * (dwidth/8) print 'Snapshot is %i bytes long' % snapshot_bytes snapshot_samples = (2**nsamples) * 4 print 'Snapshot is %i samples long' % snapshot_samples
if 'CORR2INI' in os.environ.keys() and args.config == '': args.config = os.environ['CORR2INI'] if args.config != '': host_list = utils.parse_hosts(args.config, section='fengine') else: host_list = [] try: hostname = host_list[int(args.host)] logging.info('Got hostname %s from config file.' % hostname) except ValueError: hostname = args.host f = FpgaFHost(hostname) f.get_system_information() # read the config config = utils.parse_ini_file(args.config) n_chans = int(config['fengine']['n_chans']) n_xhost = len(config['xengine']['hosts'].split(',')) x_per_host = int(config['xengine']['x_per_fpga']) NUM_FREQ = n_chans FREQS_PER_X = NUM_FREQ / (n_xhost * x_per_host) EXPECTED_PKT_LEN = 128 + 10 ips_and_freqs = {} spectrum_total = [[0] * NUM_FREQ, [0] * NUM_FREQ] spectrum_count = [[0] * NUM_FREQ, [0] * NUM_FREQ]