Skip to content

Commit

Permalink
python: Add channel method to get label
Browse files Browse the repository at this point in the history
Signed-off-by: Dan Nechita <dan.nechita@analog.com>
  • Loading branch information
dNechita committed Jan 21, 2025
1 parent 21ddf0c commit 708db12
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 @@ -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,)
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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))
Expand Down

0 comments on commit 708db12

Please sign in to comment.