aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDimitri Stolnikov <horiz0n@gmx.net>2017-06-11 22:04:03 +0200
committerDimitri Stolnikov <horiz0n@gmx.net>2017-06-11 22:04:03 +0200
commit3c7d3f166401b1af6afd903b8d2b9729e8897189 (patch)
tree71b43c31a9292f86b101be578944cc2dd4d4573b
parenta3b4e5c815511aed75bee281831db941277496d8 (diff)
rtl,rtl_tcp: add bias=0|1 parameter to switch off|on bias voltage on
gpio0
-rw-r--r--grc/gen_osmosdr_blocks.py4
-rw-r--r--lib/rtl/rtl_source_c.cc8
-rw-r--r--lib/rtl_tcp/rtl_tcp_source_c.cc13
3 files changed, 21 insertions, 4 deletions
diff --git a/grc/gen_osmosdr_blocks.py b/grc/gen_osmosdr_blocks.py
index 3daa8a0..d1f2b1a 100644
--- a/grc/gen_osmosdr_blocks.py
+++ b/grc/gen_osmosdr_blocks.py
@@ -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]
diff --git a/lib/rtl/rtl_source_c.cc b/lib/rtl/rtl_source_c.cc
index 8a8df7c..a371464 100644
--- a/lib/rtl/rtl_source_c.cc
+++ b/lib/rtl/rtl_source_c.cc
@@ -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.");
diff --git a/lib/rtl_tcp/rtl_tcp_source_c.cc b/lib/rtl_tcp/rtl_tcp_source_c.cc
index d49271f..ecdeee0 100644
--- a/lib/rtl_tcp/rtl_tcp_source_c.cc
+++ b/lib/rtl_tcp/rtl_tcp_source_c.cc
@@ -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()