How to reconfigure automatically the channel used to received data in USRPs

Hello everyone,

Before to explain my problem I give some technical information about my
hardaware. I’m using USRPs v1 and the boards integrated are XCVR2450
Transceivers.

I’m using the script usrp_spectrum_sense.py in a USRP (called USRP1) to
make
sensing in the ISM band, after a few seconds it sends to another USRP
(Called USRP2) a free sensed channel on the central frequency 2484 MHz.
USRP2 listens to the channel 2484 MHz through the script benchmark_rx.py
and
it can properly receive the free ISM channel sent by USRP1. Then, I want
to
use the USRP2 to receive data from another USRP (called USRP3) that uses
the
script benchmark_tx.py.

In the script benchmark_rx.py (used by USRP2) that listens to channel
2484
MHz I want to run another script that I called benchmark_rxr.py that
waits
for data sent by USRP3 to be received in the free ISM channel sent by
USRP1.

Relevant line of the code in the script benchmark_rx.py is attached
below:

p = Popen(‘python benchmark_rxr.py’, shell = True)

While this is the error that I get:

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 “benchmark_rxr.py”, line 153, in
main()
File “benchmark_rxr.py”, line 138, in main
tb = my_top_block(demods[options.modulation],
mods[options.modulation],
rx_callback, options)
File “benchmark_rxr.py”, line 46, in init
self.rxpath = usrp_receive_path.usrp_receive_path(demodulator,
rx_callback, options)
File
“/opt/gnuradio/gnuradio-examples/python/usrp/usrp_receive_path.py”,
line 65, in init
self._setup_usrp_source(options)
File
“/opt/gnuradio/gnuradio-examples/python/usrp/usrp_receive_path.py”,
line 78, in _setup_usrp_source
self.u = usrp_options.create_usrp_source(options)
File
“/usr/local/lib/python2.6/dist-packages/gnuradio/usrp_options.py”,
line 88, in create_usrp_source
gain=options.rx_gain,
File
“/usr/local/lib/python2.6/dist-packages/gnuradio/blks2impl/generic_usrp.py”,
line 138, in init
_generic_usrp_base.init(self, **kwargs)
File
“/usr/local/lib/python2.6/dist-packages/gnuradio/blks2impl/generic_usrp.py”,
line 63, in init
except: raise Exception, ‘Failed to automatically setup a usrp
device.’
Exception: Failed to automatically setup a usrp device.

I read different post with this problem such as “Full duplex and half
duplex
does not work” and “help: cannot send after transport endpoint shutdown”
but
I could not solve the problem yet. I need to close the reception in 2484
MHz
channel for a new reception in another channel in USRP2. The only way to
do
that seems to close the port manually (i.e. pressing ctrl+c) but I want
to
do that by code. I tried different things before the line “p =
Popen(‘python
benchmark_rxr.py’, shell = True)” such as “id_process = os.getpid()”
and
“os.killpg(id_process, 2)”, or by “tb.lock()” and “tb.unlock” and so on,
but
nothing helped me, I keep obtaining the same error. I don’t know what to
do
else, can I change by code reception frequency in USRP2? Any advice will
be
welcome, thanks a lot!

Regards


View this message in context:
http://old.nabble.com/How-to-reconfigure-automatically-the-channel-used-to-received-data-in-USRPs-tp32414957p32414957.html
Sent from the GnuRadio mailing list archive at Nabble.com.

On Wed, Sep 7, 2011 at 3:27 AM, Lebowski80 [email protected]
wrote:

(Called USRP2) a free sensed channel on the central frequency 2484 MHz.
USRP1.
Traceback (most recent call last):
self._setup_usrp_source(options)
_generic_usrp_base.init(self, **kwargs)
but
else, can I change by code reception frequency in USRP2? Any advice will be
welcome, thanks a lot!

You need to run both RX and TX in the same flowgraph. You can’t open
them in
separate flowgraphs.

–n

Hello Nick,

What do you mean? Actually I’m running RX and TX in two different
flowgraphs
on USRP1, the first one in usrp_spectrum_sense.py to look for a free
channel
(so the RX). In this script I also run benchmark_tx.py by the command p

Popen(‘python benchmark_tx.py’, shell = True), then my second
flowgrapgh
(the TX).

My problem is that on USRP2 I want to reconfigure the RX channel by
python
(RX channel = 2484 MHz in the script benchmark_rx.py and RX channel =
channel received by USRP1 in the script benchamrk_rxr.py run by
benchmark_rx.py with the command p = Popen(‘python benchmark_rxr.py’,
shell
= True)).

So I’m wondering if there exists the possibility to reconfigure the
parameters of a script in the same USRP (i.e. RX frequency channel)
while it
is running and if this is not possible what do people mean with “USRP
reconfigurability?”

I really need an answer to understand the potentiality of my hardware,
thanks a lot!

Regards

Nick F.-4 wrote:

script benchmark_tx.py.

File “benchmark_rxr.py”, line 138, in main
line 78, in _setup_usrp_source

I could not solve the problem yet. I need to close the reception in 2484
nothing helped me, I keep obtaining the same error. I don’t know what to
–n
Sent from the GnuRadio mailing list archive at Nabble.com.
[email protected]
Discuss-gnuradio Info Page


View this message in context:
http://old.nabble.com/How-to-reconfigure-automatically-the-channel-used-to-received-data-in-USRPs-tp32414957p32417577.html
Sent from the GnuRadio mailing list archive at Nabble.com.

On 07/09/2011 12:31 PM, Lebowski80 wrote:

