Example #1
0
    def __init__(self):
        gr.top_block.__init__(self)

        usage = "usage: %prog [options] host min_freq max_freq"
        parser = OptionParser(option_class=eng_option, usage=usage)
        parser.add_option("-g", "--gain", type="eng_float", default=None,
                          help="set gain in dB (default is midpoint)")
        parser.add_option("", "--tune-delay", type="eng_float", default=5e-5, metavar="SECS",
                          help="time to delay (in seconds) after changing frequency [default=%default]")
        parser.add_option("", "--dwell-delay", type="eng_float", default=50e-5, metavar="SECS",
                          help="time to dwell (in seconds) at a given frequncy [default=%default]")
        parser.add_option("-F", "--fft-size", type="int", default=256,
                          help="specify number of FFT bins [default=%default]")
        parser.add_option("-d", "--decim", type="intx", default=16,
                          help="set decimation to DECIM [default=%default]")
        parser.add_option("", "--real-time", action="store_true", default=False,
                          help="Attempt to enable real-time scheduling")

        (options, args) = parser.parse_args()
        if len(args) != 3:
            parser.print_help()
            sys.exit(1)

        self.address  = args[0]
        self.min_freq = eng_notation.str_to_num(args[1])
        self.max_freq = eng_notation.str_to_num(args[2])

        self.decim = options.decim
        self.gain  = options.gain
        
        if self.min_freq > self.max_freq:
            self.min_freq, self.max_freq = self.max_freq, self.min_freq   # swap them

	self.fft_size = options.fft_size

        if not options.real_time:
            realtime = False
        else:
            # Attempt to enable realtime scheduling
            r = gr.enable_realtime_scheduling()
            if r == gr.RT_OK:
                realtime = True
            else:
                realtime = False
                print "Note: failed to enable realtime scheduling"

        adc_rate = 102.4e6
        self.int_rate = adc_rate / self.decim
        print "Sampling rate: ", self.int_rate

        # build graph
        self.port = 10001
        self.src = msdd.source_simple(self.address, self.port)
        self.src.set_decim_rate(self.decim)

        self.set_gain(self.gain)
        self.set_freq(self.min_freq)

	s2v = gr.stream_to_vector(gr.sizeof_gr_complex, self.fft_size)

        mywindow = window.blackmanharris(self.fft_size)
        fft = gr.fft_vcc(self.fft_size, True, mywindow, True)
        power = 0
        for tap in mywindow:
            power += tap*tap
        
        norm = gr.multiply_const_cc(1.0/self.fft_size)
        c2mag = gr.complex_to_mag_squared(self.fft_size)

        # FIXME the log10 primitive is dog slow
        log = gr.nlog10_ff(10, self.fft_size,
                           -20*math.log10(self.fft_size)-10*math.log10(power/self.fft_size))
		
        # Set the freq_step to % of the actual data throughput.
        # This allows us to discard the bins on both ends of the spectrum.
        self.percent = 0.4

        self.freq_step = self.percent * self.int_rate
        self.min_center_freq = self.min_freq + self.freq_step/2
        nsteps = math.ceil((self.max_freq - self.min_freq) / self.freq_step)
        self.max_center_freq = self.min_center_freq + (nsteps * self.freq_step)

        self.next_freq = self.min_center_freq
        
        tune_delay  = max(0, int(round(options.tune_delay * self.int_rate / self.fft_size)))  # in fft_frames
        dwell_delay = max(1, int(round(options.dwell_delay * self.int_rate / self.fft_size))) # in fft_frames

        self.msgq = gr.msg_queue(16)
        self._tune_callback = tune(self)        # hang on to this to keep it from being GC'd
        stats = gr.bin_statistics_f(self.fft_size, self.msgq,
                                    self._tune_callback, tune_delay, dwell_delay)

        # FIXME leave out the log10 until we speed it up
	self.connect(self.src, s2v, fft, c2mag, log, stats)
#!/usr/bin/python

from pylab import *;
#from scipy.fftpack import fftshift;

import math;

from gnuradio import msdd,gr;


tb = gr.top_block();


src = msdd.source_simple("10.45.4.43",0);
convert = gr.interleaved_short_to_complex();
sink = gr.vector_sink_c();

