Quantcast

Reg : Simultaneous execution of two scripts

classic Classic list List threaded Threaded
7 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Reg : Simultaneous execution of two scripts

sumitstop
I have created two copies of the usrp_spectrum_sense.py for wideband spectrum sensing. Each one of them collects data from a different frequency band and then finally fusion takes place.
I am invoking both the scripts from bash with a timer which make them execute at the same instance of time.
Content of both the bash scripts are below (activate_usrp_1.sh & activate_usrp_2.sh)

While most of the time it is working fine but sometimes following error comes with either activate_usrp_1.sh or activate_usrp_2.sh :
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
sumit@sumit-desktop:~/finals/multi_usrp_same_system_different_range$ ./activate_usrp_1.sh
will start at 40
linux; GNU C++ version 4.4.3; Boost_104000; UHD_003.005.000-26-gb65a3924

Warning: this may have issues on some machines+Python version combinations to seg fault due to the callback in bin_statitics.

-- Opening a USRP1 device...
Traceback (most recent call last):
  File "./usrp_spectrum_sense_1.py", line 341, in <module>
    tb = my_top_block()
  File "./usrp_spectrum_sense_1.py", line 147, in __init__
    stream_args=uhd.stream_args('fc32'))
  File "/usr/local/lib/python2.6/dist-packages/gnuradio/uhd/__init__.py", line 116, in constructor_interceptor
    return old_constructor(*args)
  File "/usr/local/lib/python2.6/dist-packages/gnuradio/uhd/uhd_swig.py", line 2875, in usrp_source
    return _uhd_swig.usrp_source(*args)
RuntimeError: AssertionError: libusb_claim_interface(this->get(), interface) == 0
  in virtual void libusb_device_handle_impl::claim_interface(int)
  at /home/sumit/Downloads/uhd/host/lib/transport/libusb1_base.cpp:188
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#activate_usrp_1.sh
# this is a template script to start a process with respect to network time
cd /home/sumit/finals/multi_usrp_same_system_different_range
s1=40
echo "will start at $s1"
st=0
tk=0
while [ "$st" = "$tk" ]
do
s=`date +%S`
s1=40
if [ "$s1" = "$s" ]; then
st=1
else
st=0
fi
done
m=1
if [ $m=$st ] ; then
     ./usrp_spectrum_sense_1.py 2.45G 2.456G -s 8e6 --itt-time=2 --fft-size=16 --args "name=lab_4"  
fi

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#activate_usrp_2.sh
# this is a template script to start a process with respect to network time
cd /home/sumit/finals/multi_usrp_same_system_different_range
s1=40
echo "will start at $s1"
st=0
tk=0
while [ "$st" = "$tk" ]
do
s=`date +%S`
s1=40
if [ "$s1" = "$s" ]; then
st=1
else
st=0
fi
done
m=1
if [ $m=$st ] ; then
     ./usrp_spectrum_sense_2.py 2.456G 2.462G -s 8e6 --itt-time=2 --fft-size=16 --args "name=lab_2"  
fi

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Reg : Simultaneous execution of two scripts

mleech

On 07 Mar 2013 13:56, sumitstop wrote:

I have created two copies of the usrp_spectrum_sense.py for wideband spectrum
sensing. Each one of them collects data from a different frequency band and
then finally fusion takes place. 
I am invoking both the scripts from bash with a timer which make them
execute at the same instance of time.
Content of both the bash scripts are below (activate_usrp_1.sh &
activate_usrp_2.sh)

Only one application can have the USRP1 open at a time.  There's no way to effectively "share" a USB device descriptor among different applications in Linux, and there are other reasons that's a bad idea as well.

 

 

_______________________________________________
Discuss-gnuradio mailing list
[hidden email]
https://lists.gnu.org/mailman/listinfo/discuss-gnuradio
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Reg : Simultaneous execution of two scripts

sumitstop
Marcus I have two separate usrp-1 connected for each script as you can see them in the argument field ---  lab_2 , lab_4

My motive is two invoke each script simultaneously i.e. both the usrp will start simultaneously and dump the sensing data from different bands.

8 out of 10 times it is working smoothly



 
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Reg : Simultaneous execution of two scripts

mleech

On 07 Mar 2013 14:28, sumitstop wrote:

Marcus I have two separate usrp-1 connected for each script as you can see
them in the argument field ---  lab_2 , lab_4

