From 6394a7c6ea395e2d21c3e2b9e43e1b2dc84666b5 Mon Sep 17 00:00:00 2001 From: Samuel O'Brien Date: Fri, 31 Jul 2020 13:43:43 -0500 Subject: 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 --- mpm/python/usrp_mpm/sys_utils/net.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'mpm/python/usrp_mpm/sys_utils/net.py') 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] -- cgit v1.2.3