gain = 40;

fc = 2.4e9;

src.set_decim_rate(8);
#src.set_rx_freq(0,3500000000);
src.set_rx_freq(0,fc);
src.set_pga(0,gain);


tb.connect(src, convert, sink);


tb.start();
    def __init__(self):
        gr.top_block.__init__(self)

        # Build an options parser to bring in information from the user on usage
        usage = "usage: %prog [options] host min_freq max_freq"
        parser = OptionParser(option_class=eng_option, usage=usage)
        parser.add_option("-g", "--gain", type="eng_float", default=32,
                          help="set gain in dB (default is midpoint)")
        parser.add_option("", "--tune-delay", type="eng_float", default=5e-5, metavar="SECS",
                          help="time to delay (in seconds) after changing frequency [default=%default]")
        parser.add_option("", "--dwell-delay", type="eng_float", default=50e-5, metavar="SECS",
                          help="time to dwell (in seconds) at a given frequncy [default=%default]")
        parser.add_option("-F", "--fft-size", type="int", default=256,
                          help="specify number of FFT bins [default=%default]")
        parser.add_option("-d", "--decim", type="intx", default=16,
                          help="set decimation to DECIM [default=%default]")
        parser.add_option("", "--real-time", action="store_true", default=False,
                          help="Attempt to enable real-time scheduling")

        (options, args) = parser.parse_args()
        if len(args) != 3:
            parser.print_help()
            sys.exit(1)

        # get user-provided info on address of MSDD and frequency to sweep
        self.address  = args[0]
        self.min_freq = eng_notation.str_to_num(args[1])
        self.max_freq = eng_notation.str_to_num(args[2])

        self.decim = options.decim
        self.gain  = options.gain
        
        if self.min_freq > self.max_freq:
            self.min_freq, self.max_freq = self.max_freq, self.min_freq   # swap them

	self.fft_size = options.fft_size

        if not options.real_time:
            realtime = False
        else:
            # Attempt to enable realtime scheduling
            r = gr.enable_realtime_scheduling()
            if r == gr.RT_OK:
                realtime = True
            else:
                realtime = False
                print "Note: failed to enable realtime scheduling"

        # Sampling rate is hardcoded and cannot be read off device
        adc_rate = 102.4e6
        self.int_rate = adc_rate / self.decim
        print "Sampling rate: ", self.int_rate

        # build graph
        self.port = 10001   # required port for UDP packets
	
	#	which board,	op mode,	adx,	port
#        self.src = msdd.source_c(0, 1, self.address, self.port)  # build source object

	self.conv = gr.interleaved_short_to_complex();

	self.src = msdd.source_simple(self.address,self.port);
        self.src.set_decim_rate(self.decim)                      # set decimation rate
#        self.src.set_desired_packet_size(0, 1460)                # set packet size to collect

        self.set_gain(self.gain)                                 # set receiver's attenuation
        self.set_freq(self.min_freq)                             # set receiver's rx frequency
        
        # restructure into vector format for FFT input
	s2v = gr.stream_to_vector(gr.sizeof_gr_complex, self.fft_size)

        # set up FFT processing block
        mywindow = window.blackmanharris(self.fft_size)
        fft = gr.fft_vcc(self.fft_size, True, mywindow, True)
        power = 0
        for tap in mywindow:
            power += tap*tap
        
        # calculate magnitude squared of output of FFT
        c2mag = gr.complex_to_mag_squared(self.fft_size)

        # FIXME the log10 primitive is dog slow
        log = gr.nlog10_ff(10, self.fft_size,
                           -20*math.log10(self.fft_size)-10*math.log10(power/self.fft_size))
		
        # Set the freq_step to % of the actual data throughput.
        # This allows us to discard the bins on both ends of the spectrum.
        self.percent = 0.4

        # Calculate the frequency steps to use in the collection over the whole bandwidth
        self.freq_step = self.percent * self.int_rate
        self.min_center_freq = self.min_freq + self.freq_step/2
        nsteps = math.ceil((self.max_freq - self.min_freq) / self.freq_step)
        self.max_center_freq = self.min_center_freq + (nsteps * self.freq_step)

        self.next_freq = self.min_center_freq
        
        # use these values to set receiver settling time between samples and sampling time
        # the default values provided seem to work well with the MSDD over 100 Mbps ethernet
        tune_delay  = max(0, int(round(options.tune_delay * self.int_rate / self.fft_size)))  # in fft_frames
        dwell_delay = max(1, int(round(options.dwell_delay * self.int_rate / self.fft_size))) # in fft_frames

        # set up message callback routine to get data from bin_statistics_f block
        self.msgq = gr.msg_queue(16)
        self._tune_callback = tune(self)        # hang on to this to keep it from being GC'd

        # FIXME this block doesn't like to work with negatives because of the "d_max[i]=0" on line
        # 151 of gr_bin_statistics_f.cc file. Set this to -10000 or something to get it to work.
        stats = gr.bin_statistics_f(self.fft_size, self.msgq,
                                    self._tune_callback, tune_delay, dwell_delay)

        # FIXME there's a concern over the speed of the log calculation
        # We can probably calculate the log inside the stats block
	self.connect(self.src, self.conv, s2v, fft, c2mag, log, stats)
