Yeah, I know it's strange and I shouldn't need to use any of those. But, the -2 in return is because that's the value of WORK_CALLED_PRODUCE which doesn't exist in Python, so that's why we put the -2 directly. And so this doesn't terminate flowgraph. At least that's what I understand.
On Thu, Oct 28, 2021 at 1:41 PM Jeff Long <willco...@gmail.com> wrote: > You should not call produce() or consume() in a sync block, actually. The > framework does those for you, using the return value from work(). If you > return -2, you're manually terminating the flowgraph from this block? Glad > it's working for you, in any case. > > On Thu, Oct 28, 2021 at 6:24 AM Verónica Toro Betancur <vetor...@gmail.com> > wrote: > >> Nevermind now, I figured it out! >> >> It turns out that using produce() instead of consume() does the trick, >> but I couldn't say why. So, the last three lines should be >> >> output_items[0][:] = input_items[0] >> self.produce(0, len(output_items[0])) >> return -2 >> >> Although, in the following block, I just returned len(output_items[0]) >> without using consume() or produce() and it works fine. So, apparently, my >> code is a bit random, but I'm happy it works now. :) >> >> Thanks for your help, Jeff! >> >> >> Best regards, >> Verónica >> >> On Thu, Oct 28, 2021 at 8:47 AM Verónica Toro Betancur < >> vetor...@gmail.com> wrote: >> >>> I see but no, I'm not processing a finite number of samples. I'm >>> generating a message periodically with a Message Strobe, then the message >>> is encoded and modulated as a WiFi signal using the modules in: >>> https://github.com/bastibl/gr-ieee802-11. Now, I'm trying to detect the >>> signals myself and then decode them with the blocks from the same >>> gr-ieee802-11 repository. The block I'm implementing in python looks like >>> this: >>> >>> class short_sync_blk(gr.sync_block): >>> def __init__(self): >>> gr.sync_block.__init__(self,name='Custom short preamble >>> detection', in_sig=[np.complex64], out_sig=[np.complex64]) >>> <+define some variables+> >>> >>> def work(self, input_items, output_items): >>> print(input_items[0]) # Here is where I see that, after one >>> iteration, input_items[0] is filled with zeros >>> <+some processing+> >>> <+insert a tag+> >>> output_items[0][:] = input_items[0] >>> self.consume_each(len(output_items[0])) >>> return len(output_items[0]) >>> >>> Is this enough? Or should I put all the actual code in here with all the >>> connected blocks? >>> >>> Thanks in advance. >>> >>> >>> Best regards, >>> Verónica >>> >>