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 = 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

_______________________________________________
Discuss-gnuradio mailing list
Discuss-gnuradio@gnu.org
https://lists.gnu.org/mailman/listinfo/discuss-gnuradio

Reply via email to