My motive is two invoke each script simultaneously i.e. both the usrp will
start simultaneously and dump the sensing data from different bands.

8 out of 10 times it is working smoothly 


Ah, sorry, I missed that, my apologies.

Likely what's happening is that in order for UHD to determine what the name of a device is, it has to "claim" that device interface, briefly, to determine whether "this is the device we're looking for".

Likely this collides from time to time.

Try putting a few seconds pause between starting one script and the next.

 

 

_______________________________________________
Discuss-gnuradio mailing list
[hidden email]
https://lists.gnu.org/mailman/listinfo/discuss-gnuradio
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Reg : Simultaneous execution of two scripts

sumitstop
Hmm putting the delay works  ..but this is I wanted to avoid i.e. putting a few seconds delay .. any ways can't help after knowing the reason you told
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Reg : Simultaneous execution of two scripts

Tom Rondeau-2
On Thu, Mar 7, 2013 at 2:48 PM, sumitstop
<[hidden email]> wrote:
> Hmm putting the delay works  ..but this is I wanted to avoid i.e. putting a
> few seconds delay .. any ways can't help after knowing the reason you told

The problem, as you've just demonstrated, is temporary. Can you detect
when the problem occurs and rerun it until it works? The problem is
that this is a love level OS/system thing happening. I don't think
that there's anything more you can do (without a lot of work) but
retry.

Tom

_______________________________________________
Discuss-gnuradio mailing list
[hidden email]
https://lists.gnu.org/mailman/listinfo/discuss-gnuradio
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Reg : Simultaneous execution of two scripts

sumitstop
Tom I observed following :
I connected 3 usrp-1 and ran 3 scripts activate_usrp_1.sh, 2.sh, 3.sh
All were asked to execute at 44th second of any minute.
I also put a time stamp just after tb.start()

    try:
        tb.start()
        startTime = datetime.now()
        print "usrp_X started at time",
        print startTime

I got following
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
* I also varied the order in which activate_usrp_1,2,3.sh were executed which you can see

usrp_1 started at time 2013-03-08 02:58:44.519909
usrp_2 started at time 2013-03-08 02:58:44.752680
usrp_3 failed

usrp_1 started at time 2013-03-08 03:00:44.587403
usrp_2 started at time 2013-03-08 03:00:44.662657
usrp_3 started at time 2013-03-08 03:00:45.455082

usrp_1 started at time 2013-03-08 03:02:44.590596
usrp_2 started at time 2013-03-08 03:02:44.672339
usrp_3 started at time 2013-03-08 03:02:45.479982


usrp_3 started at time 2013-03-08 03:07:45.459970
usrp_2 started at time 2013-03-08 03:07:44.664802
usrp_1 started at time 2013-03-08 03:07:44.565529

usrp_3 started at time 2013-03-08 03:09:45.523806
usrp_2 failed
usrp_1 started at time 2013-03-08 03:09:44.541790

usrp_3 started at time 2013-03-08 03:11:45.464744
usrp_2 started at time 2013-03-08 03:11:44.550938
usrp_1 failed

usrp_2 started at time 2013-03-08 03:14:44.552696
usrp_1 started at time 2013-03-08 03:14:44.703248
usrp_3 started at time 2013-03-08 03:14:45.460309


usrp_2 started at time 2013-03-08 03:16:44.531649
usrp_1 started at time 2013-03-08 03:16:44.664747
usrp_3 started at time 2013-03-08 03:16:45.449123


usrp_3 started at time 2013-03-08 03:19:45.338391
usrp_1 started at time 2013-03-08 03:19:44.659291
usrp_2 started at time 2013-03-08 03:19:44.636886

usrp_3 started at time 2013-03-08 03:22:45.406933
usrp_1 started at time 2013-03-08 03:22:45.211632
usrp_2 started at time 2013-03-08 03:22:45.214003

usrp_3 started at time 2013-03-08 03:23:45.468723
usrp_1 started at time 2013-03-08 03:23:44.586787
usrp_2 started at time 2013-03-08 03:23:44.661047
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
I am not able to come up with any pattern of failure
I also observed that my new usrp i.e. usrp_3 is a bit lazier than the old ones regardless of the order of execution of activate_usrp_1,2,3.sh
Probably the new one is equipped with SBX while the old ones are with RFX2400 (just an observation)

Loading...