pothosware / SoapyRTLSDR

SoapySDR RTL-SDR Support Module
https://github.com/pothosware/SoapyRTLSDR/wiki
MIT License
134 stars 31 forks source link

rtlsdr ppm correction, how #46

Closed janvgils closed 3 years ago

janvgils commented 4 years ago

How can we correct the ppm value with soapyrtlsdr? The current SoapySDRUtil --probe="driver=rtlsdr" isn't showing a corr=value option anymore.

`SoapySDRUtil --probe="driver=rtlsdr" ######################################################

Soapy SDR -- the SDR abstraction library

######################################################

Probe device driver=rtlsdr Found Rafael Micro R820T tuner Found Rafael Micro R820T tuner


-- Device identification

driver=RTLSDR hardware=R820T origin=https://github.com/pothosware/SoapyRTLSDR rtl=0


-- Peripheral summary

Channels: 1 Rx, 0 Tx Timestamps: NO Other Settings:


-- RX Channel 0

Full-duplex: YES Supports AGC: YES Stream formats: CS8, CS16, CF32 Native format: CS8 [full-scale=128] Stream args:

kerel-fs commented 4 years ago

To answer a part of the question our-self: There are two possible ways to set the frequency correction via the provided SoapySDR APIs:

  1. via Frequency API by SoapyRTLSDR::setFrequency with name="CORR":
    const double corr_frequency = 49;  # in ppm
    std::vector<SoapySDR::Kwargs> d_tune_args;
    d_device->setFrequency(SOAPY_SDR_RX, channel, "CORR", corr_frequency, d_tune_args);
  2. via Frontend corrections API by SoapyRTLSDR::setFrequencyCorrection
    const double corr_frequency = 49;  # in ppm
    d_device->setFrequencyCorrection(SOAPY_SDR_RX, channel, corr_frequency);

(Note that the underlying rtlsdr_set_freq_correction method supports integer values only (include/rtl-sdr.h#L155-L162) while both Soapy APIs accept doubles and type-casts them.)

The only question remaining: Which of those two possibilities is preferred / do you plan to deprecate one of the two APIs in the future?

cjcliffe commented 4 years ago

Looks like setFrequencyCorrection was added two years after the initial method of using "CORR" as a workaround was implemented.

Use setFrequencyCorrection and consider calling setFrequency with "CORR" to be deprecated -- I'll be updating my own application to use the new function as well so that it will work with all supported devices.