Loading...
Searching...
No Matches
Debug and low-level functions

## Data Structures

struct | iio_data_format
| Contains the format of a data sample. More...

## Functions

__api __check_ret ssize_t | iio_device_get_sample_size (const struct iio_device *dev)
| Get the current sample size.
__api __check_ret __pure long | iio_channel_get_index (const struct iio_channel *chn)
| Get the index of the given channel.
__api __check_ret __cnst const struct iio_data_format * | iio_channel_get_data_format (const struct iio_channel *chn)
| Get a pointer to a channel's data format structure.
__api void | iio_channel_convert (const struct iio_channel *chn, void *dst, const void *src)
| Convert the sample from hardware format to host format.
__api void | iio_channel_convert_inverse (const struct iio_channel *chn, void *dst, const void *src)
| Convert the sample from host format to hardware format.
__api __check_ret __pure unsigned int | iio_device_get_debug_attrs_count (const struct iio_device *dev)
| Enumerate the debug attributes of the given device.
__api __check_ret __pure const char * | iio_device_get_debug_attr (const struct iio_device *dev, unsigned int index)
| Get the debug attribute present at the given index.
__api __check_ret __pure const char * | iio_device_find_debug_attr (const struct iio_device *dev, const char *name)
| Try to find a debug attribute by its name.
__api __check_ret ssize_t | iio_device_debug_attr_read (const struct iio_device *dev, const char *attr, char *dst, size_t len)
| Read the content of the given debug attribute.
__api __check_ret int | iio_device_debug_attr_read_all (struct iio_device *dev, int(*cb)(struct iio_device *dev, const char *attr, const char *value, size_t len, void *d), void *data)
| Read the content of all debug attributes.
__api __check_ret ssize_t | iio_device_debug_attr_write (const struct iio_device *dev, const char *attr, const char *src)
| Set the value of the given debug attribute.
__api __check_ret ssize_t | iio_device_debug_attr_write_raw (const struct iio_device *dev, const char *attr, const void *src, size_t len)
| Set the value of the given debug attribute.
__api __check_ret int | iio_device_debug_attr_write_all (struct iio_device *dev, ssize_t(*cb)(struct iio_device *dev, const char *attr, void *buf, size_t len, void *d), void *data)
| Set the values of all debug attributes.
__api __check_ret int | iio_device_debug_attr_read_bool (const struct iio_device *dev, const char *attr, bool *val)
| Read the content of the given debug attribute.
__api __check_ret int | iio_device_debug_attr_read_longlong (const struct iio_device *dev, const char *attr, long long *val)
| Read the content of the given debug attribute.
__api __check_ret int | iio_device_debug_attr_read_double (const struct iio_device *dev, const char *attr, double *val)
| Read the content of the given debug attribute.
__api __check_ret int | iio_device_debug_attr_write_bool (const struct iio_device *dev, const char *attr, bool val)
| Set the value of the given debug attribute.
__api __check_ret int | iio_device_debug_attr_write_longlong (const struct iio_device *dev, const char *attr, long long val)
| Set the value of the given debug attribute.
__api __check_ret int | iio_device_debug_attr_write_double (const struct iio_device *dev, const char *attr, double val)
| Set the value of the given debug attribute.
__api __check_ret int | iio_device_identify_filename (const struct iio_device *dev, const char *filename, struct iio_channel **chn, const char **attr)
| Identify the channel or debug attribute corresponding to a filename.
__api __check_ret int | iio_device_reg_write (struct iio_device *dev, uint32_t address, uint32_t value)
| Set the value of a hardware register.
__api __check_ret int | iio_device_reg_read (struct iio_device *dev, uint32_t address, uint32_t *value)
| Get the value of a hardware register.

## Detailed Description

## Function Documentation

## iio_channel_convert()

__api void iio_channel_convert | ( | const struct iio_channel * | chn,
|  | void * | dst,
|  | const void * | src )

Convert the sample from hardware format to host format.

Parameters

  chn | A pointer to an iio_channel structure
  dst | A pointer to the destination buffer where the converted sample should be written
  src | A pointer to the source buffer containing the sample

Here is the caller graph for this function:

## iio_channel_convert_inverse()

__api void iio_channel_convert_inverse | ( | const struct iio_channel * | chn,
|  | void * | dst,
|  | const void * | src )

Convert the sample from host format to hardware format.

Parameters

  chn | A pointer to an iio_channel structure
  dst | A pointer to the destination buffer where the converted sample should be written
  src | A pointer to the source buffer containing the sample

Here is the caller graph for this function:

## iio_channel_get_data_format()

__api __check_ret __cnst const struct iio_data_format * iio_channel_get_data_format | ( | const struct iio_channel * | chn | ) |

Get a pointer to a channel's data format structure.

Parameters

  chn | A pointer to an iio_channel structure