Example #4
0
    def __init__(self, frame, panel, vbox, argv):
        stdgui2.std_top_block.__init__(self, frame, panel, vbox, argv)

        self.frame = frame
        self.panel = panel
        
        parser = OptionParser(option_class=eng_option)
        parser.add_option("-w", "--which", type="int", default=0,
                          help="select which MSDD (0, 1, ...) default is %default",
			  metavar="NUM")
        parser.add_option("-R", "--rx-subdev-spec", type="subdev", default=None,
                          help="select MSDD Rx side A or B (default=first one with a daughterboard)")
        parser.add_option("-A", "--antenna", default=None,
                          help="select Rx Antenna (only on RFX-series boards)")
        parser.add_option("-d", "--decim", type="int", default=16,
                          help="set fgpa decimation rate to DECIM [default=%default]")
        parser.add_option("-f", "--freq", type="eng_float", default=None,
                          help="set frequency to FREQ", metavar="FREQ")
        parser.add_option("-g", "--gain", type="eng_float", default=None,
                          help="set gain in dB (default is midpoint)")
        parser.add_option("-W", "--waterfall", action="store_true", default=False,
                          help="Enable waterfall display")
        parser.add_option("-8", "--width-8", action="store_true", default=False,
                          help="Enable 8-bit samples across USB")
        parser.add_option("-S", "--oscilloscope", action="store_true", default=False,
                          help="Enable oscilloscope display")
        (options, args) = parser.parse_args()
        if len(args) != 0:
            parser.print_help()
            sys.exit(1)

        self.show_debug_info = True
        
        # build the graph

        #self.u = MSDD.source_simo(which=options.which, decim_rate=options.decim)
        self.u = msdd.source_simple("192.168.1.200", 0)
        self.u.set_decim_rate(options.decim) #(16)

#        msdd_src = gr.file_source(gr.sizeof_gr_complex, 'msdd.dat')
#        thr = gr.throttle(gr.sizeof_gr_complex, 200000)
#        self.connect(msdd_src, thr)

#        if options.rx_subdev_spec is None:
#           options.rx_subdev_spec = pick_subdevice(self.u)
#        self.u.set_mux(MSDD.determine_rx_mux_value(self.u, options.rx_subdev_spec))

#        if options.width_8:
#            width = 8
#            shift = 8
#            format = self.u.make_format(width, shift)
#            print "format =", hex(format)
#            r = self.u.set_format(format)
#            print "set_format =", r
            
        # determine the daughterboard subdevice we're using
#        self.subdev = MSDD.selected_subdev(self.u, options.rx_subdev_spec)

#        print "Initial Freq", self.u.rx_freq(0), "deci: ", self.u.decim_rate()
#        input_rate = 50e6 / self.u.decim_rate()
        input_rate = 50e6 / options.decim;

        if options.waterfall:
            self.scope = \
              waterfallsink2.waterfall_sink_c (panel, fft_size=1024, sample_rate=input_rate)
        elif options.oscilloscope:
            self.scope = scopesink2.scope_sink_c(panel, sample_rate=input_rate)
        else:
            self.scope = fftsink2.fft_sink_c (panel, fft_size=1024, sample_rate=input_rate)

