libiio: functions

libiio 1.0 Library for interfacing with IIO devices

Loading...
Searching...
No Matches
Data Structures | Macros | Functions
functions

## Data Structures
struct | iio_attr
| Structure holding meta-data for an attribute. More...

## Macros
#define | iio_attr_read(attr, ptr)
| Read the content of the given attribute.
#define | iio_attr_write(attr, val)
| Set the value of the given attribute.

## Functions
__api __check_ret ssize_t | iio_attr_read_raw (const struct iio_attr *attr, char *dst, size_t len)
| Read the content of the given attribute.
__api __check_ret ssize_t | iio_attr_write_raw (const struct iio_attr *attr, const void *src, size_t len)
| Set the value of the given attribute.
__api __pure const char * | iio_attr_get_name (const struct iio_attr *attr)
| Retrieve the name of an attribute.
__api __check_ret __pure const char * | iio_attr_get_filename (const struct iio_attr *attr)
| Retrieve the filename of an attribute.
__api __pure const char * | iio_attr_get_static_value (const struct iio_attr *attr)
| Retrieve the static value of an attribute.
__api int | iio_attr_get_range (const struct iio_attr *attr, double *min, double *step, double *max)
| Extract the range from an attribute with suffix '_available'.
__api int | iio_attr_get_available (const struct iio_attr *attr, char ***list, size_t *count)
| Extract the list of elements from an attribute with suffix '_available'.
__api int | iio_attr_get_available_buf (const struct iio_attr *attr, char *buf, size_t buflen, char **list, size_t *count)
| A variant of iio_attr_get_available() that uses a caller-supplied, preallocated buffer. If the optional 'list' and 'count' parameters are provided, the buffer will be tokenized in place by replacing each delimiter with a null terminator ('\0'). As a result, each element in 'list' will point to the start of a substring in the buffer, representing one of the available values. For instance, 'list[0]' points to the first value, 'list[1]' to the second, and so forth.
__api void | iio_available_list_free (char **list, size_t count)
| Free the resources allocated only by iio_attr_get_available()

## Detailed Description

## Macro Definition Documentation

## ◆ iio_attr_read

#define iio_attr_read | ( |  | attr,
|  |  | ptr
| ) |  |

Value:
_Generic((ptr), \
bool *: iio_attr_read_bool, \
long long *: iio_attr_read_longlong, \
double *: iio_attr_read_double)(attr, ptr)

Read the content of the given attribute.

Parameters

  attr | A pointer to an iio_attr structure
  ptr | A pointer to a variable where the value should be stored

Returns
  On success, 0 is returned
  On error, a negative errno code is returned

## ◆ iio_attr_write

#define iio_attr_write | ( |  | attr,
|  |  | val
| ) |  |

Value:
_Generic((val), \
const char *: iio_attr_write_string, \
char *: iio_attr_write_string, \
bool: iio_attr_write_bool, \
long long: iio_attr_write_longlong, \
double: iio_attr_write_double)(attr, val)

Set the value of the given attribute.

Parameters

  attr | A pointer to an iio_attr structure
  val | The value to set the attribute to

Returns
  On success, the number of bytes written
  On error, a negative errno code is returned.

## Function Documentation

## ◆ iio_attr_get_available()

__api int iio_attr_get_available | ( | const struct iio_attr * | attr,
|  | char *** | list,
|  | size_t * | count
| ) |  |

Extract the list of elements from an attribute with suffix '_available'.

Parameters

  attr | A pointer to an iio_attr structure
  list | A pointer to pointer to a dynamically allocated array of strings
  count | Will be set with the number of words found only if the string was successfully parsed.

Returns
  On success, a dynamically allocated array of strings. It is the caller’s responsibility to free these newly allocated resources
  On success, 0 is returned
  On error, a negative errno code is returned. For attributes without the '_available' suffix, -ENXIO is returned. For attributes whose values are in a range format, -EOPNOTSUPP is returned.

Here is the call graph for this function:

## ◆ iio_attr_get_available_buf()

__api int iio_attr_get_available_buf | ( | const struct iio_attr * | attr,
|  | char * | buf,
|  | size_t | buflen,
|  | char ** | list,
|  | size_t * | count
| ) |  |

