I guess I answered my own question:
The forecast function definition has changed in gnuradio 3.10 and it is now defined in such a way that the second argument is only the number of input ports.
So a correct forecast looks like this.
def forecast(self, noutput_items, ninputs):
ninput_items_required = [0] * ninputs
for i in range(ninputs):
ninput_items_required[i] = noutput_items * self.sps
return ninput_items_required
ninput_items_required = [0] * ninputs
for i in range(ninputs):
ninput_items_required[i] = noutput_items * self.sps
return ninput_items_required
Achilleas
On Fri, Nov 1, 2024 at 1:36 PM Achilleas Anastasopoulos <anastas@umich.edu> wrote:
Hi everyone,I am running a simple flowgraph where I use an embedded python block.I have rewritten a forecast function.When I run the code I get:============Executing: /usr/bin/python3 -u top_block.py
thread_body_wrapper :error: ERROR thread[thread-per-block[15]: <block MF sampler and diff decoder(7)>]: TypeError: 'int' object does not support item assignment
At:
/n/higgins/z/anastas/GNURADIO_LAB/Final Draft Lab 8/top_block_epy_block_0.py(39): forecast
/usr/lib/python3/dist-packages/gnuradio/gr/gateway.py(149): handle_forecast===============It thinks that the second argument in forecast is an "int" instead of a list to be populatedby the function.What am I missing? (I am using gnuradio 3.10.1.1 (Python 3.10.12))Also, where can i find the exact Python bindings for each of these functions?thanksAchilleasHere is the relevant code:=====================================class blk(gr.basic_block): # other base classes are basic_block, decim_block, interp_block
"""Embedded Python Block example"""
def __init__(self, datalength=10, sps = 8):
"""arguments to this function show up as parameters in GRC"""
gr.basic_block.__init__(
self,
name='MF sampler and diff decoder',
in_sig=[np.int8, np.complex64],
out_sig=[np.int8]
)
self.datalength = datalength
self.sps = sps
self.set_output_multiple(self.datalength)
self.state=1
def forecast(self, noutput_items, ninput_items_required):ninput_items_required[0] = noutput_items*self.sps
ninput_items_required[1] = noutput_items*self.sps
No comments:
Post a Comment