discuss-gnuradio
[Top][All Lists]
Advanced

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

Re: [Discuss-gnuradio] Blocks handling vectors


From: Martin Braun
Subject: Re: [Discuss-gnuradio] Blocks handling vectors
Date: Mon, 03 Aug 2015 09:37:22 -0700
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.8.0

On 03.08.2015 00:18, Galiero Casay Gabriele wrote:
> - The io signatures would be defined like this:
>         gr::io_signature::make(1,  1,  pkt_len*sizeof(float)),
>         gr::io_signature::make(1, 1, sizeof(float) * (sync_word_len +
> pkt_len)))
>  To clarify a bit what I want is to add a predefined preamble of length
> sync_word, which I define in the constructor and cannot be accessible.
>  Now, one of my questions was, is the most suitable block that I have to
> use a general one? or is it possible to use a decimator?\

In this case, you can use a sync block, because you have 1 output items
per 1 input item. However, you're packaging entire packets as vectors --
not sure if that's your intention.

If you want to handle this on an item-by-item basis, you need a general
block, because the relative rate is (sync_len+pkt_len)/pkt_len, and
that's (most likely) non-integer. This approach can be convenient if
your packets are very large, or if your packet length (with or without
sync word) is an annoying size and doesn't fit into page boundaries.

>   int
>     add_sync_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 float *in = (const float *) input_items[0];
>         float *out = (float *) output_items[0];
> 
>         // Do <+signal processing+>
>         for (int i = 0; i < noutput_items; i++) {
>             std::memcpy(&out[0], &d_sync_word[0], sizeof(float) *
> d_sync_word_len);
>             std::memcpy(&out[d_sync_word_len], &in[0], sizeof(float) *
> d_pkt_len);
>         }
>         // Tell runtime system how many input items we consumed on
>         // each input stream.
>         consume_each (d_pkt_len);

Nope, you've consumed noutput_items.

>         // Tell runtime system how many output items we produced.
>         return noutput_items;
>     }
> 
>  But when I try to connect the blocks to test them with python it gives
> me error:
>   File "<stdin>", line 1, in <module>
>   File
> "/usr/local/lib/python2.7/dist-packages/gnuradio/gr/hier_block2.py",
> line 48, in wrapped
>     raise ValueError("Unable to coerce endpoint")
> ValueError: Unable to coerce endpoint


Well, we can't see what you're connecting this too, but it probably
doesn't have pkt_len or pkt_len+sync_word vector lengths.

M



reply via email to

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