|
From: | Bakshi, Arjun |
Subject: | Re: [Discuss-gnuradio] Understanding produce, consume, and data streams |
Date: | Thu, 13 Jul 2017 14:58:11 +0000 |
Hi Michael,
Thank you for pointing out the initialization issue for the output stream. Based on that I first set everything in the output stream to 0 (out[:]=0), and then setting the bits I want to the filtered value. I think that fixes my issue and I'm getting the expected output.
Thank you for the quick response!
AB
Apologies for a possible duplicate message.
I've made a few OOT blocks and thought I had a handle on the process but I've found something that I don't understand. I have a general block that "passes" the input to the output stream. However, instead of doing something like: out[:] = in0[:], I did out[:]+=in[:] and found something strange. The full code is as follows:
import numpy as np
from gnuradio import gr
class check(gr.basic_block):
def __init__(self):
gr.basic_block.__init__(self,
name="check",
in_sig=[np.float32],
out_sig=[np.float32])
def forecast(self, noutput_items, ninput_items_required):
for i in range(len(ninput_items_required)):
ninput_items_required[i] = noutput_items
def general_work(self, input_items, output_items):
in0 = input_items[0]
out = output_items[0]
common = min(in0.shape[0], out.shape[0])
out[:common] += in0[:common] #changing += to = fixes/hides the problem
self.consume_each(common)
return common
I thought that by calling consume_each and return with common, I'd be telling the system to move forward by "common" number of input and output indices/addresses. However, in this case the system doesn't and I think reuses the indices of the output stream. I've attached a plot of the input and output.
Whats really going on here?
I've simplified the block here to focus on the issue. My actual application was a filter which selected parts of the input stream and wrote the filtered version on the corresponding parts of the output stream. I found similar issues there also.
[Prev in Thread] | Current Thread | [Next in Thread] |