diff options
author | Johnathan Corgan | 2012-03-13 17:38:12 -0700 |
---|---|---|
committer | Johnathan Corgan | 2012-03-13 17:38:12 -0700 |
commit | 62c6323bdb06d7d3f103d3a75265d45ae6ce00b4 (patch) | |
tree | 7f995aba5eb3f2e0bfeac3a4114307fd2c5a6f3a /gr-uhd/apps | |
parent | 83c6ee03ada6a44788421ebfe813b7d594fc8a7a (diff) | |
parent | 8e013157752f1b42665430fde0f1c6f7d7147153 (diff) | |
download | gnuradio-62c6323bdb06d7d3f103d3a75265d45ae6ce00b4.tar.gz gnuradio-62c6323bdb06d7d3f103d3a75265d45ae6ce00b4.tar.bz2 gnuradio-62c6323bdb06d7d3f103d3a75265d45ae6ce00b4.zip |
Merge remote branch 'gnuradio/maint' into gr-uhd-set-user-register
Diffstat (limited to 'gr-uhd/apps')
-rwxr-xr-x | gr-uhd/apps/uhd_fft.py | 41 | ||||
-rwxr-xr-x | gr-uhd/apps/uhd_rx_cfile.py | 17 | ||||
-rwxr-xr-x | gr-uhd/apps/uhd_rx_nogui.py | 15 | ||||
-rwxr-xr-x | gr-uhd/apps/uhd_siggen.py | 16 |
4 files changed, 73 insertions, 16 deletions
diff --git a/gr-uhd/apps/uhd_fft.py b/gr-uhd/apps/uhd_fft.py index f311a903b..18edc8f86 100755 --- a/gr-uhd/apps/uhd_fft.py +++ b/gr-uhd/apps/uhd_fft.py @@ -1,6 +1,6 @@ #!/usr/bin/env python # -# Copyright 2011 Free Software Foundation, Inc. +# Copyright 2012 Free Software Foundation, Inc. # # This file is part of GNU Radio # @@ -20,7 +20,7 @@ # Boston, MA 02110-1301, USA. # -from gnuradio import gr +from gnuradio import gr, gru from gnuradio import uhd from gnuradio import eng_notation from gnuradio.eng_option import eng_option @@ -75,6 +75,8 @@ class app_top_block(stdgui2.std_top_block): help="Set wire format from USRP [default=%default]") parser.add_option("", "--scalar", type="int", default=1024, help="Set scalar multiplier value sc8 wire format [default=%default]") + parser.add_option("", "--show-async-msg", action="store_true", default=False, + help="Show asynchronous message notifications from UHD [default=%default]") (options, args) = parser.parse_args() if len(args) != 0: parser.print_help() @@ -146,6 +148,16 @@ class app_top_block(stdgui2.std_top_block): if not(self.set_freq(options.freq)): self._set_status_msg("Failed to set initial frequency") + # Direct asynchronous notifications to callback function + if self.options.show_async_msg: + self.async_msgq = gr.msg_queue(0) + self.async_src = uhd.amsg_source("", self.async_msgq) + self.async_rcv = gru.msgq_runner(self.async_msgq, self.async_callback) + + def async_callback(self, msg): + md = self.async_src.msg_to_async_metadata_t(msg) + print "Channel: %i Time: %f Event: %i" % (md.channel, md.time_spec.get_real_secs(), md.event_code) + def _set_status_msg(self, msg): self.frame.GetStatusBar().SetStatusText(msg, 0) @@ -169,17 +181,24 @@ class app_top_block(stdgui2.std_top_block): g = self.u.get_gain_range() # some configurations don't have gain control - if g.stop() > g.start(): - myform['gain'] = form.slider_field(parent=self.panel, - sizer=hbox, label="Gain", - weight=3, - min=int(g.start()), max=int(g.stop()), - callback=self.set_gain) + if g.stop() <= g.start(): + glow = 0.0 + ghigh = 1.0 + + else: + glow = g.start() + ghigh = g.stop() + + myform['gain'] = form.slider_field(parent=self.panel, + sizer=hbox, label="Gain", + weight=3, + min=int(glow), max=int(ghigh), + callback=self.set_gain) - hbox.Add((5,0), 0, 0) - vbox.Add(hbox, 0, wx.EXPAND) + hbox.Add((5,0), 0, 0) + vbox.Add(hbox, 0, wx.EXPAND) - self._build_subpanel(vbox) + self._build_subpanel(vbox) def _build_subpanel(self, vbox_arg): # build a secondary information panel (sometimes hidden) diff --git a/gr-uhd/apps/uhd_rx_cfile.py b/gr-uhd/apps/uhd_rx_cfile.py index de44d4f56..718bb80b7 100755 --- a/gr-uhd/apps/uhd_rx_cfile.py +++ b/gr-uhd/apps/uhd_rx_cfile.py @@ -1,6 +1,6 @@ #!/usr/bin/env python # -# Copyright 2011 Free Software Foundation, Inc. +# Copyright 2012 Free Software Foundation, Inc. # # This file is part of GNU Radio # @@ -26,7 +26,7 @@ outputs single precision complex float values or complex short values (interleaved 16 bit signed short integers). """ -from gnuradio import gr, eng_notation +from gnuradio import gr, gru, eng_notation from gnuradio import uhd from gnuradio.eng_option import eng_option from optparse import OptionParser @@ -106,6 +106,17 @@ class rx_cfile_block(gr.top_block): else: print "Writing 32-bit complex floats" print "Output filename:", filename + + # Direct asynchronous notifications to callback function + if options.show_async_msg: + self.async_msgq = gr.msg_queue(0) + self.async_src = uhd.amsg_source("", self.async_msgq) + self.async_rcv = gru.msgq_runner(self.async_msgq, self.async_callback) + + def async_callback(self, msg): + md = self.async_src.msg_to_async_metadata_t(msg) + print "Channel: %i Time: %f Event: %i" % (md.channel, md.time_spec.get_real_secs(), md.event_code) + def get_options(): usage="%prog: [options] output_filename" @@ -134,6 +145,8 @@ def get_options(): help="set wire format from USRP [default=%default") parser.add_option("", "--scalar", type="int", default=1024, help="set scalar multiplier value for sc8 wire format [default=%default]") + parser.add_option("", "--show-async-msg", action="store_true", default=False, + help="Show asynchronous message notifications from UHD [default=%default]") (options, args) = parser.parse_args () if len(args) != 1: diff --git a/gr-uhd/apps/uhd_rx_nogui.py b/gr-uhd/apps/uhd_rx_nogui.py index e692e6ea3..bcb52c619 100755 --- a/gr-uhd/apps/uhd_rx_nogui.py +++ b/gr-uhd/apps/uhd_rx_nogui.py @@ -1,6 +1,6 @@ #!/usr/bin/env python # -# Copyright 2006,2007,2011 Free Software Foundation, Inc. +# Copyright 2006,2007,2011,2012 Free Software Foundation, Inc. # # This file is part of GNU Radio # @@ -190,6 +190,17 @@ class app_top_block(gr.top_block): AUDIO = audio.sink(int(options.output_rate), options.audio_output) self.connect(tail, AUDIO) + + # Direct asynchronous notifications to callback function + if self.options.show_async_msg: + self.async_msgq = gr.msg_queue(0) + self.async_src = uhd.amsg_source("", self.async_msgq) + self.async_rcv = gru.msgq_runner(self.async_msgq, self.async_callback) + + def async_callback(self, msg): + md = self.async_src.msg_to_async_metadata_t(msg) + print "Channel: %i Time: %f Event: %i" % (md.channel, md.time_spec.get_real_secs(), md.event_code) + def main(): parser = OptionParser(option_class=eng_option) @@ -222,6 +233,8 @@ def main(): help="set CTCSS squelch to FREQ [default=%default]") parser.add_option("-O", "--audio-output", type="string", default="", help="pcm device name. E.g., hw:0,0 or surround51 or /dev/dsp") + parser.add_option("", "--show-async-msg", action="store_true", default=False, + help="Show asynchronous message notifications from UHD [default=%default]") (options, args) = parser.parse_args() if options.frequency is None: diff --git a/gr-uhd/apps/uhd_siggen.py b/gr-uhd/apps/uhd_siggen.py index 27e9e8e01..e1af586ae 100755 --- a/gr-uhd/apps/uhd_siggen.py +++ b/gr-uhd/apps/uhd_siggen.py @@ -1,6 +1,6 @@ #!/usr/bin/env python # -# Copyright 2008,2009,2011 Free Software Foundation, Inc. +# Copyright 2008,2009,2011,2012 Free Software Foundation, Inc. # # This file is part of GNU Radio # @@ -38,7 +38,7 @@ TYPE_KEY = 'type' def setter(ps, key, val): ps[key] = val -from gnuradio import gr, uhd, eng_notation +from gnuradio import gr, gru, uhd, eng_notation from gnuradio.gr.pubsub import pubsub from gnuradio.eng_option import eng_option from optparse import OptionParser @@ -114,6 +114,16 @@ class top_block(gr.top_block, pubsub): if self._verbose: print str(self._u) + # Direct asynchronous notifications to callback function + if options.show_async_msg: + self.async_msgq = gr.msg_queue(0) + self.async_src = uhd.amsg_source("", self.async_msgq) + self.async_rcv = gru.msgq_runner(self.async_msgq, self.async_callback) + + def async_callback(self, msg): + md = self.async_src.msg_to_async_metadata_t(msg) + print "Channel: %i Time: %f Event: %i" % (md.channel, md.time_spec.get_real_secs(), md.event_code) + def _set_tx_amplitude(self, ampl): """ Sets the transmit amplitude sent to the USRP @@ -325,6 +335,8 @@ def get_options(): metavar="AMPL") parser.add_option("-v", "--verbose", action="store_true", default=False, help="Use verbose console output [default=%default]") + parser.add_option("", "--show-async-msg", action="store_true", default=False, + help="Show asynchronous message notifications from UHD [default=%default]") (options, args) = parser.parse_args() |