### Full virtual environment setup and pyadi-iio install example Source: https://github.com/analogdevicesinc/pyadi-iio/blob/main/doc/source/guides/quick.rst A complete example demonstrating the creation, activation, and installation of pyadi-iio within a virtual environment on a Linux system. ```bash dave@hal:~$ python3 -m venv /home/dave/venv/pyadi-iio dave@hal:~$ source /home/dave/venv/pyadi-iio/bin/activate (pyadi-iio) dave@hal:~$ pip install pyadi-iio Collecting pyadi-iio Downloading ... ``` -------------------------------- ### Run the MCP server using entry point Source: https://github.com/analogdevicesinc/pyadi-iio/blob/main/doc/source/mcp/index.rst Start the MCP server using the installed entry point command. ```bash pyadi-iio-mcp ``` -------------------------------- ### Install PyADI-IIO from Source Source: https://github.com/analogdevicesinc/pyadi-iio/blob/main/README.md Instructions for cloning the repository and installing the package locally from source. This is useful for development or when needing the latest changes. ```bash tcollins@jeeves:~$ git clone https://github.com/analogdevicesinc/pyadi-iio.git tcollins@jeeves:~$ cd pyadi-iio tcollins@jeeves:~$ (sudo) pip install . ``` -------------------------------- ### Install Project Requirements Source: https://github.com/analogdevicesinc/pyadi-iio/blob/main/examples/cn0565/README.md Installs project dependencies from requirements.txt and the project itself in editable mode. ```cmd pip install -r requirements.txt pip install -e . ``` -------------------------------- ### Install pyadi-iio from source Source: https://github.com/analogdevicesinc/pyadi-iio/blob/main/doc/source/guides/quick.rst Clone the pyadi-iio repository and install it using pip. This method provides the latest version from the source. ```bash git clone https://github.com/analogdevicesinc/pyadi-iio.git cd pyadi-iio (sudo) pip install . ``` -------------------------------- ### Install PyADI-IIO from Pip Source: https://github.com/analogdevicesinc/pyadi-iio/blob/main/README.md Standard installation of the pyadi-iio package using pip. This is the recommended method for general use. ```bash tcollins@jeeves:~$ (sudo) pip install pyadi-iio ``` -------------------------------- ### Install pyadi-iio using pip Source: https://github.com/analogdevicesinc/pyadi-iio/blob/main/doc/source/guides/quick.rst Install the pyadi-iio package using pip. Use sudo if installing globally. ```bash (sudo) pip install pyadi-iio ``` -------------------------------- ### Set up pyadi-iio development environment with pipenv Source: https://github.com/analogdevicesinc/pyadi-iio/blob/main/doc/source/dev/index.rst Installs pipenv, sets the local Python version, clones the repository, and installs project dependencies using pipenv. ```bash pip3 install -U pipenv pyenv local 3.6.9 git clone git@github.com:analogdevicesinc/pyadi-iio.git pipenv install pipenv shell pipenv install -r requirements.txt pipenv install -r requirements_dev.txt ``` -------------------------------- ### Run EIT GREIT Example Source: https://github.com/analogdevicesinc/pyadi-iio/blob/main/examples/cn0565/README.md Executes the GREIT EIT visualization example. This script requires PyEIT. ```cmd python cn0565_greit.py ``` -------------------------------- ### Run EIT Jacobian Example Source: https://github.com/analogdevicesinc/pyadi-iio/blob/main/examples/cn0565/README.md Executes the Jacobian EIT visualization example. This script requires PyEIT. ```cmd python cn0565_jacobian.py ``` -------------------------------- ### Install pyadi-iio with MCP dependencies Source: https://github.com/analogdevicesinc/pyadi-iio/blob/main/doc/source/mcp/index.rst Install pyadi-iio with the MCP optional dependencies to include fastmcp and numpy. ```bash pip install pyadi-iio[mcp] ``` -------------------------------- ### Create Device and Get Data with PyADI-IIO Source: https://github.com/analogdevicesinc/pyadi-iio/blob/main/README.md This snippet demonstrates how to initialize a device using its URI and retrieve received data. Ensure you have the correct URI for your device. ```python import adi # Create device from specific uri address sdr = adi.ad9361(uri="ip:192.168.2.1") # Get data from transceiver data = sdr.rx() ``` -------------------------------- ### Run EIT Back Projection Example Source: https://github.com/analogdevicesinc/pyadi-iio/blob/main/examples/cn0565/README.md Executes the back projection EIT visualization example. This script requires PyEIT. ```cmd python cn0565_back_projection.py ``` -------------------------------- ### Example workflow for MCP server interaction Source: https://github.com/analogdevicesinc/pyadi-iio/blob/main/doc/source/mcp/index.rst Demonstrates a typical workflow for interacting with the MCP server, including discovery, connection, exploration, configuration, data capture, and disconnection. ```python # 1. Find the right device class list_device_classes(filter_text="pluto") # -> ["Pluto"] # 2. Connect result = connect_device(device_class="Pluto", uri="ip:192.168.2.1") conn_id = result["connection_id"] # 3. Explore what the device can do discover_device_capabilities(connection_id=conn_id, filter_text="lo") # 4. Configure ``` -------------------------------- ### Install Tools for Building Documentation Source: https://github.com/analogdevicesinc/pyadi-iio/blob/main/README.md Installs the necessary Python packages required for building the project's documentation using Sphinx. Ensure you have the correct requirements file. ```bash tcollins@jeeves:~$ (sudo) pip install -r requirements_doc.txt ``` -------------------------------- ### Run GUI Source: https://github.com/analogdevicesinc/pyadi-iio/blob/main/examples/cn0565/README.md Starts the graphical user interface for the Electrical Impedance Tomography Measurement System. No arguments are required. ```cmd python main.py ``` -------------------------------- ### Configure Claude Desktop to use pyadi-iio MCP server Source: https://github.com/analogdevicesinc/pyadi-iio/blob/main/doc/source/mcp/index.rst Example configuration for Claude Desktop to launch the pyadi-iio MCP server as a subprocess. ```json { "mcpServers": { "pyadi-iio": { "command": "pyadi-iio-mcp" } } } ``` -------------------------------- ### Install pyenv using curl Source: https://github.com/analogdevicesinc/pyadi-iio/blob/main/doc/source/dev/index.rst Installs pyenv using the provided bash script. Ensure you have curl installed. ```bash curl https://pyenv.run | bash ``` -------------------------------- ### Install pyadi-iio using Conda Source: https://github.com/analogdevicesinc/pyadi-iio/blob/main/doc/source/guides/quick.rst Install libiio, pylibiio, and pyadi-iio from the conda-forge channel using the conda package manager. ```bash conda install -c conda-forge pyadi-iio ``` -------------------------------- ### Install pyadi-iio with optional JESD dependencies Source: https://github.com/analogdevicesinc/pyadi-iio/blob/main/doc/source/guides/quick.rst Install pyadi-iio along with optional dependencies for JESD debugging and control. This is specifically for multi-SOM configurations like ADRV9009-ZU11EG. ```bash (sudo) pip install pyadi-iio[jesd] ``` -------------------------------- ### Install Tools for Development Source: https://github.com/analogdevicesinc/pyadi-iio/blob/main/README.md Installs Python packages required for development, likely including testing and linting tools. This is for contributors to the project. ```bash tcollins@jeeves:~$ (sudo) pip install -r requirements_dev.txt ``` -------------------------------- ### Build Documentation with Sphinx Source: https://github.com/analogdevicesinc/pyadi-iio/blob/main/README.md Commands to navigate to the documentation directory and build the HTML documentation using Sphinx. This requires the documentation tools to be installed first. ```bash tcollins@jeeves:~$ cd doc tcollins@jeeves:~$ make html ``` -------------------------------- ### Minimal RX Device Class Example Source: https://github.com/analogdevicesinc/pyadi-iio/blob/main/doc/source/dev/device_base.rst A minimal RX device class using `rx_chan_comp`. No custom `__init__` is required as the base class handles connection, device lookup, and channel instantiation. ```python from adi.attribute import attribute from adi.device_base import rx_chan_comp class ad4080_channel(attribute): """AD4080 channel""" def __init__(self, ctrl, channel_name): self.name = channel_name self._ctrl = ctrl @property def scale(self): return self._get_iio_attr(self.name, "scale", False) class ad4080(rx_chan_comp): """AD4080 ADC""" compatible_parts = ["ad4080", "ad4081", "ad4083"] _complex_data = False _channel_def = ad4080_channel @property def sampling_frequency(self): return self._get_iio_dev_attr("sampling_frequency", False) ``` -------------------------------- ### Check libiio installation and version Source: https://github.com/analogdevicesinc/pyadi-iio/blob/main/doc/source/guides/quick.rst Verify that the libiio Python bindings are installed and accessible by importing the 'iio' module and checking its version. This is done within a Python interpreter. ```python dave@hal:~$ python3 Python 3.6.8 (default, Jan 14 2019, 11:02:34) [GCC 8.0.1 20180414 (experimental) [trunk revision 259383]] on linux Type "help", "copyright", "credits" or "license" for more information. >>> import iio >>> iio.version (0, 18, 'eec5616') ``` -------------------------------- ### Send and Receive Data with pyadi-iio Source: https://github.com/analogdevicesinc/pyadi-iio/blob/main/doc/source/guides/examples.rst This example shows how to send data to a device and receive data from it. It requires importing both adi and numpy libraries. The data to be sent should be a numpy array. ```python import adi import numpy as np sdr = adi.ad9361() data = np.arange(1, 10, 3) sdr.tx(data) data_rx = sdr.rx() ``` -------------------------------- ### Install Optional JESD Debugging Dependency Source: https://github.com/analogdevicesinc/pyadi-iio/blob/main/README.md Installs the pyadi-iio package with optional dependencies for JESD debugging. Use this if you need to work with JESD interfaces. ```bash tcollins@jeeves:~$ (sudo) pip install pyadi-iio[jesd] ``` -------------------------------- ### Run All EIT Plots Example Source: https://github.com/analogdevicesinc/pyadi-iio/blob/main/examples/cn0565/README.md Generates all EIT plots using the PyEIT library. This script is useful for comprehensive visualization. ```cmd python cn0565_sample_plot.py ``` -------------------------------- ### Check pyadi-iio installation and version Source: https://github.com/analogdevicesinc/pyadi-iio/blob/main/doc/source/guides/quick.rst Verify that the pyadi-iio package is installed and accessible by importing the 'adi' module and checking its version and name. This is done within a Python interpreter. ```python dave@hal:~$ python3 Python 3.6.8 (default, Jan 14 2019, 11:02:34) [GCC 8.0.1 20180414 (experimental) [trunk revision 259383]] on linux Type "help", "copyright", "credits" or "license" for more information. >>> import adi >>> adi.__version__ '0.0.5' >>> adi.name 'Analog Devices Hardware Interfaces' ``` -------------------------------- ### Access Network Devices via URI Source: https://github.com/analogdevicesinc/pyadi-iio/blob/main/doc/source/guides/examples.rst Connect to a device over the network using its URI. This example demonstrates creating an interface to an AD9361 device at a specific IP address and receiving data. ```python import adi sdr = adi.ad9361(uri="ip:192.168.2.1") data = sdr.rx() ``` -------------------------------- ### Access USB Devices via URI Source: https://github.com/analogdevicesinc/pyadi-iio/blob/main/doc/source/guides/examples.rst Connect to a device over USB using its URI. This example shows how to create an interface to a Pluto device at a specific USB address and receive data. ```python import adi sdr = adi.Pluto(uri="usb:1.24.5") data = sdr.rx() ``` -------------------------------- ### Instantiate AD4003 Class with AD4007 Device Name Source: https://github.com/analogdevicesinc/pyadi-iio/blob/main/doc/source/devices/adi.ad4020.rst Use this method to instantiate a device class with a specific model name if you are working with a different supported part. This example shows initializing the ad4003 class for an ad4007 device. ```python import adi adc = adi.ad4003(uri="ip:10.2.5.222", device_name="ad4007") ... ``` -------------------------------- ### Inspect Class Properties with help() Source: https://github.com/analogdevicesinc/pyadi-iio/blob/main/doc/source/attr/index.rst Inspect class definitions or use Python's help() method to get more detail about specific properties. This is useful for understanding available attributes and their usage. ```none pluto_help.cli ``` -------------------------------- ### Get a device property Source: https://github.com/analogdevicesinc/pyadi-iio/blob/main/doc/source/mcp/index.rst Read any device property by name using the `get_property` tool. ```python get_property(connection_id="...", property_name="rx_sample_rate") ``` -------------------------------- ### Test pyadi-iio with iio-emu emulation Source: https://github.com/analogdevicesinc/pyadi-iio/blob/main/doc/source/dev/index.rst Example of a pytest test function that uses a fixture to obtain an IIO context URI, likely for use with iio-emu. ```python import pytest import iio @pytest.mark.iio_hardware("pluto", False) # Set True disables test during emulation def test_libiio_device(iio_uri): ctx = iio.Context(iio_uri) ... ``` -------------------------------- ### Run PyADI-IIO Smoke Test with Labgrid Source: https://github.com/analogdevicesinc/pyadi-iio/blob/main/test/hw/README.md Execute a hardware smoke test for the AD9081 board using Labgrid. This involves acquiring a place, setting up the Labgrid environment, running pytest, and then releasing the place. This method handles board booting and environment setup. ```bash # Against the lab coordinator (boots the board, ~80–120s). You must acquire the place first — the conftest does NOT acquire. The labgrid env is no longer committed in-repo: fetch it from the coordinator (the exact source CI uses), then point LG_ENV at it. curl -fsSL "http://10.0.0.41:8000/api/places/mini2/env-yaml?tier=boot" -o /tmp/lg-mini2.yaml labgrid-client -x 10.0.0.41:20408 -p mini2 acquire LG_COORDINATOR=10.0.0.41:20408 \ LG_PLACE=mini2 \ LG_ENV=/tmp/lg-mini2.yaml \ pytest -v test/hw/test_ad9081_smoke.py labgrid-client -x 10.0.0.41:20408 -p mini2 release ``` -------------------------------- ### Accessing libiio Context and Devices Source: https://github.com/analogdevicesinc/pyadi-iio/blob/main/doc/source/libiio.md Demonstrates how to obtain a libiio context and compare devices with pyadi-iio. This is useful for understanding the underlying libiio structure. ```python import adi import iio sdr = adi.Pluto("ip:pluto.local") ctx = iio.Context("ip:pluto.local") for d1, d2 in zip(sdr.ctx.devices, ctx.devices): print(d1.name, "|", d2.name) ``` -------------------------------- ### Install a specific Python version with pyenv Source: https://github.com/analogdevicesinc/pyadi-iio/blob/main/doc/source/dev/index.rst Installs Python version 3.6.9 using pyenv. This allows for isolated Python environments. ```bash pyenv install 3.6.9 ``` -------------------------------- ### Instantiating the AD4020 Driver for a Specific Device Source: https://github.com/analogdevicesinc/pyadi-iio/blob/main/doc/source/devices/adi.ad4020.rst Demonstrates how to instantiate the AD4020 driver class for a specific device model (e.g., ad4007) when it differs from the class name. This is useful when using a class that supports multiple hardware variants. ```APIDOC ## Instantiating the AD4020 Driver for a Specific Device ### Description This example shows how to create an instance of the `adi.ad4020` class, specifying a `device_name` that corresponds to a supported part (e.g., "ad4007") when the actual hardware model is different from the class name. ### Usage ```python import adi # Instantiate the ad4020 class for an ad4007 device # uri: Specifies the connection URI (e.g., IP address for network connection) # device_name: Explicitly sets the target device model adc = adi.ad4020(uri="ip:10.2.5.222", device_name="ad4007") # Further operations with the adc object can be performed here... ``` ### Parameters - **uri** (str): The connection URI for the device. - **device_name** (str): The name of the specific device model to use (e.g., "ad4007"). If not provided, it defaults to the class name (e.g., "ad4020"). ``` -------------------------------- ### Connect to a device by class name and URI Source: https://github.com/analogdevicesinc/pyadi-iio/blob/main/doc/source/mcp/index.rst Use `connect_device` to establish a connection to a hardware device, returning a `connection_id`. ```python # Connect to an AD9361-based device connect_device(device_class="ad9361", uri="ip:192.168.2.1") # Connect with extra constructor arguments connect_device( device_class="ad9084", uri="ip:192.168.2.1", kwargs='{"rx1_device_name": "axi-ad9084-rx-hpc"}', ) ``` -------------------------------- ### Enable Prism Upload and Configure URL Source: https://github.com/analogdevicesinc/pyadi-iio/blob/main/test/hw/README.md Set repository variables to enable Prism upload and specify the Prism server URL. These commands configure the opt-in feature for posting test results. ```bash gh variable set PRISM_UPLOAD_ENABLED --repo analogdevicesinc/pyadi-iio --body true gh variable set PRISM_URL --repo analogdevicesinc/pyadi-iio --body 'http://10.0.0.113:8088' ``` -------------------------------- ### Configure pyenv in shell startup script Source: https://github.com/analogdevicesinc/pyadi-iio/blob/main/doc/source/dev/index.rst Adds pyenv to your system's PATH and initializes it for your shell. This is necessary for pyenv commands to work. ```bash export PATH="/home//.pyenv/bin:$PATH" eval "$(pyenv init -)" eval "$(pyenv virtualenv-init -)" ``` -------------------------------- ### Re-enter pyadi-iio development environment Source: https://github.com/analogdevicesinc/pyadi-iio/blob/main/doc/source/dev/index.rst Navigates to the project directory, sets the local Python version, and activates the pipenv shell to resume the development environment. ```bash cd pyenv local 3.6.9 pipenv shell ``` -------------------------------- ### Selecting Specific Device Instances Source: https://github.com/analogdevicesinc/pyadi-iio/blob/main/doc/source/dev/device_base.rst When multiple IIO devices share a name, use `device_index` during class construction to bind to a specific device. ```python dev0 = ad4080(uri="ip:analog.local", device_index=0) dev1 = ad4080(uri="ip:analog.local", device_index=1) ``` -------------------------------- ### Create a Python virtual environment Source: https://github.com/analogdevicesinc/pyadi-iio/blob/main/doc/source/guides/quick.rst Create a new virtual environment for your project to manage dependencies and avoid conflicts. Replace /path/to/new/virtual/environment with your desired path. ```bash python3 -m venv /path/to/new/virtual/environment ``` -------------------------------- ### Activate a Python virtual environment Source: https://github.com/analogdevicesinc/pyadi-iio/blob/main/doc/source/guides/quick.rst Activate the created virtual environment. Replace /path/to/new/virtual/environment with the path where you created the environment. ```bash source /path/to/new/virtual/environment/bin/activate ``` -------------------------------- ### Reading and Writing Device Registers via libiio Source: https://github.com/analogdevicesinc/pyadi-iio/blob/main/doc/source/libiio.md Demonstrates direct register read and write operations on libiio devices using pyadi-iio. This is useful for low-level hardware control and debugging. ```python import adi sdr = adi.Pluto() phy = sdr.ctx.find_device("ad9361-phy") # Read product ID register pi = phy.reg_read(0x37) print(f"ID: {hex(pi)}") # Enable near-end loopback in the HDL core rxfpga = sdr.ctx.find_device("cf-ad9361-lpc") rxfpga.reg_write(0x80000418, 0x1) # I channel rxfpga.reg_write(0x80000458, 0x1) # Q channel ``` -------------------------------- ### Configure DDS for Transmit FPGA Devices Source: https://github.com/analogdevicesinc/pyadi-iio/blob/main/doc/source/guides/examples.rst Configure the DDS (Direct Digital Synthesis) of a transmit-capable FPGA device. Specify the tone frequency in Hz, the scale (0-1.0), and the transmit channel (starting from 0). ```python import adi sdr = adi.DAQ2() tone_freq_hz = 1000 tone_scale = 0.9 tx_channel = 1 sdr.dds_single_tone(tone_freq_hz, tone_scale, tx_channel) ``` -------------------------------- ### Configure Hardware Properties with pyadi-iio Source: https://github.com/analogdevicesinc/pyadi-iio/blob/main/doc/source/guides/examples.rst Use this snippet to set and read back hardware properties like RF bandwidth, LO frequencies, and gain control modes. Ensure the adi library is imported and a device interface is created. ```python import adi sdr = adi.ad9361() sdr.rx_rf_bandwidth = 4000000 sdr.rx_lo = 2000000000 sdr.tx_lo = 2000000000 sdr.tx_cyclic_buffer = True sdr.tx_hardwaregain = -30 sdr.gain_control_mode = "slow_attack" print(sdr.rx_hardwaregain) ``` -------------------------------- ### List Available Invoke Tasks Source: https://github.com/analogdevicesinc/pyadi-iio/blob/main/doc/source/dev/index.rst Run this command to see all available tasks that can be executed with pyinvoke for development and maintenance of pyadi-iio. ```console invoke --list ``` -------------------------------- ### Setting Device Enable State Machine via libiio Source: https://github.com/analogdevicesinc/pyadi-iio/blob/main/doc/source/libiio.md Shows how to interact with device attributes, specifically the 'ensm_mode' for the enable state machine, using the libiio API through pyadi-iio. This is useful for configuring device operational modes. ```python import adi sdr = adi.Pluto() phy = sdr.ctx.find_device("ad9361-phy") # View current mode print(phy.attrs["ensm_mode"].value) # View options print(phy.attrs["ensm_mode_available"].value) # Update mode phy.attrs["ensm_mode"].value = "alert" # View new mode print(phy.attrs["ensm_mode"].value) ``` -------------------------------- ### Run the MCP server as a module Source: https://github.com/analogdevicesinc/pyadi-iio/blob/main/doc/source/mcp/index.rst Alternatively, run the MCP server directly as a Python module. ```bash python -m adi.mcp_server ``` -------------------------------- ### AD5592R Device Initialization and Channel Access Source: https://github.com/analogdevicesinc/pyadi-iio/blob/main/doc/source/devices/adi.ad5592r.rst Demonstrates how to initialize the AD5592R device and access its DAC, ADC, and temperature channels for reading and writing raw values. ```APIDOC ## AD5592R Device Operations ### Description This section covers the basic operations for the AD5592R device, including initialization and accessing individual channels for DAC output, ADC input, and temperature readings. ### Initialization Initialize the device by providing the appropriate URI. ```python dev = adi.ad5592r(uri="ip:analog") ``` ### DAC Channel Access Individual DAC channels can be accessed and set using their respective properties. For example, to set `dac_0`: ```python dev.dac_0.raw = 10 ``` ### ADC Channel Access Individual ADC channels can be read using their respective properties. For example, to read `adc_0`: ```python data = dev.adc_0.raw print(data) ``` ### Temperature Channel Access Temperature channels can be read, and their raw values can be converted to Celsius using offset and scale properties. ```python temp_c = (dev.temp_0.raw + dev.temp_0.offset) * dev.temp_0.scale print(temp_c) ``` ### Parameters #### DAC Channel Parameters - **raw** (int) - Required - The raw value to set for the DAC channel. #### ADC Channel Parameters - **raw** (int) - Description - The raw value read from the ADC channel. #### Temperature Channel Parameters - **raw** (int) - Description - The raw temperature value. - **offset** (float) - Description - The offset value for temperature conversion. - **scale** (float) - Description - The scale factor for temperature conversion. ### Response #### Success Response - **raw** (int/float) - The raw value read from the channel or the converted temperature in Celsius. ``` -------------------------------- ### Discover device capabilities with filter Source: https://github.com/analogdevicesinc/pyadi-iio/blob/main/doc/source/mcp/index.rst Inspect a connected device using `discover_device_capabilities` to learn its supported features and properties. An optional filter can narrow down the results. ```python # See all properties related to "nco" discover_device_capabilities(connection_id="...", filter_text="nco") ``` -------------------------------- ### Run Multiple Impedance Measurements Source: https://github.com/analogdevicesinc/pyadi-iio/blob/main/examples/cn0565/README.md Executes impedance measurements across various possible electrode combinations. No arguments are required. ```cmd python cn0565_example.py ``` -------------------------------- ### Connect to Local or Standard USB Device Source: https://github.com/analogdevicesinc/pyadi-iio/blob/main/doc/source/guides/connectivity.rst Use this for devices connected locally or via USB when only one is present. The library will attempt to connect automatically. ```python import adi sdr = adi.Pluto() print(sdr.tx_rf_bandwidth) ``` -------------------------------- ### Set RX LO and Sample Rate Source: https://github.com/analogdevicesinc/pyadi-iio/blob/main/doc/source/mcp/index.rst Use these functions to configure the receive local oscillator frequency and the sample rate for the device. Ensure the connection is established before setting properties. ```python set_property(connection_id=conn_id, property_name="rx_lo", value="2400000000") set_property(connection_id=conn_id, property_name="sample_rate", value="2084000") ``` -------------------------------- ### List available device classes with filter Source: https://github.com/analogdevicesinc/pyadi-iio/blob/main/doc/source/mcp/index.rst Use the `list_device_classes` tool to find device classes, optionally filtering by name. ```python # Example tool call list_device_classes(filter_text="936") # Returns: ["ad9361", "ad9363", "ad9364"] ``` -------------------------------- ### Create Neural Network Models Source: https://github.com/analogdevicesinc/pyadi-iio/blob/main/examples/cn0549/ml_fan_example.ipynb Initializes a basic neural network (NN) and a convolutional neural network (CNN) with a given input shape and number of classes. The CNN is noted for having significantly fewer parameters. ```python input_shape = (x_train.shape[1], x_train.shape[2], x_train.shape[3]) model_nn = create_model_nn(input_shape, num_classes) model_cnn = create_model_cnn(input_shape, num_classes) ``` -------------------------------- ### Instantiate AD3552R and Access Channels Source: https://github.com/analogdevicesinc/pyadi-iio/blob/main/doc/source/devices/adi.ad3552r.rst Instantiate the AD3552R device, specifying the device name if using a variant other than the class name. Access individual channels to read or write raw data. ```python dev = ad3552r("", "ad3552r") dev.channel[0].raw = 10 dev.channel[1].raw = 30 data = dev.channel[0].raw print(data) ``` -------------------------------- ### Run Pre-commit Checks Directly Source: https://github.com/analogdevicesinc/pyadi-iio/blob/main/doc/source/dev/index.rst Alternatively, run pre-commit checks directly from the repository root without using pyinvoke. ```console pre-commit run --all-files ``` -------------------------------- ### Run Pre-commit Checks with Invoke Source: https://github.com/analogdevicesinc/pyadi-iio/blob/main/doc/source/dev/index.rst Execute pre-commit checks using pyinvoke to ensure code quality and consistency before submitting changes. ```console invoke precommit ``` -------------------------------- ### list_device_classes Source: https://github.com/analogdevicesinc/pyadi-iio/blob/main/doc/source/mcp/index.rst Lists all available pyadi-iio device classes, with an optional filter to narrow down the results. Useful for identifying the correct class name for a specific hardware part. ```APIDOC ## list_device_classes ### Description List all available pyadi-iio device classes with an optional name filter. This is useful for finding the correct class name for a specific part. ### Parameters #### Query Parameters - **filter_text** (string) - Optional - A string to filter the device class names. ### Response #### Success Response (200) - **device_classes** (list[string]) - A list of matching device class names. ### Request Example ```python list_device_classes(filter_text="936") ``` ### Response Example ```json { "device_classes": ["ad9361", "ad9363", "ad9364"] } ``` ``` -------------------------------- ### Printing libiio Debug Attributes Source: https://github.com/analogdevicesinc/pyadi-iio/blob/main/doc/source/libiio.md Illustrates how to iterate through and print all debug attributes of a libiio device using pyadi-iio. This can be helpful for debugging and inspecting device-specific information. ```python import adi sdr = adi.Pluto() phy = sdr.ctx.find_device("ad9361-phy") for dattr in phy.debug_attrs: print(dattr, phy.debug_attrs[dattr]) ``` -------------------------------- ### Run PyADI-IIO Smoke Test Locally (No Labgrid) Source: https://github.com/analogdevicesinc/pyadi-iio/blob/main/test/hw/README.md Execute a hardware smoke test for the AD9081 board by directly pointing pytest to an IIO device URI. This method bypasses Labgrid and assumes the target device is already powered and accessible. ```bash # Without labgrid (point at an iiod yourself; no boot) pytest -v test/hw/test_ad9081_smoke.py --iio-uri-override ip:10.0.0.211 ``` -------------------------------- ### Configure DDS for single tone generation Source: https://github.com/analogdevicesinc/pyadi-iio/blob/main/doc/source/mcp/index.rst Configure the FPGA-side DDS with `configure_dds` to generate a single tone on a specified TX channel for testing. ```python configure_dds( connection_id="...", frequency=10000000, scale=0.9, channel=0, ) ``` -------------------------------- ### Configure Multiple DDS Tones Individually Source: https://github.com/analogdevicesinc/pyadi-iio/blob/main/doc/source/fpga/index.rst Configure DDSs individually by passing lists of scales, frequencies, and phases to their respective properties. Ensure dds_enabled is set for the desired number of channels. ```python import adi sdr = adi.ad9361() n = len(sdr.dds_scales) # Enable all DDSs sdr.dds_enabled = [True] * n # Set all DDSs to same frequency, scale, and phase dds_freq_hz = 10000 sdr.dds_phases = [0] * n sdr.dds_frequencies = [dds_freq_hz] * n sdr.dds_scales = [0.9] * n ``` -------------------------------- ### discover_device_capabilities Source: https://github.com/analogdevicesinc/pyadi-iio/blob/main/doc/source/mcp/index.rst Inspects a connected device to determine its supported features, including RX, TX, and DDS capabilities, and lists all available properties with their metadata. ```APIDOC ## discover_device_capabilities ### Description Inspect a connected device to learn what it supports. Returns whether the device has RX, TX, and DDS capabilities, along with a list of all available properties including read/write metadata and documentation. An optional filter narrows the property list. ### Parameters #### Query Parameters - **connection_id** (string) - Required - The UUID of the connection to the device. - **filter_text** (string) - Optional - A string to filter the discovered properties. ### Response #### Success Response (200) - **capabilities** (object) - Information about the device's RX, TX, and DDS capabilities. - **properties** (list[object]) - A list of available properties, each with details like name, type, read/write status, and documentation. ### Request Example ```python discover_device_capabilities(connection_id="a1b2c3d4-e5f6-7890-1234-567890abcdef", filter_text="nco") ``` ### Response Example ```json { "capabilities": { "has_rx": true, "has_tx": true, "has_dds": true }, "properties": [ { "name": "rx_nco_frequency", "type": "integer", "read_only": false, "doc": "Frequency of the Numerically Controlled Oscillator for RX." } ] } ``` ``` -------------------------------- ### Run Pre-commit Checks Source: https://github.com/analogdevicesinc/pyadi-iio/blob/main/README.md Executes all pre-commit hooks on the entire codebase. This is used to ensure code quality and consistency before committing changes. ```bash tcollins@jeeves:~$ pre-commit run --all-files ``` -------------------------------- ### connect_device Source: https://github.com/analogdevicesinc/pyadi-iio/blob/main/doc/source/mcp/index.rst Establishes a connection to an ADI device using its class name and URI. It returns a unique connection ID and a summary of the device's capabilities. ```APIDOC ## connect_device ### Description Create a connection to any pyadi-iio device by class name and URI. Returns a ``connection_id`` UUID used by all subsequent tools, along with a summary of device capabilities. ### Parameters #### Query Parameters - **device_class** (string) - Required - The name of the device class to connect to. - **uri** (string) - Required - The connection URI for the device (e.g., "ip:192.168.2.1"). - **kwargs** (string) - Optional - A JSON-encoded string of additional keyword arguments for device initialization. ### Response #### Success Response (200) - **connection_id** (string) - A UUID representing the established connection. - **capabilities** (object) - A summary of the device's capabilities. ### Request Example ```python connect_device(device_class="ad9361", uri="ip:192.168.2.1") connect_device( device_class="ad9084", uri="ip:192.168.2.1", kwargs='{"rx1_device_name": "axi-ad9084-rx-hpc"}' ) ``` ### Response Example ```json { "connection_id": "a1b2c3d4-e5f6-7890-1234-567890abcdef", "capabilities": { "has_rx": true, "has_tx": true, "has_dds": false } } ``` ``` -------------------------------- ### Display Neural Network Summary Source: https://github.com/analogdevicesinc/pyadi-iio/blob/main/examples/cn0549/ml_fan_example.ipynb Prints the summary of the created neural network model, detailing its layers, output shapes, and parameter counts. This is useful for understanding the model's architecture. ```python print(model_nn.summary()) ``` -------------------------------- ### AD777x Device Interface Source: https://github.com/analogdevicesinc/pyadi-iio/blob/main/doc/source/devices/adi.ad777x.rst This section covers the primary interface for the AD777x devices. It includes methods for initialization, configuration, and data retrieval. ```APIDOC ## AD777x Class This class provides an interface to the AD777x family of ADCs. ### Methods - **__init__(self, iio_device)**: Initializes the AD777x device. - **sample_rate_set(self, rate)**: Sets the sample rate of the ADC. - **sample_rate_get(self)**: Gets the current sample rate of the ADC. - **data_capture_config(self, num_samples, channel_mask)**: Configures data capture settings. - **read_data(self)**: Reads captured data from the ADC. - **reset(self)**: Resets the AD777x device to its default state. ```