diff options
author | Andrej Rode <andrej.rode@ettus.com> | 2017-04-11 15:56:25 -0700 |
---|---|---|
committer | Martin Braun <martin.braun@ettus.com> | 2017-12-22 15:03:45 -0800 |
commit | 7f7111198816cbf1e0597f7ecc9f46e4c26e916b (patch) | |
tree | 7a74ecf77569b07364de278822873d7ce1f82185 /mpm/python/usrp_mpm/periph_manager/udev.py | |
parent | f27cb2a7711e428a88c59a5af762055c7f1e3e13 (diff) | |
download | uhd-7f7111198816cbf1e0597f7ecc9f46e4c26e916b.tar.gz uhd-7f7111198816cbf1e0597f7ecc9f46e4c26e916b.tar.bz2 uhd-7f7111198816cbf1e0597f7ecc9f46e4c26e916b.zip |
mpm: comment out functionality to make it work
- add uio udev find routine
- add debug prints
Signed-off-by: Andrej Rode <andrej.rode@ettus.com>
Signed-off-by: Moritz Fischer <moritz.fischer@ettus.com>
Diffstat (limited to 'mpm/python/usrp_mpm/periph_manager/udev.py')
-rw-r--r-- | mpm/python/usrp_mpm/periph_manager/udev.py | 35 |
1 files changed, 31 insertions, 4 deletions
diff --git a/mpm/python/usrp_mpm/periph_manager/udev.py b/mpm/python/usrp_mpm/periph_manager/udev.py index 014e18ede..a42c95ef5 100644 --- a/mpm/python/usrp_mpm/periph_manager/udev.py +++ b/mpm/python/usrp_mpm/periph_manager/udev.py @@ -16,19 +16,22 @@ # import pyudev +import os +from logging import getLogger +LOG = getLogger(__name__) -def get_eeprom(address): +def get_eeprom_path(address): """ Return EEPROM device path for a given I2C address """ context = pyudev.Context() parent = pyudev.Device.from_name(context, "platform", address) - paths = [device.dev_node if device.dev_node is not None else device.sys_path + paths = [device.device_node if device.device_node is not None else device.sys_path for device in context.list_devices(parent=parent, subsystem="nvmem")] if len(paths) != 1: raise Exception("{0} paths to EEPROM found!".format(len(paths))) - return paths[0] + return paths[0] + "/nvmem" def get_spidev_nodes(spi_master): @@ -37,6 +40,30 @@ def get_spidev_nodes(spi_master): """ context = pyudev.Context() parent = pyudev.Device.from_name(context, "platform", spi_master) - paths = [device.dev_node if device.dev_node is not None else device.sys_path + paths = [device.sys_path for device in context.list_devices(parent=parent, subsystem="spidev")] return paths + +def get_uio_node(uio_name): + """ + Return found uio device path for a give parent name + """ + context = pyudev.Context() + paths = [device.sys_path + for device in context.list_devices(subsystem="uio")] + LOG.debug("get_uio_node") + LOG.debug("got paths: %s", paths) + for path in paths: + with open(os.path.join(path, "maps", "map0", "name"), "r") as uio_file: + name = uio_file.read() + LOG.debug("uio_node name: %s", name.strip()) + if name.strip() == uio_name: + with open(os.path.join(path, "maps", "map0", "size"), "r") as uio_file: + size = uio_file.read() + LOG.debug("uio_node size: %s", size.strip()) + LOG.debug("uio_node syspath: %s", path) + # device = pyudev.Device.from_sys_path(context, path) + LOG.debug("got udev device") + LOG.debug("device_node: %s size: %s", "/dev/uio0", size.strip()) + return ("/dev/uio0", int(size.strip())) + return ("", 0) |