pyadi-iio operation in GNURadio 3.8


I'm running pyadi-iio and it all works great in Python 3.7.3.  Thanks!  But I'm having trouble using it with GNURadio3.8.1.0 (which is also running Python 3.7.3). 

Here's my Python 3.7.3 output (not in GNUradio

But if I try the "import adi" in a GNUradio "Python Block", then I get this error "Can't interpret source code: module 'iio' has no attribute 'Device'.  It runs if I comment out the "import adi".  Below is my Python Block code (it's all the standard template except for the import iio and import adi):

Embedded Python Blocks:

Each time this file is saved, GRC will instantiate the first class it finds
to get ports and parameters of your block. The arguments to __init__  will
be the parameters. All of them are required to have default values!

import numpy as np
from gnuradio import gr

import sys

import iio
import adi

class blk(gr.sync_block):  # other base classes are basic_block, decim_block, interp_block
    """Embedded Python Block example - a simple multiply const"""

    def __init__(self, example_param=1.0):  # only default arguments here
        """arguments to this function show up as parameters in GRC"""
            name='Embedded Python Block',   # will show up in GRC
        # if an attribute with the same name as a parameter is found,
        # a callback is registered (properties work, too).
        self.example_param = example_param

    def work(self, input_items, output_items):
        """example: multiply with constant"""
        output_items[0][:] = input_items[0] * self.example_param
        return len(output_items[0])

  • +1
    •  Analog Employees 
    on Aug 12, 2020 9:33 PM

    Yeah, this is a known problem since gr-iio (3.8) and libiio share the same python module name (iio). This won't be a problem once gr-iio is merged upstream but right now its a problem area for out of tree modules.

    The easiest thing to do is to rename the file to something else then change the imports in pyadi to use that name. For example, if you change to, then you would have to change every "import iio" to import" in pyadi. This should be only 3 files IIR.


  • 0
    •  Analog Employees 
    on Aug 12, 2020 11:08 PM in reply to travisfcollins

    Thanks, that works!  It was two files in the adi folder: "", and ""

    In those files, I changed "import iio" to "import iiopy as iio"

    I think it's all working now!  Thanks!

Reply Children
No Data