Printing gr_vector_sink_f data

Hello,

I tried to print what data gr_vector_sink_f contains in the following
code:

#!/usr/bin/env python

import howto
from gnuradio import gr, gru
from gnuradio.gr import firdes
from optparse import OptionParser
from gnuradio import blks2

class howto_square (gr.top_block):
def init(self):
gr.top_block.init(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.connect (src, sqr)
self.connect (sqr, dst)
self.result_data = dst.data()

def print_data(self):
print self.result_data

if name == ‘main’:
#parser = OptionParser(option_class=eng_option, usage=“%prog:
[options]”)
#(options, args) = parser.parse_args()
hw = howto_square()
hw.run()
hw.print_data()

But it is always empty.

Any thoughts?

Thanks

View this message in context:
http://old.nabble.com/Printing-gr_vector_sink_f-data-tp29782854p29782854.html
Sent from the GnuRadio mailing list archive at Nabble.com.

On 09/22/2010 12:01 PM, sirjanselot wrote:

from optparse import OptionParser
self.connect (src, sqr)
self.connect (sqr, dst)
self.result_data = dst.data()

right here, you collect the data before running the flow graph

-josh

So what you are saying is when I create an instance of the class, only
the
data and blocks are initialized and glued together, but the object
didn’t
run yet. So source will never get to sink unless I use the run() method
and
then I can print the data.

Let me know if this if I am correct.

I did fix it. I put self.result_data = self.dst.data() in the
print_data
method and made the necessary changes and it worked.

Josh B.-2 wrote:

#!/usr/bin/env python
src_data = (-3, 4, -5.5, 2, 3)
-josh
hw.run()
[email protected]
Discuss-gnuradio Info Page


View this message in context:
http://old.nabble.com/Printing-gr_vector_sink_f-data-tp29782854p29783239.html
Sent from the GnuRadio mailing list archive at Nabble.com.