Search code examples
pythongnuradiousrp

GNU Radio: tune_request with python


I am trying to make 2 TX 2 RX (MIMO) config with a USRP X310. I made the flowgraph for 2TX and 2RX config in GRC and generated the python script.

I have a question about tune request. In general with a 2 TX 2 RX config with python, there are 4 tune requests for 4 ports, which looks like

self.usrp_source0.set_center_freq(f, 0)
self.usrp_source0.set_center_freq(f, 1)
self.usrp_sink0.set_center_freq(f, 0)
self.usrp_sink0.set_center_freq(f, 1)

where usrp_sink0 is the TX usrp object and usrp_source0 is the RX usrp object.

Is it possible to define 1 tune request for all TXs and 1 tune request for all RXs like described below?

self.usrp_source0.set_center_freq(f, all_chan)
self.usrp_sink0.set_center_freq(f, all_chan)

Solution

  • Because of how the usrp_source block is written, you will only be able to send a command to a single channel at a time.

    ::uhd::tune_result_t
    usrp_source_impl::set_center_freq(const ::uhd::tune_request_t tune_request,
                                      size_t chan)
    {
      const size_t user_chan = chan;
      chan = _stream_args.channels[chan];
      const ::uhd::tune_result_t res = _dev->set_rx_freq(tune_request, chan);
      _center_freq = this->get_center_freq(user_chan);
      _tag_now = true;
      return res;
    }
    

    Notice that the chan parameter is of type size_t, so you can only pass in a single, non-negative integer.

    I'm going to assume the sink has the same restriction.

    https://github.com/gnuradio/gnuradio/blob/master/gr-uhd/lib/usrp_source_impl.cc#L137