aboutsummaryrefslogtreecommitdiffstats
path: root/mpm/python/usrp_mpm/sys_utils
diff options
context:
space:
mode:
authorSamuel O'Brien <sam.obrien@ni.com>2020-07-31 13:43:43 -0500
committerAaron Rossetto <aaron.rossetto@ni.com>2020-10-07 15:29:19 -0500
commit6394a7c6ea395e2d21c3e2b9e43e1b2dc84666b5 (patch)
treee5c230efe4781ac294641464d99cf51b6bf44024 /mpm/python/usrp_mpm/sys_utils
parent1bb603fffdbdcc87f7c26809d495ced7a5afc93b (diff)
downloaduhd-6394a7c6ea395e2d21c3e2b9e43e1b2dc84666b5.tar.gz
uhd-6394a7c6ea395e2d21c3e2b9e43e1b2dc84666b5.tar.bz2
uhd-6394a7c6ea395e2d21c3e2b9e43e1b2dc84666b5.zip
sim: Lay Groundwork for Simulator
At this point, only about half of the mpm methods work on the simulator over the mpm shell, and it hasn't been tested with uhd at all. If you want to give it a try, first install all of the python dependencies of mpm (The simulator doesn't require libusrp or any of the C++ deps). In addition, running mpm on a desktop machine requires the python lib netifaces. Next, make an /mpm/build directory and open it. Run `cmake .. -DMPM_DEVICE=sim`, then `make`. Finally, run `python3 python/usrp_hwd.py`. You should be able to open another terminal and run `mpm/tools/mpm_shell.py localhost` to connect to the mpm server. Signed-off-by: Samuel O'Brien <sam.obrien@ni.com>
Diffstat (limited to 'mpm/python/usrp_mpm/sys_utils')
-rw-r--r--mpm/python/usrp_mpm/sys_utils/net.py10
1 files changed, 9 insertions, 1 deletions
diff --git a/mpm/python/usrp_mpm/sys_utils/net.py b/mpm/python/usrp_mpm/sys_utils/net.py
index a9be7b87d..6ba5f0c3e 100644
--- a/mpm/python/usrp_mpm/sys_utils/net.py
+++ b/mpm/python/usrp_mpm/sys_utils/net.py
@@ -31,7 +31,10 @@ def get_valid_interfaces(iface_list):
continue
valid_iface_idx = valid_iface_idx[0]
link_info = ipr.get_links(valid_iface_idx)[0]
- if link_info.get_attr('IFLA_OPERSTATE') == 'UP' \
+ # IFLA_OPERSTATE attribute isn't implemented on WSL
+ # Workaround is ignore it in the simulator
+ from usrp_mpm import __simulated__
+ if (link_info.get_attr('IFLA_OPERSTATE') == 'UP' or __simulated__) \
and len(get_iface_addrs(link_info.get_attr('IFLA_ADDRESS'))):
assert link_info.get_attr('IFLA_IFNAME') == iface
valid_ifaces.append(iface)
@@ -83,6 +86,11 @@ def get_link_speed(ifname):
The speed is Megabits/sec
(from kernel at https://www.kernel.org/doc/Documentation/ABI/testing/sysfs-class-net)
"""
+ # This wasn't implemented in WSL or in the linux pc I tested it on
+ # We will return a sensible default
+ from usrp_mpm import __simulated__
+ if __simulated__:
+ return 1000
net_sysfs = [device for device in pyudev.Context().list_devices(subsystem='net')
if device.sys_name == ifname][0]