#        self.connect(self.u, self.scope)
               
        msdd_sink = gr.file_sink(gr.sizeof_gr_complex, 'schmen1.dat')
	
	self.conv = gr.interleaved_short_to_complex();
        self.connect(self.u, self.conv,  msdd_sink)
        self._build_gui(vbox)

        # set initial values

        if options.gain is None:
            # if no gain was specified, use the mid-point in dB
            #g = self.subdev.gain_range()
            self.gain_range = (20,70,.5);
	    options.gain = float(self.gain_range[0]+self.gain_range[1])/2

        if options.freq is None:
            # if no freq was specified, use the mid-point
            #r = self.subdev.freq_range()
	    r = (30e6,6e9,1e6)
            options.freq = float(r[0]+r[1])/2

        self.set_gain(options.gain)
#
#	if options.antenna is not None:
#            print "Selecting antenna %s" % (options.antenna,)
#            self.subdev.select_rx_antenna(options.antenna)

        if self.show_debug_info:
            #self.myform['decim'].set_value(self.u.decim_rate())
            self.myform['decim'].set_value(options.decim)
 #           self.myform['fs@usb'].set_value(self.u.adc_freq() / self.u.decim_rate())
 #           self.myform['dbname'].set_value(self.subdev.name())
            self.myform['baseband'].set_value(0)
            self.myform['ddc'].set_value(0)

        if not(self.set_freq(options.freq)):
            self._set_status_msg("Failed to set initial frequency")
Example #5
0
    def __init__(self, frame, panel, vbox, argv):
        stdgui2.std_top_block.__init__(self, frame, panel, vbox, argv)

        self.frame = frame
        self.panel = panel
        
        parser = OptionParser(option_class=eng_option)
        parser.add_option("-w", "--which", type="int", default=0,
                          help="select which USRP (0, 1, ...) default is %default",
			  metavar="NUM")
        parser.add_option("-R", "--rx-subdev-spec", type="subdev", default=None,
                          help="select USRP Rx side A or B (default=first one with a daughterboard)")
        parser.add_option("-A", "--antenna", default=None,
                          help="select Rx Antenna (only on RFX-series boards)")
        parser.add_option("-d", "--decim", type="int", default=16,
                          help="set fgpa decimation rate to DECIM [default=%default]")
        parser.add_option("-f", "--freq", type="eng_float", default=None,
                          help="set frequency to FREQ", metavar="FREQ")
        parser.add_option("-g", "--gain", type="eng_float", default=None,
                          help="set gain in dB (default is midpoint)")
        parser.add_option("-W", "--waterfall", action="store_true", default=False,
                          help="Enable waterfall display")
        parser.add_option("-8", "--width-8", action="store_true", default=False,
                          help="Enable 8-bit samples across USB")
        parser.add_option( "--no-hb", action="store_true", default=False,
                          help="don't use halfband filter in usrp")
        parser.add_option("-S", "--oscilloscope", action="store_true", default=False,
                          help="Enable oscilloscope display")
	parser.add_option("", "--avg-alpha", type="eng_float", default=1e-1,
			  help="Set fftsink averaging factor, default=[%default]")
	parser.add_option("", "--ref-scale", type="eng_float", default=13490.0,
			  help="Set dBFS=0dB input value, default=[%default]")
        (options, args) = parser.parse_args()
        if len(args) != 0:
            parser.print_help()
            sys.exit(1)
	self.options = options
        self.show_debug_info = True
        
        # build the graph
        if options.no_hb or (options.decim<8):
          #Min decimation of this firmware is 4. 
          #contains 4 Rx paths without halfbands and 0 tx paths.
          self.fpga_filename="std_4rx_0tx.rbf"
