discuss-gnuradio
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Discuss-gnuradio] Understanding produce, consume, and data streams


From: Bakshi, Arjun
Subject: [Discuss-gnuradio] Understanding produce, consume, and data streams
Date: Thu, 13 Jul 2017 14:01:08 +0000

Hi all,

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.

Thank you,
 

AB

Attachment: input.png
Description: input.png

Attachment: output.png
Description: output.png


reply via email to

[Prev in Thread] Current Thread [Next in Thread]