discuss-gnuradio
[Top][All Lists]
Advanced

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

Re: Out Of Tree module works only partially


From: Federico 'Larroca' La Rocca
Subject: Re: Out Of Tree module works only partially
Date: Thu, 2 Dec 2021 08:18:12 -0300

Hi,
I think you're not taking into account the fact that you're working with vectors. The line
out[i] = in[i];
Should actually be
for(j=0; j<d_blk_size; j++){
out[i*d_blk_size+j] = in[i*d_blk_size + j];
}
and you should "save" blk_size as a block's attribute (I've used it above as d_blk_size, following GNU Radio's typical way of naming attributes).
best
Federico

El jue, 2 dic 2021 a las 7:25, Ralf Gorholt (<ralf.gorholt@gmx.de>) escribió:
Dear all,

I am quite new to GNU Radio and in order to see how GNU Radio blocks
work I would like to create my own block that (for the moment) just
copies complex data from the input to the output. This works as long as
I copy only one number but not when I want to copy packets of numbers
that come from the preceeding block. My block takes one parameter:
blk_size. I would like to insert it in my DVB-T receiver flowgraph to
analyze data (in a later step).

I had a look at the square_ff example and other blocks to see how they
are built but I still don't see what I am doing wrong. It must be a
silly mistake. Perhaps you can help me? Here is the code:

myblock_impl::myblock_impl(int blk_size)
         : gr::block("myblock",
                 gr::io_signature::make(1, 1, blk_size *
sizeof(gr_complex)),
                 gr::io_signature::make(1, 1, blk_size *
sizeof(gr_complex)))
     {
     }

void
     myblock_impl::forecast(int noutput_items, gr_vector_int
&ninput_items_required)
     {
         ninput_items_required[0] = noutput_items;
     }

int
     myblock_impl::general_work(int noutput_items,
                                gr_vector_int &ninput_items,
                                gr_vector_const_void_star &input_items,
                                gr_vector_void_star &output_items)
     {
         const gr_complex *in = (const gr_complex *) input_items[0];
         gr_complex *out = (gr_complex *) output_items[0];

         for (int i = 0; i < noutput_items; i++) {
             out[i] = in[i];
         }

         consume_each(noutput_items);

         return noutput_items;
     }

And the YML file:

id: dl5eu_myblock
label: myblock
category: '[dl5eu]'

templates:
   imports: import dl5eu
   make: dl5eu.myblock(${blk_size})

parameters:
- id: blk_size
   label: Block size
   dtype: int
   default: '1'

inputs:
- label: in
   domain: stream
   dtype: complex
   vlen: ${blk_size}
   optional: '0'

outputs:
- label: out
   domain: stream
   dtype: complex
   vlen: ${blk_size}
   optional: '0'

file_format: 1

Thank you very much for your help!

Kind regards,

Ralf

reply via email to

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