commit-gnuradio
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Commit-gnuradio] [gnuradio] 09/18: uhd: Added controlport interface for


From: git
Subject: [Commit-gnuradio] [gnuradio] 09/18: uhd: Added controlport interface for UHD sink's "command" message handler.
Date: Tue, 8 Dec 2015 00:31:22 +0000 (UTC)

This is an automated email from the git hooks/post-receive script.

jcorgan pushed a commit to branch master
in repository gnuradio.

commit bd339909e6a89fc2e9db582ba01960a0283b4506
Author: Tom Rondeau <address@hidden>
Date:   Sun Dec 6 18:23:19 2015 -0500

    uhd: Added controlport interface for UHD sink's "command" message handler.
    
    Also added an example, usrp_sink_controller.py, to excercise this
    feature. Fixed up the source example, too, to better manage parsing
    options and setting the UHD source block alias (defaults to 'gr uhd
    usrp source0', which is the default for any flowgraph with a single
    UHD source block).
---
 .../examples/ctrlport/usrp_sink_controller.py      | 42 ++++++++++++++++++++++
 .../examples/ctrlport/usrp_source_control.grc      | 14 +++++++-
 .../examples/ctrlport/usrp_source_controller.py    | 33 +++++++++++------
 gr-uhd/lib/usrp_sink_impl.cc                       | 13 +++++++
 gr-uhd/lib/usrp_sink_impl.h                        |  2 ++
 5 files changed, 93 insertions(+), 11 deletions(-)

