diff options
author | Dimitri Stolnikov <horiz0n@gmx.net> | 2017-06-12 00:04:36 +0200 |
---|---|---|
committer | Dimitri Stolnikov <horiz0n@gmx.net> | 2017-06-12 00:04:36 +0200 |
commit | c653754dde5e2cf682965e939cc016fbddbd45e4 (patch) | |
tree | cdaa8bbb1797c8f4c4d49739278fb417cb754b86 /lib/soapy/soapy_source_c.cc | |
parent | b7aab458ed706387cd34bc2c08c65f7562aee51b (diff) | |
parent | cf9549485af61658eab3e14e0a89db80742eb547 (diff) |
Merge branch 'master' of git.osmocom.org:gr-osmosdr
Diffstat (limited to 'lib/soapy/soapy_source_c.cc')
-rw-r--r-- | lib/soapy/soapy_source_c.cc | 29 |
1 files changed, 27 insertions, 2 deletions
diff --git a/lib/soapy/soapy_source_c.cc b/lib/soapy/soapy_source_c.cc index d066ed8..a645361 100644 --- a/lib/soapy/soapy_source_c.cc +++ b/lib/soapy/soapy_source_c.cc @@ -29,6 +29,7 @@ #endif #include <iostream> +#include <algorithm> //find #include <boost/assign.hpp> #include <boost/format.hpp> @@ -123,10 +124,17 @@ size_t soapy_source_c::get_num_channels( void ) osmosdr::meta_range_t soapy_source_c::get_sample_rates( void ) { osmosdr::meta_range_t result; + #ifdef SOAPY_SDR_API_HAS_GET_SAMPLE_RATE_RANGE + BOOST_FOREACH(const SoapySDR::Range &r, _device->getSampleRateRange(SOAPY_SDR_RX, 0)) + { + result.push_back(osmosdr::range_t(r.minimum(), r.maximum())); + } + #else BOOST_FOREACH(const double rate, _device->listSampleRates(SOAPY_SDR_RX, 0)) { result.push_back(osmosdr::range_t(rate)); } + #endif return result; } @@ -164,13 +172,30 @@ double soapy_source_c::get_center_freq( size_t chan ) double soapy_source_c::set_freq_corr( double ppm, size_t chan ) { - _device->setFrequency(SOAPY_SDR_RX, chan, "CORR", ppm); + #ifdef SOAPY_SDR_API_HAS_FREQUENCY_CORRECTION_API + _device->setFrequencyCorrection(SOAPY_SDR_RX, chan, ppm); + #else + std::vector<std::string> components = _device->listFrequencies(SOAPY_SDR_RX, chan); + if (std::find(components.begin(), components.end(), "CORR") != components.end()) + { + _device->setFrequency(SOAPY_SDR_RX, chan, "CORR", ppm); + } + #endif return this->get_freq_corr(chan); } double soapy_source_c::get_freq_corr( size_t chan ) { - return _device->getFrequency(SOAPY_SDR_RX, chan, "CORR"); + #ifdef SOAPY_SDR_API_HAS_FREQUENCY_CORRECTION_API + return _device->getFrequencyCorrection(SOAPY_SDR_RX, chan); + #else + std::vector<std::string> components = _device->listFrequencies(SOAPY_SDR_RX, chan); + if (std::find(components.begin(), components.end(), "CORR") != components.end()) + { + return _device->getFrequency(SOAPY_SDR_RX, chan, "CORR"); + } + return 0.0; + #endif } std::vector<std::string> soapy_source_c::get_gain_names( size_t chan ) |