GRC Block XML Tags

Hi,

I’m having issues creating a GRC block in an “out-of-tree-project” that
will generate a few lines of python code and update a python variable
(similar to the “variable_function_probe”). In my project, the
<var_make> and tags do not seem to behave as they do in the
“variable_function_probe.” GRC does not appear to be recognizing
<var_make>, and generates "self.my_block_0 = " (as expected).
Are there any limitations preventing me from using the <var_make> tag?
Also, how can I get to not generate "self.my_block_0 = " as it
does for the “variable_function_probe”?

I’ve tried copying ‘variable_function_probe.xml’ and ‘variable.xml’ into
my project and they do not behave as they do when they’re in the
gnuradio directory. Thus, I’m wondering if I need to designate my block
as being a special “Variable” type block. Any help would be greatly
appreciated.

Thanks,
Jordan

On 08/19/2011 02:11 PM, Jordan O. wrote:

as it does for the “variable_function_probe”?

GRC will recognize a block as a variable if it passes the regexp
“_variable_matcher = re.compile(‘^(variable\w*)$’)”, in other words, if
the key starts with the string “variable”

If grc recognizes the block as a variable, it will eval the var_make,
#for $var in $variables
$indent($var.get_var_make())
#end for

I’ve tried copying ‘variable_function_probe.xml’ and ‘variable.xml’
into my project and they do not behave as they do when they’re in the
gnuradio directory. Thus, I’m wondering if I need to designate my
block as being a special “Variable” type block. Any help would be
greatly appreciated.

There is nothing special about the directory an xml file is in. As long
as grc is told to import it. If you actually copied the file and it was
imported twice, grc would print an error

http://gnuradio.org/redmine/projects/gnuradio/wiki/GNURadioCompanion#Installing-the-XML-Block-Definition

-josh

Hi Josh,

Thanks for your help. I don’t encounter the mentioned error, as I
renamed the copied file. Oddly, the two *.xml files are generating
different code. The gnuradio project file (properly) generates:

self.variable_function_probe_0 = variable_function_probe_0 = 0

def _variable_function_probe_0_probe():
while True:
val = self.my_block_0.get_number()
try: self.set_variable_function_probe_0(val)
except AttributeError, e: pass
time.sleep(1.0/(10))
_variable_function_probe_0_thread =
threading.Thread(target=_variable_function_probe_0_probe)
_variable_function_probe_0_thread.daemon = True
_variable_function_probe_0_thread.start()

while the copied definition generates:

self.variable_function_probe_1 = def _variable_function_probe_1_probe():
while True:
val = self.my_block_0.get_number()
try: self.set_variable_function_probe_1(val)
except AttributeError, e: pass
time.sleep(1.0/(10))
_variable_function_probe_1_thread =
threading.Thread(target=_variable_function_probe_1_probe)
_variable_function_probe_1_thread.daemon = True
_variable_function_probe_1_thread.start()

The copied definition is clearly producing incorrect code, but I can’t
seem to figure out why. All I did was copy and rename the *.xml and
added:

my_blocks

Any further help would be greatly appreciated.

Thanks!
Jordan

----- Original Message -----
From: “Josh B.” [email protected]
To: [email protected]
Sent: Saturday, August 20, 2011 9:53:30 PM
Subject: Re: [Discuss-gnuradio] GRC Block XML Tags

On 08/19/2011 02:11 PM, Jordan O. wrote:

as it does for the “variable_function_probe”?

GRC will recognize a block as a variable if it passes the regexp
“_variable_matcher = re.compile(‘^(variable\w*)$’)”, in other words, if
the key starts with the string “variable”

If grc recognizes the block as a variable, it will eval the var_make,
#for $var in $variables
$indent($var.get_var_make())
#end for

I’ve tried copying ‘variable_function_probe.xml’ and ‘variable.xml’
into my project and they do not behave as they do when they’re in the
gnuradio directory. Thus, I’m wondering if I need to designate my
block as being a special “Variable” type block. Any help would be
greatly appreciated.

There is nothing special about the directory an xml file is in. As long
as grc is told to import it. If you actually copied the file and it was
imported twice, grc would print an error

http://gnuradio.org/redmine/projects/gnuradio/wiki/GNURadioCompanion#Installing-the-XML-Block-Definition

-josh


Discuss-gnuradio mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/discuss-gnuradio