# Running a GNU Radio Companion generated code

**URL:** <https://www.ruby-forum.com/t/running-a-gnu-radio-companion-generated-code/233530>\
**Category:** GNU Radio\
**Created:** [December 22, 2014, 3:07pm UTC](https://www.ruby-forum.com/t/running-a-gnu-radio-companion-generated-code/233530 "2014-12-22T15:07:17Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![addis\_a](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/c4cdca/32.png) [@addis\_a](https://www.ruby-forum.com/u/addis_a)\
**Post date:** [December 22, 2014, 3:07pm UTC](https://www.ruby-forum.com/t/running-a-gnu-radio-companion-generated-code/233530/1 "2014-12-22T15:07:17Z")

</div>

Hi people,

Sorry for the dummy question, but I didn’t find a simple and direct  
answer searching around for this. (Not need to say also that I am just  
starting with GNU Radio… 🙂

OK I have a code, generated with Gnu radio companion that i want to  
run  
over the command line to follow with GDB. I was under the impression  
that  
if I simply got the code generated in the ~/.grc\_gnuradio, add the

* * *

## def main(): “”" go, go, go “”" top\_block = CLASS top\_block.run() if **name** == “ **main** ”: print ‘Blocked waiting for GDB attach (pid = %d)’ % (os.getpid(),) raw\_input ('Press Enter to continue: ') main()

as stated at  
[https://gnuradio.org/redmine/projects/gnuradio/wiki/TutorialsDebugging](https://gnuradio.org/redmine/projects/gnuradio/wiki/TutorialsDebugging)  
it  
would run to attach GDB. However, i am getting the following error:

* * *

## Traceback (most recent call last): File “ieee802\_15\_4\_phy.py”, line 120, in main() File “ieee802\_15\_4\_phy.py”, line 115, in main top\_block.run() File “/usr/local/lib/python2.7/dist-packages/gnuradio/gr/hier\_block2.py”, line 53, in **getattr** return getattr(self.\_hb, name) AttributeError: ‘hier\_block2\_sptr’ object has no attribute ‘run’

The code runs correctly on Gnuradio companion! No problem whatsoever!  
Which would be the correct way to run the code auto-generated by  
gnuradio  
companion in a stand alone way?

Thanks in advance…

```
       Daniel

```

–  
Best regards…

```
                 Daniel

```

---

<div class="post-metadata">

**Author:** ![dcarneiro](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/e36b37/32.png) [@dcarneiro](https://www.ruby-forum.com/u/dcarneiro)\
**Post date:** [December 22, 2014, 4:26pm UTC](https://www.ruby-forum.com/t/running-a-gnu-radio-companion-generated-code/233530/2 "2014-12-22T16:26:25Z")

</div>

-----BEGIN PGP SIGNED MESSAGE-----  
Hash: SHA1

Hi Daniel,

> OK I have a code, generated with Gnu radio companion that i want  
> to run over the command line to follow with GDB. I was under the  
> impression that if I simply got the code generated in the  
> ~/.grc\_gnuradio, add the  
> This folder usually only contains ‘hier\_blocks’. Executable flowgraph  
> pythons files are usually created in the same folder your .grc file is  
> located in.

> * * *
> 
> |def main(): “”" go, go, go “”" top\_block = CLASS  
> top\_block.run()  
> Did you replace a class by [Class]? According to the Tutorial it  
> expects an object of type gr.top\_block in this line.

> if **name** == “ **main** ”: print ‘Blocked waiting for GDB attach  
> (pid = %d)’ % (os.getpid(),) raw\_input ('Press Enter to continue:  
> ') main() ---- |
> 
> as stated at  
> [https://gnuradio.org/redmine/projects/gnuradio/wiki/TutorialsDebugging](https://gnuradio.org/redmine/projects/gnuradio/wiki/TutorialsDebugging)

it would run to attach GDB. However, i am getting the following error:

> — Traceback (most recent call last): File “ieee802\_15\_4\_phy.py”,  
> line 120, in main() File “ieee802\_15\_4\_phy.py”, line 115,  
> in main top\_block.run() File  
> “/usr/local/lib/python2.7/dist-packages/gnuradio/gr/hier\_block2.py”,

line 53, in **getattr**

> return getattr(self.\_hb, name) AttributeError: ‘hier\_block2\_sptr’  
> object has no attribute ‘run’  
> You try to call run on a ‘hier\_block’. ‘run’ is a member of  
> ‘gr.top\_block’. top\_block contains the scheduler and takes care of  
> correct initialization etc. So it is essentially the flowgraph.

I hope I could give you some hints on what might go wrong.  
-----BEGIN PGP SIGNATURE-----  
Version: GnuPG v1

iQIcBAEBAgAGBQJUmDfBAAoJEO7fmkDsqywMbyoQAKyANgElQ64/Ox81/gwl4TOY  
k3NCr9Stj8CEUG65bYBPo4eDoVT5+xyA7e4HYTYrKMlHT+J2c/iG3ckH9sK7khoO  
1jpFOtQn688tih6uBRhlVgNKWH26B2Hia8U4zIzavDcnt+B3aIRm+MG19Zlg6Ggg  
XLD9KeJ6A5nfgrx+jsylAZGWmp4u6ZFupAVjuTA0vHab/3BOjCuJq2IOveWtSfhg  
gPoHowIvWFwuiR/owJjwHhSGyCmZU1/Iz3yGT0TLdOZ8odlP0z9braIOt2bT3x9V  
OQzgpQFBVuEEdSRJETZkWw0Lr4Jwl/Bko9pHi3tj6MGEcq8U6fP4Ml8dhiG1IE9q  
UZ9XdSNJqDBNylfRxsyBm1oBmUV/gF6mXpD3851lQLdTNvP3R2QD7QrFP9UxRPKj  
c300eaCsRhucDT7ApQmqTguPeL8ds+z6eN8BZ41BtD9etBPjbJDjoV+hfk4z16jF  
gHEjVTAKti2OCiyya19xb67XJoufNz3Fjn09idG7YDAYRG7Qvn3XZCUpLAzO79pg  
axceRvfxgMqws21NgTEDiEndDxjEeJm0mh1jcNUwoM6vlRar/JbEwRxPSCuvfUdx  
GQac8LmkYJsROja1UgADE06fTEJZtLWUEQqBXhKlBlQz6sx1OA42XU8PPDm5c3SY  
AQfwe85pgdf1nQY19UEv  
=wYmS  
-----END PGP SIGNATURE-----

---

<div class="post-metadata">

**Author:** ![dcarneiro](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/e36b37/32.png) [@dcarneiro](https://www.ruby-forum.com/u/dcarneiro)\
**Post date:** [December 23, 2014, 9:12am UTC](https://www.ruby-forum.com/t/running-a-gnu-radio-companion-generated-code/233530/3 "2014-12-23T09:12:45Z")

</div>

Hi Johannes,

THANKS a lot!!! Yes you did really helped, as you said I was trying  
to  
run the wrong .py!!! The example generates two .py on on the main  
directory, as you said, and another on the ~/.grc\_gnuradio. I had seen  
somewhere that gnuradio companion generate code on the ~/.grc\_gnuradio.  
I  
looked, the code was there, I didn’t even think it could have also  
generated other part of the code on the same directory of the .grc. It  
was  
naive, sorry.

I managed to run and connect gdb to it, using the PID. Now things will  
become really interesting, i.e.e me fighting with gdb, and the  
breakpoints,  
to understand the values it passes through the code ;).

Thanks again Johannes, for taking your time to answer! 🙂

Best regards…

```
   Daniel

```

On Mon, Dec 22, 2014 at 4:24 PM, Johannes D. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
wrote:

> This folder usually only contains ‘hier\_blocks’. Executable flowgraph
> 
> > 
> 
> ‘gr.top\_block’. top\_block contains the scheduler and takes care of  
> gPoHowIvWFwuiR/owJjwHhSGyCmZU1/Iz3yGT0TLdOZ8odlP0z9braIOt2bT3x9V
> 
> * * *
> 
> Discuss-gnuradio mailing list  
> [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
> [Discuss-gnuradio Info Page](https://lists.gnu.org/mailman/listinfo/discuss-gnuradio)

–  
Best regards…

```
                 Daniel

```
