On Wed, Jan 30, 2013 at 8:26 AM, maiconkist <maiconk...@gmail.com> 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
_______________________________________________
Discuss-gnuradio mailing list
Discuss-gnuradio@gnu.org
https://lists.gnu.org/mailman/listinfo/discuss-gnuradio

Reply via email to