diff --git a/gr-blocks/examples/ctrlport/usrp_sink_controller.py 
b/gr-blocks/examples/ctrlport/usrp_sink_controller.py
new file mode 100755
index 0000000..d8c38e3
--- /dev/null
+++ b/gr-blocks/examples/ctrlport/usrp_sink_controller.py
@@ -0,0 +1,42 @@
+#!/usr/bin/env python
+
+import sys
+import pmt
+from gnuradio.ctrlport.GNURadioControlPortClient import 
GNURadioControlPortClient
+from optparse import OptionParser
+
+parser = OptionParser(usage="%prog: [options]")
+parser.add_option("-H", "--host", type="string", default="localhost",
+                  help="Hostname to connect to (default=%default)")
+parser.add_option("-p", "--port", type="int", default=9090,
+                  help="Port of Controlport instance on host 
(default=%default)")
+parser.add_option("-a", "--alias", type="string", default="gr uhd usrp sink0",
+                  help="The UHD block's alias to control (default=%default)")
+options, args = parser.parse_args()
+
+if(len(args) < 2):
+    sys.stderr.write('Not enough arguments: usrp_source_controller.py 
[options] <command> <value>\n')
+    sys.stderr.write('See the "UHD Interface" section of the manual for 
available commands.\n\n')
+    sys.exit(1)
+
+port = 'command'
+alias = options.alias
+hostname = options.host
+portnum = options.port
+cmd = args[0]
+val = args[1]
+
+if(cmd == "tune" or cmd == "time"):
+    sys.stderr.write("This application currently does not support the 'tune' 
or 'time' UHD "
+                     "message commands.\n\n")
+    sys.exit(1)
+elif(cmd == "antenna"):
+    val = pmt.intern(val)
+else:
+    val = pmt.from_double(float(val))
+
+argv = [None, hostname, portnum]
+radiosys = GNURadioControlPortClient(argv=argv, rpcmethod='thrift')
+radio = radiosys.client
+
+radio.postMessage(alias, port, pmt.cons(pmt.intern(cmd), val))
diff --git a/gr-blocks/examples/ctrlport/usrp_source_control.grc 
b/gr-blocks/examples/ctrlport/usrp_source_control.grc
index b668388..33dafdf 100644
--- a/gr-blocks/examples/ctrlport/usrp_source_control.grc
+++ b/gr-blocks/examples/ctrlport/usrp_source_control.grc
@@ -41,6 +41,10 @@
       <value>qt_gui</value>
     </param>
     <param>
+      <key>hier_block_src_path</key>
+      <value>.:</value>
+    </param>
+    <param>
       <key>id</key>
       <value>usrp_source_control</value>
     </param>
@@ -49,10 +53,18 @@
       <value>0</value>
     </param>
     <param>
+      <key>qt_qss_theme</key>
+      <value></value>
+    </param>
+    <param>
       <key>realtime_scheduling</key>
       <value></value>
     </param>
     <param>
+      <key>run_command</key>
+      <value>{python} -u {filename}</value>
+    </param>
+    <param>
       <key>run_options</key>
       <value>prompt</value>
     </param>
@@ -746,7 +758,7 @@
     <key>uhd_usrp_source</key>
     <param>
       <key>alias</key>
-      <value>usrp_source0</value>
+      <value></value>
     </param>
     <param>
       <key>ant0</key>
diff --git a/gr-blocks/examples/ctrlport/usrp_source_controller.py 
b/gr-blocks/examples/ctrlport/usrp_source_controller.py
index 77a6cb4..02d30a9 100755
--- a/gr-blocks/examples/ctrlport/usrp_source_controller.py
+++ b/gr-blocks/examples/ctrlport/usrp_source_controller.py
@@ -3,24 +3,37 @@
 import sys
 import pmt
 from gnuradio.ctrlport.GNURadioControlPortClient import 
GNURadioControlPortClient
+from optparse import OptionParser
 
-args = sys.argv
-if(len(args) < 4):
-    sys.stderr.write('Not enough arguments: usrp_source_controller.py <host> 
<port> <command> <value>\n')
+parser = OptionParser(usage="%prog: [options]")
+parser.add_option("-H", "--host", type="string", default="localhost",
+                  help="Hostname to connect to (default=%default)")
+parser.add_option("-p", "--port", type="int", default=9090,
+                  help="Port of Controlport instance on host 
(default=%default)")
+parser.add_option("-a", "--alias", type="string", default="gr uhd usrp 
source0",
+                  help="The UHD block's alias to control (default=%default)")
+options, args = parser.parse_args()
+
+if(len(args) < 2):
+    sys.stderr.write('Not enough arguments: usrp_source_controller.py 
[options] <command> <value>\n')
     sys.stderr.write('See the "UHD Interface" section of the manual for 
available commands.\n\n')
     sys.exit(1)
 
-alias = 'usrp_source0'
 port = 'command'
+alias = options.alias
+hostname = options.host
+portnum = options.port
+cmd = args[0]
+val = args[1]
 
-hostname = args[1]
-portnum = int(args[2])
-cmd = args[3].lower()
-
+if(cmd == "tune" or cmd == "time"):
+    sys.stderr.write("This application currently does not support the 'tune' 
or 'time' UHD "
+                     "message commands.\n\n")
+    sys.exit(1)
 if(cmd == "antenna"):
-    val = pmt.intern(args[4])
+    val = pmt.intern(val)
 else:
-    val = pmt.from_double(float(args[4]))
+    val = pmt.from_double(float(val))
 
 argv = [None, hostname, portnum]
 radiosys = GNURadioControlPortClient(argv=argv, rpcmethod='thrift')
diff --git a/gr-uhd/lib/usrp_sink_impl.cc b/gr-uhd/lib/usrp_sink_impl.cc
index 8f2d2ad..64d25bd 100644
--- a/gr-uhd/lib/usrp_sink_impl.cc
+++ b/gr-uhd/lib/usrp_sink_impl.cc
@@ -618,5 +618,18 @@ namespace gr {
       return true;
     }
 
+
+    void
+    usrp_sink_impl::setup_rpc()
+    {
+#ifdef GR_CTRLPORT
+      add_rpc_variable(
+        rpcbasic_sptr(new rpcbasic_register_handler<usrp_block>(
+          alias(), "command",
+          "", "UHD Commands",
+          RPC_PRIVLVL_MIN, DISPNULL)));
+#endif /* GR_CTRLPORT */
+    }
+
   } /* namespace uhd */
 } /* namespace gr */
diff --git a/gr-uhd/lib/usrp_sink_impl.h b/gr-uhd/lib/usrp_sink_impl.h
index 1575378..d509bae 100644
--- a/gr-uhd/lib/usrp_sink_impl.h
+++ b/gr-uhd/lib/usrp_sink_impl.h
@@ -103,6 +103,8 @@ namespace gr {
 
       inline void tag_work(int &ninput_items);
 
+      void setup_rpc();
+
     private:
       //! Like set_center_freq(), but uses _curr_freq and _curr_lo_offset
       ::uhd::tune_result_t _set_center_freq_from_internals(size_t chan);



reply via email to

[Prev in Thread] Current Thread [Next in Thread]