Hi
I'm new to GNU radio and is trying to develop my own block. I want to develop a
block that intake a vector and out put sum of the vector elements. I used the
out of tree module and followed tutorial using python code. How should be the
arguments of blocks.vector_source_f to be given if i am inputting vector stream
of four integers is used. the python code and test file is given below.
Code:
def __init__(self, in_arg):
gr.sync_block.__init__(self,
name="sream_ff",
in_sig=[(numpy.float32, 4)],
out_sig=[numpy.float32])
def work(self, input_items, output_items):
in0 = input_items[0]
out = output_items[0]
# <+signal processing here+>
out[:] = sum(in0)*in_arg
return len(output_items[0])
Test code:
def test_001_t (self):
src_data = (([1,1,1,1],4), ([1,2,3,4],4))
expected_result = (8, 20)
src = blocks.vector_source_f(src_data)
fxn = sream_ff(2)
snk = blocks.vector_sink_f()
# set up fg
self.tb.connect(src, fxn)
self.tb.connect(fxn, snk)
self.tb.run ()
# check data
result_data = snk.data ()
self.assertFloatTuplesAlmostEqual (expected_result, result_data, 6)
_______________________________________________
Discuss-gnuradio mailing list
Discuss-gnuradio@gnu.org
https://lists.gnu.org/mailman/listinfo/discuss-gnuradio