discuss-gnuradio
[Top][All Lists]
Advanced

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

[Discuss-gnuradio] gr_sync_block, AttributeError: No constructor defined


From: Jason Bonior
Subject: [Discuss-gnuradio] gr_sync_block, AttributeError: No constructor defined
Date: Wed, 15 Feb 2012 18:22:36 -0600

I am trying to create a block using gr.gr_sync_block which will select
a value from an input vector, pass that value to output, and discard
the rest of the vector:

!/usr/bin/env python

from gnuradio import gr
import numpy

class vector_parser(gr.gr_sync_block):
        def __init__(self):
                gr.gr_sync_block.__init__(
                        self,
                        name = "vector_parser",
                        in_sig = [(numpy.float32, 5)],
                        out_sig = [numpy.float32]
                )

        def work(self, input_items, output_items):
                output_items[0] = input_items[2]
                return len(output_items[0])

class test(gr.top_block):

        def __init__(self):
                gr.top_block.__init__(self)

                self.samp_rate = samp_rate = 32000

                self.gr_vector_source_x_0 = gr.vector_source_f((1, 0, 2, 0, 3), 
True, 5)
                self.gr_null_sink_0 = gr.null_sink(gr.sizeof_float*1)
                self.vector_parser = vector_parser()

                self.connect((self.gr_vector_source_x_0, 0), 
(self.vector_parser, 0))
                self.connect((self.vector_parser, 0), (self.gr_null_sink_0, 0))

        def get_samp_rate(self):
                return self.samp_rate

        def set_samp_rate(self, samp_rate):
                self.samp_rate = samp_rate

if __name__ == '__main__':
        tb = test()
        tb.Run(True)

Each time I try to run this script I receive the following error:

Traceback (most recent call last):
  File "./tone_filter_test.py", line 40, in <module>
    tb = test()
  File "./tone_filter_test.py", line 28, in __init__
    self.vector_parser = vector_parser()
  File "./tone_filter_test.py", line 12, in __init__
    out_sig = [numpy.float32]
  File 
"/usr/local/lib/python2.6/dist-packages/gnuradio/gr/gnuradio_core_runtime.py",
line 2121, in __init__
    def __init__(self, *args, **kwargs): raise AttributeError("No
constructor defined")
AttributeError: No constructor defined

Can anyone tell me what is causing this error?

Thanks!
-- 
Jason



reply via email to

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