aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMartin Braun <martin.braun@ettus.com>2017-05-30 23:50:35 -0700
committerMartin Braun <martin.braun@ettus.com>2017-12-22 15:03:58 -0800
commit3aa899e1f5a1e3b7c9e69ccdd19aeb3fe2ffd672 (patch)
tree16c45e17f1dd25c1ab7f83331371dc1e87dbd00b
parent34174c98f38a9096adc71665fbb9c00aed345293 (diff)
downloaduhd-3aa899e1f5a1e3b7c9e69ccdd19aeb3fe2ffd672.tar.gz
uhd-3aa899e1f5a1e3b7c9e69ccdd19aeb3fe2ffd672.tar.bz2
uhd-3aa899e1f5a1e3b7c9e69ccdd19aeb3fe2ffd672.zip
mpm: udev now sorts EEPROM paths properly (9-0050 before 10-0050)
-rw-r--r--mpm/python/usrp_mpm/periph_manager/udev.py12
1 files changed, 9 insertions, 3 deletions
diff --git a/mpm/python/usrp_mpm/periph_manager/udev.py b/mpm/python/usrp_mpm/periph_manager/udev.py
index c0b85b032..cb3b35a66 100644
--- a/mpm/python/usrp_mpm/periph_manager/udev.py
+++ b/mpm/python/usrp_mpm/periph_manager/udev.py
@@ -15,8 +15,8 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
-import pyudev
import os
+import pyudev
from ..mpmlog import get_logger
def get_eeprom_paths(address):
@@ -25,8 +25,14 @@ def get_eeprom_paths(address):
"""
context = pyudev.Context()
parent = pyudev.Device.from_name(context, "platform", address)
- 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")]
+ paths = [d.device_node if d.device_node is not None else d.sys_path
+ for d in context.list_devices(parent=parent, subsystem="nvmem")]
+ # We need to sort this so 9-0050 comes before 10-0050 (etc.)
+ maxlen = max((len(os.path.split(p)[1]) for p in paths))
+ paths = sorted(
+ paths,
+ key=lambda x: "{:>0{maxlen}}".format(os.path.split(x)[1], maxlen=maxlen)
+ )
return [os.path.join(x.encode('ascii'), 'nvmem') for x in paths]
def get_spidev_nodes(spi_master):