Dear Marcus,

Thanks. This solves the problem completely.

In summary, to stop the flowgraph when the source is empty, we need to:
1).  The source block's work() method returns "WORK_DONE"  ( which is -1 )
2).  The sink block's work() method returns "noutput_items"

Additional Questions:
1). In general, shouldn't a sink block's work() method always return 0
instead of "noutput_items"?
     (Sink block doesn't produce any output, isn't the number of output
produced is zero?)

2). In practical cases, under what circumstances we should let the source
block's work() method return 0?
     When it returns 0, the sceduler will still continue to call the source
block's work() method repeatly.

3). Under what scenario we will need to use the stop() method ?
     (In python script we see stop() method quit often, but it seems never
needed in c++ code)

Thanks.
activecat

Note:
This flow graph doesn't involve any message passing at all.



On Sun, Feb 2, 2014 at 1:58 AM, Marcus Müller <mar...@hostalia.de> wrote:

> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
> That run-to-completion method has never failed me; the only
> explanation for that kind of behavior would be if your flowgraph
> employed message passing. Is that the case?
>
> Anyway, to make GNU Radio stop the flowgraph when your source is
> empty, you shouldn't call stop().
> The source's work() method returns the number of produced items. A
> zero there should make the flowgraph realize you're done. If you want
> it explicitely (and right), let the work method return WORK_DONE (==-1).
>
> Greetings,
> Marcus
>
> On 01.02.2014 13:57, Activecat wrote:
> > Dear Josh,
> >
> > Your method below doesn't work on GNU Radio v3.6.5.1 In this case,
> > how to stop the flow graph in v3.6.5.1 ..?
> >
> > Thanks & regards, activecat
> >
> >
> > Subject: Re: [Discuss-gnuradio] Stop GRC flow graph after defined
> > time Date: Wed, 29 Sep 2010 08:33:49 -0700 User-agent: Mozilla/5.0
> > (X11; U; Linux i686; en-US; rv:1.9.1.12) Gecko/20100915
> > Thunderbird/3.0.8 You can use the Misc->Head block to limit the
> > samples. Then set the flow graph options to "run to completion",
> > this option is only available in non-gui mode. See the options
> > blocks.
> >
> > -Josh
> >
> > On 09/29/2010 04:31 AM, Thorsten Laude wrote: Hallo,
> >
> > I'm executing a flow graph in GRC and want to stop this flow graph
> > after some defined time, for example 3 seconds, or after a defined
> > amount of samples.
> >
> > Currently I stop the flow graph by clicking on "Kill the flow
> > graph". How can I implement, that the flow graph is stopped
> > automatically?
> >
> > Thorsten
> >
> > _______________________________________________ Discuss-gnuradio
> > mailing list address@hidden
> > http://lists.gnu.org/mailman/listinfo/discuss-gnuradio
> >
> > http://lists.gnu.org/archive/html/discuss-gnuradio/2010-09/msg00420.html
> >
> >
> >
> >
> > _______________________________________________ Discuss-gnuradio
> > mailing list Discuss-gnuradio@gnu.org
> > https://lists.gnu.org/mailman/listinfo/discuss-gnuradio
> >
> -----BEGIN PGP SIGNATURE-----
> Version: GnuPG v1
> Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/
>
> iQEcBAEBAgAGBQJS7TW6AAoJEAFxB7BbsDrL50kH/3hvueTfOvJP1WG+7zEd263u
> RTaeaSg8Y3Hh6rfsp1G2iq6EEogyR6QfToBeSJjAM8f1dA9fV1yU+iV09L3pwo87
> 0vWst6AP03316umqH+nj2WiKsEfcV5QaZNEkNKYZfYuFj1Xqi1c/h1M9JOfWGSII
> 3JgndjvPR7eALLX8NxJtXQGwnwR0lEZFPiA2eCJAZsRSRBOr8Vzd0thunZrZmcYZ
> QnMK+svY84XmZhYBlkyC1X7heil/zb2r/pG2C57GojTGXgS1pdPy5HqU4f4eB2iK
> o/4DLy8/PN+pBORDryvrTX0AU7HHfJxtkLUlct/jGnCnHGGLWR8eWcVoE10UPgc=
> =M1pB
> -----END PGP SIGNATURE-----
>
> _______________________________________________
> Discuss-gnuradio mailing list
> Discuss-gnuradio@gnu.org
> https://lists.gnu.org/mailman/listinfo/discuss-gnuradio
>
_______________________________________________
Discuss-gnuradio mailing list
Discuss-gnuradio@gnu.org
https://lists.gnu.org/mailman/listinfo/discuss-gnuradio

Reply via email to