Friday, January 17, 2025

Re: Stuck in tutorial "Creating Python OOT with gr-modtool"

Hi Robert,

Glad to hear it works for you. I thought about your problem, and
wondered if I should also give you an explanation on how to fix it
permanently. (Until your next GNU Radio update.) It's a simple fix,
so I'll describe the steps needed to fix it.

On ubuntu run ...

dpkg -L gnuradio | grep util_functions.py

(Or if you were on arch like me, run pacman -Ql gnuradio | grep
util_functions.py.)

This will find the file you need to edit to fix the problem. On my
arch system it's

/usr/lib/python3.13/site-packages/gnuradio/modtool/tools/util_functions.py

Edit this file with your favourite text editor, but you must be root
when you edit this file. (So be very careful.) Run ...

sudo <editor_name>
/usr/lib/python3.13/site-packages/gnuradio/modtool/tools/util_functions.py

Go down to line 45 in the file. The line should be ...

modified_last = last_line + '\n'

Change it to ...

modified_last = last_line + newline + '\n'

Save and exit the file.

The next time you create a python module with gr_modtool, it should
work without the need to edit __init__.py.

All the best,

Chris



On Fri, Jan 17, 2025 at 3:20 PM Robert Heerekop
<robertheerekop@gmail.com> wrote:
>
> Chris, thanks a lot for taking the time to answer my question.
> I understand your explanation and
> Yes, your work-a-round works perfectly here and you enabled me to proceed with my next steps.
>
>
> Op wo 15 jan 2025 om 19:19 schreef Chris Gorman <chrisjohgorman@gmail.com>:
>>
>> Hi Robert,
>>
>> There is a bug in gnuradio 3.10.11.0 with the gr_modtool add command.
>> It was rewritten and a small code mistake causes the error you're
>> experiencing. It has been fixed in the main branch, so the next
>> iteration of gnuradio should work as described in the tutorial.
>>
>> When gr_modtool add is run during the tutorial, it is supposed to edit
>> the file ...
>>
>> python/customModule/__init__.py
>>
>> and add the line ...
>>
>> from .addSubSelect import addSubSelect
>>
>> to __init__.py.
>>
>> In 3.10.11.0 it doesn't do this. It creates the space for the python
>> import, but forgets to add the command. So how to get around this.
>> The simplest way is to add the 'from .module_name import module_name'
>> line to __init__.py file in the space created near the end of the
>> file, under the comment # import any pure python here. Then when you
>> go to build the program the build will succeed. I recommend removing
>> the build directory and creating a new one before restarting the build
>> process.
>>
>> So make the changes to __init__.py, then from the gr-customModule directory ...
>>
>> rm -rf build
>> mkdir build && cd build
>> cmake ..
>>
>> If I recall correctly, this shouldn't affect the building of the C++
>> OOT modules.
>>
>> Let me know if you run into any more obstacles with this.
>>
>> Best regards,
>>
>> Chris
>>
>>
>>
>>
>> On Tue, Jan 14, 2025 at 5:31 AM Robert Heerekop
>> <robertheerekop@gmail.com> wrote:
>> >
>> > Thanks for providing all the documentation and tutorials.
>> > They are really usefull for beginners like me.
>> > I'm trying to learn and following the tutorials but I got stuck in "Creating Python OOT with gr-modtool"
>> >
>> > I keep facing the following error message:
>> >
>> > "AttributeError: module 'gnuradio.customModule' has no attribute 'addSubSelect'"
>> >
>> > Question:
>> > I wonder if I make a mistake or is there something wrong with my (freshly installed) system setup (Ubuntu 24.10 GRC3.10.11.0) ?
>> > Thanks in advance for helping me out, guidance, tips or tricks!
>> >
>> > Robert
>> >
>> > This is the complete log:
>> > <<< Welcome to GNU Radio Companion 3.10.11.0 >>>
>> > Block paths:
>> > /home/robert/.local/state/gnuradio
>> > /usr/share/gnuradio/grc/blocks
>> > /usr/local/share/gnuradio/grc/blocks
>> > Loading: "/home/robert/My_First-block.grc"
>> > >>> Done
>> > Loading: "/home/robert/Creating_Python_OOT2.grc"
>> > >>> Done
>> > Loading: "/home/robert/Creating_Python_OOT.grc"
>> > >>> Done
>> > Generating: "/home/robert/default.py"
>> > Executing: /usr/bin/python3 -u /home/robert/default.py
>> > QSocketNotifier: Can only be used with threads started with QThread
>> > Traceback (most recent call last):
>> > File "/home/robert/default.py", line 186, in <module>
>> > main()
>> > File "/home/robert/default.py", line 163, in main
>> > tb = top_block_cls()
>> > ^^^^^^^^^^^^^^^
>> > File "/home/robert/default.py", line 124, in __init__
>> > self.customModule_addSubSelect_0 = customModule.addSubSelect(True)
>> > ^^^^^^^^^^^^^^^^^^^^^^^^^
>> > AttributeError: module 'gnuradio.customModule' has no attribute 'addSubSelect'
>> > >>> Done (return code 1)
>> >
>> >

No comments:

Post a Comment