#!/usr/bin/env python from gnuradio import gr, gru, eng_notation from gnuradio import usrp from gnuradio.eng_option import eng_option from optparse import OptionParser import usrp_dbid import time import os.path import struct fg=gr.flow_graph() ### Create the USRP ### u = usrp.source_c(0, decim_rate=256) ### determine the daughterboard subdevice we're using ### rx_subdev_spec = usrp.pick_subdev(u, (usrp_dbid.TV_RX,)) u.set_mux(usrp.determine_rx_mux_value(u, rx_subdev_spec)) subdev = usrp.selected_subdev(u, rx_subdev_spec) #### set initial values # Set gain # Gain is 0 to 115, in steps of 1 g_range = subdev.gain_range() subdev.set_gain(50) # Set frequency to mid-point # Frequency is 500MHz to 2.6GHZ, in steps of 1MHz f_range = subdev.freq_range() freq = 100e6 # frequency to tune to r = u.tune(0, subdev, freq) # 0 is DDC channel #Vector sink #sink = gr.file_sink(gr.sizeof_float, "signal_samples.dat") #Set number of samples nsamples = 2000 #Complex to Float Conversion c2f=gr.complex_to_float() head = gr.head(gr.sizeof_float, int(nsamples)) #Wiring it all together fg.connect(u, c2f, head, sink) fg.start() #Read in num_samples at a time, and display the average #fin = open("signal_samples.dat", 'rb') #Dump the first set of samples as they will be erroneous (bug in USRP) #fin.read(2 * nsamples * gr.sizeof_short) #fin.close() #Stop the graph fg.stop()