#          self.u = usrp.source_c(which=options.which, decim_rate=options.decim, fpga_filename=self.fpga_filename)
	  self.u = msdd.source_simple("192.168.1.200",0);
        else:
          #Min decimation of standard firmware is 8. 
          #standard fpga firmware "std_2rxhb_2tx.rbf" 
          #contains 2 Rx paths with halfband filters and 2 tx paths (the default)
          #self.u = usrp.source_c(which=options.which, decim_rate=options.decim)
	  self.u = msdd.source_simple("192.168.1.200",0);

            
        input_rate = self.u.adc_freq() / self.u.decim_rate()

        if options.waterfall:
            self.scope = \
              waterfallsink2.waterfall_sink_c (panel, fft_size=1024, sample_rate=input_rate)
        elif options.oscilloscope:
            self.scope = scopesink2.scope_sink_c(panel, sample_rate=input_rate)
        else:
            self.scope = fftsink2.fft_sink_c (panel, fft_size=1024, sample_rate=input_rate, 
					      ref_scale=options.ref_scale, ref_level=0.0, y_divs = 10,
					      avg_alpha=options.avg_alpha)

	self.conv = gr.interleaved_short_to_complex();
        self.connect(self.u, self.conv,  self.scope)

        self._build_gui(vbox)
	self._setup_events()
	
        # set initial values

        if options.gain is None:
            # if no gain was specified, use the mid-point in dB
            #g = self.subdev.gain_range()
            #g = self.u.gain_range()
            g = [0,10]
            options.gain = float(g[0]+g[1])/2

        if options.freq is None:
            # if no freq was specified, use the mid-point
            #r = self.subdev.freq_range()
            #r = self.u.freq_range()
	    r = [30e6, 6e9]
            options.freq = float(r[0]+r[1])/2

        self.set_gain(options.gain)

	if options.antenna is not None:
            print "Selecting antenna %s" % (options.antenna,)
            self.subdev.select_rx_antenna(options.antenna)

        if self.show_debug_info:
            self.myform['decim'].set_value(self.u.decim_rate())
            self.myform['fs@usb'].set_value(self.u.adc_freq() / self.u.decim_rate())
            self.myform['dbname'].set_value("no subdevs used")
            self.myform['baseband'].set_value(0)
            self.myform['ddc'].set_value(0)

        if not(self.set_freq(options.freq)):
            self._set_status_msg("Failed to set initial frequency")
#!/usr/bin/python

from pylab import *
#from scipy.fftpack import fftshift;

import math

from gnuradio import msdd, gr

tb = gr.top_block()

src = msdd.source_simple("10.45.4.43", 0)
convert = gr.interleaved_short_to_complex()
sink = gr.vector_sink_c()

gain = 40

fc = 2.4e9

src.set_decim_rate(8)
#src.set_rx_freq(0,3500000000);
src.set_rx_freq(0, fc)
src.set_pga(0, gain)

tb.connect(src, convert, sink)

tb.start()

v = []
for i in range(0, 10000):
    b = math.sqrt(i)