channel received by USRP1 in the script benchamrk_rxr.py run by

Regards

So, presumably, your “benchmark_rxr.py” script attempts to independently
create a USRP2 source/sink block, in order to
change the frequency of your (executing) benchmark_rx.py. This isn’t
allowed. The network-level socket used to communicate
with the USRP2 cannot be shared among multiple programs/processes.
That’s a limitation of the systems networking stack, and
not a limitation of the hardware.

A properly constructed flow-graph will have a source block, whose
parameters can be changed dynamically during execution of the
flow-graph. You can see how this works in general by building
yourself a simple flow-graph with GRC, and observing that you can
(for example) create a UHD/USRP2 source block, with frequency and
gain parameters that can be changed at run-time by
text input widgets, for example. When I’m building flow-graphs that
need to have parameters tweaked at run-time
by an external agent, I use the XMLRPC-server block within GRC to
allow me to modify runtime parameters from an external
program. Most (but not ALL) blocks in Gnu Radio that take parameters
that could reasonably be changed at runtime, allow
those parameters to be changed at runtime. Using GRC to see how this
all fits together (by constructing a flow-graph, and then
examining the resulting code) lets you see how it’s done.

The benchmark_* examples may not actually be the best starting point for
doing this type of work, since they’re old, they don’t
support UHD, and they were designed to fulfill a specific purpose.
YES, they can be re-purposed, but only if you understand
how they work, and how they use the underlying Gnu Radio
architecture.

Ok, thank you for your advice, I will try with interprocess
communication.

Regards

Nick F.-4 wrote:

wish to change the parameters of USRP#2 while it is running, rather than
wrote:

(the TX).
parameters of a script in the same USRP (i.e. RX frequency channel) while

hardaware. I’m using USRPs v1 and the boards integrated are XCVR2450
and
MHz I want to run another script that I called benchmark_rxr.py that

File “benchmark_rxr.py”, line 46, in init
File

shutdown"

do that by code. I tried different things before the line "p =
will

Sent from the GnuRadio mailing list archive at Nabble.com.
[email protected]



View this message in context:
http://old.nabble.com/How-to-reconfigure-automatically-the-channel-used-to-received-data-in-USRPs-tp32414957p32421703.html
Sent from the GnuRadio mailing list archive at Nabble.com.

Short answer: You cannot open a new USRP instance to reconfigure an
already-running USRP instance. You must reconfigure the existing
instance.

The best advice I can give is that only one flowgraph can be operational
per
USRP device. In your setup, USRP#1 will run a single flowgraph with a
source
and/or sink, USRP#2 will run a single flowgraph with a source and/or
sink,
and USRP#3 will run a single flowgraph with a source and/or sink. If you
wish to change the parameters of USRP#2 while it is running, rather than
try
to open a new USRP device in your benchmark_rxr.py flowgraph, use any of
the
standard interprocess communication methods to talk to your
already-running
USRP#2 script and reconfigure it as necessary.

–n

Hi Nick,

I just wanted tell you that I solved my problem using interprocess
communication, thank you for your advice!

Regards

Lebowski80 wrote:

instance.
to open a new USRP device in your benchmark_rxr.py flowgraph, use any of

(the TX).
parameters of a script in the same USRP (i.e. RX frequency channel)

my
benchmark_rx.py

2484
While this is the error that I get:
rx_callback, options)
self.u = usrp_options.create_usrp_source(options)
File
does not work" and "help: cannot send after transport endpoint
to
else, can I change by code reception frequency in USRP2? Any advice
–n

http://old.nabble.com/How-to-reconfigure-automatically-the-channel-used-to-received-data-in-USRPs-tp32414957p32414957.html

Discuss-gnuradio mailing list


View this message in context:
http://old.nabble.com/How-to-reconfigure-automatically-the-channel-used-to-received-data-in-USRPs-tp32414957p32456030.html
Sent from the GnuRadio mailing list archive at Nabble.com.

Hi Johnny,

These are the line of the code I used in the script benchmark_rx.py
where
the selected channel was 2484 MHz:

id_process = os.getpid()
p = Popen(‘python benchmark_rxr.py’, preexec_fn = os.kill(id_process,
2),
close_fds = True, shell = True)

killing and closing the process where benchmark_rx.py was running
allowed me
to run benchmark_rxr.py in another channel.

Regards

Tuan (Johnny) Ta wrote:

instance.
wish to change the parameters of USRP#2 while it is running, rather

(so the RX). In this script I also run benchmark_tx.py by the command
benchmark_rx.py with the command p = Popen(‘python benchmark_rxr.py’,
I really need an answer to understand the potentiality of my
[email protected]

Transceivers.
benchmark_rx.py

Relevant line of the code in the script benchmark_rx.py is
Traceback (most recent call last):
“/opt/gnuradio/gnuradio-examples/python/usrp/usrp_receive_path.py”,
File
“/usr/local/lib/python2.6/dist-packages/gnuradio/blks2impl/generic_usrp.py”,
but
to
what
open

Discuss-gnuradio mailing list

Discuss-gnuradio Info Page


Discuss-gnuradio mailing list
[email protected]
Discuss-gnuradio Info Page


View this message in context:
http://old.nabble.com/How-to-reconfigure-automatically-the-channel-used-to-received-data-in-USRPs-tp32414957p32722439.html
Sent from the GnuRadio mailing list archive at Nabble.com.

Can you elaborate on how exactly you solved this problem without using
GRC?
What kind of interprocess communication did you use?

Thanks,
Johnny