aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--host/docs/mpm.dox22
-rw-r--r--host/python/uhd/usrp/multi_usrp.py19
2 files changed, 39 insertions, 2 deletions
diff --git a/host/docs/mpm.dox b/host/docs/mpm.dox
index d53025fb5..d5dcc4d31 100644
--- a/host/docs/mpm.dox
+++ b/host/docs/mpm.dox
@@ -59,6 +59,28 @@ typically, high-performance applications will always run in network mode).
\section mpm_debug Debugging Tools
+\subsection mpm_debug_python Python-based Debugging
+
+The Python API has additional methods for interacting with MPM. When creating a
+multi_usrp object, it is possible to get a direct reference to an MPM client:
+
+~~~{.python}
+import uhd
+# Assume args contains valid device args:
+usrp = uhd.MultiUSRP(args)
+mpmc = usrp.get_mpm_client()
+# Now load device info over RPC and print:
+print(mpmc.get_device_info())
+~~~
+
+The RPC API calls are directly mapped to Python.
+
+\b Note: When using the MPM client directly, it is possible to put UHD and the
+device into unsynchronized states. It is an advanced API, only recommended for
+unusual low-level access to the device, or debugging.
+
+\subsection mpm_debug_other MPM Tools
+
The `mpm/tools/` subdirectory provides a useful tool for debugging and
interacting with MPM called `mpm_shell.py`. It is a command line tool to
directly access MPM commands. Like MPM, it requires Python 3. It can be invoked
diff --git a/host/python/uhd/usrp/multi_usrp.py b/host/python/uhd/usrp/multi_usrp.py
index adb03d436..7fb73c97e 100644
--- a/host/python/uhd/usrp/multi_usrp.py
+++ b/host/python/uhd/usrp/multi_usrp.py
@@ -11,6 +11,16 @@ import numpy as np
from .. import libpyuhd as lib
+def _get_mpm_client(token, mb_args):
+ """
+ Wrapper function to dynamically generate a Pythonic MPM client from
+ MultiUSRP.
+ """
+ from uhd.utils import mpmtools
+ rpc_addr = mb_args.get('mgmt_addr')
+ rpc_port = mb_args.get('rpc_port', mpmtools.MPM_RPC_PORT)
+ return mpmtools.MPMClient(mpmtools.InitMode.Hijack, rpc_addr, rpc_port, token)
+
class MultiUSRP(lib.usrp.multi_usrp):
"""
MultiUSRP object for controlling devices
@@ -18,6 +28,13 @@ class MultiUSRP(lib.usrp.multi_usrp):
def __init__(self, args=""):
"""MultiUSRP constructor"""
super(MultiUSRP, self).__init__(args)
+ # If we're on an MPM device, dynamically add this method to access the
+ # MPM client
+ if self.get_tree().exists("/mboards/0/token"):
+ token = self.get_tree().access_str("/mboards/0/token").get()
+ mb_args = \
+ self.get_tree().access_device_addr("/mboards/0/args").get().to_dict()
+ setattr(self, 'get_mpm_client', lambda: _get_mpm_client(token, mb_args))
def recv_num_samps(self, num_samps, freq, rate=1e6, channels=(0,), gain=10):
"""
@@ -124,5 +141,3 @@ class MultiUSRP(lib.usrp.multi_usrp):
# Help the garbage collection
streamer = None
return send_samps
-
-