示例#1
0
    def __init__(self, options, queue):
        gr.top_block.__init__(self, "usrp_flex_all")

        if options.from_file is not None:
            src = gr.file_source(gr.sizeof_gr_complex, options.from_file)
            if options.verbose:
                print "Reading samples from file", options.from_file
        else:
            src = usrp.source_c()
            if options.rx_subdev_spec is None:
                options.rx_subdev_spec = usrp.pick_rx_subdevice(src)
            subdev = usrp.selected_subdev(src, options.rx_subdev_spec)
            src.set_mux(
                usrp.determine_rx_mux_value(src, options.rx_subdev_spec))
            src.set_decim_rate(20)
            result = usrp.tune(src, 0, subdev,
                               930.5125e6 + options.calibration)
            if options.verbose:
                print "Using", subdev.name(), " for receiving."
                print "Tuned USRP to", 930.5125e6 + options.calibration

        taps = gr.firdes.low_pass(1.0, 1.0, 1.0 / 128.0 * 0.4,
                                  1.0 / 128.0 * 0.1, gr.firdes.WIN_HANN)

        if options.verbose:
            print "Channel filter has", len(taps), "taps"

        bank = blks2.analysis_filterbank(128, taps)
        self.connect(src, bank)

        if options.log and options.from_file == None:
            src_sink = gr.file_sink(gr.sizeof_gr_complex, 'usrp.dat')
            self.connect(src, src_sink)

        for i in range(128):
            if i < 64:
                freq = 930.5e6 + i * 25e3
            else:
                freq = 928.9e6 + (i - 64) * 25e3

            if (freq < 929.0e6 or freq > 932.0e6):
                self.connect((bank, i), gr.null_sink(gr.sizeof_gr_complex))
            else:
                self.connect((bank, i),
                             pager.flex_demod(queue, freq, options.verbose,
                                              options.log))
                if options.log:
                    self.connect(
                        (bank, i),
                        gr.file_sink(gr.sizeof_gr_complex, 'chan_' + '%3.3f' %
                                     (freq / 1e6) + '.dat'))
示例#2
0
    def __init__(self, frame, panel, vbox, argv):
        stdgui2.std_top_block.__init__(self, frame, panel, vbox, argv)

        parser = OptionParser (option_class=eng_option)
        (options, args) = parser.parse_args ()

        sample_rate = 16e3
        mpoints = 4
        ampl = 1000
        freq = 0

        lo_freq = 1e6
        lo_ampl = 1
        
        vbox.Add(slider.slider(panel,
                               -sample_rate/2, sample_rate/2,
                               self.set_lo_freq), 0, wx.ALIGN_CENTER)


        src = gr.sig_source_c(sample_rate, gr.GR_CONST_WAVE,
                              freq, ampl, 0)

        self.lo = gr.sig_source_c(sample_rate, gr.GR_SIN_WAVE,
                                  lo_freq, lo_ampl, 0)

        mixer = gr.multiply_cc()
        self.connect(src, (mixer, 0))
        self.connect(self.lo, (mixer, 1))
        
        # We add these throttle blocks so that this demo doesn't
        # suck down all the CPU available.  Normally you wouldn't use these.
        thr = gr.throttle(gr.sizeof_gr_complex, sample_rate)

        taps = gr.firdes.low_pass(1,   # gain
                                  1,   # rate
                                  1.0/mpoints * 0.4,  # cutoff
                                  1.0/mpoints * 0.1,  # trans width
                                  gr.firdes.WIN_HANN)
        print len(taps)
        analysis = blks2.analysis_filterbank(mpoints, taps)
        
        self.connect(mixer, thr)
        self.connect(thr, analysis)

        for i in range(mpoints):
            fft = fftsink2.fft_sink_c(frame, fft_size=128,
                                     sample_rate=sample_rate/mpoints,
                                     fft_rate=5,
                                     title="Ch %d" % (i,))
            self.connect((analysis, i), fft)
            vbox.Add(fft.win, 1, wx.EXPAND)
