discuss-gnuradio
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Discuss-gnuradio] usage: vector_sink_X ??


From: Eric Blossom
Subject: Re: [Discuss-gnuradio] usage: vector_sink_X ??
Date: Fri, 21 Jan 2005 15:59:22 -0800
User-agent: Mutt/1.5.6i

On Fri, Jan 21, 2005 at 03:13:08PM -0500, cswiger wrote:
> Gang - How is vector_sink_X used?  I though it would take a vector
> argument and read a datastream into it, like a reverse of vector
> source, however it takes no arguments?
> 
> src_vect = [1, 2, 3, 4]
> src0 = gr.vector_source_f (src_vect, 1) # send 1,2,3,4 forever
> 
> dst0 = gr.vector_sink_f ()    # where does it go? Already have null_sink
> 
> Thanks
> 

You're right.  It is the opposite of the a vector_source.
Use the dst0.data () method to fetch the data.

Outside of grabbing a small amount of data from test cases, it's
probably not particularly useful.  It could have to allocate a
potentially unbounded amount of memory to hold what ever you're
shoving into it.

Here's an example from the test code in "How to Write a Block"

----------------------------------------------------------------

from gnuradio import gr, gr_unittest
import howto

class qa_howto (gr_unittest.TestCase):

    def setUp (self):
        self.fg = gr.flow_graph ()

    def tearDown (self):
        self.fg = None

    def test_001_square_ff (self):
        src_data = (-3, 4, -5.5, 2, 3)
        expected_result = (9, 16, 30.25, 4, 9)
        src = gr.vector_source_f (src_data)
        sqr = howto.square_ff ()
        dst = gr.vector_sink_f ()
        self.fg.connect (src, sqr)
        self.fg.connect (sqr, dst)
        self.fg.run ()
        result_data = dst.data ()
        self.assertFloatTuplesAlmostEqual (expected_result, result_data, 6)

if __name__ == '__main__':
    gr_unittest.main ()




reply via email to

[Prev in Thread] Current Thread [Next in Thread]