|
From: | Marcus Müller |
Subject: | Re: [Discuss-gnuradio] testing block written in block |
Date: | Wed, 18 Jun 2014 11:30:12 +0200 |
User-agent: | Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Thunderbird/24.5.0 |
Hi Sreena, a few quick remarks: - where does in_arg come from? - in0 should be seen as a vector of vectors. It's often useful to "print in0.shape", if in0 is a numpy array - potential mistake: just returning len(input_items[0]). Be *very* aware of what the return value of a work call should be (i.e. the number of items produced). I think you meant to calculate but one sum, is that right? Greetings, Marcus On 18.06.2014 10:57, sreena p h wrote:
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 = "" 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) |
[Prev in Thread] | Current Thread | [Next in Thread] |