示例#3
0
    def __init__(self, options, queue):
	gr.top_block.__init__(self, "usrp_flex_all")

        if options.from_file is not None:
            src = gr.file_source(gr.sizeof_gr_complex, options.from_file)
            if options.verbose:
                print "Reading samples from file", options.from_file
        else:
            src = usrp.source_c()
            if options.rx_subdev_spec is None:
                options.rx_subdev_spec = usrp.pick_rx_subdevice(src)
            subdev = usrp.selected_subdev(src, options.rx_subdev_spec)
            src.set_mux(usrp.determine_rx_mux_value(src, options.rx_subdev_spec))
            src.set_decim_rate(20)
            result = usrp.tune(src, 0, subdev, 930.5125e6+options.calibration)
            if options.verbose:
                print "Using", subdev.name(), " for receiving."
                print "Tuned USRP to", 930.5125e6+options.calibration
                
        taps = gr.firdes.low_pass(1.0,
                                  1.0,
                                  1.0/128.0*0.4,
                                  1.0/128.0*0.1,
                                  gr.firdes.WIN_HANN)

        if options.verbose:
            print "Channel filter has", len(taps), "taps"

        bank = blks2.analysis_filterbank(128, taps)
        self.connect(src, bank)

        if options.log and options.from_file == None:
            src_sink = gr.file_sink(gr.sizeof_gr_complex, 'usrp.dat')
            self.connect(src, src_sink)

        for i in range(128):
	    if i < 64:
		freq = 930.5e6+i*25e3
	    else:
		freq = 928.9e6+(i-64)*25e3

	    if (freq < 929.0e6 or freq > 932.0e6):
                self.connect((bank, i), gr.null_sink(gr.sizeof_gr_complex))
	    else:
            	self.connect((bank, i), pager.flex_demod(queue, freq, options.verbose, options.log))
                if options.log:
                    self.connect((bank, i), gr.file_sink(gr.sizeof_gr_complex, 'chan_'+'%3.3f'%(freq/1e6)+'.dat'))
    def __init__(self, options, queue):
	gr.top_block.__init__(self, "usrp_flex_all")

        if options.from_file is not None:
            self.u = gr.file_source(gr.sizeof_gr_complex, options.from_file)
            if options.verbose:
                print "Reading samples from file", options.from_file
        else:
            # Set up USRP source
            self.u = uhd.usrp_source(device_addr=options.address, stream_args=uhd.stream_args('fc32'))

            # Grab 1 MHz of spectrum
            # (A UHD facility to get sample rate range and granularity would be useful)
            self.u.set_samp_rate(1e6)
            rate = self.u.get_samp_rate()
            if rate != 1e6:
                print "Unable to set required sample rate of 1 Msps (got %f)" % rate
                sys.exit(1)
                
            # Tune daughterboard
            r = self.u.set_center_freq(options.freq+options.calibration, 0)
            if not r:
                frange = self.u.get_freq_range()
                sys.stderr.write(("\nRequested frequency (%f) out or range [%f, %f]\n") % \
                                     (freq, frange.start(), frange.stop()))
                sys.exit(1)

            # if no gain was specified, use the mid-point in dB
            if options.rx_gain is None:
                grange = self.u.get_gain_range()
                options.rx_gain = float(grange.start()+grange.stop())/2.0
                print "\nNo gain specified."
                print "Setting gain to %f (from [%f, %f])" % \
                    (options.rx_gain, grange.start(), grange.stop())
        
            self.u.set_gain(options.rx_gain, 0)


        taps = gr.firdes.low_pass(1.0,
                                  1.0,
                                  1.0/40.0*0.4,
                                  1.0/40.0*0.1,
                                  gr.firdes.WIN_HANN)

        if options.verbose:
            print "Channel filter has", len(taps), "taps"

        bank = blks2.analysis_filterbank(40, taps)
        self.connect(self.u, bank)

        if options.log and options.from_file == None:
            src_sink = gr.file_sink(gr.sizeof_gr_complex, 'usrp.dat')
            self.connect(self.u, src_sink)

        for i in range(40):
	    if i < 20:
		freq = options.freq+i*25e3
	    else:
		freq = options.freq-0.5e6+(i-20)*25e3

	    self.connect((bank, i), pager.flex_demod(queue, freq, options.verbose, options.log))
	    if options.log:
		self.connect((bank, i), gr.file_sink(gr.sizeof_gr_complex, 'chan_'+'%3.3f'%(freq/1e6)+'.dat'))
