pothosware / SoapySDRPlay3

Soapy SDR plugin for SDRPlay APIv3
https://github.com/pothosware/SoapySDRPlay3/wiki
MIT License
90 stars 15 forks source link

Start at the same time (and time synchronisation?) #45

Closed Alster closed 2 years ago

Alster commented 2 years ago

Hi! (Sorry for my terrible English)

I tried to use RSPDuo for synchronised by time/phase two-channel signal reception. As I understand - this device can solve this task in Dual Tuner mode with Independent RX. Your repo is exactly what I need! Thank you for your work!

Question: is there any way to start two channels at the same time? For now I see big difference between: telegram-cloud-photo-size-2-5327846101522429445-x As you see, red channel starts much later than blue.

For now I using your Soapy module from dual-tuner-submodules branch, and trying to write custom block for GnuRadio, here is device creation:

d_samp_rate = 1e6;

d_device = SoapySDR::Device::make(SoapySDR::KwargsFromString("driver=sdrplay, rspduo_mode=2, rspduo_dual_tuner_independent_rx=true"));

d_device->setSampleRate(SOAPY_SDR_RX, 0, d_samp_rate);
d_device->setSampleRate(SOAPY_SDR_RX, 1, d_samp_rate);

d_device->setGainMode(SOAPY_SDR_RX, 0, false);
d_device->setGainMode(SOAPY_SDR_RX, 1, false);

d_device->setFrequency(SOAPY_SDR_RX, 0, fc1);
d_device->setFrequency(SOAPY_SDR_RX, 1, fc2);

d_stream1 = d_device->setupStream(SOAPY_SDR_RX, "CF32", {0}, SoapySDR::KwargsFromString(""));
d_stream2 = d_device->setupStream(SOAPY_SDR_RX, "CF32", {1}, SoapySDR::KwargsFromString(""));
d_device->activateStream(d_stream1);
d_device->activateStream(d_stream2);

And buffers reading:

int
rspduo_source_impl::work(int noutput_items,
  gr_vector_const_void_star &input_items,
  gr_vector_void_star &output_items)
{
  int flags = 0;
  long long timeNs = 0;
  // read from first stream
  int read = d_device->readStream(d_stream1, &output_items[0], noutput_items, flags, timeNs);
  if (read < 0) {
    std::cout << "A";
  }
  // and read from second stream, with same count of items but into another buffer
  read = d_device->readStream(d_stream2, &output_items[1], noutput_items, flags, timeNs);
  if (read < 0) {
    std::cout << "B";
  }
  return noutput_items;
}

Looks like I missed something in docs, will be very appreciated for any help!

fventuri commented 2 years ago

@Alster - thanks for nice words and no problem at all for your English!

If you are looking for a GNU Radio OOT module that can stream both of the channels of the RSPduo, I suggest that you take a look at the gr-sdrplay3 module I wrote a few months ago: https://github.com/fventuri/gr-sdrplay3

This is the message I sent to the GNU Radio discussion mailing list last year to announce it: https://lists.gnu.org/archive/html/discuss-gnuradio/2020-08/msg00001.html

It should build and run under GNU Radio version 3.9 (and newer versions), and it supports the SDRplay RSPduo in dual-tuner mode.

If you have any problem with it, feel free to create new issue here: https://github.com/fventuri/gr-sdrplay3/issues

Franco