forked from sdr/gr-osmosdr
rtl: add xtal arguments for rtl and tuner chips
parent
6c30964893
commit
34baaf3f93
|
@ -107,7 +107,7 @@ of devices. If left blank, the first device found will be used.
|
|||
|
||||
Examples:
|
||||
fcd=0 fcd=1 fcd=2 ...
|
||||
rtl=0 rtl=1 rtl=2 ...
|
||||
rtl=0 rtl=1 rtl=2,rtl_xtal=28.80001e6,tuner_xtal=26e6 ...
|
||||
uhd=0|name,mcr=52e6,nchan=2,subdev='\\\\'B:0 A:0'\\\\' ...
|
||||
osmosdr=0|name,mcr=64e6,nchan=5,port=/dev/ttyUSB0 ...
|
||||
|
||||
|
|
|
@ -31,6 +31,7 @@
|
|||
#include <gr_io_signature.h>
|
||||
|
||||
#include <boost/assign.hpp>
|
||||
#include <boost/format.hpp>
|
||||
|
||||
#include <stdexcept>
|
||||
#include <iostream>
|
||||
|
@ -77,13 +78,19 @@ rtl_source_c::rtl_source_c (const std::string &args)
|
|||
gr_make_io_signature (MIN_OUT, MAX_OUT, sizeof (gr_complex)))
|
||||
{
|
||||
int ret;
|
||||
unsigned int dev_index = 0;
|
||||
unsigned int dev_index = 0, rtl_freq = 0, tuner_freq = 0;
|
||||
|
||||
dict_t dict = params_to_dict(args);
|
||||
|
||||
if (dict.count("rtl"))
|
||||
dev_index = boost::lexical_cast< unsigned int >( dict["rtl"] );
|
||||
|
||||
if (dict.count("rtl_xtal"))
|
||||
rtl_freq = (unsigned int)boost::lexical_cast< double >( dict["rtl_xtal"] );
|
||||
|
||||
if (dict.count("tuner_xtal"))
|
||||
tuner_freq = (unsigned int)boost::lexical_cast< double >( dict["tuner_xtal"] );
|
||||
|
||||
_buf_num = 32;
|
||||
_buf = (unsigned short **) malloc(_buf_num * sizeof(unsigned short *));
|
||||
|
||||
|
@ -116,6 +123,18 @@ rtl_source_c::rtl_source_c (const std::string &args)
|
|||
if (ret < 0)
|
||||
throw std::runtime_error("Failed to open rtlsdr device.");
|
||||
|
||||
if (rtl_freq > 0 || tuner_freq > 0) {
|
||||
if (rtl_freq)
|
||||
std::cerr << "Setting rtl clock to " << rtl_freq << " Hz." << std::endl;
|
||||
if (tuner_freq)
|
||||
std::cerr << "Setting tuner clock to " << tuner_freq << " Hz." << std::endl;
|
||||
|
||||
ret = rtlsdr_set_xtal_freq( _dev, rtl_freq, tuner_freq );
|
||||
if (ret < 0)
|
||||
throw std::runtime_error(
|
||||
str(boost::format("Failed to set xtal frequencies. Error %d.") % ret ));
|
||||
}
|
||||
|
||||
ret = rtlsdr_set_sample_rate( _dev, 1024000 );
|
||||
if (ret < 0)
|
||||
throw std::runtime_error("Failed to set default samplerate.");
|
||||
|
|
Loading…
Reference in New Issue