summaryrefslogtreecommitdiff
path: root/gr-uhd
diff options
context:
space:
mode:
Diffstat (limited to 'gr-uhd')
-rwxr-xr-xgr-uhd/apps/uhd_fft.py41
-rwxr-xr-xgr-uhd/apps/uhd_rx_cfile.py17
-rwxr-xr-xgr-uhd/apps/uhd_rx_nogui.py15
-rwxr-xr-xgr-uhd/apps/uhd_siggen.py16
-rw-r--r--gr-uhd/grc/gen_uhd_usrp_blocks.py4
-rw-r--r--gr-uhd/include/gr_uhd_amsg_source.h7
-rw-r--r--gr-uhd/lib/gr_uhd_amsg_source.cc5
7 files changed, 87 insertions, 18 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()
diff --git a/gr-uhd/grc/gen_uhd_usrp_blocks.py b/gr-uhd/grc/gen_uhd_usrp_blocks.py
index 67343541c..25b0a4c46 100644
--- a/gr-uhd/grc/gen_uhd_usrp_blocks.py
+++ b/gr-uhd/grc/gen_uhd_usrp_blocks.py
@@ -411,10 +411,10 @@ max_num_channels = max_num_mboards*4
if __name__ == '__main__':
import sys
for file in sys.argv[1:]:
- if 'source' in file:
+ if file.endswith ('source.xml'):
sourk = 'source'
direction = 'out'
- elif 'sink' in file:
+ elif file.endswith ('sink.xml'):
sourk = 'sink'
direction = 'in'
else: raise Exception, 'is %s a source or sink?'%file
diff --git a/gr-uhd/include/gr_uhd_amsg_source.h b/gr-uhd/include/gr_uhd_amsg_source.h
index accf15ce2..3c1b59fa7 100644
--- a/gr-uhd/include/gr_uhd_amsg_source.h
+++ b/gr-uhd/include/gr_uhd_amsg_source.h
@@ -38,6 +38,13 @@ GR_UHD_API boost::shared_ptr<uhd_amsg_source> uhd_make_amsg_source(
);
class GR_UHD_API uhd_amsg_source{
+public:
+ /*!
+ * Convert a raw asynchronous message to an asynchronous metatdata object.
+ * \return The asynchronous metadata object.
+ */
+ static uhd::async_metadata_t msg_to_async_metadata_t(const gr_message_sptr msg);
+
};
#endif /* INCLUDED_GR_UHD_AMSG_SOURCE_H */
diff --git a/gr-uhd/lib/gr_uhd_amsg_source.cc b/gr-uhd/lib/gr_uhd_amsg_source.cc
index f2958f115..08941584b 100644
--- a/gr-uhd/lib/gr_uhd_amsg_source.cc
+++ b/gr-uhd/lib/gr_uhd_amsg_source.cc
@@ -75,6 +75,11 @@ protected:
bool _running;
};
+uhd::async_metadata_t uhd_amsg_source::msg_to_async_metadata_t(const gr_message_sptr msg)
+{
+ return *(uhd::async_metadata_t *)msg->msg();
+}
+
/***********************************************************************
* Make UHD Asynchronous Message Source
**********************************************************************/