diff options
author | Tom Rondeau | 2011-10-21 18:51:07 -0400 |
---|---|---|
committer | Tom Rondeau | 2011-10-21 18:51:07 -0400 |
commit | 3e7ca8bfb95658dd9204e1d859e572b82e3b80d4 (patch) | |
tree | 4249d8b9db44a51c8976b39531aec5c916938a33 | |
parent | fef8376c0be52cf065b59925abe69209bdcfc1ee (diff) | |
download | gnuradio-3e7ca8bfb95658dd9204e1d859e572b82e3b80d4.tar.gz gnuradio-3e7ca8bfb95658dd9204e1d859e572b82e3b80d4.tar.bz2 gnuradio-3e7ca8bfb95658dd9204e1d859e572b82e3b80d4.zip |
uhd: fixing uhd apps to take a subdev spec; also changing to more general uhd parameter of 'args' instead of 'address' which defaults to the first uhd dev found.
-rwxr-xr-x | gr-uhd/apps/uhd_fft.py | 14 | ||||
-rwxr-xr-x | gr-uhd/apps/uhd_rx_cfile.py | 16 | ||||
-rwxr-xr-x | gr-uhd/apps/uhd_rx_nogui.py | 23 | ||||
-rwxr-xr-x | gr-uhd/apps/uhd_siggen.py | 17 |
4 files changed, 50 insertions, 20 deletions
diff --git a/gr-uhd/apps/uhd_fft.py b/gr-uhd/apps/uhd_fft.py index 0f0c274e8..7f529a528 100755 --- a/gr-uhd/apps/uhd_fft.py +++ b/gr-uhd/apps/uhd_fft.py @@ -45,9 +45,10 @@ class app_top_block(stdgui2.std_top_block): self.panel = panel parser = OptionParser(option_class=eng_option) - parser.add_option("-a", "--address", type="string", - default="addr=192.168.10.2", - help="Address of UHD device, [default=%default]") + parser.add_option("-a", "--args", type="string", default="", + help="UHD device address args , [default=%default]") + parser.add_option("", "--spec", type="string", default=None, + help="Subdevice of UHD device where appropriate") parser.add_option("-A", "--antenna", type="string", default=None, help="select Rx Antenna where appropriate") parser.add_option("-s", "--samp-rate", type="eng_float", default=1e6, @@ -73,7 +74,7 @@ class app_top_block(stdgui2.std_top_block): self.options = options self.show_debug_info = True - self.u = uhd.usrp_source(device_addr=options.address, + self.u = uhd.usrp_source(device_addr=options.args, io_type=uhd.io_type.COMPLEX_FLOAT32, num_channels=1) @@ -118,6 +119,11 @@ class app_top_block(stdgui2.std_top_block): self.set_gain(options.gain) + # Set the subdevice spec + if(options.spec): + self.u.set_subdev_spec(options.spec, 0) + + # Set the antenna if(options.antenna): self.u.set_antenna(options.antenna, 0) diff --git a/gr-uhd/apps/uhd_rx_cfile.py b/gr-uhd/apps/uhd_rx_cfile.py index f49052d9c..625de36d3 100755 --- a/gr-uhd/apps/uhd_rx_cfile.py +++ b/gr-uhd/apps/uhd_rx_cfile.py @@ -41,12 +41,12 @@ class rx_cfile_block(gr.top_block): # Create a UHD device source if options.output_shorts: - self._u = uhd.usrp_source(device_addr=options.address, + self._u = uhd.usrp_source(device_addr=options.args, io_type=uhd.io_type.COMPLEX_INT16, num_channels=1) self._sink = gr.file_sink(gr.sizeof_short*2, filename) else: - self._u = uhd.usrp_source(device_addr=options.address, + self._u = uhd.usrp_source(device_addr=options.args, io_type=uhd.io_type.COMPLEX_FLOAT32, num_channels=1) self._sink = gr.file_sink(gr.sizeof_gr_complex, filename) @@ -61,6 +61,10 @@ class rx_cfile_block(gr.top_block): print "Using mid-point gain of", options.gain, "(", g.start(), "-", g.stop(), ")" self._u.set_gain(options.gain) + # Set the subdevice spec + if(options.spec): + self._u.set_subdev_spec(options.spec, 0) + # Set the antenna if(options.antenna): self._u.set_antenna(options.antenna, 0) @@ -89,7 +93,7 @@ class rx_cfile_block(gr.top_block): input_rate = self._u.get_samp_rate() if options.verbose: - print "Address:", options.address + print "Args: ", options.args print "Rx gain:", options.gain print "Rx baseband frequency:", n2s(tr.actual_rf_freq) print "Rx DDC frequency:", n2s(tr.actual_dsp_freq) @@ -107,8 +111,10 @@ class rx_cfile_block(gr.top_block): def get_options(): usage="%prog: [options] output_filename" parser = OptionParser(option_class=eng_option, usage=usage) - parser.add_option("-a", "--address", type="string", default="addr=192.168.10.2", - help="Address of UHD device, [default=%default]") + parser.add_option("-a", "--args", type="string", default="", + help="UHD device address args , [default=%default]") + parser.add_option("", "--spec", type="string", default=None, + help="Subdevice of UHD device where appropriate") parser.add_option("-A", "--antenna", type="string", default=None, help="select Rx Antenna where appropriate") parser.add_option("", "--samp-rate", type="eng_float", default=1e6, diff --git a/gr-uhd/apps/uhd_rx_nogui.py b/gr-uhd/apps/uhd_rx_nogui.py index 6f860b820..25068b3ac 100755 --- a/gr-uhd/apps/uhd_rx_nogui.py +++ b/gr-uhd/apps/uhd_rx_nogui.py @@ -83,12 +83,12 @@ class uhd_src(gr.hier_block2): Calibration value is the offset from the tuned frequency to the actual frequency. """ - def __init__(self, address, samp_rate, gain=None, calibration=0.0): + def __init__(self, args, spec, antenna, samp_rate, gain=None, calibration=0.0): gr.hier_block2.__init__(self, "uhd_src", gr.io_signature(0, 0, 0), # Input signature gr.io_signature(1, 1, gr.sizeof_gr_complex)) # Output signature - self._src = uhd.usrp_source(device_addr=address, + self._src = uhd.usrp_source(device_addr=args, io_type=uhd.io_type.COMPLEX_FLOAT32, num_channels=1) @@ -106,7 +106,15 @@ class uhd_src(gr.hier_block2): gain = (g.start()+g.stop())/2.0 print "Using gain: ", gain self._src.set_gain(gain) + + # Set the subdevice spec + if(spec): + self._src.set_subdev_spec(spec, 0) + # Set the antenna + if(antenna): + self._src.set_antenna(antenna, 0) + self._cal = calibration self.connect(self._src, self._resamp, self) @@ -124,7 +132,9 @@ class app_top_block(gr.top_block): (dev_rate, channel_rate, audio_rate, channel_pass, channel_stop, demod) = demod_params[options.modulation] - DEV = uhd_src(options.address, # UHD device address + DEV = uhd_src(options.args, # UHD device address + options.spec, # device subdev spec + options.antenna, # device antenna dev_rate, # device sample rate options.gain, # Receiver gain options.calibration) # Frequency offset @@ -185,9 +195,10 @@ class app_top_block(gr.top_block): def main(): parser = OptionParser(option_class=eng_option) - parser.add_option("-a", "--address", type="string", - default="addr=192.168.10.2", - help="Address of UHD device, [default=%default]") + parser.add_option("-a", "--args", type="string", default="", + help="UHD device address args , [default=%default]") + parser.add_option("", "--spec", type="string", default=None, + help="Subdevice of UHD device where appropriate") parser.add_option("-A", "--antenna", type="string", default=None, help="select Rx Antenna where appropriate [default=%default]") parser.add_option("-f", "--frequency", type="eng_float", diff --git a/gr-uhd/apps/uhd_siggen.py b/gr-uhd/apps/uhd_siggen.py index 921ba44b5..4b7060460 100755 --- a/gr-uhd/apps/uhd_siggen.py +++ b/gr-uhd/apps/uhd_siggen.py @@ -92,12 +92,18 @@ class top_block(gr.top_block, pubsub): self[TYPE_KEY] = options.type #set type last def _setup_usrpx(self, options): - self._u = uhd.usrp_sink(device_addr=options.address, + self._u = uhd.usrp_sink(device_addr=options.args, io_type=uhd.io_type.COMPLEX_FLOAT32, num_channels=1) self._u.set_samp_rate(options.samp_rate) + + # Set the subdevice spec + if(options.spec): + self._u.set_subdev_spec(options.spec, 0) + + # Set the antenna if(options.antenna): - self._u.set_antenna(options.antenna) + self._u.set_antenna(options.antenna, 0) self.publish(DESC_KEY, lambda: str(self._u)) self.publish(FREQ_RANGE_KEY, self._u.get_freq_range) @@ -280,9 +286,10 @@ def get_options(): usage="%prog: [options]" parser = OptionParser(option_class=eng_option, usage=usage) - parser.add_option("-a", "--address", type="string", - default="addr=192.168.10.2", - help="Address of UHD device, [default=%default]") + parser.add_option("-a", "--args", type="string", default="", + help="UHD device address args , [default=%default]") + parser.add_option("", "--spec", type="string", default=None, + help="Subdevice of UHD device where appropriate") parser.add_option("-A", "--antenna", type="string", default=None, help="select Rx Antenna where appropriate") parser.add_option("-s", "--samp-rate", type="eng_float", default=1e6, |