Post Go back to editing

error using pyadi-iio

Category: Software
Product Number: ad9361

Hi 

I have a board with ad9361 and zynq(petalinux):

when I working with pyadi-iio in python3.10 I got this error:


>>> import adi
>>>
>>> sdr = adi.ad9361(uri="ip:localhost")
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/lib/python3.10/site-packages/adi/rx_tx.py", line 734, in __init__
rx_def.__init__(self, *args, **kwargs)
File "/usr/lib/python3.10/site-packages/adi/rx_tx.py", line 658, in __init__
raise Exception(
Exception: No device found with name cf-ad9361-lpc


--------------------------------------------------------------

while cat /sys/bus/iio/devices/iio\:device*/name give:
ad7291
ad9361-phy
xadc
cf-ad9361-dds-core-lpc

--------------------------------------------------------------

and pip3 list give this output:
Package          Version
----------            --------------
gpg                  1.18.0-unknown
iniparse            0.5
numpy             1.23.3
pip                   22.2.2
pyadi-iio           0.0.18
pylibiio             0.25
setuptools        65.0.2
six                   1.16.0



pyadi-iio issues
[edited by: tomhal at 7:39 PM (GMT -5) on 10 Nov 2024]
  • Your board does not have the RX DMA available.

    cf-ad9361-lpc

    This is the driver name.

    What AD9361 platform is this? Can you provide details (versions) about your PetaLinux build?

    -Travis

  • Hi

    petalinux version: 2023.2

    platform: custom board like: adrv9361z7035

    I have another question: if I connect to board via osc:

    I run this command in board console: 

    $ cat sinewave_0.6.mat | iio_writedev -b 100000 cf-ad9361-dds-core-lpc  voltage0 voltage1

    do this command equal to above image function? and how I can set Scale(dBFS): 0.0 dB (like in above image) via iio command line tool (iio_writedev)

    ( sinewave_0.6.mat is https://github.com/analogdevicesinc/iio-oscilloscope/blob/main/waveforms/sinewave_0.6.mat)

  • platform: custom board like: adrv9361z7035

    You have not configured the RX DMA correctly then in your device tree, or don't use it in your HDL/SW design. If you expect to have it working do you get errors in dmesg initializing it?

    do this command equal to above image function? and how I can set Scale(dBFS): 0.0 dB (like in above image) via iio command line tool (iio_writedev)

    No. iio_writedev simply writes bytes from the input stream directly into buffers. It basically does a memcopy. So you need to provide data in the format your target buffer expects. As a result their is no processing done on the data.

    You can create the files of the required format with the python module pyadi-iio with a special hidden flag (_push_to_file). For AD9361 the code would be:

    import adi
    sdr = adi.ad9361(uri="ip:analog")
    sdr._push_to_file = True
    sdr._output_byte_filename = 'out.bin'
    sdr.tx_enabled_channels = [0]
    # Create  data set as numpy array
    ...
    # Generate file
    sdr.tx(data_array)
    #See out.bin

    -Travis

  • you're right, dmesg is:

    ad9361 spi0.0: ad9361_dig_tune_delay: Tuning RX FAILED!
    cf_axi_adc: probe of 79020000.cf-ad9361-lpc failed with error -5

    but I want only do this like below image:

    how can I do that? or how can I resolve issue mentioned in dmesg?

  • ad9361 spi0.0: ad9361_dig_tune_delay: Tuning RX FAILED!
    cf_axi_adc: probe of 79020000.cf-ad9361-lpc failed with error -5

    These point to an issue with your hardware. Specifically the data interface between the FPGA and AD9361. See here for more info https://wiki.analog.com/resources/eval/user-guides/ad-fmcomms2-ebz/interface_timing_validation

    but I want only do this like below image:

    I explained this in my last post. Did that make sense?

    -Travis

  • Did that make sense?

    No, while that issue(ad9361 spi0.0: ad9361_dig_tune_delay: Tuning RX FAILED!) still exits but I can set dds mode in osc and select DAC Channels (votage0 and voltage1) and load mat file and for Tx everything is OK and now I want do like this in my board your solution doesn't work:

    >>> sdr = adi.ad9361(uri="ip:analog")
    ERROR: Unable to find host: Name or service not known
    Traceback (most recent call last):
    File "/home/analog/.local/lib/python3.10/site-packages/adi/context_manager.py", line 36, in __init__
    self._ctx = iio.Context(self.uri)
    File "/usr/lib/python3.10/site-packages/iio.py", line 1328, in __init__
    self._context = _new_uri(_context.encode("ascii"))
    File "/usr/lib/python3.10/site-packages/iio.py", line 56, in _check_null
    raise OSError(err, _strerror(err))
    FileNotFoundError: [Errno 2] No such file or directory

    During handling of the above exception, another exception occurred:

    Traceback (most recent call last):
    File "<stdin>", line 1, in <module>
    File "/home/analog/.local/lib/python3.10/site-packages/adi/rx_tx.py", line 734, in __init__
    rx_def.__init__(self, *args, **kwargs)
    File "/home/analog/.local/lib/python3.10/site-packages/adi/rx_tx.py", line 653, in __init__
    shared_def.__init__(self, *args, **kwargs)
    File "/home/analog/.local/lib/python3.10/site-packages/adi/rx_tx.py", line 603, in __init__
    context_manager.__init__(self, uri_ctx, self._device_name)
    File "/home/analog/.local/lib/python3.10/site-packages/adi/context_manager.py", line 38, in __init__
    raise Exception("No device found")
    Exception: No device found

    --------------------------------> for solving this issue I do:

    >>> sdr = adi.ad9361(uri="ip:localhost")
    Traceback (most recent call last):
    File "<stdin>", line 1, in <module>
    File "/home/analog/.local/lib/python3.10/site-packages/adi/rx_tx.py", line 734, in __init__
    rx_def.__init__(self, *args, **kwargs)
    File "/home/analog/.local/lib/python3.10/site-packages/adi/rx_tx.py", line 658, in __init__
    raise Exception(
    Exception: No device found with name cf-ad9361-lpc

    --------------------------------> I also do like this:

    >>> adi.ad9361._push_to_file = True
    >>> adi.ad9361._output_byte_filename = "sinwave_0.6.mat"
    >>> adi.ad9361.tx_enabled_channels = [0]
    >>> adi.ad9361.tx(data_array)
    Traceback (most recent call last):
    File "<stdin>", line 1, in <module>
    NameError: name 'data_array' is not defined

    so what is data_array?

  • data_array is a numpy array or list of numpy arrays with the data you want to transmit: https://analogdevicesinc.github.io/pyadi-iio/buffers/index.html#adi.rx_tx.tx_core.tx

    -Travis

  • >>> adi.ad9361._push_to_file = True
    >>> adi.ad9361.tx_enabled_channels = [0]
    >>> fc = 3000000
    >>> N = 1024
    >>> ts = 1 / 30000000.0
    >>> i = np.cos(2 * np.pi * t * fc) * 2 ** 14
    >>> q = np.sin(2 * np.pi * t * fc) * 2 ** 14
    >>> iq = i + 1j * q
    >>> adi.ad9361.tx(iq)
    Traceback (most recent call last):
    File "<stdin>", line 1, in <module>
    File "/home/analog/.local/lib/python3.10/site-packages/adi/rx_tx.py", line 422, in tx
    if not self.__tx_enabled_channels and data_np:
    AttributeError: 'numpy.ndarray' object has no attribute '_tx_core__tx_enabled_channels'

  • You need to create objects from the class definitions like in the code I provided.

    sdr = adi.ad9361(uri=uri)

    -Travis

  • These point to an issue with your hardware. Specifically the data interface between the FPGA and AD9361. See here for more info https://wiki.analog.com/resources/eval/user-guides/ad-fmcomms2-ebz/interface_timing_validation

    as you said: my board has issue in hardware in rx path but with this condition i can connect to that with osc software from ad and can connect and setup cf-ad9361-dds-core-lpc i want do like this (and only this: connect to cf-ad9361-dds-core-lpc) in board in my console in petalinux but:

    >>> sdr = adi.ad9361(uri="ip:127.0.0.1")
    Traceback (most recent call last):
    File "<stdin>", line 1, in <module>
    File "/home/analog/.local/lib/python3.10/site-packages/adi/rx_tx.py", line 734, in __init__
    rx_def.__init__(self, *args, **kwargs)
    File "/home/analog/.local/lib/python3.10/site-packages/adi/rx_tx.py", line 658, in __init__
    raise Exception(
    Exception: No device found with name cf-ad9361-lpc

    cf-ad9361-lpc has issue but how osc can setup cf-ad9361-dds-core-lpc?