discuss-gnuradio
[Top][All Lists]
Advanced

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

Re: [Discuss-gnuradio] std::cin inside work()


From: Martin Braun
Subject: Re: [Discuss-gnuradio] std::cin inside work()
Date: Wed, 26 Mar 2014 10:43:01 +0100
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Thunderbird/24.4.0

On 03/26/2014 09:17 AM, Activecat wrote:> Dear sir,
> Why below custom block doesn't work..?

Activecat,

first, don't ask open questions like this. How do you know it's not
working? What did you try? Is there an error message? Always provide all
of these infos when asking questions. You will get much better answers.
Make sure you've read
http://gnuradio.org/redmine/projects/gnuradio/wiki/ReportingErrors.

>     int
>     console1_impl::work(
>               int noutput_items,
>               gr_vector_const_void_star &input_items,
>               gr_vector_void_star &output_items)
>     {
>         int *out = (int *) output_items[0];
> 
>         int x;
>         std::cout << "Please key in an integer: ";
>         std::cin >> x;
>         std::cout << "You have given me " << x << std::endl;
> 
>         out[0] = x;
>         return 1;
>     }

A couple of guidelines:
- Don't block in work()! (i.e., don't do this)
- This would probably be better solved by passing info into the stream
with other means, e.g. messages (PDUs), or by writing to a pipe and
reading from there.
- Try adding a std::flush after the first cout.

M



reply via email to

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