pyadi-iio operation in GNURadio 3.8

Hello,

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 3.8.1.0):

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[0][:] = input_items[0] * self.example_param
        return len(output_items[0])

  • 0
    •  Analog Employees 
    on Feb 3, 2021 6:54 PM in reply to Wireless

    Just for reference, if a USB context is used it cannot have multiple remote contexts using it. So you must be using all IP contexts or just a single USB context from a single application.

    Also, having multiple applications compete over RX or TX buffer control is not a good idea and will likely break. So if you are using sdr.rx(), do not use a source block in GR. The same goes for TX.

    -Travis

  • Travis. I don't intend operating gnuradio and python scripts at the same time. Sorry for the confusion.

    1. Sticking to python with pyadi, why is this simple script throwing an error? 
  • 0
    •  Analog Employees 
    on Feb 3, 2021 7:28 PM in reply to Wireless

    Can you run this code and provide the output:

    import adi

    sdr = adi.Pluto('ip:pluto.local')

    print(dir(sdr._ctx))

    print(sdr._ctx.name)

    print(dir(sdr._rxadc))

    -Travis

  • Can do:-

    ['__class__', '__del__', '__delattr__', '__dict__', '__dir__', '__doc__', '__eq__', '__format__', '__ge__', '__getattribute__', '__gt__', '__hash__', '__init__', '__init_subclass__', '__le__', '__lt__', '__module__', '__ne__', '__new__', '__reduce__', '__reduce_ex__', '__repr__', '__setattr__', '__sizeof__', '__str__', '__subclasshook__', '__weakref__', '_attrs', '_context', '_description', '_devices', '_name', '_version', '_xml', 'attrs', 'clone', 'description', 'devices', 'find_device', 'name', 'set_timeout', 'version', 'xml']
    network
    ['__class__', '__delattr__', '__dict__', '__dir__', '__doc__', '__eq__', '__format__', '__ge__', '__getattribute__', '__gt__', '__hash__', '__init__', '__init_subclass__', '__le__', '__lt__', '__module__', '__ne__', '__new__', '__reduce__', '__reduce_ex__', '__repr__', '__setattr__', '__sizeof__', '__str__', '__subclasshook__', '__weakref__', '_attrs', '_buffer_attrs', '_channels', '_context', '_debug_attrs', '_device', '_get_trigger', '_id', '_name', '_set_trigger', 'attrs', 'buffer_attrs', 'channels', 'context', 'ctx', 'debug_attrs', 'find_channel', 'id', 'name', 'reg_read', 'reg_write', 'sample_size', 'set_kernel_buffers_count', 'trigger']

  • 0
    •  Analog Employees 
    on Feb 3, 2021 9:20 PM in reply to Wireless

    ok that seems fine.

    Can you add this call too:

    print(dir(rx._rxadc.ctx()))

    -Travis