# Usrp\_basic and gr\_block

**URL:** <https://www.ruby-forum.com/t/usrp-basic-and-gr-block/63706>\
**Category:** GNU Radio\
**Created:** [June 17, 2006, 10:25pm UTC](https://www.ruby-forum.com/t/usrp-basic-and-gr-block/63706 "2006-06-17T22:25:10Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![mifi](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/7993a0/32.png) [@mifi](https://www.ruby-forum.com/u/mifi)\
**Post date:** [June 17, 2006, 10:25pm UTC](https://www.ruby-forum.com/t/usrp-basic-and-gr-block/63706/1 "2006-06-17T22:25:10Z")

</div>

I’m trying to use a function in the usrp\_basic class, but there’s no  
SWIG .i  
script for it. While looking at the tutorials, I read that all  
processing  
blocks need to derive from the class gr\_block. However, this isn’t the  
case  
for usrp\_basic. I guess this makes sense, as usrp\_basic isn’t really a  
processing block - the function I’m wanting to use just reads input from  
the  
RSSI circuit. Should I be consulting the Dawei Shen’s processing block  
tutorial at all then? the usrp\_basic class isn’t even under the gr  
package.

-Michael F.-

---

<div class="post-metadata">

**Author:** ![mifi](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/7993a0/32.png) [@mifi](https://www.ruby-forum.com/u/mifi)\
**Post date:** [June 18, 2006, 7:02pm UTC](https://www.ruby-forum.com/t/usrp-basic-and-gr-block/63706/2 "2006-06-18T19:02:22Z")

</div>

On Sat, Jun 17, 2006 at 03:23:53PM -0500, Michael F. wrote:

> I’m trying to use a function in the usrp\_basic class, but there’s no SWIG .i  
> script for it. While looking at the tutorials, I read that all processing  
> blocks need to derive from the class gr\_block. However, this isn’t the case  
> for usrp\_basic. I guess this makes sense, as usrp\_basic isn’t really a  
> processing block - the function I’m wanting to use just reads input from the  
> RSSI circuit. Should I be consulting the Dawei Shen’s processing block  
> tutorial at all then? the usrp\_basic class isn’t even under the gr package.

Hi Michael,

Pretty much all of usrp\_basic.h as well as usrp\_standard.h is wrapped  
by gr-usrp/src/usrp1.i. The usrp specific classes that derive from  
gr\_block are usrp1\_source\_base.h and usrp1\_sink\_base.h.

I recall Matt mentioning that to read the RSSI you use one of the aux  
adcs. These are already wrapped.

See usrp1.i:

int read\_aux\_adc (int which\_dboard, int which\_adc);

Eric

---

<div class="post-metadata">

**Author:** ![mifi](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/7993a0/32.png) [@mifi](https://www.ruby-forum.com/u/mifi)\
**Post date:** [June 18, 2006, 7:33pm UTC](https://www.ruby-forum.com/t/usrp-basic-and-gr-block/63706/3 "2006-06-18T19:33:32Z")

</div>

I apologize for not responding earlier - I found the usrp1.i file not  
long  
after I made my post. I was confused at first because in my search for  
the  
read\_aux\_adc() function, I had originally found it in usrp\_basic.{cc, h}

-Michael F.-

---

<div class="post-metadata">

**Author:** ![mifi](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/7993a0/32.png) [@mifi](https://www.ruby-forum.com/u/mifi)\
**Post date:** [June 18, 2006, 9:20pm UTC](https://www.ruby-forum.com/t/usrp-basic-and-gr-block/63706/4 "2006-06-18T21:20:57Z")

</div>

after setting the PYTHONPATH variable to point to  
~/gr-build/gr-usrp/src/  
(where usrp1.py is located), I ran my python test script, and got the  
following error:

$ python test\_sender.py Traceback (most recent call last):  
File “test\_sender.py”, line 22, in ?  
import usrp1  
File “/home/mford1/gr-build/gr-usrp/src/usrp1.py”, line 4, in ?  
import \_usrp1  
ImportError: No module named \_usrp1

After searching my computer, I find that there is in fact no module  
called  
\_usrp1, only a libtool file in the ~/gr-build/gr-usrp/src/ directory  
called  
usrp1.la. I’m guessing there might be something wrong with my  
installation.

-Michael F.-

---

<div class="post-metadata">

**Author:** ![mifi](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/7993a0/32.png) [@mifi](https://www.ruby-forum.com/u/mifi)\
**Post date:** [June 19, 2006, 1:35am UTC](https://www.ruby-forum.com/t/usrp-basic-and-gr-block/63706/5 "2006-06-19T01:35:52Z")

</div>

This is all well for functions found in usrp.py, but even though I  
import  
usrp.py, and usrp.py successfully imports usrp1.py, I’m unable to  
successfully call functions from usrp1.py (i.e. read\_aux\_adc()). Calling  
the  
function with either a usrp- or usrp1- prefix gives me an error of the  
module not having a read\_aux\_adc attribute.

---

<div class="post-metadata">

**Author:** ![mifi](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/7993a0/32.png) [@mifi](https://www.ruby-forum.com/u/mifi)\
**Post date:** [June 18, 2006, 11:52pm UTC](https://www.ruby-forum.com/t/usrp-basic-and-gr-block/63706/6 "2006-06-18T23:52:35Z")

</div>

On Sun, Jun 18, 2006 at 02:18:01PM -0500, Michael F. wrote:

> ImportError: No module named \_usrp1
> 
> After searching my computer, I find that there is in fact no module called  
> \_usrp1, only a libtool file in the ~/gr-build/gr-usrp/src/ directory called  
> usrp1.la. I’m guessing there might be something wrong with my installation.
> 
> -Michael F.-

Don’t do it that way 😉

Just install gr-usrp as usual, then write your test script someplace  
else. To import the usrp code, do like all of the examples:

from gnuradio import usrp

u = usrp.source\_c(…)

You may want to take a look at the code in gnuradio-examples/python/usrp

Eric

---

<div class="post-metadata">

**Author:** ![mifi](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/7993a0/32.png) [@mifi](https://www.ruby-forum.com/u/mifi)\
**Post date:** [June 19, 2006, 3:25am UTC](https://www.ruby-forum.com/t/usrp-basic-and-gr-block/63706/7 "2006-06-19T03:25:41Z")

</div>

On Sun, Jun 18, 2006 at 06:34:19PM -0500, Michael F. wrote:

> This is all well for functions found in usrp.py, but even though I import  
> usrp.py, and usrp.py successfully imports usrp1.py, I’m unable to  
> successfully call functions from usrp1.py (i.e. read\_aux\_adc()). Calling the  
> function with either a usrp- or usrp1- prefix gives me an error of the  
> module not having a read\_aux\_adc attribute.

After creating an instance of the usrp object use the object,  
not the class. You want to invoke a method of the object.

```
[eb@cyan tmp]$ python
Python 2.4.1 (#1, Sep 13 2005, 00:39:20)
[GCC 4.0.2 20050901 (prerelease) (SUSE Linux)] on linux2
Type "help", "copyright", "credits" or "license" for more 

```

information.  
\>\>\> from gnuradio import usrp  
\>\>\> u = usrp.source\_c(0, 64)  
\>\>\> v = u.read\_aux\_adc(0, 0)  
\>\>\> print v  
224

You might want to spend a bit of time with the python tutorial at

> **[Welcome to Python.org](https://www.python.org/doc/)**
>
> The official home of the Python Programming Language

I prefer the pdf formatted version available here:  
[http://docs.python.org/download.html](http://docs.python.org/download.html)

Eric
