Skip to content

Commit

Permalink
Python: Add support for reading device labels
Browse files Browse the repository at this point in the history
Add support for reading the label attribute of devices.

Signed-off-by: Paul Cercueil <[email protected]>
  • Loading branch information
pcercuei committed Apr 9, 2021
1 parent d928de3 commit 830ad1a
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions bindings/python/iio.py
Original file line number Diff line number Diff line change
Expand Up @@ -368,6 +368,10 @@ class ChannelType(Enum):
_d_get_name.restype = c_char_p
_d_get_name.argtypes = (_DevicePtr,)

_d_get_label = _lib.iio_device_get_label
_d_get_label.restype = c_char_p
_d_get_label.argtypes = (_DevicePtr,)

_d_attr_count = _lib.iio_device_get_attrs_count
_d_attr_count.restype = c_uint
_d_attr_count.argtypes = (_DevicePtr,)
Expand Down Expand Up @@ -1152,6 +1156,9 @@ def __init__(self, _device):
name_raw = _d_get_name(self._device)
self._name = name_raw.decode("ascii") if name_raw is not None else None

label_raw = _d_get_label(self._device)
self._label = label_raw.decode("ascii") if label_raw is not None else None

def reg_write(self, reg, value):
"""
Set a value to one register of this device.
Expand Down Expand Up @@ -1229,6 +1236,9 @@ def sample_size(self):
name = property(
lambda self: self._name, None, None, "The name of this device.\n\ttype=str"
)
label = property(
lambda self: self._label, None, None, "The label of this device.\n\ttype=str",
)
attrs = property(
lambda self: self._attrs,
None,
Expand Down

0 comments on commit 830ad1a

Please sign in to comment.