Embedded python block code:
import numpy as np
import adi
import iio
from gnuradio import gr
class blk(gr.sync_block): # other base classes are basic_block, decim_block, interp_block
def __init__(self, pluto = "ip:192.168.2.1", device = "ad9361-phy", sdr = None, ctx = None, phy = None): # only default arguments here
"""arguments to this function show up as parameters in GRC"""
gr.sync_block.__init__(
self,
name='PlutoReadReg', # will show up in GRC
in_sig=None,
out_sig=[np.short]
)
# if an attribute with the same name as a parameter is found,
# a callback is registered (properties work, too).
self.pluto = pluto
self.device = device
self.sdr = adi.Pluto(pluto)
self.ctx = iio.Context(pluto)
self.phy = self.sdr.ctx.find_device(device)
def work(self, input_items, output_items):
output_items[0][:] = np.short(self.phy.reg_read(0x1A7))
#output_items[0][:] = np.short(self.sdr._get_iio_attr('voltage0', 'rssi', False))
return len(output_items[0])
Kommentit
Tämän blogin kommentit tarkistetaan ennen julkaisua.