diff options
Diffstat (limited to 'gr-uhd')
-rw-r--r-- | gr-uhd/CMakeLists.txt | 2 | ||||
-rw-r--r-- | gr-uhd/apps/uhd_app.py | 21 | ||||
-rwxr-xr-x | gr-uhd/apps/uhd_fft | 8 | ||||
-rwxr-xr-x | gr-uhd/apps/uhd_rx_cfile | 6 | ||||
-rw-r--r-- | gr-uhd/apps/uhd_siggen_base.py | 20 | ||||
-rw-r--r-- | gr-uhd/grc/CMakeLists.txt | 26 | ||||
-rw-r--r-- | gr-uhd/grc/gen_uhd_usrp_blocks.py | 1012 | ||||
-rw-r--r-- | gr-uhd/grc/uhd.tree.yml | 5 | ||||
-rw-r--r-- | gr-uhd/grc/uhd_amsg_source.block.yml | 18 | ||||
-rw-r--r-- | gr-uhd/grc/uhd_amsg_source.xml | 24 | ||||
-rw-r--r-- | gr-uhd/grc/uhd_block_tree.xml | 15 | ||||
-rw-r--r-- | gr-uhd/python/uhd/CMakeLists.txt | 2 | ||||
-rw-r--r-- | gr-uhd/python/uhd/__init__.py | 21 | ||||
-rw-r--r-- | gr-uhd/python/uhd/qa_uhd.py | 4 |
14 files changed, 426 insertions, 758 deletions
diff --git a/gr-uhd/CMakeLists.txt b/gr-uhd/CMakeLists.txt index 74c8159274..e7a25e51e7 100644 --- a/gr-uhd/CMakeLists.txt +++ b/gr-uhd/CMakeLists.txt @@ -59,7 +59,7 @@ add_subdirectory(examples/c++) if(ENABLE_PYTHON) add_subdirectory(swig) add_subdirectory(python/uhd) - add_subdirectory(grc) + #add_subdirectory(grc) add_subdirectory(apps) add_subdirectory(examples/grc) endif(ENABLE_PYTHON) diff --git a/gr-uhd/apps/uhd_app.py b/gr-uhd/apps/uhd_app.py index 5c8881ce34..5a8290fe52 100644 --- a/gr-uhd/apps/uhd_app.py +++ b/gr-uhd/apps/uhd_app.py @@ -24,6 +24,8 @@ USRP Helper Module: Common tasks for uhd-based apps. """ from __future__ import print_function +from __future__ import division +from __future__ import unicode_literals import sys import time import argparse @@ -163,18 +165,18 @@ class UHDApp(object): self.spec = self.normalize_sel("mboards", "subdev", self.usrp.get_num_mboards(), args.spec) if self.spec: - for mb_idx in xrange(self.usrp.get_num_mboards()): + for mb_idx in range(self.usrp.get_num_mboards()): self.usrp.set_subdev_spec(self.spec[mb_idx], mb_idx) # Set the clock and/or time source: if args.clock_source is not None: self.clock_source = self.normalize_sel("mboards", "clock-source", self.usrp.get_num_mboards(), args.clock_source) - for mb_idx in xrange(self.usrp.get_num_mboards()): + for mb_idx in range(self.usrp.get_num_mboards()): self.usrp.set_clock_source(self.clock_source[mb_idx], mb_idx) if args.time_source is not None: self.time_source = self.normalize_sel("mboards", "time-source", self.usrp.get_num_mboards(), args.time_source) - for mb_idx in xrange(self.usrp.get_num_mboards()): + for mb_idx in range(self.usrp.get_num_mboards()): self.usrp.set_time_source(self.time_source[mb_idx], mb_idx) # Sampling rate: self.usrp.set_samp_rate(args.samp_rate) @@ -235,7 +237,7 @@ class UHDApp(object): self.usrp.set_time_unknown_pps(uhd.time_spec()) cmd_time = self.usrp.get_time_now() + uhd.time_spec(COMMAND_DELAY) try: - for mb_idx in xrange(self.usrp.get_num_mboards()): + for mb_idx in range(self.usrp.get_num_mboards()): self.usrp.set_command_time(cmd_time, mb_idx) command_time_set = True except RuntimeError: @@ -248,7 +250,7 @@ class UHDApp(object): )) exit(1) if command_time_set: - for mb_idx in xrange(self.usrp.get_num_mboards()): + for mb_idx in range(self.usrp.get_num_mboards()): self.usrp.clear_command_time(mb_idx) self.vprint("Syncing channels...".format(prefix=self.prefix)) time.sleep(COMMAND_DELAY) @@ -283,7 +285,7 @@ class UHDApp(object): """ Safely tune all channels to freq. """ - self.vprint("Tuning all channels to {freq} MHz.".format(freq=freq/1e6)) + self.vprint("Tuning all channels to {freq} MHz.".format(freq=freq / 1e6)) # Set frequency (tune request takes lo_offset): if hasattr(self.args, 'lo_offset') and self.args.lo_offset is not None: treq = uhd.tune_request(freq, self.args.lo_offset) @@ -310,7 +312,7 @@ class UHDApp(object): if len(self.channels) > 1 and not skip_sync: cmd_time = self.usrp.get_time_now() + uhd.time_spec(COMMAND_DELAY) try: - for mb_idx in xrange(self.usrp.get_num_mboards()): + for mb_idx in range(self.usrp.get_num_mboards()): self.usrp.set_command_time(cmd_time, mb_idx) command_time_set = True except RuntimeError: @@ -323,12 +325,12 @@ class UHDApp(object): )) exit(1) if command_time_set: - for mb_idx in xrange(self.usrp.get_num_mboards()): + for mb_idx in range(self.usrp.get_num_mboards()): self.usrp.clear_command_time(mb_idx) self.vprint("Syncing channels...".format(prefix=self.prefix)) time.sleep(COMMAND_DELAY) self.freq = self.usrp.get_center_freq(0) - self.vprint("First channel has freq: {freq} MHz.".format(freq=self.freq/1e6)) + self.vprint("First channel has freq: {freq} MHz.".format(freq=self.freq / 1e6)) @staticmethod def setup_argparser( @@ -390,4 +392,3 @@ class UHDApp(object): group.add_argument("--time-source", help="Set the time source") return parser - diff --git a/gr-uhd/apps/uhd_fft b/gr-uhd/apps/uhd_fft index 4cb5eed0d1..777461fd63 100755 --- a/gr-uhd/apps/uhd_fft +++ b/gr-uhd/apps/uhd_fft @@ -218,7 +218,7 @@ class uhd_fft(gr.top_block, Qt.QWidget, UHDApp): self.qtgui_waterfall_sink_x_0.enable_grid(False) self.qtgui_waterfall_sink_x_0.disable_legend() alpha = 10.**(len(self.channels)-1) - for i in xrange(len(self.channels)): + for i in range(len(self.channels)): self.qtgui_waterfall_sink_x_0.set_line_label(i, "Channel {0}".format(i)) self.qtgui_waterfall_sink_x_0.set_color_map(i, 0) self.qtgui_waterfall_sink_x_0.set_line_alpha(i, alpha) @@ -240,7 +240,7 @@ class uhd_fft(gr.top_block, Qt.QWidget, UHDApp): self.qtgui_time_sink_x_0.enable_grid(False) self.qtgui_time_sink_x_0.enable_control_panel(True) self.qtgui_time_sink_x_0.disable_legend() - for i in xrange(2*len(self.channels)): + for i in range(2*len(self.channels)): if(i % 2 == 0): self.qtgui_time_sink_x_0.set_line_label(i, "Re{{Channel {0}}}".format(i/2)) else: @@ -268,7 +268,7 @@ class uhd_fft(gr.top_block, Qt.QWidget, UHDApp): self.qtgui_freq_sink_x_0.set_fft_average(self.fft_average) self.qtgui_freq_sink_x_0.enable_control_panel(True) self.qtgui_freq_sink_x_0.disable_legend() - for i in xrange(len(self.channels)): + for i in range(len(self.channels)): self.qtgui_freq_sink_x_0.set_line_label(i, "Channel {0}".format(i)) self.qtgui_freq_sink_x_0.set_line_width(i, widths[i]) self.qtgui_freq_sink_x_0.set_line_color(i, colors[i]) @@ -305,7 +305,7 @@ class uhd_fft(gr.top_block, Qt.QWidget, UHDApp): self.qtgui_phase_plot.enable_grid(True) self.qtgui_phase_plot.enable_control_panel(True) self.qtgui_phase_plot.disable_legend() - for i in xrange(len(self.channels) - 1): + for i in range(len(self.channels) - 1): self.qtgui_phase_plot.set_line_label(i, "Phase Delta Channels {0}/{1}".format(i, i+1)) self.qtgui_phase_plot.set_line_width(i, widths[i]) self.qtgui_phase_plot.set_line_color(i, colors[i]) diff --git a/gr-uhd/apps/uhd_rx_cfile b/gr-uhd/apps/uhd_rx_cfile index 2a1ed0fcb5..d41027ff39 100755 --- a/gr-uhd/apps/uhd_rx_cfile +++ b/gr-uhd/apps/uhd_rx_cfile @@ -79,7 +79,7 @@ class rx_cfile_block(gr.top_block): ) # Set the subdevice spec: if options.spec: - for mb_idx in xrange(self._u.get_num_mboards()): + for mb_idx in range(self._u.get_num_mboards()): self._u.set_subdev_spec(options.spec, mb_idx) # Set the antenna: if options.antenna is not None: @@ -125,7 +125,7 @@ class rx_cfile_block(gr.top_block): self._u.set_time_unknown_pps(uhd.time_spec()) cmd_time = self._u.get_time_now() + uhd.time_spec(COMMAND_DELAY) try: - for mb_idx in xrange(self._u.get_num_mboards()): + for mb_idx in range(self._u.get_num_mboards()): self._u.set_command_time(cmd_time, mb_idx) command_time_set = True except RuntimeError: @@ -136,7 +136,7 @@ class rx_cfile_block(gr.top_block): sys.stderr.write('[UHD_RX] [ERROR] Failed to set center frequency on channel {chan}\n'.format(chan=chan)) exit(1) if command_time_set: - for mb_idx in xrange(self._u.get_num_mboards()): + for mb_idx in range(self._u.get_num_mboards()): self._u.clear_command_time(mb_idx) print("[UHD_RX] Syncing channels...") time.sleep(COMMAND_DELAY) diff --git a/gr-uhd/apps/uhd_siggen_base.py b/gr-uhd/apps/uhd_siggen_base.py index cc699dd145..9714810cdd 100644 --- a/gr-uhd/apps/uhd_siggen_base.py +++ b/gr-uhd/apps/uhd_siggen_base.py @@ -24,6 +24,8 @@ Provide a base flow graph for USRP signal generators. """ from __future__ import print_function +from __future__ import division +from __future__ import unicode_literals import math try: from uhd_app import UHDApp @@ -124,7 +126,7 @@ class USRPSiggen(gr.top_block, pubsub, UHDApp): """ When sampling rate is updated, also update the signal sources. """ - self.vprint("Setting sampling rate to: {rate} Msps".format(rate=samp_rate/1e6)) + self.vprint("Setting sampling rate to: {rate} Msps".format(rate=samp_rate / 1e6)) self.usrp.set_samp_rate(samp_rate) samp_rate = self.usrp.get_samp_rate() if self[TYPE_KEY] in (analog.GR_SIN_WAVE, analog.GR_CONST_WAVE): @@ -137,7 +139,7 @@ class USRPSiggen(gr.top_block, pubsub, UHDApp): self._src2.set_sampling_freq(self[WAVEFORM_FREQ_KEY]*2*math.pi/self[SAMP_RATE_KEY]) else: return True # Waveform not yet set - self.vprint("Set sample rate to: {rate} Msps".format(rate=samp_rate/1e6)) + self.vprint("Set sample rate to: {rate} Msps".format(rate=samp_rate / 1e6)) return True def set_waveform_freq(self, freq): @@ -184,14 +186,14 @@ class USRPSiggen(gr.top_block, pubsub, UHDApp): self._src1 = analog.sig_source_c(self[SAMP_RATE_KEY], analog.GR_SIN_WAVE, self[WAVEFORM_FREQ_KEY], - self[AMPLITUDE_KEY]/2.0, + self[AMPLITUDE_KEY] / 2.0, 0) if self[WAVEFORM2_FREQ_KEY] is None: self[WAVEFORM2_FREQ_KEY] = -self[WAVEFORM_FREQ_KEY] self._src2 = analog.sig_source_c(self[SAMP_RATE_KEY], analog.GR_SIN_WAVE, self[WAVEFORM2_FREQ_KEY], - self[AMPLITUDE_KEY]/2.0, + self[AMPLITUDE_KEY] / 2.0, 0) self._src = blocks.add_cc() self.connect(self._src1, (self._src, 0)) @@ -213,7 +215,7 @@ class USRPSiggen(gr.top_block, pubsub, UHDApp): self.connect(self._src1, self._src2, self._src) else: raise RuntimeError("[UHD-SIGGEN] Unknown waveform waveform_type") - for chan in xrange(len(self.channels)): + for chan in range(len(self.channels)): self.connect(self._src, (self.usrp, chan)) if self.extra_sink is not None: self.connect(self._src, self.extra_sink) @@ -226,7 +228,7 @@ class USRPSiggen(gr.top_block, pubsub, UHDApp): self.vprint("Tone 1: %sHz" % (n2s(self[WAVEFORM_FREQ_KEY]),)) self.vprint("Tone 2: %sHz" % (n2s(self[WAVEFORM2_FREQ_KEY]),)) elif waveform_type == "sweep": - self.vprint("Sweeping across %sHz to %sHz" % (n2s(-self[WAVEFORM_FREQ_KEY]/2.0), n2s(self[WAVEFORM_FREQ_KEY]/2.0))) + self.vprint("Sweeping across %sHz to %sHz" % (n2s(-self[WAVEFORM_FREQ_KEY] / 2.0), n2s(self[WAVEFORM_FREQ_KEY] / 2.0))) self.vprint("Sweep rate: %sHz" % (n2s(self[WAVEFORM2_FREQ_KEY]),)) self.vprint("TX amplitude:", self[AMPLITUDE_KEY]) @@ -240,8 +242,8 @@ class USRPSiggen(gr.top_block, pubsub, UHDApp): if self[TYPE_KEY] in (analog.GR_SIN_WAVE, analog.GR_CONST_WAVE, analog.GR_GAUSSIAN, analog.GR_UNIFORM): self._src.set_amplitude(amplitude) elif self[TYPE_KEY] == "2tone": - self._src1.set_amplitude(amplitude/2.0) - self._src2.set_amplitude(amplitude/2.0) + self._src1.set_amplitude(amplitude / 2.0) + self._src2.set_amplitude(amplitude / 2.0) elif self[TYPE_KEY] == "sweep": self._src.set_k(amplitude) else: @@ -293,7 +295,7 @@ def main(): print(ex) exit(1) tb.start() - raw_input('[UHD-SIGGEN] Press Enter to quit:\n') + input('[UHD-SIGGEN] Press Enter to quit:\n') tb.stop() tb.wait() diff --git a/gr-uhd/grc/CMakeLists.txt b/gr-uhd/grc/CMakeLists.txt index d748bfacef..72a6543df3 100644 --- a/gr-uhd/grc/CMakeLists.txt +++ b/gr-uhd/grc/CMakeLists.txt @@ -18,28 +18,28 @@ # Boston, MA 02110-1301, USA. ######################################################################## -# Rules for generating the source and sink xml wrappers +# Rules for generating the source and sink yml wrappers ######################################################################## include(GrPython) -macro(GEN_BLOCK_XML _generator _xml_block) +macro(GEN_BLOCK_YML _generator _yml_block) set(generator ${CMAKE_CURRENT_SOURCE_DIR}/${_generator}) - set(xml_block ${CMAKE_CURRENT_BINARY_DIR}/${_xml_block}) - list(APPEND xml_blocks ${xml_block}) + set(yml_block ${CMAKE_CURRENT_BINARY_DIR}/${_yml_block}) + list(APPEND yml_blocks ${yml_block}) add_custom_command( - DEPENDS ${generator} OUTPUT ${xml_block} - COMMAND ${PYTHON_EXECUTABLE} ${generator} ${xml_block} + DEPENDS ${generator} OUTPUT ${yml_block} + COMMAND ${PYTHON_EXECUTABLE} ${generator} ${yml_block} ) -endmacro(GEN_BLOCK_XML) +endmacro(GEN_BLOCK_YML) -GEN_BLOCK_XML(gen_uhd_usrp_blocks.py uhd_usrp_source.xml) -GEN_BLOCK_XML(gen_uhd_usrp_blocks.py uhd_usrp_sink.xml) +GEN_BLOCK_YML(gen_uhd_usrp_blocks.py uhd_usrp_source.block.yml) +GEN_BLOCK_YML(gen_uhd_usrp_blocks.py uhd_usrp_sink.block.yml) -add_custom_target(uhd_grc_xml_blocks ALL DEPENDS ${xml_blocks}) +add_custom_target(uhd_grc_yml_blocks ALL DEPENDS ${yml_blocks}) install(FILES - ${xml_blocks} - uhd_amsg_source.xml - uhd_block_tree.xml + ${yml_blocks} + uhd_amsg_source.block.yml + uhd.tree.yml DESTINATION ${GRC_BLOCKS_DIR} ) diff --git a/gr-uhd/grc/gen_uhd_usrp_blocks.py b/gr-uhd/grc/gen_uhd_usrp_blocks.py index 8b7c58682a..4a7b484f7d 100644 --- a/gr-uhd/grc/gen_uhd_usrp_blocks.py +++ b/gr-uhd/grc/gen_uhd_usrp_blocks.py @@ -19,696 +19,372 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA """ MAIN_TMPL = """\ -<?xml version="1.0"?> -<block> - <name>UHD: USRP $sourk.title()</name> - <key>uhd_usrp_$(sourk)</key> - <flags>throttle</flags> - <import>from gnuradio import uhd</import> - <import>import time</import> - <make>uhd.usrp_$(sourk)( - ",".join((\$dev_addr, \$dev_args)), - uhd.stream_args( - cpu_format="\$type", - \#if \$otw() - otw_format=\$otw, - \#end if - \#if \$stream_args() - args=\$stream_args, - \#end if - \#if \$stream_chans() - channels=\$stream_chans, - \#else - channels=range(\$nchan), - \#end if - ),$lentag_arg -) -\#if \$clock_rate() -self.\$(id).set_clock_rate(\$clock_rate, uhd.ALL_MBOARDS) -\#end if -#for $m in range($max_mboards) -######################################################################## -\#if \$num_mboards() > $m and \$clock_source$(m)() -self.\$(id).set_clock_source(\$clock_source$(m), $m) -\#end if -######################################################################## -\#if \$num_mboards() > $m and \$time_source$(m)() -self.\$(id).set_time_source(\$time_source$(m), $m) -\#end if -######################################################################## -\#if \$num_mboards() > $m and \$sd_spec$(m)() -self.\$(id).set_subdev_spec(\$sd_spec$(m), $m) -\#end if -######################################################################## -#end for -self.\$(id).set_samp_rate(\$samp_rate) -\#if \$sync() == 'sync' -self.\$(id).set_time_unknown_pps(uhd.time_spec()) -\#elif \$sync() == 'pc_clock' -self.\$(id).set_time_now(uhd.time_spec(time.time()), uhd.ALL_MBOARDS) -\#end if -#for $n in range($max_nchan) -\#if \$nchan() > $n -self.\$(id).set_center_freq(\$center_freq$(n), $n) -\#if \$norm_gain${n}() -self.\$(id).set_normalized_gain(\$gain$(n), $n) -\#else -self.\$(id).set_gain(\$gain$(n), $n) -\#end if - \#if \$ant$(n)() -self.\$(id).set_antenna(\$ant$(n), $n) - \#end if - \#if \$bw$(n)() -self.\$(id).set_bandwidth(\$bw$(n), $n) - \#end if -#if $sourk == 'source' - \#if \$lo_export$(n)() and not \$hide_lo_controls() -self.\$(id).set_lo_export_enabled(\$lo_export$(n), uhd.ALL_LOS, $n) - \#end if - \#if \$lo_source$(n)() and not \$hide_lo_controls() -self.\$(id).set_lo_source(\$lo_source$(n), uhd.ALL_LOS, $n) - \#end if - \#if \$dc_offs_enb$(n)() -self.\$(id).set_auto_dc_offset(\$dc_offs_enb$(n), $n) - \#end if - \#if \$iq_imbal_enb$(n)() -self.\$(id).set_auto_iq_balance(\$iq_imbal_enb$(n), $n) - \#end if -#end if -\#end if -#end for -</make> - <callback>set_samp_rate(\$samp_rate)</callback> - #for $n in range($max_nchan) - <callback>set_center_freq(\$center_freq$(n), $n)</callback> - <callback>\#if \$norm_gain${n}() -self.\$(id).set_normalized_gain(\$gain$(n), $n) -\#else -self.\$(id).set_gain(\$gain$(n), $n) -\#end if - </callback> - <callback>\#if not \$hide_lo_controls() -set_lo_source(\$lo_source$(n), uhd.ALL_LOS, $n) -\#end if - </callback> - <callback>\#if not \$hide_lo_controls() -set_lo_export_enabled(\$lo_export$(n), uhd.ALL_LOS, $n) -\#end if - </callback> - <callback>set_antenna(\$ant$(n), $n)</callback> - <callback>set_bandwidth(\$bw$(n), $n)</callback> - #end for - <param> - <name>$(direction.title())put Type</name> - <key>type</key> - <type>enum</type> - <option> - <name>Complex float32</name> - <key>fc32</key> - <opt>type:fc32</opt> - </option> - <option> - <name>Complex int16</name> - <key>sc16</key> - <opt>type:sc16</opt> - </option> - <option> - <name>VITA word32</name> - <key>item32</key> - <opt>type:s32</opt> - </option> - </param> - <param> - <name>Wire Format</name> - <key>otw</key> - <value></value> - <type>string</type> - <hide> - \#if \$otw() - none - \#else - part - \#end if - </hide> - <option> - <name>Automatic</name> - <key></key> - </option> - <option> - <name>Complex int16</name> - <key>sc16</key> - </option> - <option> - <name>Complex int12</name> - <key>sc12</key> - </option> - <option> - <name>Complex int8</name> - <key>sc8</key> - </option> - </param> - <param> - <name>Stream args</name> - <key>stream_args</key> - <value></value> - <type>string</type> - <hide> - \#if \$stream_args() - none - \#else - part - \#end if - </hide> - <option> - <name>peak=0.003906</name> - <key>peak=0.003906</key> - </option> - </param> - <param> - <name>Stream channels</name> - <key>stream_chans</key> - <value>[]</value> - <type>int_vector</type> - <hide> - \#if \$stream_chans() - none - \#else - part - \#end if - </hide> - </param> - <param> - <name>Device Address</name> - <key>dev_addr</key> - <value>""</value> - <type>string</type> - <hide> - \#if \$dev_addr() - none - \#else - part - \#end if - </hide> - </param> - <param> - <name>Device Arguments</name> - <key>dev_args</key> - <value>""</value> - <type>string</type> - <hide> - \#if \$dev_args() - none - \#else - part - \#end if - </hide> - </param> - <param> - <name>Sync</name> - <key>sync</key> - <value></value> - <type>enum</type> - <hide>\#if \$sync() then 'none' else 'part'#</hide> - <option> - <name>unknown PPS</name> - <key>sync</key> - </option> - <option> - <name>PC Clock</name> - <key>pc_clock</key> - </option> - <option> - <name>don't sync</name> - <key></key> - </option> - </param> - <param> - <name>Clock Rate (Hz)</name> - <key>clock_rate</key> - <value>0.0</value> - <type>real</type> - <hide>\#if \$clock_rate() then 'none' else 'part'#</hide> - <option> - <name>Default</name> - <key>0.0</key> - </option> - <option> - <name>200 MHz</name> - <key>200e6</key> - </option> - <option> - <name>184.32 MHz</name> - <key>184.32e6</key> - </option> - <option> - <name>120 MHz</name> - <key>120e6</key> - </option> - <option> - <name>30.72 MHz</name> - <key>30.72e6</key> - </option> - </param> - <param> - <name>Num Mboards</name> - <key>num_mboards</key> - <value>1</value> - <type>int</type> - <hide>part</hide> - #for $m in range(1, $max_mboards+1) - <option> - <name>$(m)</name> - <key>$m</key> - </option> - #end for - </param> - #for $m in range($max_mboards) - <param> - <name>Mb$(m): Clock Source</name> - <key>clock_source$(m)</key> - <value></value> - <type>string</type> - <hide> - \#if not \$num_mboards() > $m - all - \#elif \$clock_source$(m)() - none - \#else - part - \#end if - </hide> - <option><name>Default</name><key></key></option> - <option><name>Internal</name><key>internal</key></option> - <option><name>External</name><key>external</key></option> - <option><name>MIMO Cable</name><key>mimo</key></option> - <option><name>O/B GPSDO</name><key>gpsdo</key></option> - </param> - <param> - <name>Mb$(m): Time Source</name> - <key>time_source$(m)</key> - <value></value> - <type>string</type> - <hide> - \#if not \$num_mboards() > $m - all - \#elif \$time_source$(m)() - none - \#else - part - \#end if - </hide> - <option><name>Default</name><key></key></option> - <option><name>External</name><key>external</key></option> - <option><name>MIMO Cable</name><key>mimo</key></option> - <option><name>O/B GPSDO</name><key>gpsdo</key></option> - </param> - <param> - <name>Mb$(m): Subdev Spec</name> - <key>sd_spec$(m)</key> - <value></value> - <type>string</type> - <hide> - \#if not \$num_mboards() > $m - all - \#elif \$sd_spec$(m)() - none - \#else - part - \#end if - </hide> - </param> - #end for - <param> - <name>Num Channels</name> - <key>nchan</key> - <value>1</value> - <type>int</type> - #for $n in range(1, $max_nchan+1) - <option> - <name>$(n)</name> - <key>$n</key> - </option> - #end for - </param> - <param> - <name>Samp Rate (Sps)</name> - <key>samp_rate</key> - <value>samp_rate</value> - <type>real</type> - </param> - $params - <check>$max_nchan >= \$nchan</check> - <check>\$nchan > 0</check> - <check>$max_mboards >= \$num_mboards</check> - <check>\$num_mboards > 0</check> - <check>\$nchan >= \$num_mboards</check> - <check>(not \$stream_chans()) or (\$nchan == len(\$stream_chans))</check> - #for $n in range($max_nchan) - <check>(\$norm_gain${n} and \$gain${n} >= 0 and \$gain${n} <= 1) or not \$norm_gain${n}</check> - #end for - <sink> - <name>command</name> - <type>message</type> - <optional>1</optional> - <hide>\$hide_cmd_port</hide> - </sink> - <$sourk> - <name>$direction</name> - <type>\$type.type</type> - <nports>\$nchan</nports> - </$sourk> - <doc> -The UHD USRP $sourk.title() Block: - -Device Address: -The device address is a delimited string used to locate UHD devices on your system. \\ -If left blank, the first UHD device found will be used. \\ -Use the device address to specify a specific device or list of devices. -USRP1 Example: serial=12345678 -USRP2 Example: addr=192.168.10.2 -USRP2 Example: addr0=192.168.10.2, addr1=192.168.10.3 - -$(direction.title()) Type: -This parameter controls the data type of the stream in gnuradio. - -Wire Format: -This parameter controls the form of the data over the bus/network. \ -Complex bytes may be used to trade off precision for bandwidth. \ -Not all formats are supported on all devices. - -Stream Args: -Optional arguments to be passed in the UHD streamer object. \ -Streamer args is a list of key/value pairs; usage is determined by the implementation. -Ex: the scalar key affects the scaling between 16 and 8 bit integers in sc8 wire format. - -Num Motherboards: -Selects the number of USRP motherboards in this device configuration. - -Reference Source: -Where the motherboard should sync its time and clock references. -If source and sink blocks reference the same device, -it is only necessary to set the reference source on one of the blocks. - -Subdevice specification: -Each motherboard should have its own subdevice specification \\ -and all subdevice specifications should be the same length. \\ -Select the subdevice or subdevices for each channel using a markup string. \\ -The markup string consists of a list of dboard_slot:subdev_name pairs (one pair per channel). \\ -If left blank, the UHD will try to select the first subdevice on your system. \\ -See the application notes for further details. -Single channel example: :AB -Dual channel example: :A :B - -Num Channels: -Selects the total number of channels in this multi-USRP configuration. -Ex: 4 motherboards with 2 channels per board = 8 channels total - -Sample rate: -The sample rate is the number of samples per second input by this block. \\ -The UHD device driver will try its best to match the requested sample rate. \\ -If the requested rate is not possible, the UHD block will print an error at runtime. - -Center frequency: -The center frequency is the overall frequency of the RF chain. \\ -For greater control of how the UHD tunes elements in the RF chain, \\ +id: uhd_usrp_sink +label: 'UHD: USRP ${sourk.title()}' +flags: throttle + +parameters: +- id: type + label: ${'$'}{direction.title()}put Type + dtype: enum + options: [fc32, sc16, item32] + option_labels: [Complex float32, Complex int16, VITA word32] + option_attributes: + type: [fc32, sc16, s32] + hide: part +- id: otw + label: Wire Format + dtype: enum + options: ['', sc16, sc12, sc8] + option_labels: [Automatic, Complex int16, Complex int12, Complex int8] + hide: ${'$'}{ 'none' if otw else 'part'} +- id: stream_args + label: Stream args + dtype: string + options: [peak=0.003906] + option_labels: [peak=0.003906] + hide: ${'$'}{ 'none' if stream_args else 'part'} +- id: stream_chans + label: Stream channels + dtype: int_vector + default: '[]' + hide: ${'$'}{ 'none' if stream_chans else 'part'} +- id: dev_addr + label: Device Address + dtype: string + default: '""' + hide: ${'$'}{ 'none' if dev_addr else 'part'} +- id: dev_args + label: Device Arguments + dtype: string + default: '""' + hide: ${'$'}{ 'none' if dev_args else 'part'} +- id: sync + label: Sync + dtype: enum + options: [sync, pc_clock, ''] + option_labels: [unknown PPS, PC Clock, don't sync] + hide: ${'$'}{ 'none' if sync else 'part'} +- id: clock_rate + label: Clock Rate (Hz) + dtype: real + default: '0.0' + options: ['0.0', 200e6, 184.32e6, 120e6, 30.72e6] + option_labels: [Default, 200 MHz, 184.32 MHz, 120 MHz, 30.72 MHz] + hide: ${'$'}{ 'none' if clock_rate else 'part' } +- id: num_mboards + label: Num Mboards + dtype: int + default: '1' + options: ['1', '2', '3', '4', '5', '6', '7', '8'] + hide: part +% for m in range(max_mboards): +- id: clock_source${m} + label: 'Mb${m}: Clock Source' + dtype: string + options: ['', internal, external, mimo, gpsdo] + option_labels: [Default, Internal, External, MIMO Cable, O/B GPSDO] + hide: ${'$'}{ 'all' if not (num_mboards > ${m}) else ( 'none' if clock_source${m}) else 'part')} +- id: time_source${m} + label: 'Mb${m}: Time Source' + dtype: string + options: ['', external, mimo, gpsdo] + option_labels: [Default, External, MIMO Cable, O/B GPSDO] + hide: ${'$'}{ 'all' if not (num_mboards > ${m}) else ('none' if time_source${m}) else 'part')} +- id: sd_spec${m} + label: 'Mb${m}: Subdev Spec' + dtype: string + hide: ${'$'}{ 'all' if not (num_mboards > ${m}) else ('none' if sd_spec${m}) else 'part')} +% endfor +- id: nchan + label: Num Channels + dtype: int + default: 1 + options: [ ${", ".join([str(n) for n in range(1, max_nchan+1)])} ] + hide: part +- id: samp_rate + label: Smp rate (Sps) + dtype: real +${params} + + + +inputs: +- domain: message + id: command + optional: true + hide: ${'$'}{hide_cmd_port} +% if sourk == 'sink': +- domain: stream +% else: + +outputs: +- domain: stream +% endif + dtype: ${'$'}{type.type} + multiplicity: ${'$'}{nchan} + +templates: + imports: |- + from gnuradio import uhd + import time + make: | + uhd.usrp_sink( + ",".join((${'$'}{dev_addr}, ${'$'}{dev_args})), + uhd.stream_args( + cpu_format="${'$'}{type}", + ${'%'} if otw: + otw_format=${'$'}{otw}, + ${'%'} endif + ${'%'} if stream_args: + args=${'$'}{stream_args}, + ${'%'} endif + ${'%'} if stream_chans: + channels=${'$'}{stream_chans}, + ${'%'} else: + channels=range(${'$'}{nchan}), + ${'%'} endif + ), + ${'%'} if len_tag_name: + ${'$'}{len_tag_name}, + ${'%'} endif + ) + ${'%'} if clock_rate: + self.${'$'}{id}.set_clock_rate(${'$'}{clock_rate}, uhd.ALL_MBOARDS) + ${'%'} endif + self.${'$'}{id}.set_samp_rate(${'$'}{samp_rate}) + ${'%'} if sync == 'sync': + self.${'$'}{id}.set_time_unknown_pps(uhd.time_spec()) + #elif ${'$'}{sync} == 'pc_clock' + self.${'$'}{id}.set_time_now(uhd.time_spec(time.time()), uhd.ALL_MBOARDS) + ${'%'} endif + callbacks: + - set_samp_rate(${'$'}{samp_rate}) + % for n in range(max_nchan): + - set_center_freq(${'center_freq' + str(n)}, ${n}) + - self.${'$'}{id}.set_${'$'}{'normalized_' if eval('norm_gain' + str(n))}gain(gain${n}, ${n}) + - ${'$'}{'set_lo_source(lo_source${n}, uhd.ALL_LOS, ${n})' if not hide_lo_controls()} + - ${'$'}{'set_lo_export_enabled(lo_export${n}, uhd.ALL_LOS, ${n})' if not hide_lo_controls()} + - set_antenna(${'ant' + str(n)}, ${n}) + - set_bandwidth(${'bw' + str(n)}, ${n}) + % endfor + + +documentation: |- + The UHD USRP ${sourk.title()} Block: + + Device Address: + The device address is a delimited string used to locate UHD devices on your system. \\ + If left blank, the first UHD device found will be used. \\ + Use the device address to specify a specific device or list of devices. + USRP1 Example: serial=12345678 + USRP2 Example: addr=192.168.10.2 + USRP2 Example: addr0=192.168.10.2, addr1=192.168.10.3 + + ${direction.title()} Type: + This parameter controls the data type of the stream in gnuradio. + + Wire Format: + This parameter controls the form of the data over the bus/network. \ + Complex bytes may be used to trade off precision for bandwidth. \ + Not all formats are supported on all devices. + + Stream Args: + Optional arguments to be passed in the UHD streamer object. \ + Streamer args is a list of key/value pairs; usage is determined by the implementation. + Ex: the scalar key affects the scaling between 16 and 8 bit integers in sc8 wire format. + + Num Motherboards: + Selects the number of USRP motherboards in this device configuration. + + Reference Source: + Where the motherboard should sync its time and clock references. + If source and sink blocks reference the same device, + it is only necessary to set the reference source on one of the blocks. + + Subdevice specification: + Each motherboard should have its own subdevice specification \\ + and all subdevice specifications should be the same length. \\ + Select the subdevice or subdevices for each channel using a markup string. \\ + The markup string consists of a list of dboard_slot:subdev_name pairs (one pair per channel). \\ + If left blank, the UHD will try to select the first subdevice on your system. \\ + See the application notes for further details. + Single channel example: :AB + Dual channel example: :A :B + + Num Channels: + Selects the total number of channels in this multi-USRP configuration. + Ex: 4 motherboards with 2 channels per board = 8 channels total + + Sample rate: + The sample rate is the number of samples per second input by this block. \\ + The UHD device driver will try its best to match the requested sample rate. \\ + If the requested rate is not possible, the UHD block will print an error at runtime. + + Center frequency: + The center frequency is the overall frequency of the RF chain. \\ + For greater control of how the UHD tunes elements in the RF chain, \\ pass a tune_request object rather than a simple target frequency. -Tuning with an LO offset example: uhd.tune_request(freq, lo_off) -Tuning without DSP: uhd.tune_request(target_freq, dsp_freq=0, \\ + Tuning with an LO offset example: uhd.tune_request(freq, lo_off) + Tuning without DSP: uhd.tune_request(target_freq, dsp_freq=0, \\ dsp_freq_policy=uhd.tune_request.POLICY_MANUAL) -Antenna: -For subdevices with only one antenna, this may be left blank. \\ -Otherwise, the user should specify one of the possible antenna choices. \\ -See the daughterboard application notes for the possible antenna choices. + Antenna: + For subdevices with only one antenna, this may be left blank. \\ + Otherwise, the user should specify one of the possible antenna choices. \\ + See the daughterboard application notes for the possible antenna choices. -Bandwidth: -To use the default bandwidth filter setting, this should be zero. \\ -Only certain subdevices have configurable bandwidth filters. \\ -See the daughterboard application notes for possible configurations. + Bandwidth: + To use the default bandwidth filter setting, this should be zero. \\ + Only certain subdevices have configurable bandwidth filters. \\ + See the daughterboard application notes for possible configurations. -Length tag key (Sink only): -When a nonempty string is given, the USRP sink will look for length tags \\ -to determine transmit burst lengths. + Length tag key (Sink only): + When a nonempty string is given, the USRP sink will look for length tags \\ + to determine transmit burst lengths. -See the UHD manual for more detailed documentation: -http://uhd.ettus.com - </doc> -</block> + See the UHD manual for more detailed documentation: + http://uhd.ettus.com + +file_format: 1 """ -PARAMS_TMPL = """ <param> - <name>Ch$(n): Center Freq (Hz)</name> - <key>center_freq$(n)</key> - <value>0</value> - <type>real</type> - <hide>\#if \$nchan() > $n then 'none' else 'all'#</hide> - <tab>RF Options</tab> - </param> - <param> - <name>Ch$(n): Gain Value</name> - <key>gain$(n)</key> - <value>0</value> - <type>float</type> - <hide>\#if \$nchan() > $n then 'none' else 'all'#</hide> - <tab>RF Options</tab> - </param> - <param> - <name>Ch$(n): Gain Type</name> - <key>norm_gain$(n)</key> - <value>False</value> - <type>bool</type> - <hide>\#if \$nchan() <= $n - all - \#elif bool(\$norm_gain${n}()) - none - \#else - part - \#end if</hide> - <option> - <name>Absolute (dB)</name> - <key>False</key> - </option> - <option> - <name>Normalized</name> - <key>True</key> - </option> - <tab>RF Options</tab> - </param> - <param> - <name>Ch$(n): Antenna</name> - <key>ant$(n)</key> - <value></value> - <type>string</type> - <hide> - \#if not \$nchan() > $n - all - \#elif \$ant$(n)() - none - \#else - part - \#end if - </hide> - <option> - <name>TX/RX</name> - <key>TX/RX</key> - </option> -#if $sourk == 'source' - <option> - <name>RX2</name> - <key>RX2</key> - </option> - <option> - <name>RX1</name> - <key>RX1</key> - </option> -#end if - <tab>RF Options</tab> - </param> - <param> - <name>Ch$(n): Bandwidth (Hz)</name> - <key>bw$(n)</key> - <value>0</value> - <type>real</type> - <hide> - \#if not \$nchan() > $n - all - \#elif \$bw$(n)() - none - \#else - part - \#end if - </hide> - <tab>RF Options</tab> - </param> -#if $sourk == 'source' - <param> - <name>Ch$(n): LO Source</name> - <key>lo_source$(n)</key> - <value>internal</value> - <type>string</type> - <hide> - \#if not \$nchan() > $n - all - \#elif \$hide_lo_controls() - all - \#else - none - \#end if - </hide> - <option> - <name>Internal</name> - <key>internal</key> - </option> - <option> - <name>External</name> - <key>external</key> - </option> - <option> - <name>Companion</name> - <key>companion</key> - </option> - <tab>RF Options</tab> - </param> -#end if -#if $sourk == 'source' - <param> - <name>Ch$(n): LO Export</name> - <key>lo_export$(n)</key> - <value>False</value> - <type>bool</type> - <hide> - \#if not \$nchan() > $n - all - \#elif \$hide_lo_controls() - all - \#else - none - \#end if - </hide> - <option> - <name>True</name> - <key>True</key> - </option> - <option> - <name>False</name> - <key>False</key> - </option> - <tab>RF Options</tab> - </param> -#end if -#if $sourk == 'source' - <param> - <name>Ch$(n): Enable DC Offset Correction</name> - <key>dc_offs_enb$(n)</key> - <value>""</value> - <type>raw</type> - <hide> - \#if not \$nchan() > $n - all - \#else - part - \#end if - </hide> - <tab>FE Corrections</tab> - </param> - <param> - <name>Ch$(n): Enable IQ Imbalance Correction</name> - <key>iq_imbal_enb$(n)</key> - <value>""</value> - <type>raw</type> - <hide> - \#if not \$nchan() > $n - all - \#else - part - \#end if - </hide> - <tab>FE Corrections</tab> - </param> -#end if +PARAMS_TMPL = """ +- id: center_freq${n} + label: 'Ch${n}: Center Freq (Hz)' + category: RF Options + dtype: real + default: '0' + hide: ${'$'}{ 'none' if (nchan > ${n}) else 'all' } +- id: gain${n} + label: 'Ch${n}: Gain Value' + category: RF Options + dtype: float + default: '0' + hide: ${'$'}{ 'none' if nchan > ${n} else 'all' } +- id: norm_gain${n} + label: 'Ch${n}: Gain Type' + category: RF Options + dtype: bool + default: 'False' + options: ['False', 'True'] + option_labels: [Absolute (dB), Normalized] + hide: ${'$'}{ 'all' if nchan <= ${n} else ('none' if bool(eval('norm_gain' + str(n))) else 'part')} +- id: ant${n} + label: 'Ch${n}: Antenna' + category: RF Options + dtype: string +% if sourk == 'source': + options: [TX/RX, RX2, RX1] + option_labels: [TX/RX, RX2, RX1] +% else: + options: [TX/RX] + option_labels: [TX/RX] +% endif + hide: ${'$'}{ 'all' if not nchan > ${n} else ('none' if eval('ant' + str(n)) else 'part')} +- id: bw${n} + label: 'Ch${n}: Bandwidth (Hz)' + category: RF Options + dtype: real + default: '0' + hide: ${'$'}{ 'all' if not nchan > ${n} else ('none' if eval('bw' + str(n)) else 'part')} +% if sourk == 'source': +- id: lo_source${n} + label: 'Ch${n}: LO Source' + category: RF Options + dtype: string + default: internal + options: [internal, external, companion] + hide: ${'$'}{ 'all' if not nchan > ${n} else ('all' if hide_lo_controls else 'none')} +- id: lo_export + label: 'Ch${n}: LO Export' + category: RF Options + dtype: bool + default: 'False' + options: ['True', 'False'] + hide: ${'$'}{ 'all' if not nchan > ${n} else ('all' if hide_lo_controls else 'none')} +- id: dc_offs_enb${n} + label: 'Ch${n}: Enable DC Offset Correction' + category: FE Corrections + dtype: raw + default: '""' + hide: ${'$'}{ 'all' if not nchan > ${n} else 'part'} +- id: iq_imbal_enb${n} + label: 'Ch${n}: Enable IQ Imbalance Correction' + category: FE Corrections + dtype: raw + default: '""' + hide: ${'$'}{ 'all' if not nchan > ${n} else 'part'} +% endif """ SHOW_CMD_PORT_PARAM = """ - <param> - <name>Show Command Port</name> - <key>hide_cmd_port</key> - <value>False</value> - <type>enum</type> - <hide>part</hide> - <option> - <name>Yes</name> - <key>False</key> - </option> - <option> - <name>No</name> - <key>True</key> - </option> - <tab>Advanced</tab> - </param> +- id: hide_cmd_port + label: Show Command Port + category: Advanced + dtype: enum + default: 'False' + options: ['False', 'True'] + option_labels: ['Yes', 'No'] + hide: part """ SHOW_LO_CONTROLS_PARAM = """ - <param> - <name>Show LO Controls</name> - <key>hide_lo_controls</key> - <value>True</value> - <type>bool</type> - <hide>part</hide> - <option> - <name>Yes</name> - <key>False</key> - </option> - <option> - <name>No</name> - <key>True</key> - </option> - <tab>Advanced</tab> - </param> +- id: hide_lo_controls + label: Show LO Controls + category: Advanced + dtype: bool + default: 'True' + options: ['False', 'True'] + option_labels: ['Yes', 'No'] + hide: part """ -TSBTAG_PARAM = """ <param> - <name>TSB tag name</name> - <key>len_tag_name</key> - <value></value> - <type>string</type> - <hide>\#if len(str(\$len_tag_name())) then 'none' else 'part'#</hide> - </param>""" +TSBTAG_PARAM = """ +- id: len_tag_name + label: TSB tag name + dtype: string + hide: ${ 'none' if len(str(len_tag_name)) else 'part'} +""" TSBTAG_ARG = """ - #if $len_tag_name() - $len_tag_name, - #end if""" +${'%'} if len_tag_name(): +${'$'}{len_tag_name}, +${'%'} endif +""" def parse_tmpl(_tmpl, **kwargs): - from Cheetah import Template - return str(Template.Template(_tmpl, kwargs)) + from mako.template import Template + block_template = Template(_tmpl) + return str(block_template.render(**kwargs)) max_num_mboards = 8 max_num_channels = max_num_mboards*4 if __name__ == '__main__': - import sys - for file in sys.argv[1:]: - if file.endswith ('source.xml'): - sourk = 'source' - direction = 'out' - elif file.endswith ('sink.xml'): - sourk = 'sink' - direction = 'in' - else: raise Exception, 'is %s a source or sink?'%file - - params = ''.join([parse_tmpl(PARAMS_TMPL, n=n, sourk=sourk) for n in range(max_num_channels)]) - params += SHOW_CMD_PORT_PARAM - params += SHOW_LO_CONTROLS_PARAM - if sourk == 'sink': - params += TSBTAG_PARAM - lentag_arg = TSBTAG_ARG - else: lentag_arg = '' - open(file, 'w').write(parse_tmpl(MAIN_TMPL, - lentag_arg=lentag_arg, - max_nchan=max_num_channels, - max_mboards=max_num_mboards, - params=params, - sourk=sourk, - direction=direction, - )) + import sys + for file in sys.argv[1:]: + if file.endswith ('source.block.yml'): + sourk = 'source' + direction = 'out' + elif file.endswith ('sink.block.yml'): + sourk = 'sink' + direction = 'in' + else: raise Exception('is % a source or sink?'%file) + + params = ''.join([parse_tmpl(PARAMS_TMPL, n=n, sourk=sourk) for n in range(max_num_channels)]) + params += SHOW_CMD_PORT_PARAM + params += SHOW_LO_CONTROLS_PARAM + if sourk == 'sink': + params += TSBTAG_PARAM + lentag_arg = TSBTAG_ARG + else: lentag_arg = '' + + open(file, 'w').write(parse_tmpl(MAIN_TMPL, + lentag_arg=lentag_arg, + max_nchan=max_num_channels, + max_mboards=max_num_mboards, + params=params, + sourk=sourk, + direction=direction, + )) diff --git a/gr-uhd/grc/uhd.tree.yml b/gr-uhd/grc/uhd.tree.yml new file mode 100644 index 0000000000..a4d140d779 --- /dev/null +++ b/gr-uhd/grc/uhd.tree.yml @@ -0,0 +1,5 @@ +'[Core]': +- UHD: + - uhd_usrp_source + - uhd_usrp_sink + - uhd_amsg_source diff --git a/gr-uhd/grc/uhd_amsg_source.block.yml b/gr-uhd/grc/uhd_amsg_source.block.yml new file mode 100644 index 0000000000..b07ab77913 --- /dev/null +++ b/gr-uhd/grc/uhd_amsg_source.block.yml @@ -0,0 +1,18 @@ +id: uhd_amsg_source +label: 'UHD: USRP Async Msg Source' + +parameters: +- id: dev_addr + label: Device Addr + dtype: string + hide: ${ 'none' if dev_addr else 'part' } + +outputs: +- domain: stream + dtype: msg + +templates: + imports: from gnuradio import uhd + make: uhd.amsg_source(device_addr=${dev_addr}, msgq=${id}_msgq_out) + +file_format: 1 diff --git a/gr-uhd/grc/uhd_amsg_source.xml b/gr-uhd/grc/uhd_amsg_source.xml deleted file mode 100644 index 78c9d7b58e..0000000000 --- a/gr-uhd/grc/uhd_amsg_source.xml +++ /dev/null @@ -1,24 +0,0 @@ -<?xml version="1.0"?> -<block> - <name>UHD: USRP Async Msg Source</name> - <key>uhd_amsg_source</key> - <import>from gnuradio import uhd</import> - <make>uhd.amsg_source(device_addr=$dev_addr, msgq=$(id)_msgq_out)</make> - <param> - <name>Device Addr</name> - <key>dev_addr</key> - <value></value> - <type>string</type> - <hide> - #if $dev_addr() - none - #else - part - #end if - </hide> - </param> - <source> - <name>out</name> - <type>msg</type> - </source> -</block> diff --git a/gr-uhd/grc/uhd_block_tree.xml b/gr-uhd/grc/uhd_block_tree.xml deleted file mode 100644 index c598645526..0000000000 --- a/gr-uhd/grc/uhd_block_tree.xml +++ /dev/null @@ -1,15 +0,0 @@ -<?xml version="1.0"?> -<!-- -################################################### -##Block Tree for uhd blocks. -################################################### - --> -<cat> - <name>[Core]</name> <!-- Blank for Root Name --> - <cat> - <name>UHD</name> - <block>uhd_usrp_source</block> - <block>uhd_usrp_sink</block> - <block>uhd_amsg_source</block> - </cat> -</cat> diff --git a/gr-uhd/python/uhd/CMakeLists.txt b/gr-uhd/python/uhd/CMakeLists.txt index ee69e8eb7d..e736edebf0 100644 --- a/gr-uhd/python/uhd/CMakeLists.txt +++ b/gr-uhd/python/uhd/CMakeLists.txt @@ -44,6 +44,6 @@ include(GrTest) file(GLOB py_qa_test_files "qa_*.py") foreach(py_qa_test_file ${py_qa_test_files}) get_filename_component(py_qa_test_name ${py_qa_test_file} NAME_WE) - GR_ADD_TEST(${py_qa_test_name} ${QA_PYTHON_EXECUTABLE} ${PYTHON_DASH_B} ${py_qa_test_file}) + GR_ADD_TEST(${py_qa_test_name} ${QA_PYTHON_EXECUTABLE} -B ${py_qa_test_file}) endforeach(py_qa_test_file) endif(ENABLE_TESTING) diff --git a/gr-uhd/python/uhd/__init__.py b/gr-uhd/python/uhd/__init__.py index 0e8176f97f..d9f4eaab3e 100644 --- a/gr-uhd/python/uhd/__init__.py +++ b/gr-uhd/python/uhd/__init__.py @@ -25,17 +25,20 @@ Used to send and receive data between the Ettus Research, LLC product line. ''' +from __future__ import absolute_import +from __future__ import unicode_literals + ######################################################################## # Prepare uhd swig module to make it more pythonic ######################################################################## def _prepare_uhd_swig(): try: - import uhd_swig + from . import uhd_swig except ImportError: import os dirname, filename = os.path.split(os.path.abspath(__file__)) __path__.append(os.path.join(dirname, "..", "..", "swig")) - import uhd_swig + from . import uhd_swig #some useful typedefs for the user setattr(uhd_swig, 'freq_range_t', uhd_swig.meta_range_t) @@ -50,7 +53,7 @@ def _prepare_uhd_swig(): def __float__(self): return self.target_freq def __init__(self, *args, **kwargs): super(tune_request_t, self).__init__(*args) - for key, val in kwargs.iteritems(): setattr(self, key, val) + for key, val in list(kwargs.items()): setattr(self, key, val) setattr(uhd_swig, 'tune_request_t', tune_request_t) #Make the python tune request object inherit from string @@ -64,14 +67,14 @@ def _prepare_uhd_swig(): def __init__(self, *args, **kwargs): super(device_addr_t, self).__init__(*args) if args and isinstance(args[0], device_addr_t): - for key in args[0].keys(): self[key] = args[0][key] + for key in list(args[0].keys()): self[key] = args[0][key] setattr(uhd_swig, 'device_addr_t', device_addr_t) #make the streamer args take **kwargs on init class stream_args_t(uhd_swig.stream_args_t): def __init__(self, *args, **kwargs): super(stream_args_t, self).__init__(*args) - for key, val in kwargs.iteritems(): + for key, val in list(kwargs.items()): #for some reason, I can't assign a list in the constructor #but what I can do is append the elements individually if key == 'channels': @@ -97,7 +100,7 @@ def _prepare_uhd_swig(): def find_devices(*args, **kwargs): def to_pythonized_dev_addr(dev_addr): new_dev_addr = uhd_swig.device_addr_t() - for key in dev_addr.keys(): new_dev_addr[key] = dev_addr.get(key) + for key in list(dev_addr.keys()): new_dev_addr[key] = dev_addr.get(key) return new_dev_addr return __builtins__['map'](to_pythonized_dev_addr, uhd_swig.find_devices_raw(*args, **kwargs)) setattr(uhd_swig, 'find_devices', find_devices) @@ -114,11 +117,11 @@ def _prepare_uhd_swig(): ): try: if len(args) > index: args[index] = cast(args[index]) - if kwargs.has_key(key): kwargs[key] = cast(kwargs[key]) + if key in kwargs: kwargs[key] = cast(kwargs[key]) except: pass #don't pass kwargs, it confuses swig, map into args list: for key in ('device_addr', 'stream_args', 'io_type', 'num_channels', 'msgq'): - if kwargs.has_key(key): args.append(kwargs[key]) + if key in kwargs: args.append(kwargs[key]) return old_constructor(*args) return constructor_interceptor setattr(uhd_swig, attr, constructor_factory(getattr(uhd_swig, attr))) @@ -133,4 +136,4 @@ def _prepare_uhd_swig(): # Initialize this module with the contents of uhd swig ######################################################################## _prepare_uhd_swig() -from uhd_swig import * +from .uhd_swig import * diff --git a/gr-uhd/python/uhd/qa_uhd.py b/gr-uhd/python/uhd/qa_uhd.py index 4df0d4273e..bab029a9a8 100644 --- a/gr-uhd/python/uhd/qa_uhd.py +++ b/gr-uhd/python/uhd/qa_uhd.py @@ -20,6 +20,8 @@ # Boston, MA 02110-1301, USA. # +from __future__ import print_function + from gnuradio import gr, gr_unittest, uhd class test_uhd(gr_unittest.TestCase): @@ -50,7 +52,7 @@ class test_uhd(gr_unittest.TestCase): sa = uhd.stream_args_t() sa.channels.append(1) sa.channels.append(0) - print sa.channels + print(sa.channels) self.assertEqual(len(sa.channels), 2) self.assertEqual(sa.channels[0], 1) self.assertEqual(sa.channels[1], 0) |