From 708db1266d6ab3073eb375de07d6b78944c6c537 Mon Sep 17 00:00:00 2001 From: Dan Nechita Date: Thu, 16 Jan 2025 16:00:08 +0200 Subject: [PATCH] python: Add channel method to get label Signed-off-by: Dan Nechita --- bindings/python/iio.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/bindings/python/iio.py b/bindings/python/iio.py index d0ee12dbb..bccd7a1f4 100644 --- a/bindings/python/iio.py +++ b/bindings/python/iio.py @@ -535,6 +535,10 @@ class ChannelType(Enum): _c_get_name.restype = c_char_p _c_get_name.argtypes = (_ChannelPtr,) +_c_get_label = _lib.iio_channel_get_label +_c_get_label.restype = c_char_p +_c_get_label.argtypes = (_ChannelPtr,) + _c_is_output = _lib.iio_channel_is_output _c_is_output.restype = c_bool _c_is_output.argtypes = (_ChannelPtr,) @@ -845,6 +849,9 @@ def __init__(self, dev, _channel): self._output = _c_is_output(self._channel) self._scan_element = _c_is_scan_element(self._channel) + label_raw = _c_get_label(self._channel) + self._name = label_raw.decode("ascii") if label_raw is not None else None + def read(self, block, raw=False): """ Extract the samples corresponding to this channel from the given iio.Block object. @@ -892,6 +899,9 @@ def write(self, block, array, raw=False): name = property( lambda self: self._name, None, None, "The name of this channel.\n\ttype=str" ) + label = property( + lambda self: self._label, None, None, "The label of this channel.\n\ttype=str" + ) attrs = property( lambda self: {attr.name: attr for attr in [ Attr(self, _c_get_attr(self._channel, x))