Strange inheritance in gnuradio.. or something wrong with SWIG

Hello,

I don’t understand one think… Class usrp_sink_c inherit from usrp_base
a
public method read_aux_adc(int,int).

int usrp_base::read_aux_adc (int which_dboard, int which_adc)
{
 return d_usrp_basic->read_aux_adc (which_dboard, which_adc);}

According to my OO knowledge objects of usrp_sinc_c should have this
method.
But it doesn’t.

I am trying to call method on usrp_sink_c object in python.

        self.u = usrp_options.create_usrp_sink(options)
        dac_rate = self.u.dac_rate()
        rssi = self.u.read_aux_adc(0,0)

But it doesn’t work.
Can someone explain me what strange things are happening here?
Thanks in advance,
Tom

View this message in context:
http://www.nabble.com/strange-inheritance-in-gnuradio…-or-something-wrong-with-SWIG…-tp25393083p25393083.html
Sent from the GnuRadio mailing list archive at Nabble.com.

OK, there is not problem with inheritance in C++.

There is something strange in SWIG interface or python.
I am able to create objects and call method read_aux_adc() in C++.
but whenever I create second object in python I got errors:

./streamer_rx_tx_t.py -f 2.4G
usrp_open_interface:usb_claim_interface: failed interface 2
could not claim interface 2: Device or resource busy
usrp_basic_rx: can’t open rx interface
Traceback (most recent call last):
File “./streamer_rx_tx_t.py”, line 251, in
main()
File “./streamer_rx_tx_t.py”, line 203, in main
tb_rx = my_top_block_rx(demods[options.modulation], rx_callback,
test123, options)
File “./streamer_rx_tx_t.py”, line 71, in init
self.rxpath = receive_path(demodulator, rx_callback, test123,
options)
File “/home/tom/projects/testy/2threads_1/receive_path.py”, line 62,
in
init
self._setup_usrp_source(options)
File “/home/tom/projects/testy/2threads_1/receive_path.py”, line 123,
in
_setup_usrp_source
self.u = usrp_options.create_usrp_source(options)
File “/home/tom/projects/testy/2threads_1/usrp_options.py”, line 70,
in
create_usrp_source
fusb_nblocks=options.fusb_nblocks,
File “/home/tom/projects/testy/2threads_1/generic_usrp.py”, line 98,
in
init
except: self._setup_usrp_source()
File “/home/tom/projects/testy/2threads_1/generic_usrp.py”, line 117,
in
_setup_usrp_source
fusb_nblocks=self._fusb_nblocks)
File “/usr/lib/python2.6/dist-packages/gnuradio/usrp/usrp_swig.py”,
line
1646, in source_c
return _usrp_swig.source_c(*args, **kwargs)
RuntimeError: can’t open usrp
Exception AttributeError: “‘gr_hier_block2_sptr’ object has no attribute
‘_type’” in <bound method generic_usrp_source_c.del of
<generic_usrp.generic_usrp_source_c object at 0xa7336cc>> ignored

u = usrp.source_c()
u.read_aux_adc(0,0)

Any ideas what is wrong with SWIG interface?

Concerning inheritance in C++ I think that SWIG doesn’t know anything
about
inheritance mechanism in C++. It only exports stuff that is represented
by
given class. Correct me if I am wrong.

Tom


View this message in context:
http://www.nabble.com/strange-inheritance-in-gnuradio…-or-something-wrong-with-SWIG…-tp25393083p25423236.html
Sent from the GnuRadio mailing list archive at Nabble.com.

On Fri, Sep 11, 2009 at 02:14:16AM -0700, tom_unaff wrote:

[/code]
[/code]

But it doesn’t work.
Can someone explain me what strange things are happening here?
Thanks in advance,
Tom

Works for me:

[[email protected] gnuradio-eb]$ python
Python 2.5.1 (r251:54863, Jun 15 2008, 18:24:56)
[GCC 4.3.0 20080428 (Red Hat 4.3.0-8)] on linux2
Type "help", "copyright", "credits" or "license" for more 

information.
>>> from gnuradio import usrp
>>> u=usrp.sink_c(0)
>>> u.read_aux_adc(0, 0)
112
>>>

Eric

On Mon, Sep 14, 2009 at 02:35:10PM -0700, tom_unaff wrote:

usrp_basic_tx: can’t open tx interface
[/LOG]

You can have a maximum of a single usrp_source and a single usrp_sink
open at
the same time. That is, one of each. The log message indicates that
you were attempting to open a second usrp_sink

Eric

Eric, I am also able to run this 2 lines of code… but problem occures
when
this object is created in one of the benchmark examples (tx or rx).

Those benchmarks also create usrp objects.
The error I get when second time such object is created is following:

[LOG]
usrp_open_interface:usb_claim_interface: failed interface 1
could not claim interface 1: Device or resource busy
usrp_basic_tx: can’t open tx interface
[/LOG]

Although I got RSSI value, the whole TX or RX path fails…

I see solution for this in C++…

I have already tried to display RSSI in C++ and it is working with
benchmark. But now I want to call function defined in C++ from python.

I find wired thing… I add function definition in usrp_sink_c.cc and
declarations in usrp_sink_c.h & usrp_sink_c.i

I compiled and installed this and python doesn’t recognize my function.

Next I define the same function (with different singature) for class
usrp_sink_base. Did not work as well.
Finally, I definie same function in files: usrp_base.cc (and
declarations
in usrp_base.i usrp_base.h)
And this time I could call function from python:

u=usrp.usrp_base()
u.printme2()

Please note that inheritance goes like that: usrp_base <-
usrp_sink_base <-
usrp_sink_c
(from http://gnuradio.org/doc/doxygen/classusrp__sink__c.html )

Why in python(SWIG interface) I don’t get any methods from classes which
are
inherited from usrp_base?

Tom

View this message in context:
http://www.nabble.com/strange-inheritance-in-gnuradio…-or-something-wrong-with-SWIG…-tp25393083p25444056.html
Sent from the GnuRadio mailing list archive at Nabble.com.

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs