def switch_source(usrp_source, freq, lo_offset):
    start_souce = time.perf_counter()
    # time.sleep(2)
    usrp_source.set_center_freq(uhd.tune_request(freq, rf_freq=freq - lo_offset,
                                                 
rf_freq_policy=uhd.tune_request.POLICY_MANUAL), 0)
    end_souce = time.perf_counter()
    print("Source Switch Time: ", end_souce - start_souce)

def switch_sink(usrp_sink, freq, lo_offset):
    start_sink = time.perf_counter()
    # time.sleep(2)
    usrp_sink.set_center_freq(uhd.tune_request(freq, rf_freq=freq - lo_offset,
                                               
rf_freq_policy=uhd.tune_request.POLICY_MANUAL), 0)
    end_sink = time.perf_counter()
    print("Sink Switch Time: ", end_sink - start_sink)


sw_start = time.perf_counter()
with ThreadPoolExecutor(max_workers=2) as ex:
    futures = [
        ex.submit(switch_source, usrp_source=self.uhd_usrp_source_0, 
freq=freqList[j], lo_offset=lo_offset),
        ex.submit(switch_sink, usrp_sink=self.uhd_usrp_sink_0, 
freq=freqList[j], lo_offset=lo_offset)]
    wait(futures, timeout=None, return_when=ALL_COMPLETED)
sw_end = time.perf_counter()
print("Total Switch Time: ", sw_end - sw_start)


Hello Jim,
I am sending the code you see above that I wrote before as an example. If you 
enable the time.sleep(2) commands, you will see that the 'Total Switch Time' 
takes about 2.2 seconds (this is what I observed). This brings me to the point 
that if the processor had performed the operation serially it should have taken 
more than 4 seconds, but instead it took '2 + switch time'. In fact, if you 
look at it, the code is played in parallel.
The problem starts here: When I comment on the time.sleep(2) commands, and 
leave only the switch commands, my observation is that it takes about 200 ms 
and this process takes place serially. Somehow, the SDRs lock the processor and 
the other one does not start until the process of one is finished. I will try 
this without the 'Usb Hub', in fact, if you look, it can actually serialize the 
process.

Reply via email to