Skip to content

Commit cb7b04f

Browse files
Merge pull request #1793 from Bastian-Krause/bst/udev-uncached
resource/udev: read uncached sysfs value via pyudev
2 parents 61dfc07 + 94c739c commit cb7b04f

2 files changed

Lines changed: 4 additions & 11 deletions

File tree

labgrid/resource/udev.py

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import os
21
import queue
32
import warnings
43
from collections import OrderedDict
@@ -214,16 +213,10 @@ def model_id(self):
214213
return None
215214

216215
def read_attr(self, attribute):
217-
"""read uncached attribute value from sysfs
218-
219-
pyudev currently supports only cached access to attributes, so we read
220-
directly from sysfs.
221-
"""
222-
# FIXME update pyudev to support udev_device_set_sysattr_value(dev,
223-
# attr, None) to clear the cache
216+
"""read uncached attribute value"""
224217
if self.device is not None:
225-
with open(os.path.join(self.device.sys_path, attribute), 'rb') as f:
226-
return f.read().rstrip(b'\n') # drop trailing newlines
218+
self.device.attributes.unset(attribute)
219+
return self.device.attributes.get(attribute)
227220

228221
return None
229222

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ dependencies = [
4242
"pexpect>=4.8.0",
4343
"pyserial-labgrid>=3.4.0.1",
4444
"pytest>=7.0.0",
45-
"pyudev>=0.22.0",
45+
"pyudev>=0.24.4",
4646
"pyusb>=1.2.1",
4747
"PyYAML>=6.0.1",
4848
"requests>=2.26.0",

0 commit comments

Comments
 (0)