discuss-gnuradio
[Top][All Lists]
Advanced

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

Re: [Discuss-gnuradio] Python block composed of other blocks


From: Tom Rondeau
Subject: Re: [Discuss-gnuradio] Python block composed of other blocks
Date: Wed, 30 Jan 2013 08:29:54 -0500

On Wed, Jan 30, 2013 at 8:26 AM, maiconkist <address@hidden> wrote:
Hi list,

I'm trying to write a block in python.

What I want to do is create a block that passes the signal through some well
know blocks (such as FFT), do its processing and output the signal.

Basically, what I did so far is:

#####
class energy_detector(gr.hier_block2):
        class energy_calculator(gr.sync_block):
                """ Nested class
                """
                def __init__(self, fft_size):
                        gr.sync_block.__init__(
                                        self,
                                        name = "energy_detector",
                                        in_sig =  [np.dtype((np.float32, fft_size))],
                                        out_sig = [np.float32]
                                        )

                        def work(self, input_items, output_items):
                                """ Work here
                                """

                                return len(out)

                """
                Main block
                """
        def __init__(self, fft_size):
                """
                Constructor
                """

                """ Initialize our energy detector block
                        in_sig:  vector of fft_size elements
                        out_sig: one float for each input vector
                """
                gr.hier_block2.__init__(
                                self,
                                name = "energy_detector",
                                in_sig =  [np.dtype((np.float32, fft_size))],
                                out_sig = [np.float32]
                                )

                #
                # Blocks
                #
                self.fft  =  fft. fft_vcc(fft_size, True, [], False)
                self.v2s = gr.vector_to_stream(gr.sizeof_gr_complex, fft_size)
                self.c2f = gr.complex_to_float()
                self.s2v = gr.stream_to_vector(gr.sizeof_float, fft_size)
                self.ec  = self.energy_calculator(fft_size)

                # Flow graph
                self.connect(self, self.fft, self.v2s, self.c2f, self.s2v, self.ec, self)
########

But it does not work. What can I do to achieve the result I need ?

Thanks

Sorry, but "it does not work" is not a very useful way to get us to help you. What about it does not work? What are the error messages, if any, that you are seeing. What steps have you taken after writing the code to test it? What version of GNU Radio are you using?

You need to help us help you.

Tom
 

reply via email to

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