示例#5
0
    def __init__(self, options, queue):
	gr.top_block.__init__(self, "usrp_flex_all")

        if options.from_file is not None:
            self.u = gr.file_source(gr.sizeof_gr_complex, options.from_file)
            self.nchan = options.nchan
            if options.verbose:
                print "Reading samples from file", options.from_file
                print "User specified file contains", options.nchan, "25 KHz channels."

        else:
            # Set up USRP source
            self.u = uhd.usrp_source(device_addr=options.address,
                                     io_type=uhd.io_type.COMPLEX_FLOAT32,
                                     num_channels=1)

            # Tune daughterboard
            r = self.u.set_center_freq(options.freq+options.calibration, 0)
            if not r:
                frange = self.u.get_freq_range()
                sys.stderr.write(("\nRequested frequency (%f) out or range [%f, %f]\n") % \
                                     (freq, frange.start(), frange.stop()))
                sys.exit(1)

            if options.verbose:
                print "Tuned to center frequency", (options.freq+options.calibration)/1e6, "MHz"

            # if no gain was specified, use the mid-point in dB
            if options.rx_gain is None:
                grange = self.u.get_gain_range()
                options.rx_gain = float(grange.start()+grange.stop())/2.0
                print "\nNo gain specified."
                print "Setting gain to %f (from [%f, %f])" % \
                    (options.rx_gain, grange.start(), grange.stop())
        
            self.u.set_gain(options.rx_gain, 0)

            # Grab >=3 MHz of spectrum, evenly divisible by 25 KHz channels
            # (A UHD facility to get sample rate range and granularity would be useful)

            self.u.set_samp_rate(3.125e6) # Works if USRP is 100 Msps and can decimate by 32
            rate = self.u.get_samp_rate()

            if rate != 3.125e6:
                self.u.set_samp_rate(3.2e6) # Works if USRP is 64 Msps and can decimate by 20
                rate = self.u.get_samp_rate()
                if (rate != 3.2e6):
                    print "Unable to set required sample rate for >= 3MHz of 25 KHz channels."
                    sys.exit(1)
            
            self.nchan = int(rate/25e3)
            if options.verbose:
                print "\nReceiving", rate/1e6, "MHz of bandwidth containing", self.nchan, "baseband channels."
                    
        taps = gr.firdes.low_pass(1.0,
                                  1.0,
                                  1.0/self.nchan*0.4,
                                  1.0/self.nchan*0.1,
                                  gr.firdes.WIN_HANN)

        if options.verbose:
            print "Channel filter has", len(taps), "taps"

        self.bank = blks2.analysis_filterbank(self.nchan, taps)
        self.connect(self.u, self.bank)

        if options.log and options.from_file == None:
            src_sink = gr.file_sink(gr.sizeof_gr_complex, 'usrp.dat')
            self.connect(self.u, src_sink)

        mid_chan = int(self.nchan/2)
        for i in range(self.nchan):
	    if i < mid_chan:
		freq = 930.5e6+i*25e3
	    else:
		freq = 930.5e6-(self.nchan-i)*25e3

	    if (freq < 929.0e6 or freq > 932.0e6):
                self.connect((self.bank, i), gr.null_sink(gr.sizeof_gr_complex))
	    else:
            	self.connect((self.bank, i), pager.flex_demod(queue, freq, options.verbose, options.log))
                if options.log:
                    self.connect((self.bank, i), gr.file_sink(gr.sizeof_gr_complex, 'chan_'+'%3.3f'%(freq/1e6)+'.dat'))
