discuss-gnuradio
[Top][All Lists]
Advanced

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

Re: [Discuss-gnuradio] Sharing variable


From: Marcus Müller
Subject: Re: [Discuss-gnuradio] Sharing variable
Date: Tue, 26 May 2015 09:15:39 +0200
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.6.0

I'm a bit confused; Luis and Anil, are the two of you working on the same project?
I might have oversimplified when I said it's a python concept: GRC variables are actually quite a handy tool that GRC brings, and GNU Radio contains quite some blocks to make use of it. However,
I would like to do something like the block "variable" or the "probe signal" block that shares a variable will all blocks in GNUradio
There is no such thing as "sharing"; if you change something for example in a QT GUI range slider, and that changes the parametrization of another block, then there's an underlying callback/signalling architecture that will, when the slider changes, call the appropriate setter on the other block.
In fact, this depends on the GUI framework you're using, if I'm not mistaken (i.e. QT offers the callback/slot signalling functionality, and GRC just "connects" QT slots to functions of the top block). The function probe block is a terrible, terrible thing in production: if really just polls the function and consumes CPU for nothing; I like it for debugging purposes, and nothing else, since it's asynchronous, gives no guarantees on actual update rate, is CPU-hungry...

You can get a call-on-event behaviour by giving your block something like the following:

class Luis_class ...
....
    def set_callback(self, callable):
        self._callme = callable
    def work(...):
        ...
        if condition:
            self._callme(newvalue)

and doing something like

myblock = Luis_class(...)
multiply = blocks.multiply_const_ff(1.0);
...
myblock.set_callback(lambda x: multiply.set_k(x))

in your top_block (or wherever you set up your flow graph)

However, I'd strongly discourage you to do that! Seriously, that's ignoring core functionality of GNU Radio, breaking what I consider contracts, will be hard to debug, have terrible multithreading issues, undetermined sample-time timing...

I want to do a block that changes the samp_rate or the center frequency automatically if a condition is true inside my block.
That doesn't sound like you should be using the GRC variable mechanism at all. Just use message passing or stream tags, both of which were invented for exactly this kind of thing.

Best regards,
Marcus


On 05/26/2015 08:52 AM, Luis urday wrote:
Hello Marcus,

In your original reply you said that variable sharing was a python concept, So I wrote my block in python.

I would like to do something like the block "variable" or the "probe signal" block that shares a variable will all blocks in GNUradio

I want to do a block that changes the samp_rate or the center frequency automatically if a condition is true inside my block.

Thanks

Luis

2015-05-26 8:37 GMT+02:00 <address@hidden>:
Hi Marcus,

An example I can think of is let's say there's a channel estimation block followed by an equalizer block. 

Let's say the channel estimator estimates the channel by looking for a training sequence in the incoming data. Once it finds the training sequence it needs to transfer the data into the equalizer which it will through its output port. 

But how is the channel vector sent to the equalizer? Its not going to be a constant stream, it may just be a fixed vector of so and so number of taps. Is there a way to make the equalizer see this channel vector?

Thanks
Anil 

_______________________________________________
Discuss-gnuradio mailing list
address@hidden
https://lists.gnu.org/mailman/listinfo/discuss-gnuradio




_______________________________________________
Discuss-gnuradio mailing list
address@hidden
https://lists.gnu.org/mailman/listinfo/discuss-gnuradio


reply via email to

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