Post Go back to editing

pyadi-iio ad9081.py IIO Attribute Key Error

Thread Summary

The user encountered a KeyError when accessing read-only properties like `rx_sample_rate` or `dac_frequency` in a Quad MxFE setup with pyadi-iio 0.0.19. The issue was resolved by referencing the correct channel names in the `_rx_coarse_ddc_channel_names` dictionary, as discussed in the GitHub issue #702.
AI Generated Content
Category: Software
Product Number: AD9081
Software Version: 0.0.19

I have a Quad MxFE setup with the default bitstream and Linux image. The device is connected via local ethernet, and I have pyadi-iio version 0.0.19 installed on my laptop which I am trying to use to interface to the device. I can initialize the adi.QuadMxFE object, however I get errors when I try to access adi.ad9081 inherited read only properties, for example rx_sample_rate or dac_frequency, I get a key error.

Reproduction steps:

```

import adi

mxfe = adi.QuadMxFE('ip:192.168.2.1', False)

print(mxfe.adc_frequency)

```

Results:

```

Traceback (most recent call last):
File "<python-input-40>", line 1, in <module>
print(mxfe.adc_frequency)
^^^^^^^^^^^^^^^^^^
File "C:\Users\cub_s\miniconda3\envs\mxfe\Lib\site-packages\adi\ad9081.py", line 653, in adc_frequency
self._rx_coarse_ddc_channel_names[0], "adc_frequency", False
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^
KeyError: 0

```

To debug, I looked at `mxfe._rx_coarse_ddc_channel_names`, which is a dictionary: `{'axi-ad9081-rx-2': ['voltage0_i', 'voltage1_i', 'voltage2_i', 'voltage3_i'], 'axi-ad9081-rx-3': ['voltage0_i', 'voltage1_i', 'voltage2_i', 'voltage3_i'], 'axi-ad9081-rx-0': ['voltage0_i', 'voltage1_i', 'voltage2_i', 'voltage3_i'], 'axi-ad9081-rx-1': ['voltage0_i', 'voltage1_i', 'voltage2_i', 'voltage3_i']}`

So when I try to replicate the adc_frequency property getter with

```

mxfe._get_iio_attr_single(mxfe._rx_coarse_ddc_channel_names['axi-ad9081-rx-3'][0], 'adc_frequency', False)

```

The output returns the expected sample frequencies for every `axi-ad9081-rx-<n>` device:

```

{'axi-ad9081-rx-2': 4000000000, 'axi-ad9081-rx-3': 4000000000, 'axi-ad9081-rx-0': 4000000000, 'axi-ad9081-rx-1': 4000000000}

```

It appears that the ad9081.py code should have a handling case in its readonly properties which handles the multi-chip scenario where `_rx_coarse_ddc_channel_names` and `_tx_caorse_duc_channel_names` are dictionaries containing multiple devices.

Before You Switch


Switching languages will make ADI Explorer unavailable. Resume your session by switching back to English and reopening ADI Explorer.