How analogdevicesinc/pyadi-iio works
Purpose and Public Entry Point
PyADI-IIO is a Python library that simplifies control and data capture for Analog Devices hardware exposed through Industrial I/O (IIO) drivers. Users import adi and instantiate a device class with a libiio URI, then use device-specific properties plus RX/TX methods. Package entry surface: adi/__init__.py; representative device APIs: adi/ad936x.py, adi/ad9081.py, adi/adrv9002.py.
Transport and Context Boundary
libiio and its Python bindings are the fundamental external runtime dependency; NumPy carries sample arrays. Device instances obtain an IIO context from a URI (local, network, or other libiio-supported transport), isolating hardware discovery and connection lifecycle from device-facing APIs. Context reuse/lifecycle infrastructure is centered in adi/context_manager.py and adi/device_base.py; compatibility handling is in adi/compat.py.
Shared Device Abstractions
adi/device_base.py is the common layer beneath part-specific classes, providing the foundation for IIO device/channel lookup and configuration. adi/attribute.py maps Python properties to IIO attributes, creating the principal control-plane boundary: Python property reads/writes become libiio attribute operations. adi/rx_tx.py supplies common streaming behavior for devices that acquire or transmit samples.
Device and Board Facades
The adi/ package contains the primary implementation: per-part classes expose hardware-specific configuration while composing shared abstractions. This covers converters, RF transceivers, sensors, clocks, and complete development platforms. Board/system facades coordinate multiple underlying IIO devices, for example adi/daq3.py, adi/fmcomms5.py, and adi/QuadMxFE_multi.py. The public class layer is intentionally hardware-oriented rather than a generic service or web API.
Streaming, FPGA, and Synchronization Features
Data-plane operations flow from configured IIO channels through libiio buffers into NumPy arrays, and reverse for transmission. Advanced FPGA-connected systems add DMA, DDS, JESD, triggering, timing, and synchronized start controls. Core modules are adi/dsp.py, adi/dds.py, adi/jesd.py, adi/sync_start.py, adi/tdd.py, and adi/axi_aion_trig.py. These form a higher-level coordination layer over IIO-exposed FPGA IP and device channels.
Optional Integrations and Runtime Services
The package includes utilities for remote mounting and device-adjacent control (adi/sshfs.py, adi/obs.py) plus an MCP server integration (adi/mcp_server.py). JESD debugging is an optional package extra. Example programs are executable consumer entry points demonstrating connection, configuration, and capture workflows, e.g. examples/ad9361_example.py, examples/ad9081_dma_example.py, and examples/adrv9002_example.py.
Verification and Delivery Boundaries
Most verification can run against libiio emulator device descriptions, separating interface behavior from physical hardware: test/emu/devices/, test/conftest.py, and test/attr_tests.py. A separate physical-board smoke-test tier exists under test/hw/, driven by hardware CI workflows such as .github/workflows/hardware-test.yml; board inventory is maintained in .github/supported-boards.yml. Packaging is Python/PyPI-oriented through pyproject.toml and setup.cfg; Sphinx documentation is sourced from doc/source/.
Main entry points: ad936x.py Part-specific devices · __init__.py adi package entry · rx_tx.py RX/TX streaming · device_base.py Device base
Components 19
Python API
- adi package entry · Users import device classes from this package.
adi/__init__.py - Part-specific devices · Hardware-oriented configuration and RX/TX facades.
adi/ad936x.py - Board/system facades · Coordinate multiple underlying IIO devices.
adi/daq3.py - Example programs · Demonstrate connection, configuration, and capture.
examples/ad9361_example.py
Shared runtime
- Device base · Provides IIO device and channel lookup foundations.
adi/device_base.py - Context manager · Creates and reuses IIO contexts from URIs.
adi/context_manager.py - Attribute mapping · Maps Python properties to IIO attribute operations.
adi/attribute.py - RX/TX streaming · Common sample acquisition and transmission behavior.
adi/rx_tx.py - Compatibility layer
adi/compat.py
IIO hardware boundary
- libiio context & buffers · Discovers hardware, performs attribute I/O, and moves stream buffers.
- NumPy arrays · Carries received and transmitted sample arrays.
- IIO devices & FPGA IP · IIO drivers expose converter channels and FPGA controls.
FPGA coordination
- FPGA control modules · DMA, DDS, JESD, triggering, timing, and synchronized start controls.
adi/dsp.py - Remote & MCP services · Remote mounting, device-adjacent control, and MCP integration.
adi/mcp_server.py
Verification & delivery
- Emulator tests · Validate interfaces against libiio emulator descriptions.
test/emu/devices/adrv9361-z7035.xml - Physical-board smoke tests · Exercise supported boards through hardware CI.
test/hw/test_ad9081_smoke.py - Hardware CI workflow
.github/workflows/hardware-test.yml - PyPI packaging
pyproject.toml - Sphinx documentation
doc/source/index.rst
Connections 22
- adi package entry → Part-specific devices: exports
- adi package entry → Board/system facades: exports
- Example programs → adi package entry: imports
- Part-specific devices → Device base: extends
- Board/system facades → Part-specific devices: composes
- Device base → Context manager: uses
- Part-specific devices → Attribute mapping: configures through
- Part-specific devices → RX/TX streaming: uses
- Context manager → libiio context & buffers: opens URI context
- Attribute mapping → libiio context & buffers: attribute I/O
- RX/TX streaming → libiio context & buffers: buffer I/O
- RX/TX streaming → NumPy arrays: reads/writes
- libiio context & buffers → IIO devices & FPGA IP: connects to
- FPGA control modules → Device base: builds on
- FPGA control modules → IIO devices & FPGA IP: coordinates
- Remote & MCP services → Part-specific devices: integrates with
- Emulator tests → Part-specific devices: verifies
- Emulator tests → libiio context & buffers: uses emulator
- Physical-board smoke tests → IIO devices & FPGA IP: smoke tests
- Hardware CI workflow → Physical-board smoke tests: runs
- PyPI packaging → adi package entry: packages
- Sphinx documentation → adi package entry: documents