Skip to content

Commit

Permalink
treewide: Add API function iio_channel_get_label()
Browse files Browse the repository at this point in the history
This function can be used to retrieve the label for this IIO Channel, if
it was specified in linux driver.

Signed-off-by: Dan Nechita <[email protected]>
  • Loading branch information
dNechita committed Jan 27, 2025
1 parent f7af85f commit fc7ab0e
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 1 deletion.
5 changes: 5 additions & 0 deletions channel.c
Original file line number Diff line number Diff line change
Expand Up @@ -326,6 +326,11 @@ const char * iio_channel_get_name(const struct iio_channel *chn)
return chn->name;
}

const char * iio_channel_get_label(const struct iio_channel *chn)
{
return chn->label;
}

bool iio_channel_is_output(const struct iio_channel *chn)
{
return chn->is_output;
Expand Down
2 changes: 1 addition & 1 deletion context.c
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ static const char xml_header[] = "<?xml version=\"1.0\" encoding=\"utf-8\"?>"
"version-minor CDATA #REQUIRED version-git CDATA #REQUIRED description CDATA #IMPLIED>"
"<!ATTLIST context-attribute name CDATA #REQUIRED value CDATA #REQUIRED>"
"<!ATTLIST device id CDATA #REQUIRED name CDATA #IMPLIED label CDATA #IMPLIED>"
"<!ATTLIST channel id CDATA #REQUIRED type (input|output) #REQUIRED name CDATA #IMPLIED>"
"<!ATTLIST channel id CDATA #REQUIRED type (input|output) #REQUIRED name CDATA #IMPLIED label CDATA #IMPLIED>"
"<!ATTLIST scan-element index CDATA #REQUIRED format CDATA #REQUIRED scale CDATA #IMPLIED>"
"<!ATTLIST attribute name CDATA #REQUIRED filename CDATA #IMPLIED>"
"<!ATTLIST debug-attribute name CDATA #REQUIRED>"
Expand Down
6 changes: 6 additions & 0 deletions include/iio/iio.h
Original file line number Diff line number Diff line change
Expand Up @@ -876,6 +876,12 @@ __api __check_ret __pure const char * iio_channel_get_id(const struct iio_channe
* <b>NOTE:</b> if the channel has no name, NULL is returned. */
__api __check_ret __pure const char * iio_channel_get_name(const struct iio_channel *chn);

/** @brief Retrieve the channel label (e.g. <b><i>anglY</i></b>)
* @param chn A pointer to an iio_channel structure
* @return A pointer to a static NULL-terminated string
*
* <b>NOTE:</b> if the channel has no label, NULL is returned. */
__api __check_ret __pure const char * iio_channel_get_label(const struct iio_channel *chn);

/** @brief Return True if the given channel is an output channel
* @param chn A pointer to an iio_channel structure
Expand Down

0 comments on commit fc7ab0e

Please sign in to comment.