Example #7
0
    def __init__(self, frame, panel, vbox, argv):
        stdgui2.std_top_block.__init__(self, frame, panel, vbox, argv)

        self.frame = frame
        self.panel = panel

        parser = OptionParser(option_class=eng_option)
        parser.add_option(
            "-w",
            "--which",
            type="int",
            default=0,
            help="select which MSDD (0, 1, ...) default is %default",
            metavar="NUM")
        parser.add_option(
            "-R",
            "--rx-subdev-spec",
            type="subdev",
            default=None,
            help=
            "select MSDD Rx side A or B (default=first one with a daughterboard)"
        )
        parser.add_option("-A",
                          "--antenna",
                          default=None,
                          help="select Rx Antenna (only on RFX-series boards)")
        parser.add_option(
            "-d",
            "--decim",
            type="int",
            default=16,
            help="set fgpa decimation rate to DECIM [default=%default]")
        parser.add_option("-f",
                          "--freq",
                          type="eng_float",
                          default=None,
                          help="set frequency to FREQ",
                          metavar="FREQ")
        parser.add_option("-g",
                          "--gain",
                          type="eng_float",
                          default=None,
                          help="set gain in dB (default is midpoint)")
        parser.add_option("-W",
                          "--waterfall",
                          action="store_true",
                          default=False,
                          help="Enable waterfall display")
        parser.add_option("-8",
                          "--width-8",
                          action="store_true",
                          default=False,
                          help="Enable 8-bit samples across USB")
        parser.add_option("-S",
                          "--oscilloscope",
                          action="store_true",
                          default=False,
                          help="Enable oscilloscope display")
        (options, args) = parser.parse_args()
        if len(args) != 0:
            parser.print_help()
            sys.exit(1)

        self.show_debug_info = True

        # build the graph

        #self.u = MSDD.source_simo(which=options.which, decim_rate=options.decim)
        self.u = msdd.source_simple("192.168.1.200", 0)
        self.u.set_decim_rate(options.decim)  #(16)

        #        msdd_src = gr.file_source(gr.sizeof_gr_complex, 'msdd.dat')
        #        thr = gr.throttle(gr.sizeof_gr_complex, 200000)
        #        self.connect(msdd_src, thr)

        #        if options.rx_subdev_spec is None:
        #           options.rx_subdev_spec = pick_subdevice(self.u)
        #        self.u.set_mux(MSDD.determine_rx_mux_value(self.u, options.rx_subdev_spec))

        #        if options.width_8:
        #            width = 8
        #            shift = 8
        #            format = self.u.make_format(width, shift)
        #            print "format =", hex(format)
        #            r = self.u.set_format(format)
        #            print "set_format =", r

        # determine the daughterboard subdevice we're using
        #        self.subdev = MSDD.selected_subdev(self.u, options.rx_subdev_spec)

        #        print "Initial Freq", self.u.rx_freq(0), "deci: ", self.u.decim_rate()
        #        input_rate = 50e6 / self.u.decim_rate()
        input_rate = 50e6 / options.decim

        if options.waterfall:
            self.scope = \
              waterfallsink2.waterfall_sink_c (panel, fft_size=1024, sample_rate=input_rate)
        elif options.oscilloscope:
            self.scope = scopesink2.scope_sink_c(panel, sample_rate=input_rate)
        else:
            self.scope = fftsink2.fft_sink_c(panel,
                                             fft_size=1024,
                                             sample_rate=input_rate)


