rtl,rtl_tcp: add bias=0|1 parameter to switch off|on bias voltage on

gpio0
This commit is contained in:
Dimitri Stolnikov 2017-06-11 22:04:03 +02:00
parent a3b4e5c815
commit 3c7d3f1664
3 changed files with 21 additions and 4 deletions

View File

@ -251,8 +251,8 @@ Lines ending with ... mean it's possible to bind devices together by specifying
rtl=serial_number ...
rtl=0[,rtl_xtal=28.8e6][,tuner_xtal=28.8e6] ...
rtl=1[,buffers=32][,buflen=N*512] ...
rtl=2[,direct_samp=0|1|2][,offset_tune=0|1] ...
rtl_tcp=127.0.0.1:1234[,psize=16384][,direct_samp=0|1|2][,offset_tune=0|1] ...
rtl=2[,direct_samp=0|1|2][,offset_tune=0|1][,bias=0|1] ...
rtl_tcp=127.0.0.1:1234[,psize=16384][,direct_samp=0|1|2][,offset_tune=0|1][,bias=0|1] ...
osmosdr=0[,buffers=32][,buflen=N*512] ...
file='/path/to/your file',rate=1e6[,freq=100e6][,repeat=true][,throttle=true] ...
netsdr=127.0.0.1[:50000][,nchan=2]

View File

@ -92,6 +92,7 @@ rtl_source_c::rtl_source_c (const std::string &args)
{
int ret;
int index;
int bias_tee = 0;
unsigned int dev_index = 0, rtl_freq = 0, tuner_freq = 0, direct_samp = 0;
unsigned int offset_tune = 0;
char manufact[256];
@ -150,6 +151,9 @@ rtl_source_c::rtl_source_c (const std::string &args)
if (dict.count("offset_tune"))
offset_tune = boost::lexical_cast< unsigned int >( dict["offset_tune"] );
if (dict.count("bias"))
bias_tee = boost::lexical_cast<bool>( dict["bias"] );
_buf_num = _buf_len = _buf_head = _buf_used = _buf_offset = 0;
if (dict.count("buffers"))
@ -217,6 +221,10 @@ rtl_source_c::rtl_source_c (const std::string &args)
throw std::runtime_error("Failed to enable offset tuning.");
}
ret = rtlsdr_set_bias_tee(_dev, bias_tee);
if (ret < 0)
throw std::runtime_error("Failed to set bias tee.");
ret = rtlsdr_reset_buffer( _dev );
if (ret < 0)
throw std::runtime_error("Failed to reset usb buffers.");

View File

@ -154,6 +154,7 @@ rtl_tcp_source_c::rtl_tcp_source_c(const std::string &args) :
unsigned short port = 1234;
int payload_size = 16384;
unsigned int direct_samp = 0, offset_tune = 0;
int bias_tee = 0;
_freq = 0;
_rate = 0;
@ -182,6 +183,9 @@ rtl_tcp_source_c::rtl_tcp_source_c(const std::string &args) :
if (dict.count("offset_tune"))
offset_tune = boost::lexical_cast< unsigned int >( dict["offset_tune"] );
if (dict.count("bias"))
bias_tee = boost::lexical_cast<bool>( dict["bias"] );
if (!host.length())
host = "127.0.0.1";
@ -218,7 +222,6 @@ rtl_tcp_source_c::rtl_tcp_source_c(const std::string &args) :
report_error("rtl_tcp_source_f/getaddrinfo",
"can't initialize source socket" );
// FIXME leaks if report_error throws below
d_temp_buff = new unsigned char[payload_size]; // allow it to hold up to payload_size bytes
d_LUT = new float[0x100];
for (int i = 0; i < 0x100; ++i)
@ -293,7 +296,9 @@ rtl_tcp_source_c::rtl_tcp_source_c(const std::string &args) :
set_gain_mode(false); /* enable manual gain mode by default */
// set direct sampling
struct command cmd = { 0x09, htonl(direct_samp) };
struct command cmd;
cmd = { 0x09, htonl(direct_samp) };
send(d_socket, (const char*)&cmd, sizeof(cmd), 0);
if (direct_samp)
_no_tuner = true;
@ -301,6 +306,10 @@ rtl_tcp_source_c::rtl_tcp_source_c(const std::string &args) :
// set offset tuning
cmd = { 0x0a, htonl(offset_tune) };
send(d_socket, (const char*)&cmd, sizeof(cmd), 0);
// set bias tee
cmd = { 0x0e, htonl(bias_tee) };
send(d_socket, (const char*)&cmd, sizeof(cmd), 0);
}
rtl_tcp_source_c::~rtl_tcp_source_c()