Returns
  A pointer to the channel's iio_data_format structure

## iio_channel_get_index()

__api __check_ret __pure long iio_channel_get_index | ( | const struct iio_channel * | chn | ) |

Get the index of the given channel.

Parameters

  chn | A pointer to an iio_channel structure

Returns
  On success, the index of the specified channel
  On error, a negative errno code is returned

## iio_device_debug_attr_read()

__api __check_ret ssize_t iio_device_debug_attr_read | ( | const struct iio_device * | dev,
|  | const char * | attr,
|  | char * | dst,
|  | size_t | len )

Read the content of the given debug attribute.

Parameters

  dev | A pointer to an iio_device structure
  attr | A NULL-terminated string corresponding to the name of the debug attribute
  dst | A pointer to the memory area where the NULL-terminated string corresponding to the value read 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

NOTE:By passing NULL as the "attr" argument to iio_device_debug_attr_read, it is now possible to read all of the debug attributes of a device.

The buffer is filled with one block of data per debug attribute of the device, by the order they appear in the iio_device structure.

The first four bytes of one block correspond to a 32-bit signed value in network order. If negative, it corresponds to the errno code that were returned when reading the debug attribute; if positive, it corresponds to the length of the data read. In that case, the rest of the block contains the data.

Here is the caller graph for this function:

## iio_device_debug_attr_read_all()

__api __check_ret int iio_device_debug_attr_read_all | ( | struct iio_device * | dev,
|  | int(* | cb )(struct iio_device *dev, const char *attr, const char *value, size_t len, void *d),
|  | void * | data )

Read the content of all debug attributes.

Parameters

  dev | A pointer to an iio_device structure
  cb | A pointer to a callback function
  data | A pointer that will be passed to the callback function

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

NOTE: This function is especially useful when used with the network backend, as all the debug attributes are read in one single command.

## iio_device_debug_attr_read_bool()

__api __check_ret int iio_device_debug_attr_read_bool | ( | const struct iio_device * | dev,
|  | const char * | attr,
|  | bool * | val )

Read the content of the given debug attribute.

Parameters

  dev | A pointer to an iio_device structure
  attr | A NULL-terminated string corresponding to the name of the debug attribute
  val | A pointer to a bool variable where the value should be stored

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

Here is the call graph for this function:

## iio_device_debug_attr_read_double()

__api __check_ret int iio_device_debug_attr_read_double | ( | const struct iio_device * | dev,
|  | const char * | attr,
|  | double * | val )

Read the content of the given debug attribute.

Parameters

  dev | A pointer to an iio_device structure
  attr | A NULL-terminated string corresponding to the name of the debug attribute
  val | A pointer to a double variable where the value should be stored

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

Here is the call graph for this function:

## iio_device_debug_attr_read_longlong()

__api __check_ret int iio_device_debug_attr_read_longlong | ( | const struct iio_device * | dev,
|  | const char * | attr,
|  | long long * | val )

Read the content of the given debug attribute.

Parameters

  dev | A pointer to an iio_device structure
  attr | A NULL-terminated string corresponding to the name of the debug attribute
  val | A pointer to a long long variable where the value should be stored

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

Here is the call graph for this function:
Here is the caller graph for this function:

## iio_device_debug_attr_write()

__api __check_ret ssize_t iio_device_debug_attr_write | ( | const struct iio_device * | dev,
|  | const char * | attr,
|  | const char * | src )

Set the value of the given debug attribute.

Parameters

  dev | A pointer to an iio_device structure
  attr | A NULL-terminated string corresponding to the name of the debug attribute
  src | A NULL-terminated string to set the debug attribute to

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

NOTE:By passing NULL as the "attr" argument to iio_device_debug_attr_write, it is now possible to write all of the debug attributes of a device.

The buffer must contain one block of data per debug attribute of the device, by the order they appear in the iio_device structure.

The first four bytes of one block correspond to a 32-bit signed value in network order. If negative, the debug attribute is not written; if positive, it corresponds to the length of the data to write. In that case, the rest of the block must contain the data.

Here is the call graph for this function:
Here is the caller graph for this function:

## iio_device_debug_attr_write_all()

__api __check_ret int iio_device_debug_attr_write_all | ( | struct iio_device * | dev,
|  | ssize_t(* | cb )(struct iio_device *dev, const char *attr, void *buf, size_t len, void *d),
|  | void * | data )

Set the values of all debug attributes.

Parameters

  dev | A pointer to an iio_device structure
  cb | A pointer to a callback function
  data | A pointer that will be passed to the callback function

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

NOTE: This function is especially useful when used with the network backend, as all the debug attributes are written in one single command.

## iio_device_debug_attr_write_bool()

__api __check_ret int iio_device_debug_attr_write_bool | ( | const struct iio_device * | dev,
|  | const char * | attr,
|  | bool | val )

Set the value of the given debug attribute.

