Hello: We have successfully used a GUI block to open (or close) a valve by pressing the mouse button. Now we want to open (or close) the valve from a Python block that we are writing after comparing two messages. If the messages are the same, we want to open the valve, otherwise the valve should remain closed.
Below is the xml definition of our Python block as well as the Python code. The problem we are having is that GRC does not allow us to compile the code. The variable beacon_tx is not recognized by the valve block. Can somebody help u with this issue? Thanks. XML FILE *************************************************** <?xml version="1.0"?> <block> <name>compare</name> <key>conditions_compare</key> <category>conditions</category> <import>import conditions</import> <make>conditions.compare()</make> <!-- Make one 'param' node for every Parameter you want settable from the GUI. Sub-nodes: * name * key (makes the value accessible as $keyname, e.g. in the make node) * type --> <!-- Make one 'sink' node per input. Sub-nodes: * name (an identifier for the GUI) * type * vlen * optional (set to 1 for optional inputs) --> <sink> <name>in</name> <type>int</type> </sink> <sink>beacon_tx <name>in</name> <type>int</type> </sink> <!-- Make one 'source' node per output. Sub-nodes: * name (an identifier for the GUI) * type * vlen * optional (set to 1 for optional inputs) --> </block> **************************************************************** PYTHON CODE *************************************************************** import numpy import smbus import time import subprocess beacon_tx from gnuradio import gr class compare(gr.sync_block): """ docstring for block compare """ def __init__(self): gr.sync_block.__init__(self, name="compare",beacon_tx in_sig=[numpy.int,numpy.int],beacon_tx out_sig=None) def work(self, input_items, output_items): in0 = input_items[0] in1 = input_items[1] if numpy.array_equal(in0,in1): self.beacon_tx = True pr.sync_block): """ docstring for block compare """ def __init__(self): gr.sync_block.__init__(self, name="compare", in_sig=[numpy.int,numpy.int], out_sig=None) def work(self, input_items, output_items): in0 = input_items[0] in1 = input_items[1] if numpy.array_equal(in0,in1): self.beacon_tx = True print True else: self.beacon_tx = False print False # <+signal processing here+> return len(self.beacon_tx) -- Posted via http://www.ruby-forum.com/. _______________________________________________ Discuss-gnuradio mailing list Discuss-gnuradio@gnu.org https://lists.gnu.org/mailman/listinfo/discuss-gnuradio