Performing callback function in GRC

I am trying to build a flow graph in GNU Radio Companion consisting of a
USRP source block and a FFT sink. During runtime, I would like to send a
user settings register to the USRP.
Fortunately, everything is already employed so I only need to build some
sort of variable control. By now, that already works out quite well
using the WX GUI Widgets. A user settings command basically be send to
the USRP using the

void set_user_register(const uint8_t addr, const uint32_t data, size_t
mboard)

function that is part of the USRP source block. When changing the two
variables $user_reg_addr and $user_reg_data, GRC invokes the callback
function that I have defined in the file
gnuradio/gr-uhd/grc/gen_uhd_usrp_blocks.py:

set_user_register($user_reg_addr,
$user_reg_data,uhd.ALL_MBOARDS)

If I now change either $user_reg_addr or $user_reg_data, the callback
function is executed, which is not intended. In turn, I first would like
to execute the callback function after I have modified both variables.

Is there a convenient way to execute the callback function on a button
click or something similar?

On 05/27/2013 07:54 AM, Florian Schlembach wrote:

to execute the callback function after I have modified both variables.

Is there a convenient way to execute the callback function on a button
click or something similar?

Perhaps it would work better to treat the input as one variable. Use a
tuple of numbers instead. You can make a text entry widget w/ converter
type “Evaluate”.

The callback would probably look more like this:
set_user_register(*$user_reg_args)

-josh

Perhaps it would work better to treat the input as one variable. Use a
tuple of numbers instead. You can make a text entry widget w/ converter
type “Evaluate”.

The callback would probably look more like this:
set_user_register(*$user_reg_args)

-josh

Thanks, thats already a good solution. However, I would like to select
the user_reg_addr from another Checkbox Widget (e.g. to select a
specific function). Assuming an evaluated $user_reg_args by
[user_reg_addr,1], it always executes the callback on an update of
user_reg_addr, which is obvious.
Thus, I always need to type in the value and the address into the text
field. Although this would be acceptable, it wouldn’t be so handy.

I am wondering if there is some sort of a conditional execution of the
callback in the python-xml framework?

On 05/28/2013 04:32 AM, Florian Schlembach wrote:

Thanks, thats already a good solution. However, I would like to select
the user_reg_addr from another Checkbox Widget (e.g. to select a
specific function). Assuming an evaluated $user_reg_args by
[user_reg_addr,1], it always executes the callback on an update of
user_reg_addr, which is kinda obvious.
Thus, I always need to type in the value and the address into the text
field by hand. Although this would be acceptable, it is not so handy.

I am wondering if there is some sort of a conditional execution of the
callback in the python-xml framework?

I guess at some point, the builtin GRC functionality isnt smart enough.
I think you could obtain this with some custom python code. For example,
howabout a custom xml for grc that calls
self.my_usrp_source_block_id.set_user_reg, but all caches the address so
it doesnt give extra calls when the user makes gui changes.

You can put pretty much anything inside those tags, so I
am imagining a class with a callback that does the right logic.

-josh

On 05/28/2013 01:15 PM, Josh B. wrote:

-josh

I’ve done that sort of thing, but without the XML.

It would be nice for there to be a mechanism for getting access to a
blocks object handle for “helper” code, for doing things like calling
getter methods so that “helper” python code can do things based on
calls to an objects “parametric” methods (that is, non-data-path).


Marcus L.
Principal Investigator
Shirleys Bay Radio Astronomy Consortium

Perhaps it would work better to treat the input as one variable. Use a
tuple of numbers instead. You can make a text entry widget w/ converter
type “Evaluate”.

The callback would probably look more like this:
set_user_register(*$user_reg_args)

-josh

Thanks, thats already a good solution. However, I would like to select
the user_reg_addr from another Checkbox Widget (e.g. to select a
specific function). Assuming an evaluated $user_reg_args by
[user_reg_addr,1], it always executes the callback on an update of
user_reg_addr, which is kinda obvious.
Thus, I always need to type in the value and the address into the text
field by hand. Although this would be acceptable, it is not so handy.

I am wondering if there is some sort of a conditional execution of the
callback in the python-xml framework?