[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Discuss-gnuradio] Calling C++ method from Python
From: |
Patrick Sathyanathan |
Subject: |
[Discuss-gnuradio] Calling C++ method from Python |
Date: |
Sun, 5 Jul 2015 19:09:25 -0700 |
Hi,
I have worked my way through the Guided Tutorials on gnuradio.org. I have
written OOT blocks in Python and managed to expose some set methods in the
block as callbacks. Now I have written an OOT C++ block sweeper_cpp_f and I
want to expose a couple of setter methods in my block's class as callbacks that
can be invoked from Python. Initially I just defined the methods in my
sweeper_cpp_f_impl.cc file and added the following to the matching XML file:
<callback>set_direction($direction)</callback>
<callback>set_trigger_level($trigger_level)</callback>
This builds fine and I am able to use the block in a GRC flow-graph. But at
runtime when one of the above methods is invoked as a result of GUI input I get
an error message:
File "/home/wpats/ettus/grc/new_sweep_cpp.py", line 141, in
set_variable_chooser_direction
self.tutorial_sweeper_cpp_f_0.set_direction(self.variable_chooser_direction)
AttributeError: 'sweeper_cpp_f_sptr' object has no attribute 'set_direction'
I looked at built in module sig_source_X_impl.h.t and sig_source_X_impl.cc.t
(this is the analog signal source block) in gr-analog as an example for what I
am trying to accomplish. I converted my sources into a similar format and
modified the CMakeLists.txt in the .../gr-tutorial/lib directory to add:
########################################################################
# Invoke macro to generate various sources and headers
########################################################################
include(GrMiscUtils)
GR_EXPAND_X_CC_H(tutorial sweeper_cpp_X_impl f)
This again builds fine after I edit the generate_helper.py generated script to
find an import module. I assumed that the above would do the necessary magic to
generate the wrappers for my callback methods but no such luck. I still get the
attribute error when invoking my C++ method.
What is the right way to do this ? Any help/suggestions/pointers would be
appreciated. I can't be the first one to try to do this seemingly simple task...
Thanks,
--Patrick
- [Discuss-gnuradio] Calling C++ method from Python,
Patrick Sathyanathan <=