A variant of iio_attr_get_available() that uses a caller-supplied, preallocated buffer. If the optional 'list' and 'count' parameters are provided, the buffer will be tokenized in place by replacing each delimiter with a null terminator ('\0'). As a result, each element in 'list' will point to the start of a substring in the buffer, representing one of the available values. For instance, 'list[0]' points to the first value, 'list[1]' to the second, and so forth.

Parameters

  attr | A pointer to an iio_attr structure
  buf | A buffer where the available data will be stored
  buflen | The available length of the buffer, in bytes
  list | Optional output array of char* pointers. Each element points to a token within the provided buffer and must not be freed, as the data is part of the buffer itself.
  count | On input: should contain the size of the list[] array (number of available slots). On output: will contain the actual number of tokens (strings) found and stored in list[]. parsed. On fail, it will be set to 0

Returns
  On success, 0 is returned
  On error, a negative errno code is returned. For attributes without the '_available' suffix, -ENXIO is returned. For attributes whose values are in a range format, -EOPNOTSUPP is returned. If not enough space is available in list[], the function returns -ENOSPC

Here is the call graph for this function:

## ◆ iio_attr_get_filename()

__api __check_ret __pure const char * iio_attr_get_filename | ( | const struct iio_attr * | attr | ) |

Retrieve the filename of an attribute.

Parameters

  attr | A pointer to an iio_attr structure

Returns
  A pointer to a static NULL-terminated string

## ◆ iio_attr_get_name()

__api __pure const char * iio_attr_get_name | ( | const struct iio_attr * | attr | ) |

Retrieve the name of an attribute.

Parameters

  attr | A pointer to an iio_attr structure

Returns
  A pointer to a static NULL-terminated string

Here is the caller graph for this function:

## ◆ iio_attr_get_range()

__api int iio_attr_get_range | ( | const struct iio_attr * | attr,
|  | double * | min,
|  | double * | step,
|  | double * | max
| ) |  |

Extract the range from an attribute with suffix '_available'.

Parameters

  attr | A pointer to an iio_attr structure
  min | Will be set with the range minimum value if string was successfully parsed
  step | Will be set with the range step value if string was successfully parsed
  max | Will be set with the range maximum value if string was successfully parsed

Returns
  On success, 0 is returned
  On error, a negative errno code is returned. For attributes without the '_available' suffix, -ENXIO is returned. For attributes whose values do not follow the [min step max] format, -EOPNOTSUPP is returned.

Here is the call graph for this function:

## ◆ iio_attr_get_static_value()

__api __pure const char * iio_attr_get_static_value | ( | const struct iio_attr * | attr | ) |

Retrieve the static value of an attribute.

Parameters

  attr | A pointer to an iio_attr structure

Returns
  On success, a pointer to a static NULL-terminated string
  If the attribute does not have a static value, NULL is returned.

## ◆ iio_attr_read_raw()

__api __check_ret ssize_t iio_attr_read_raw | ( | const struct iio_attr * | attr,
|  | char * | dst,
|  | size_t | len
| ) |  |

Read the content of the given attribute.

Parameters

  attr | A pointer to an iio_attr structure
  dst | A pointer to the memory area where the read data will be stored
  len | The available length of the memory area, in bytes

Returns
  On success, the number of bytes written to the buffer
  On error, a negative errno code is returned

Here is the caller graph for this function:

## ◆ iio_attr_write_raw()

__api __check_ret ssize_t iio_attr_write_raw | ( | const struct iio_attr * | attr,
|  | const void * | src,
|  | size_t | len
| ) |  |

Set the value of the given attribute.

Parameters

  attr | A pointer to an iio_attr structure
  src | A pointer to the data to be written
  len | The number of bytes that should be written

Returns
  On success, the number of bytes written
  On error, a negative errno code is returned

## ◆ iio_available_list_free()

__api void iio_available_list_free | ( | char ** | list,
|  | size_t | count
| ) |  |

Free the resources allocated only by iio_attr_get_available()

Parameters

  list | A pointer to a dynamically allocated array to be freed
  count | The number of elements counted by iio_attr_get_available()