#        self.connect(self.u, self.scope)

        msdd_sink = gr.file_sink(gr.sizeof_gr_complex, 'schmen1.dat')

        self.conv = gr.interleaved_short_to_complex()
        self.connect(self.u, self.conv, msdd_sink)
        self._build_gui(vbox)

        # set initial values

        if options.gain is None:
            # if no gain was specified, use the mid-point in dB
            #g = self.subdev.gain_range()
            self.gain_range = (20, 70, .5)
            options.gain = float(self.gain_range[0] + self.gain_range[1]) / 2

        if options.freq is None:
            # if no freq was specified, use the mid-point
            #r = self.subdev.freq_range()
            r = (30e6, 6e9, 1e6)
            options.freq = float(r[0] + r[1]) / 2

        self.set_gain(options.gain)
        #
        #	if options.antenna is not None:
        #            print "Selecting antenna %s" % (options.antenna,)
        #            self.subdev.select_rx_antenna(options.antenna)

        if self.show_debug_info:
            #self.myform['decim'].set_value(self.u.decim_rate())
            self.myform['decim'].set_value(options.decim)
            #           self.myform['fs@usb'].set_value(self.u.adc_freq() / self.u.decim_rate())
            #           self.myform['dbname'].set_value(self.subdev.name())
            self.myform['baseband'].set_value(0)
            self.myform['ddc'].set_value(0)

        if not (self.set_freq(options.freq)):
            self._set_status_msg("Failed to set initial frequency")
    def __init__(self):
        gr.top_block.__init__(self)

        # Build an options parser to bring in information from the user on usage
        usage = "usage: %prog [options] host min_freq max_freq"
        parser = OptionParser(option_class=eng_option, usage=usage)
        parser.add_option("-g",
                          "--gain",
                          type="eng_float",
                          default=32,
                          help="set gain in dB (default is midpoint)")
        parser.add_option(
            "",
            "--tune-delay",
            type="eng_float",
            default=5e-5,
            metavar="SECS",
            help=
            "time to delay (in seconds) after changing frequency [default=%default]"
        )
        parser.add_option(
            "",
            "--dwell-delay",
            type="eng_float",
            default=50e-5,
            metavar="SECS",
            help=
            "time to dwell (in seconds) at a given frequncy [default=%default]"
        )
        parser.add_option("-F",
                          "--fft-size",
                          type="int",
                          default=256,
                          help="specify number of FFT bins [default=%default]")
        parser.add_option("-d",
                          "--decim",
                          type="intx",
                          default=16,
                          help="set decimation to DECIM [default=%default]")
        parser.add_option("",
                          "--real-time",
                          action="store_true",
                          default=False,
                          help="Attempt to enable real-time scheduling")

        (options, args) = parser.parse_args()
        if len(args) != 3:
            parser.print_help()
            sys.exit(1)

        # get user-provided info on address of MSDD and frequency to sweep
        self.address = args[0]
        self.min_freq = eng_notation.str_to_num(args[1])
        self.max_freq = eng_notation.str_to_num(args[2])

        self.decim = options.decim
        self.gain = options.gain

        if self.min_freq > self.max_freq:
            self.min_freq, self.max_freq = self.max_freq, self.min_freq  # swap them

        self.fft_size = options.fft_size

        if not options.real_time:
            realtime = False
        else:
            # Attempt to enable realtime scheduling
            r = gr.enable_realtime_scheduling()
            if r == gr.RT_OK:
                realtime = True
            else:
                realtime = False
                print "Note: failed to enable realtime scheduling"

        # Sampling rate is hardcoded and cannot be read off device
        adc_rate = 102.4e6
        self.int_rate = adc_rate / self.decim
        print "Sampling rate: ", self.int_rate

        # build graph
        self.port = 10001  # required port for UDP packets

        #	which board,	op mode,	adx,	port
        #        self.src = msdd.source_c(0, 1, self.address, self.port)  # build source object

        self.conv = gr.interleaved_short_to_complex()

        self.src = msdd.source_simple(self.address, self.port)
        self.src.set_decim_rate(self.decim)  # set decimation rate
        #        self.src.set_desired_packet_size(0, 1460)                # set packet size to collect

        self.set_gain(self.gain)  # set receiver's attenuation
        self.set_freq(self.min_freq)  # set receiver's rx frequency

        # restructure into vector format for FFT input
        s2v = gr.stream_to_vector(gr.sizeof_gr_complex, self.fft_size)

        # set up FFT processing block
        mywindow = window.blackmanharris(self.fft_size)
        fft = gr.fft_vcc(self.fft_size, True, mywindow, True)
        power = 0
        for tap in mywindow:
            power += tap * tap

        # calculate magnitude squared of output of FFT
        c2mag = gr.complex_to_mag_squared(self.fft_size)

        # FIXME the log10 primitive is dog slow
        log = gr.nlog10_ff(
            10, self.fft_size, -20 * math.log10(self.fft_size) -
            10 * math.log10(power / self.fft_size))

        # Set the freq_step to % of the actual data throughput.
        # This allows us to discard the bins on both ends of the spectrum.
        self.percent = 0.4

        # Calculate the frequency steps to use in the collection over the whole bandwidth
        self.freq_step = self.percent * self.int_rate
        self.min_center_freq = self.min_freq + self.freq_step / 2
        nsteps = math.ceil((self.max_freq - self.min_freq) / self.freq_step)
        self.max_center_freq = self.min_center_freq + (nsteps * self.freq_step)

        self.next_freq = self.min_center_freq

        # use these values to set receiver settling time between samples and sampling time
        # the default values provided seem to work well with the MSDD over 100 Mbps ethernet
        tune_delay = max(0,
                         int(
                             round(options.tune_delay * self.int_rate /
                                   self.fft_size)))  # in fft_frames
        dwell_delay = max(1,
                          int(
                              round(options.dwell_delay * self.int_rate /
                                    self.fft_size)))  # in fft_frames

        # set up message callback routine to get data from bin_statistics_f block
        self.msgq = gr.msg_queue(16)
        self._tune_callback = tune(
            self)  # hang on to this to keep it from being GC'd

        # FIXME this block doesn't like to work with negatives because of the "d_max[i]=0" on line
        # 151 of gr_bin_statistics_f.cc file. Set this to -10000 or something to get it to work.
        stats = gr.bin_statistics_f(self.fft_size, self.msgq,
                                    self._tune_callback, tune_delay,
                                    dwell_delay)

        # FIXME there's a concern over the speed of the log calculation
        # We can probably calculate the log inside the stats block
        self.connect(self.src, self.conv, s2v, fft, c2mag, log, stats)