discuss-gnuradio
[Top][All Lists]
Advanced

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

Re: [Discuss-gnuradio] Work function template for vector I/O


From: Martin Braun
Subject: Re: [Discuss-gnuradio] Work function template for vector I/O
Date: Tue, 11 Feb 2014 10:46:32 -0800
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Thunderbird/24.2.0

On 11.02.2014 09:57, Randall Poe wrote:
I'm sure this must exist somewhere but I've been unable to find it among
the tutorials and mailing lists.
I've got the basics of writing blocks down. I've successfully created a
C++ block with float input and output streams, and gotten it to load
into GRC.
Now I'd like to do something more interesting with vector I/O, probably
complex vectors. It's my understanding that each input or output item
can be an entire vector<float>, correct? and that consuming or
generating one item means consuming or generating that entire array?
Does anyone have a source example? I'm uncertain about things like what
the cast of input_items and output_items should look like. Also the
memory allocation. Do I create a new vector for each output item and
trust that GRC will destroy it somewhere downstream? I'm talking about
vectors that may potentially contain megabytes, so I want to make sure I
do the memory management right.

Randall,

a couple of things:

* There's tons of examples, check out any block with a _vcc suffix. Short answer, you just set the item size (e.g. sizeof(gr_complex) * vlen).
* Cast: const gr_complex *input_items = (const gr_complex *) input_items[0];
* This will *not* generate a std::vector, but a regular C-style array. You don't need to destroy it, the buffers get allocated automatically. * You don't have unlimited space in buffers between blocks. If you're streaming massive amounts, you might want to use tags to declare item boundaries.

MB



reply via email to

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