I'm running pyadi-iio and it all works great in Python 3.7.3. Thanks! But I'm having trouble using it with GNURadio184.108.40.206 (which is also running Python 3.7.3).
Here's my Python 3.7.3 output (not in GNUradio 220.127.116.11):
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 sys.path.append('/usr/lib/python2.7/site-packages/') sys.path.append('/lib/python3.7/site-packages/') 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""" gr.sync_block.__init__( self, name='Embedded Python Block', # will show up in GRC in_sig=[np.complex64], out_sig=[np.complex64] ) # 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[:] = input_items * self.example_param return len(output_items)
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…
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 iio.py file to something else then change the imports in pyadi to use that name. For example, if you change iio.py to iiopy.py, then you would have to change every "import iio" to import iiopy.py" in pyadi. This should be only 3 files IIR.
Thanks, that works! It was two files in the adi folder: "rx_tx.py", and "context_manager.py"
In those files, I changed "import iio" to "import iiopy as iio"
I think it's all working now! Thanks!