diff options
Diffstat (limited to 'gr-utils')
-rw-r--r-- | gr-utils/src/python/Makefile.am | 1 | ||||
-rwxr-xr-x | gr-utils/src/python/create-gnuradio-out-of-tree-project | 69 | ||||
-rwxr-xr-x | gr-utils/src/python/usrp2_fft.py | 4 | ||||
-rwxr-xr-x | gr-utils/src/python/usrp_fft.py | 6 | ||||
-rwxr-xr-x | gr-utils/src/python/usrp_oscope.py | 2 | ||||
-rwxr-xr-x | gr-utils/src/python/usrp_siggen.py | 19 | ||||
-rwxr-xr-x | gr-utils/src/python/usrp_siggen_gui.py | 9 |
7 files changed, 96 insertions, 14 deletions
diff --git a/gr-utils/src/python/Makefile.am b/gr-utils/src/python/Makefile.am index fb21e4f44..9c4e222c8 100644 --- a/gr-utils/src/python/Makefile.am +++ b/gr-utils/src/python/Makefile.am @@ -35,6 +35,7 @@ ourpython_PYTHON = \ pyqt_filter.py bin_SCRIPTS = \ + create-gnuradio-out-of-tree-project \ gr_plot_char.py \ gr_plot_const.py \ gr_plot_fft.py \ diff --git a/gr-utils/src/python/create-gnuradio-out-of-tree-project b/gr-utils/src/python/create-gnuradio-out-of-tree-project new file mode 100755 index 000000000..1f512b219 --- /dev/null +++ b/gr-utils/src/python/create-gnuradio-out-of-tree-project @@ -0,0 +1,69 @@ +#!/usr/bin/env python + +from optparse import OptionParser +import os +import re +import sys +import subprocess + +tarball_url="http://gnuradio.org/releases/gnuradio/gr-howto-write-a-block-3.3git-651-g642252d8.tar.gz" + +def open_tarball(tarball_name=None): + """Return a readable fileobject that references the tarball. + If tarball_name is None, download from the net + """ + if tarball_name: + return open(tarball_name, 'r') + p = subprocess.Popen(["wget", "-O", "-", tarball_url], + close_fds=True, stdout=subprocess.PIPE) + return p.stdout + +def extract_and_rename_files(tarball, module_name): + # Requires GNU tar. + tar_cmd = 'tar xz --strip-components=1 --transform="s/howto/%s/g"' % (module_name,) + p = subprocess.Popen(tar_cmd, shell=True, stdin=tarball, close_fds=True) + sts = os.waitpid(p.pid, 0) + return sts == 0 + +def main(): + usage = "%prog: [options] new_module_name" + description="Create a prototype 'out of tree' GNU Radio project" + parser = OptionParser(usage=usage, description=description) + parser.add_option("-T", "--tarball", type="string", default=None, + help="path to gr-howto-build-a-block gzipped tarball [default=<get from web>]") + (options, args) = parser.parse_args() + if len(args) != 1: + parser.print_help() + raise SystemExit,2 + module_name = args[0] + if not re.match(r'[_a-z][_a-z0-9]*$', module_name): + sys.stderr.write("module_name '%s' may only contain [a-z0-9_]\n" % (module_name)) + raise SystemExit, 1 + + # Ensure there's no file or directory called <module_name> + if os.path.exists(module_name): + sys.stderr.write("A file or directory named '%s' already exists\n" % (module_name,)) + raise SystemExit, 1 + + os.mkdir(module_name) + os.chdir(module_name) + + ok = extract_and_rename_files(open_tarball(options.tarball), module_name) + + # rename file contents + upper_module_name = module_name.upper() + sed_cmd = 'sed -i -e "s/howto/%s/g" -e "s/HOWTO/%s/g"' % (module_name, + upper_module_name) + os.system('find . -type f -print0 | xargs -0 ' + sed_cmd) + + sys.stdout.write(""" +Project '%s' is now ready to build. + + $ ./bootstrap + $ ./configure --prefix=/home/[user]/install + $ (make && make check && make install) 2>&1 | tee make.log + +""" % (module_name,)) + +if __name__ == '__main__': + main() diff --git a/gr-utils/src/python/usrp2_fft.py b/gr-utils/src/python/usrp2_fft.py index 1e8cf89ea..4276e389a 100755 --- a/gr-utils/src/python/usrp2_fft.py +++ b/gr-utils/src/python/usrp2_fft.py @@ -1,6 +1,6 @@ #!/usr/bin/env python # -# Copyright 2004,2005,2007,2008 Free Software Foundation, Inc. +# Copyright 2004,2005,2007,2008,2010 Free Software Foundation, Inc. # # This file is part of GNU Radio # @@ -218,7 +218,7 @@ class app_top_block(stdgui2.std_top_block): self.myform['baseband'].set_value(r.baseband_freq) self.myform['ddc'].set_value(r.dxc_freq) if not self.options.oscilloscope: - self.scope.win.set_baseband_freq(target_freq) + self.scope.set_baseband_freq(target_freq) return True return False diff --git a/gr-utils/src/python/usrp_fft.py b/gr-utils/src/python/usrp_fft.py index 4aa70adab..eda9bd57c 100755 --- a/gr-utils/src/python/usrp_fft.py +++ b/gr-utils/src/python/usrp_fft.py @@ -1,6 +1,6 @@ #!/usr/bin/env python # -# Copyright 2004,2005,2007,2008 Free Software Foundation, Inc. +# Copyright 2004,2005,2007,2008,2010 Free Software Foundation, Inc. # # This file is part of GNU Radio # @@ -39,7 +39,7 @@ def pick_subdevice(u): """ if u.db(0, 0).dbid() >= 0: # dbid is < 0 if there's no d'board or a problem return (0, 0) - if u.db(0, 0).dbid() >= 0: + if u.db(1, 0).dbid() >= 0: return (1, 0) return (0, 0) @@ -255,7 +255,7 @@ class app_top_block(stdgui2.std_top_block): self.myform['baseband'].set_value(r.baseband_freq) self.myform['ddc'].set_value(r.dxc_freq) if not self.options.oscilloscope: - self.scope.win.set_baseband_freq(target_freq) + self.scope.set_baseband_freq(target_freq) return True return False diff --git a/gr-utils/src/python/usrp_oscope.py b/gr-utils/src/python/usrp_oscope.py index f4a539dd5..9921e9873 100755 --- a/gr-utils/src/python/usrp_oscope.py +++ b/gr-utils/src/python/usrp_oscope.py @@ -42,7 +42,7 @@ def pick_subdevice(u): """ if u.db(0, 0).dbid() >= 0: # dbid is < 0 if there's no d'board or a problem return (0, 0) - if u.db(0, 0).dbid() >= 0: + if u.db(1, 0).dbid() >= 0: return (1, 0) return (0, 0) diff --git a/gr-utils/src/python/usrp_siggen.py b/gr-utils/src/python/usrp_siggen.py index 8ee8cfd2a..da83da770 100755 --- a/gr-utils/src/python/usrp_siggen.py +++ b/gr-utils/src/python/usrp_siggen.py @@ -305,7 +305,7 @@ def get_options(): return (options, args) # If this script is executed, the following runs. If it is imported, the below does not run. -if __name__ == "__main__": +def main(): if gr.enable_realtime_scheduling() != gr.RT_OK: print "Note: failed to enable realtime scheduling, continuing" @@ -318,9 +318,14 @@ if __name__ == "__main__": print e sys.exit(1) - # Run it - try: - tb.run() - - except KeyboardInterrupt: - pass + tb.start() + raw_input('Press Enter to quit: ') + tb.stop() + tb.wait() + +# Make sure to create the top block (tb) within a function: +# That code in main will allow tb to go out of scope on return, +# which will call the decontructor on usrp and stop transmit. +# Whats odd is that grc works fine with tb in the __main__, +# perhaps its because the try/except clauses around tb. +if __name__ == "__main__": main() diff --git a/gr-utils/src/python/usrp_siggen_gui.py b/gr-utils/src/python/usrp_siggen_gui.py index 40848fbee..47d47bdb3 100755 --- a/gr-utils/src/python/usrp_siggen_gui.py +++ b/gr-utils/src/python/usrp_siggen_gui.py @@ -284,7 +284,7 @@ class app_gui(pubsub): self.vbox.AddSpacer(5) self.vbox.AddStretchSpacer() -if __name__ == "__main__": +def main(): try: # Get command line parameters (options, args) = usrp_siggen.get_options() @@ -308,3 +308,10 @@ if __name__ == "__main__": except RuntimeError, e: print e sys.exit(1) + +# Make sure to create the top block (tb) within a function: +# That code in main will allow tb to go out of scope on return, +# which will call the decontructor on usrp and stop transmit. +# Whats odd is that grc works fine with tb in the __main__, +# perhaps its because the try/except clauses around tb. +if __name__ == "__main__": main() |