discuss-gnuradio
[Top][All Lists]
Advanced

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

Re: [Discuss-gnuradio] Type Selectable GRC Blocks


From: Martin Braun
Subject: Re: [Discuss-gnuradio] Type Selectable GRC Blocks
Date: Tue, 07 Jul 2015 16:44:25 -0700
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.7.0

On 07.07.2015 15:57, Richard Bell wrote:
> This assumes the input/output types are gr_complex, which makes me think
> is causing the problems I'm seeing. I tried to look in other built-in
> blocks to see how they work but it hasn't cleared up my confusion. For
> example, in 'Stream to Tagged Stream', which lets users select the type,
> the lines above are declared as follows:
> 
> const *unsigned char* *in = (const *unsigned char* *) input_items[0];
> *unsigned char* *out = (*unsigned char* *) output_items[0];
> 
> Why would this work if the user selects complex type from GRC?

Because the block itself is agnostic of the data, and 'unsigned char' is
a safe type to declare pointers. You'll notice that we drag an 'item
size' attribute around which is then used for the actual data copying.

> The big question is, how do I properly define the buffer pointer types
> for user selectable type blocks in the C++ code?

There's 2 cases: Either the block doesn't care about the actual type
(e.g. as in stream to tagged stream), then you use the char-pointer +
item size. Or your block *does* care about the type, then you need to
reimplement the block for every type (e.g. the add blocks). We do have a
template mechanism for this, mind you.

M



reply via email to

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