discuss-gnuradio
[Top][All Lists]
Advanced

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

Re: [Discuss-gnuradio] Custom Block ID as variable


From: CEL
Subject: Re: [Discuss-gnuradio] Custom Block ID as variable
Date: Wed, 30 Jan 2019 16:26:21 +0000

Hi Erik,

I'm not sure I'd do it the way you do; wouldn't something that simply
only lets through N samples each time after you send a message or call
a function be better? There's nothing "forcing" a block to "forward"
input to an output. On the contrary, you can just consume from the
input without producing on the output of your block.

That makes things quite a bit easier. Write a block that drops all
samples, unless it gets a message (via a message port: see [1]), then
it passes N samples.

How to send that message? Basically, you could write your own block
which has a <callback> attribute that gets called when a value changes,
and use one of the Qt GUI widgets' IDs as variable in there. 

Or you can basically use my variable to message source [2]. I haven't
tested it in ages, and I wrote it as a debugging tool, because I don't
consider it architecturally wise in the long run¹, but it might just be
useful for this very specific use case.

[1] 
https://wiki.gnuradio.org/index.php/Guided_Tutorial_Programming_Topics
[2] 
https://github.com/marcusmueller/gr-msgtools/blob/master/python/variable_to_msg.py
¹ The future is bright and RPC-y; I'd love GRC to migrate from sharing
state between blocks via random Python objects to communicating via
messages in general, but we're clearly not there yet.

On Wed, 2019-01-30 at 17:06 +0100, Erik von Keyserlingk wrote:
> Hi,
> I am developing a program with GRC where I want to take N samples. (The 
> hardware is a HackRF-one). I want to take N samples because I want to measure 
> at certain points with a H-field probe.
> 
> The way I have thought to solve it is to develop a custom block, "sampling 
> counter" (in python), to count the number of samples that have passed and 
> after N samples it changes its value from 1 to 0 and a "selector" block is 
> directing other samples to /dev/null. This works with a "check box" where a 
> user can set/unset and change where the stream goes, either into a file or to 
> /dev/null.  See attached flowgraph.png.
> 
> TLDR:
> Q: How to implement the ID of a custom block so that it can be used as a 
> variable as from a checkbox, slider etc. Both in python an xml, that is what 
> is needed to be added in the .xml file and in the .py file to use the ID as a 
> variable?
> 
> _______________________________________________
> Discuss-gnuradio mailing list
> address@hidden
> https://lists.gnu.org/mailman/listinfo/discuss-gnuradio

Attachment: smime.p7s
Description: S/MIME cryptographic signature


reply via email to

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