Parameters

  dev | A pointer to an iio_device structure
  attr | A NULL-terminated string corresponding to the name of the debug attribute
  val | A bool value to set the debug attribute to

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

Here is the call graph for this function:

## iio_device_debug_attr_write_double()

__api __check_ret int iio_device_debug_attr_write_double | ( | const struct iio_device * | dev,
|  | const char * | attr,
|  | double | val )

Set the value of the given debug attribute.

Parameters

  dev | A pointer to an iio_device structure
  attr | A NULL-terminated string corresponding to the name of the debug attribute
  val | A double value to set the debug attribute to

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

Here is the call graph for this function:

## iio_device_debug_attr_write_longlong()

__api __check_ret int iio_device_debug_attr_write_longlong | ( | const struct iio_device * | dev,
|  | const char * | attr,
|  | long long | val )

Set the value of the given debug attribute.

Parameters

  dev | A pointer to an iio_device structure
  attr | A NULL-terminated string corresponding to the name of the debug attribute
  val | A long long value to set the debug attribute to

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

Here is the call graph for this function:
Here is the caller graph for this function:

## iio_device_debug_attr_write_raw()

__api __check_ret ssize_t iio_device_debug_attr_write_raw | ( | const struct iio_device * | dev,
|  | const char * | attr,
|  | const void * | src,
|  | size_t | len )

Set the value of the given debug attribute.

Parameters

  dev | A pointer to an iio_device structure
  attr | A NULL-terminated string corresponding to the name of the debug attribute
  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

Here is the caller graph for this function:

## iio_device_find_debug_attr()

__api __check_ret __pure const char * iio_device_find_debug_attr | ( | const struct iio_device * | dev,
|  | const char * | name )

Try to find a debug attribute by its name.

Parameters

  dev | A pointer to an iio_device structure
  name | A NULL-terminated string corresponding to the name of the debug attribute

Returns
  On success, a pointer to a static NULL-terminated string
  If the name does not correspond to any known debug attribute of the given device, NULL is returned

NOTE: This function is useful to detect the presence of a debug attribute. It can also be used to retrieve the name of a debug attribute as a pointer to a static string from a dynamically allocated string.

## iio_device_get_debug_attr()

__api __check_ret __pure const char * iio_device_get_debug_attr | ( | const struct iio_device * | dev,
|  | unsigned int | index )

Get the debug attribute present at the given index.

Parameters

  dev | A pointer to an iio_device structure
  index | The index corresponding to the debug attribute

Returns
  On success, a pointer to a static NULL-terminated string
  If the index is invalid, NULL is returned

## iio_device_get_debug_attrs_count()

__api __check_ret __pure unsigned int iio_device_get_debug_attrs_count | ( | const struct iio_device * | dev | ) |

Enumerate the debug attributes of the given device.

Parameters

  dev | A pointer to an iio_device structure

Returns
  The number of debug attributes found

## iio_device_get_sample_size()

__api __check_ret ssize_t iio_device_get_sample_size | ( | const struct iio_device * | dev | ) |

Get the current sample size.

Parameters

  dev | A pointer to an iio_device structure

Returns
  On success, the sample size in bytes
  On error, a negative errno code is returned

NOTE: The sample size is not constant and will change when channels get enabled or disabled.

Here is the caller graph for this function:

## iio_device_identify_filename()

__api __check_ret int iio_device_identify_filename | ( | const struct iio_device * | dev,
|  | const char * | filename,
|  | struct iio_channel ** | chn,
|  | const char ** | attr )

Identify the channel or debug attribute corresponding to a filename.

Parameters

  dev | A pointer to an iio_device structure
  filename | A NULL-terminated string corresponding to the filename
  chn | A pointer to a pointer of an iio_channel structure. The pointed pointer will be set to the address of the iio_channel structure if the filename correspond to the attribute of a channel, or NULL otherwise.
  attr | A pointer to a NULL-terminated string. The pointer pointer will be set to point to the name of the attribute corresponding to the filename.

Returns
  On success, 0 is returned, and *chn and *attr are modified.
  On error, a negative errno code is returned. *chn and *attr are not modified.

## iio_device_reg_read()

__api __check_ret int iio_device_reg_read | ( | struct iio_device * | dev,
|  | uint32_t | address,
|  | uint32_t * | value )

Get the value of a hardware register.

Parameters

  dev | A pointer to an iio_device structure
  address | The address of the register
  value | A pointer to the variable where the value will be written

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

Here is the call graph for this function:

## iio_device_reg_write()

__api __check_ret int iio_device_reg_write | ( | struct iio_device * | dev,
|  | uint32_t | address,
|  | uint32_t | value )

Set the value of a hardware register.

Parameters

  dev | A pointer to an iio_device structure
  address | The address of the register
  value | The value to set the register to

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

Here is the call graph for this function: