Usrp_basic and gr_block

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.-

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

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.-

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.-

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.

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 :wink:

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

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

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

Eric