[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Python module: object as a reference (just as "Block ID" in "Function Pr
Python module: object as a reference (just as "Block ID" in "Function Probe" block)
Fri, 21 Feb 2020 00:24:13 +0100
I am using the "Embedded Python Block" to create a simple controller that
controls my USRP Source/Sink blocks.
These blocks support a message interface but unfortunately this is pretty
useless except for the simplest applications (I need to control advanced tuning
with timed commands, GPIO ports etc).
Hence I need to call the methods of these objects directly but I need a
reference to them inside my custom block.
Within my python block I cannot reference the parent blocks, hence I need to
pass a reference to these two objects via the constructor (and parameters).
Basically I want to do the same as parameter "Block ID" from the block
"Function Probe" does.
What is the best way to implement this?
class blk(gr.sync_block): # other base classes are basic_block, decim_block,
def __init__(self, sample_rate=1.0, usrp_source_block=''): # only default
"""arguments to this function show up as parameters in GRC"""
name='Controller', # will show up in GRC
# if an attribute with the same name as a parameter is found,
# a callback is registered (properties work, too).
self.sample_rate = sample_rate
self.usrp_source_block = usrp_source_block
# here I want to execute for example
When I then create an USRP Sink object with ID uhd_usrp_sink_0 and enter as
parameter I get the error:
Param - Usrp Source Block(usrp_source_block):
Value "uhd_usrp_sink_0" cannot be evaluated:
name 'uhd_usrp_sink_0' is not defined
- Python module: object as a reference (just as "Block ID" in "Function Probe" block),
Lukas Haase <=