Forum: GNU Radio Casting an input value using block() function

Posted by Jose Torres Diaz (Guest)
on 2012-11-05 01:13
(Received via mailing list)
Hi,

My question is related to the work function using block() as provided in
GRExtras. I have a block that input a gr_complex value and output a
gr_complex value. I'm trying to cast the input and output, in order to 
use
them in my work function, what I have is:

 int work(
        const InputItems &input_items,
        const OutputItems &output_items
    ){

      std::complex<float> * in = input_items[0].cast<std::complex<float>
*>();
      std::complex<float> * out = 
output_items[0].cast<std::complex<float>
*>();

     //Processing here

    } //End of work function

I can cast the output without problem, but I cannot do it for the input. 
I
got the following error:


/home/project/grextras/include/gnuradio/block.h: In member function T
gnuradio::Buffer<PtrType>::cast() const [with T = std::complex<float>*,
PtrType = const void*]:
/home/project/grextras/lib/s_asrp_st2up_insertcp.cc:76:77: 
instantiated
from here
/home/project/grextras/include/gnuradio/block.h:43:47: error:
reinterpret_cast from type const void* to type std::complex<float>*
casts away qualifiers

So, I checked into the block.h I have the following:

 typedef std::vector<Buffer<const void *> > InputItems;
 typedef std::vector<Buffer<void *> > OutputItems;

Does it mean that I cannot cast my input_items in my work function?
If the answer is no, how can I use the input_items in my work function?,
because I have to receive a stream of values.

Thanks for your comments,

Regards,

Jose
Posted by Jose Torres Diaz (Guest)
on 2012-11-05 01:48
(Received via mailing list)
Hi,

In order to add more information, I found some information here:
http://publib.boulder.ibm.com/infocenter/lnxpcomp/...

As I understand, the issue is with this line in block. h

typedef std::vector<Buffer<const void *> > InputItems;

Because it is casting using const, rather than:

typedef std::vector<Buffer<void *> > OutputItems;


I'm stuck in this point, because I'm not sure how to use the input_items 
in
my work function, if I'm not able to cast it.

Regards,

Jose


On Mon, Nov 5, 2012 at 10:42 AM, Jose Torres Diaz 
<torresdiaz.jose@gmail.com
Posted by Jose Torres Diaz (Guest)
on 2012-11-06 00:59
(Received via mailing list)
Thanks Bastian,

This fix the issue,

Regards,

Jose
Please log in before posting. Registration is free and takes only a minute.
Existing account (Switch to SSL-encrypted connection)
NEW: Do you have a Google/GoogleMail or Yahoo account? No registration required!
Log in with Google account | Log in with Yahoo account
No account? Register here.