pyadi-iio

0.0.20 · active · verified Thu Apr 16

pyadi-iio is a Python abstraction module developed by Analog Devices for interfacing with their hardware devices that utilize Industrial I/O (IIO) drivers. It simplifies interaction with complex IIO interfaces by providing device-specific APIs, reducing boilerplate code for common operations like data acquisition and control. The current version is 0.0.20, and the library is actively maintained with ongoing development and contributions.

Common errors

Warnings

Install

Imports

Quickstart

Initializes a connection to an Analog Devices IIO device, typically an SDR like AD9361, using its URI (IP address for network connection). It then demonstrates reading a device property and capturing a block of RX data. The `ADIIO_URI` environment variable can be used to specify the device's address, otherwise a default IP is attempted. This requires the `libiio` C library to be installed and the hardware device to be reachable.

import adi
import os

# Replace with your device's actual IP address or leave empty for local/USB detection
# Ensure the target hardware is powered on and configured for network/USB communication
# For network connection, the IP address should be accessible from the host.
# Example: 'ip:192.168.2.1' for Ethernet, 'usb:1.24.5' for specific USB device
device_uri = os.environ.get('ADIIO_URI', 'ip:192.168.2.1') 

try:
    # Create a device interface for a supported device, e.g., AD9361
    sdr = adi.ad9361(uri=device_uri)

    # Example: Print RX LO Frequency
    print(f"RX LO Frequency: {sdr.rx_lo}")

    # Example: Capture and print some RX data (ensure device is transmitting/receiving)
    # This part assumes the device is configured and streaming data.
    # In a real scenario, you'd configure sample rates, gains, etc. before reading.
    sdr.rx_buffer_size = 2**12  # Set buffer size
    data = sdr.rx()
    print(f"Captured {len(data)} RX samples.")
    # print(f"First 10 RX samples: {data[:10]}") # Uncomment to see sample values

except Exception as e:
    print(f"Could not connect to or interact with device at {device_uri}: {e}")
    print("Please ensure libiio is installed and the device is accessible. "
          "Refer to pyadi-iio documentation for device-specific setup.")

view raw JSON →