示例#6
0
	def __init__(self, options, queue):
		gr.top_block.__init__(self, "flex_hackrf")

		# Set up HackRF source
		self.u = osmosdr.source_c(args="nchan=" + str(1) + " ")

		# Tune hackRF
		r = self.u.set_center_freq(options.freq+options.calibration, 0)
		if not r:
			frange = self.u.get_freq_range()
			sys.stderr.write(("\nRequested frequency (%f) out or range [%f, %f]\n") % \
								 (freq, frange.start(), frange.stop()))
			sys.exit(1)

		if options.verbose:
			print "Tuned to center frequency", (options.freq+options.calibration)/1e6, "MHz"

		# if no gain was specified, use the mid-point in dB
		if options.rx_gain is None:
			grange = self.u.get_gain_range()
			options.rx_gain = float(grange.start()+grange.stop())/2.0
			print "\nNo gain specified."
			print "Setting gain to %f (from [%f, %f])" % \
				(options.rx_gain, grange.start(), grange.stop())

		self.u.set_gain(options.rx_gain, 0)

		# Grab >=3 MHz of spectrum, evenly divisible by 25 KHz channels
		# (A UHD facility to get sample rate range and granularity would be useful)

		self.u.set_sample_rate(3.125e6) # Works if USRP is 100 Msps and can decimate by 32
		rate = self.u.get_sample_rate()

		if rate != 3.125e6:
			self.u.set_sample_rate(3.2e6) # Works if USRP is 64 Msps and can decimate by 20
			rate = self.u.get_sample_rate()
			if (rate != 3.2e6):
				print "Unable to set required sample rate for >= 3MHz of 25 KHz channels."
				sys.exit(1)

		self.nchan = int(rate/25e3)
		if options.verbose:
			print "\nReceiving", rate/1e6, "MHz of bandwidth containing", self.nchan, "baseband channels."

		taps = gr.firdes.low_pass(1.0,
								  1.0,
								  1.0/self.nchan*0.4,
								  1.0/self.nchan*0.1,
								  gr.firdes.WIN_HANN)

		if options.verbose:
			print "Channel filter has", len(taps), "taps"

		self.bank = blks2.analysis_filterbank(self.nchan, taps)
		self.connect(self.u, self.bank)

		mid_chan = int(self.nchan/2)
		for i in range(self.nchan):
			if i < mid_chan:
				freq = options.freq+i*25e3
			else:
				freq = options.freq-(self.nchan-i)*25e3

			if (freq < 929.0e6 or freq > 932.0e6):
				self.connect((self.bank, i), gr.null_sink(gr.sizeof_gr_complex))
			else:
				self.connect((self.bank, i), pager.flex_demod(queue, freq, options.verbose))
    def __init__(self, options, queue):
	gr.top_block.__init__(self, "usrp_flex_all")

        if options.from_file is not None:
            self.u = gr.file_source(gr.sizeof_gr_complex, options.from_file)
            self.nchan = options.nchan
            if options.verbose:
                print "Reading samples from file", options.from_file
                print "User specified file contains", options.nchan, "25 KHz channels."

        else:
            # Set up USRP source
            self.u = uhd.usrp_source(device_addr=options.address, stream_args=uhd.stream_args('fc32'))

            # Tune daughterboard
            r = self.u.set_center_freq(options.freq+options.calibration, 0)
            if not r:
                frange = self.u.get_freq_range()
                sys.stderr.write(("\nRequested frequency (%f) out or range [%f, %f]\n") % \
                                     (freq, frange.start(), frange.stop()))
                sys.exit(1)

            if options.verbose:
                print "Tuned to center frequency", (options.freq+options.calibration)/1e6, "MHz"

            # if no gain was specified, use the mid-point in dB
            if options.rx_gain is None:
                grange = self.u.get_gain_range()
                options.rx_gain = float(grange.start()+grange.stop())/2.0
                print "\nNo gain specified."
                print "Setting gain to %f (from [%f, %f])" % \
                    (options.rx_gain, grange.start(), grange.stop())
        
            self.u.set_gain(options.rx_gain, 0)

            # Grab >=3 MHz of spectrum, evenly divisible by 25 KHz channels
            # (A UHD facility to get sample rate range and granularity would be useful)

            self.u.set_samp_rate(3.125e6) # Works if USRP is 100 Msps and can decimate by 32
            rate = self.u.get_samp_rate()

            if rate != 3.125e6:
                self.u.set_samp_rate(3.2e6) # Works if USRP is 64 Msps and can decimate by 20
                rate = self.u.get_samp_rate()
                if (rate != 3.2e6):
                    print "Unable to set required sample rate for >= 3MHz of 25 KHz channels."
                    sys.exit(1)
            
            self.nchan = int(rate/25e3)
            if options.verbose:
                print "\nReceiving", rate/1e6, "MHz of bandwidth containing", self.nchan, "baseband channels."
                    
        taps = gr.firdes.low_pass(1.0,
                                  1.0,
                                  1.0/self.nchan*0.4,
                                  1.0/self.nchan*0.1,
                                  gr.firdes.WIN_HANN)

        if options.verbose:
            print "Channel filter has", len(taps), "taps"

        self.bank = blks2.analysis_filterbank(self.nchan, taps)
        self.connect(self.u, self.bank)

        if options.log and options.from_file == None:
            src_sink = gr.file_sink(gr.sizeof_gr_complex, 'usrp.dat')
            self.connect(self.u, src_sink)

        mid_chan = int(self.nchan/2)
        for i in range(self.nchan):
	    if i < mid_chan:
		freq = 930.5e6+i*25e3
	    else:
		freq = 930.5e6-(self.nchan-i)*25e3

	    if (freq < 929.0e6 or freq > 932.0e6):
                self.connect((self.bank, i), gr.null_sink(gr.sizeof_gr_complex))
	    else:
            	self.connect((self.bank, i), pager.flex_demod(queue, freq, options.verbose, options.log))
                if options.log:
                    self.connect((self.bank, i), gr.file_sink(gr.sizeof_gr_complex, 'chan_'+'%3.3f'%(freq/1e6)+'.dat'))
    def __init__(self, options, queue):
        gr.top_block.__init__(self, "usrp_flex_all")

        if options.from_file is not None:
            self.u = gr.file_source(gr.sizeof_gr_complex, options.from_file)
            if options.verbose:
                print "Reading samples from file", options.from_file
        else:
            # Set up USRP source
            self.u = uhd.usrp_source(device_addr=options.address,
                                     stream_args=uhd.stream_args('fc32'))

            # Grab 1 MHz of spectrum
            # (A UHD facility to get sample rate range and granularity would be useful)
            self.u.set_samp_rate(1e6)
            rate = self.u.get_samp_rate()
            if rate != 1e6:
                print "Unable to set required sample rate of 1 Msps (got %f)" % rate
                sys.exit(1)

            # Tune daughterboard
            r = self.u.set_center_freq(options.freq + options.calibration, 0)
            if not r:
                frange = self.u.get_freq_range()
                sys.stderr.write(("\nRequested frequency (%f) out or range [%f, %f]\n") % \
                                     (freq, frange.start(), frange.stop()))
                sys.exit(1)

            # if no gain was specified, use the mid-point in dB
            if options.rx_gain is None:
                grange = self.u.get_gain_range()
                options.rx_gain = float(grange.start() + grange.stop()) / 2.0
                print "\nNo gain specified."
                print "Setting gain to %f (from [%f, %f])" % \
                    (options.rx_gain, grange.start(), grange.stop())

            self.u.set_gain(options.rx_gain, 0)

        taps = gr.firdes.low_pass(1.0, 1.0, 1.0 / 40.0 * 0.4, 1.0 / 40.0 * 0.1,
                                  gr.firdes.WIN_HANN)

        if options.verbose:
            print "Channel filter has", len(taps), "taps"

        bank = blks2.analysis_filterbank(40, taps)
        self.connect(self.u, bank)

        if options.log and options.from_file == None:
            src_sink = gr.file_sink(gr.sizeof_gr_complex, 'usrp.dat')
            self.connect(self.u, src_sink)

        for i in range(40):
            if i < 20:
                freq = options.freq + i * 25e3
            else:
                freq = options.freq - 0.5e6 + (i - 20) * 25e3

            self.connect((bank, i),
                         pager.flex_demod(queue, freq, options.verbose,
                                          options.log))
            if options.log:
                self.connect(
                    (bank, i),
                    gr.file_sink(gr.sizeof_gr_complex,
                                 'chan_' + '%3.3f' % (freq / 1e6) + '.dat'))