Created
June 5, 2017 12:44
-
-
Save anonymous/d3c0c9f1f72ab7cdc2c3460126682bc6 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from gnuradio import blocks | |
from gnuradio import gr | |
from gnuradio import uhd | |
import random | |
sample_rate = int(2e6) | |
num_acquisition = 1000 | |
class simple_acquirer(gr.top_block): | |
def __init__(self, sdr): | |
gr.top_block.__init__( | |
self, "Simple acquirer", | |
) | |
self.sdr = sdr | |
self.head = blocks.head(gr.sizeof_gr_complex * 1, int(1 * sample_rate)) | |
self.sink = blocks.null_sink(gr.sizeof_gr_complex * 1) | |
self.connect((self.sdr, 0), (self.head, 0)) | |
self.connect((self.head, 0), (self.sink, 0)) | |
sdr = uhd.usrp_source( | |
"", | |
uhd.stream_args( | |
cpu_format="fc32", | |
otw_format="fc32", | |
channels=range(1), | |
), | |
) | |
sdr.set_clock_source("gpsdo") | |
sdr.set_samp_rate(sample_rate) | |
sdr.set_gain(56, 0) | |
sdr.set_antenna("RX2", 0) | |
sdr.set_bandwidth(2e6, 0) | |
receiver = simple_acquirer(sdr) | |
for i in range(num_acquisition): | |
freq = random.randint(1e9, 2e9) | |
print("Tuning to {0} MHz".format(freq / 1e6)) | |
dummy = sdr.set_center_freq(freq) | |
receiver.start() | |
receiver.wait() | |
receiver.stop() | |
print("Acquisition N° {0} finished\n".format(i)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment