aboutsummaryrefslogtreecommitdiffstats
path: root/mpm/python/usrp_mpm/periph_manager/udev.py
diff options
context:
space:
mode:
authorAndrej Rode <andrej.rode@ettus.com>2017-03-27 18:03:52 -0700
committerMartin Braun <martin.braun@ettus.com>2017-12-22 15:03:45 -0800
commit6a12add1560545438e1bebc05efbafd05aace4f9 (patch)
treec94dbbbd4da0c7ef41fc8849f174875a13f0b511 /mpm/python/usrp_mpm/periph_manager/udev.py
parentba4fad345d7489b40a7dab83842ac21d13c4f460 (diff)
downloaduhd-6a12add1560545438e1bebc05efbafd05aace4f9.tar.gz
uhd-6a12add1560545438e1bebc05efbafd05aace4f9.tar.bz2
uhd-6a12add1560545438e1bebc05efbafd05aace4f9.zip
mpm: mpm reorganization
Diffstat (limited to 'mpm/python/usrp_mpm/periph_manager/udev.py')
-rw-r--r--mpm/python/usrp_mpm/periph_manager/udev.py42
1 files changed, 42 insertions, 0 deletions
diff --git a/mpm/python/usrp_mpm/periph_manager/udev.py b/mpm/python/usrp_mpm/periph_manager/udev.py
new file mode 100644
index 000000000..014e18ede
--- /dev/null
+++ b/mpm/python/usrp_mpm/periph_manager/udev.py
@@ -0,0 +1,42 @@
+#
+# Copyright 2017 Ettus Research (National Instruments)
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+#
+
+import pyudev
+
+
+def get_eeprom(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
+ 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]
+
+
+def get_spidev_nodes(spi_master):
+ """
+ Return found spidev device paths for a given 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
+ for device in context.list_devices(parent=parent, subsystem="spidev")]
+ return paths