discuss-gnuradio
[Top][All Lists]
Advanced

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

Re: Python tutorials (was: Re: Discuss-gnuradio Digest, Vol 250, Issue 1


From: Marcus Müller
Subject: Re: Python tutorials (was: Re: Discuss-gnuradio Digest, Vol 250, Issue 16)
Date: Mon, 21 Aug 2023 17:54:31 +0200
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.13.0

Hi Tom

On 21.08.23 14:29, tom sutherland wrote:
To answer your question* below, here is an example that may clarify what I am asking.
Example:
I have a 'vector source' of 63 floating point numbers, [1.2,  4.5, 2.3, 8.1 ...], that is outputting one floating point point number. It sends out  one number at each sample time (Can I assume one sample at a time i.e. it only sends 1 32bit number at a time).

No, you can't make such assumptions.

To say that explicitly: Your block does not control with how many input items it is called. It might be called with a block of 10000 input items, and then next time it's being called with 3.

Your work function must make sure that a) it doesn't consume input that is not there, and b) it doesn't produce more input than there is output space.

If I create a python block that takes the input value. I want a "work" function that can calculate the average of the current input value and 5 previous inputs. I have these questions:

Questions:
1) How do I save the previous values in "memory" that are used to generate the new average?
you don't! You just consume at most as many items so that there's 4 items left in your input. Then, these four items will be the first four items when your work is being called again.
    A) Does/can the python module store old previous values? If so how?
That's a basic Python question: using a class member variable. That's the same as the tutorial shows with "self.additionFlag"! You don't need that here, though, due to the underlying "only the input that is consumed disappears" logic of GNU Radio.
    B) How much delay does the the python code cause? i.e If I have the original data and "delay" data and plot them on a time sync are the aligned?
That doesn't make sense to ask; the computational delay doesn't matter. Your block, and any other block, doesn't care about the "time on the clock on the wall". It sees a sequence of samples. If a block has two inputs, and always consumes the same number of items from both inputs (like, for example, the "Add" block does), then it doesn't matter whether one input has more time delay: it will wait until there's input items on both inputs.
    C) Can the output of the python block ever send data back to an another block that was in the signal path before it, i.e. feedback

Not through streams. Only by messages, which, unlike I explain above for the synchronous consumption of values on input ports, are **not** sample-synchronous and will arrive at any specific item number. You probably don't want to deal with that.

Best,
Marcus


reply via email to

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