Error in Python file generated by GnuRadio Companion

Hello,

I have created My QPSK Demodulator following tutorial 4:
https://gnuradio.org/redmine/projects/gnuradio/wiki/Guided_Tutorial_GNU_Radio_in_C++

My source files (C++, XML) look exactly like those in the repository and
the build and installation produced the same output as shown in the
tutorial.

I have created a .gnuradio/config.conf file in my home directory so that
I could add the XML installation file to GRC search path:

[grc]
local_blocks_path=/usr/local/share/gnuradio/grc/blocks

My QPSK Demodulator appears correctly in GRC and I could connect the
block in the attached GRC application (source and screenshot attached).

However, when I click on the “Generate the flow graph” button, the
Python file generated has the following lines:

self.tutorial_my_qpsk_demod_cb_0 = -------->
cannot find ‘Gray_code’: tutorial.my_qpsk_demod_cb($Gray_code)
<--------

And if I execute the graph, the following error happens, unsurprisingly:

Executing: “/home/dpi/projects/seethroughwalls/CHa/mpsk_stage6.py”

File “/home/dpi/projects/seethroughwalls/CHa/mpsk_stage6.py”, line
197
self.tutorial_my_qpsk_demod_cb_0 = -------->
^
SyntaxError: invalid syntax

My configuration:

Ubuntu 14.04
GNU Radio Companion 3.7.2.1
GNU Radio 3.7.2.1

All installed via Ubuntu packages.

I am sure this is a simple thing, but unfortunately my investigations so
far have been unsuccessful. Any help would be appreciated.

Best regards,
Damien


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

Dear Sebastian,

Thank you very much for your help.

I checked my XML block file and it uses gray_code with lower ‘g’, this
is why I don’t understand why GRC generates a Python code with upper G.
Moreover, the Pythong code generated by GRC calls the Demodulator, hence
it should pass the parameter value like it does for the other blocks,
not its name or am I wrong ?

Here is my block XML:

<?xml version="1.0"?> My QPSK Demodulator tutorial_my_qpsk_demod_cb Tutorial import tutorial tutorial.my_qpsk_demod_cb($Gray_code) Gray Code gray_code ...

Thanks again,
Damien

On 01/09/2015 03:36 PM, PIGUET Damien wrote:

 <name>Gray Code</name>
 <key>gray_code</key>


GRC uses whatever you put in to create the python code. Yours
still reads

tutorial.my_qpsk_demod_cb($Gray_code)

instead of

tutorial.my_qpsk_demod_cb($gray_code)

which is why GRC can’t replace the template variable “$Gray_code”. It
is undefined.

Oh sorry I was looking at the wrong line. Now it works, thanks!

Damien

Was this code you wrote, or is it from gr-tutorial?

M

Hi Martin, and thank you for your help.

The answer is gr-tutorial.

Thanks to the correction suggested by Sebastian I can go beyond this
step, but then GRC fails to find the library compiled and installed
following the instructions in the tutorial:

File
“/usr/local/lib/python2.7/dist-packages/tutorial/tutorial_swig.py”, line
24, in swig_import_helper
_mod = imp.load_module(’_tutorial_swig’, fp, pathname, description)
ImportError: libgnuradio-tutorial.so: cannot open shared object file: No
such file or directory

Note: the installer (sudo make install) put the library in:
/usr/local/lib/

If you have a hint, thanks for letting me know.

Best regards,
Damien