Exemplo n.º 1
0
#!/usr/bin/env python

import sys
from pyrf.devices.thinkrf import WSA

# connect to wsa
dut = WSA()
dut.connect(sys.argv[1])

# setup test conditions
dut.reset()
dut.request_read_perm()
dut.freq(2450e6)

# capture 1 packet
dut.capture(1024, 1)

# read until I get 1 data packet
while not dut.eof():
    pkt = dut.read()

    if pkt.is_data_packet():
        break

# print I/Q data into i and q
for i, q in pkt.data:
    print "%d,%d" % (i, q)
Exemplo n.º 2
0
    s = SweepEntry(
        fstart=100 * M,
        fstop=7900 * M,
        fstep=100 * M,
        fshift=0,
        decimation=1,
        spp=spp,
        ppb=ppb,
        )
    dut.sweep_add(s)
    captures = max(SAMPLES/spp, 1)
    dut.sweep_iterations(0) # continuous
    dut.sweep_start(spp)
    start = None
    while True:
        pkt = dut.read()
        if pkt.is_context_packet() and pkt.fields.get('sweepid') == spp:
            break
    start = time.time()
    for i in xrange(captures * ppb):
        data, context = collect_data_and_context(dut)
        if '-f' in sys.argv:
            pow_data = compute_fft(dut,data, context)

    stop = time.time()
    dut.sweep_stop()
    dut.flush()
    print 'blksize: %8d spp: %8d %6.1f GHz/second (%6d blocks, %4.1fs,  %10.1f samples/s)' % (
        spp * ppb,
        spp,
        100 * M * captures / (stop - start) / 1e9,
Exemplo n.º 3
0
freq_range = np.linspace(fstart, fstop, len(spectra_data))
stopT = time()
print(
    f"Averages = {AVERAGE}, time = {stopT-startT:2.2f} sec, len = {len(spectra_data)}"
)
plt.plot(freq_range, spectra_data, label='Sweep capture')

# %%
dut.scpiset(':sweep:list:stop')
dut.abort()
dut.flush()
dut.flush_captures()
dut.connect(addr)
#%%
dut.attenuator()
# %%
from pyrf.util import collect_data_and_context
collect_data_and_context(dut)
# %%
dut.reset()
# %%
dut.flush_captures()
# %%
dut.scpiget(':syst:capt:mode?')
# %%
dut.scpiset(':SYSTEM:ABORT')
# %%
data = dut.read()
# %%
print(data)
# %%