Re: [Discuss-gnuradio] Calling produce()/consume() multiple times
In general you should only call produce() and consume() from within general_work(), and, really, you only need to consume() because produce() can be called with the return value from the function call (or, return WORK_CALLED_PRODUCE to indicate as much). The other block types (e.g. sync), call both produce() and consume() for you already, so you generally should not need to call them directly from your code. In general, you should be able to get away with calling produce() and/or consume() just once. I can think of some scenarios where interim calls might make sense, but those are rare circumstances. Sure please do submit a PR to fix documentation; those are always welcome! - MLD On Sun, Nov 19, 2017, at 02:49 PM, rear1019 wrote: > On Sun, 19 Nov 2017 at 13:16:14 -0500, Michael Dickens wrote: > > You can safely call produce() and consume() multiple times in the same > > work() call: yes! > > I assume this also applies to general_work()? > > > Note that by doing so, if you're using the nitems_written() or > > nitems_read() [e.g., for finding or writing tags], then those values > > will be updated when you call produce() and consume() > > This is an important information missing in the documentation. I will > make a pull request to fix this. > > > Hope this helps! - MLD > > Thank you very much for the fast and detailed answer. ___ Discuss-gnuradio mailing list Discuss-gnuradio@gnu.org https://lists.gnu.org/mailman/listinfo/discuss-gnuradio
Re: [Discuss-gnuradio] Calling produce()/consume() multiple times
On Sun, 19 Nov 2017 at 13:16:14 -0500, Michael Dickens wrote: > You can safely call produce() and consume() multiple times in the same > work() call: yes! I assume this also applies to general_work()? > Note that by doing so, if you're using the nitems_written() or > nitems_read() [e.g., for finding or writing tags], then those values > will be updated when you call produce() and consume() This is an important information missing in the documentation. I will make a pull request to fix this. > Hope this helps! - MLD Thank you very much for the fast and detailed answer. ___ Discuss-gnuradio mailing list Discuss-gnuradio@gnu.org https://lists.gnu.org/mailman/listinfo/discuss-gnuradio
Re: [Discuss-gnuradio] Calling produce()/consume() multiple times
You can safely call produce() and consume() multiple times in the same work() call: yes! Note that by doing so, if you're using the nitems_written() or nitems_read() [e.g., for finding or writing tags], then those values will be updated when you call produce() and consume() -BUT- inside the work() method of your block, you will have to keep track of the I/O data pointers yourself. Hope this helps! - MLD On Sun, Nov 19, 2017, at 11:37 AM, schneider wrote: > On 19/11/17 17:22, rear1019 wrote: > > > I have a question regarding the usage of produce() and consume(): Is it > > safe to call these functions multiple times? Or must the calls be > > merged into a single one? > > consume() in the end calls buffer_reader::update_read_pointer(int > nitems) which again calls index_add() > > Looking at the code I'd say consume(a+b) is equivalent to consume(a) + > consume(b). > > You can find the source for these things in the gnuradio-runtime/ > directory. It is pretty straight forward code. I'll leave produce() as > an exercise for you ;) ___ Discuss-gnuradio mailing list Discuss-gnuradio@gnu.org https://lists.gnu.org/mailman/listinfo/discuss-gnuradio
Re: [Discuss-gnuradio] Calling produce()/consume() multiple times
On 19/11/17 17:22, rear1019 wrote: > I have a question regarding the usage of produce() and consume(): Is it > safe to call these functions multiple times? Or must the calls be > merged into a single one? consume() in the end calls buffer_reader::update_read_pointer(int nitems) which again calls index_add() Looking at the code I'd say consume(a+b) is equivalent to consume(a) + consume(b). You can find the source for these things in the gnuradio-runtime/ directory. It is pretty straight forward code. I'll leave produce() as an exercise for you ;) Regards schneider ___ Discuss-gnuradio mailing list Discuss-gnuradio@gnu.org https://lists.gnu.org/mailman/listinfo/discuss-gnuradio
[Discuss-gnuradio] Calling produce()/consume() multiple times
Hello, I have a question regarding the usage of produce() and consume(): Is it safe to call these functions multiple times? Or must the calls be merged into a single one? Documentation of consume() [1] states that “this function should be called at the end of work() or general_work(), after all processing is finished.” It is not clear whether multiple calls are really forbidden (as in “must be called only once”). Documentation of produce() [2] is even more vague. [1] https://gnuradio.org/doc/doxygen/classgr_1_1block.html#a4719ce3fe1536fb1663bf314f63d [2] https://gnuradio.org/doc/doxygen/classgr_1_1block.html#aa5581727d057bdd8113f8b2a3fc5bd66 ___ Discuss-gnuradio mailing list Discuss-gnuradio@gnu.org https://lists.gnu.org/mailman/listinfo/discuss-gnuradio