-
Notifications
You must be signed in to change notification settings - Fork 322
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Travis F. Collins <travis.collins@analog.com>
- Loading branch information
Showing
22 changed files
with
2,067 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,71 @@ | ||
# Examples | ||
|
||
This page provides a few examples of how to use the libIIO library. The examples are written in C and are intended to be used as a starting point for your own application. For other languages, please refer to the [Bindings](bindings.md) page. | ||
|
||
:::{note} | ||
To reduce verbosity, the error handling code has been omitted from the examples. In a real application, you should always check the return value of each function call. | ||
::: | ||
|
||
## Connect to Ethernet Context and List Devices | ||
|
||
```c | ||
#include <stdio.h> | ||
#include <iio.h> | ||
|
||
int main() { | ||
|
||
struct iio_context *ctx; | ||
struct iio_device *dev; | ||
struct iio_device **devices; | ||
int i, ndevices; | ||
|
||
ctx = iio_create_context(NULL, "ip:analog.local"); | ||
ndevices = iio_context_get_devices_count(ctx); | ||
for (i = 0; i < ndevices; i++) { | ||
dev = iio_context_get_device(ctx, i); | ||
printf("Device %d: %s\n", i, iio_device_get_name(dev)); | ||
} | ||
|
||
iio_context_destroy(ctx); | ||
|
||
return 0; | ||
} | ||
``` | ||
|
||
## Write Device and Channel Attribute | ||
|
||
```c | ||
|
||
#include <stdio.h> | ||
#include <iio.h> | ||
|
||
int main() { | ||
|
||
struct iio_context *ctx; | ||
struct iio_device *dev; | ||
struct iio_channel *ch; | ||
struct iio_attr *attr; | ||
|
||
ctx = iio_create_context(NULL, "ip:analog.local"); | ||
dev = iio_context_find_device(ctx, "ad9361-phy"); | ||
attr = iio_device_find_attr(dev, "ensm_mode"); | ||
iio_attr_write(attr, "fdd"); | ||
|
||
ch = iio_device_find_channel(dev, "voltage0", false); | ||
attr = iio_channel_find_attr(ch, "hardwaregain"); | ||
iio_attr_write(attr, "0"); | ||
|
||
iio_context_destroy(ctx); | ||
|
||
return 0; | ||
} | ||
``` | ||
|
||
## Device Specific Examples | ||
|
||
The following examples are available in the libiio repository: | ||
|
||
- [ad9361-iiostream.c](https://github.com/analogdevicesinc/libiio/blob/main/examples/ad9361-iiostream.c) | ||
- [ad9361-iio-stream.c](https://github.com/analogdevicesinc/libiio/blob/main/examples/ad93761-iiostream.c) | ||
- [adrv9002-iiostream.c](https://github.com/analogdevicesinc/libiio/blob/main/examples/adrv9002-iiostream.c) | ||
- [adrv9009-iiostream.c](https://github.com/analogdevicesinc/libiio/blob/main/examples/adrv9009-iiostream.c) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,47 @@ | ||
# Installation | ||
|
||
It is recommended to use the latest releases through pre-built packages when available. If you need the latest features or are developing libIIO itself, you can build from source following guides: | ||
|
||
```{toctree} | ||
:maxdepth: 1 | ||
install/source | ||
``` | ||
|
||
## Installation Packages | ||
|
||
Pre-built packages are available for the following for a number of different platforms from GitHub as well as from different package managers. | ||
|
||
### Windows | ||
|
||
Install the latest release from the [GitHub releases page](https://github.com/analogdevicesinc/libiio/releases). | ||
|
||
The EXE installer is recommend but zip packages include the same files, which can be useful for developers. | ||
|
||
|
||
### Linux | ||
|
||
Most Linux users can install libIIO from their distribution's package manager. For example, on Ubuntu, you can install libIIO with the following command: | ||
|
||
```bash | ||
sudo apt-get install libiio0 | ||
``` | ||
|
||
It can be also useful to install the development package and tools: | ||
|
||
```bash | ||
sudo apt-get install libiio-dev libiio-utils | ||
``` | ||
|
||
Please reference your OS's package manager for the correct package names. Alternatively, you can download the latest release from the [GitHub releases page](https://github.com/analogdevicesinc/libiio/releases) or build from source. | ||
|
||
### macOS | ||
|
||
For macOS there are four options: | ||
|
||
- [Homebrew](install/homebrew.md) | ||
- [MacPorts](https://ports.macports.org/port/libiio/) | ||
- DMG installer from the [GitHub releases page](ttps://github.com/analogdevicesinc/libiio/releases) | ||
- [Building from source](install/source.md) | ||
|
||
|
Oops, something went wrong.