|
From: | Verónica Toro Betancur |
Subject: | Re: Python embedded block stops working after consume() |
Date: | Thu, 28 Oct 2021 13:50:26 +0300 |
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 <vetorobe@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 -2Although, 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ónicaOn Thu, Oct 28, 2021 at 8:47 AM Verónica Toro Betancur <vetorobe@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
[Prev in Thread] | Current Thread | [Next in Thread] |