Problem with Basic Block in Python

Hi,

I have been writing a Python block and having realised I would need to
have a mismatch between input and output items, I tried to create a new
‘basic block’.

I haven’t even added any code yet, it is:

"import numpy
from gnuradio import gr

class insert_packets_bb(gr.basic_block):
“”"
docstring for block insert_packets_bb
“”"
def init(self, bits_per_symbol=1):
gr.basic_block.init(self,
name=“insert_packets_bb”,
in_sig=[numpy.byte],
out_sig=[numpy.byte])

def forecast(self, noutput_items, ninput_items_required):
    #setup size of input_items[i] for work call
    for i in range(len(ninput_items_required)):
        ninput_items_required[i] = noutput_items

def general_work(self, input_items, output_items):
    output_items[0][:] = input_items[0]
    consume(0, len(input_items[0]))
    #self.consume_each(len(input_items[0]))
    return len(output_items[0])"

And I get the error

"handler caught exception: operands could not be broadcast together with
shapes (512) (595)
Traceback (most recent call last):
File “/usr/local/lib/python2.7/dist-packages/gnuradio/gr/gateway.py”,
line 55, in eval
try: self._callback()
File “/usr/local/lib/python2.7/dist-packages/gnuradio/gr/gateway.py”,
line 144, in __gr_block_handle
) for i in self.__out_indexes],
File
“/usr/local/lib/python2.7/dist-packages/trl/insert_packets_bb.py”, line
46, in general_work
output_items[0][:n_processed] = input_items[0]
ValueError: operands could not be broadcast together with shapes (512)
(595) "

Can you help?

Many thanks.

David

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs