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: Activecat
Subject: Re: [Discuss-gnuradio] std::cin inside work()
Date: Wed, 26 Mar 2014 18:56:34 +0800

Thank you very much.

On Wed, Mar 26, 2014 at 5:43 PM, Martin Braun <address@hidden> wrote:
> 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
>
> _______________________________________________
> Discuss-gnuradio mailing list
> address@hidden
> https://lists.gnu.org/mailman/listinfo/discuss-gnuradio



reply via email to

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