diff options
Diffstat (limited to 'gr-uhd/apps')
-rwxr-xr-x | gr-uhd/apps/uhd_fft.py | 16 | ||||
-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, 57 insertions, 7 deletions
diff --git a/gr-uhd/apps/uhd_fft.py b/gr-uhd/apps/uhd_fft.py index 7314c4759..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) 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() |