diff options
author | Dimitri Stolnikov <horiz0n@gmx.net> | 2017-06-11 22:04:03 +0200 |
---|---|---|
committer | Dimitri Stolnikov <horiz0n@gmx.net> | 2017-06-11 22:04:03 +0200 |
commit | 3c7d3f166401b1af6afd903b8d2b9729e8897189 (patch) | |
tree | 71b43c31a9292f86b101be578944cc2dd4d4573b /lib | |
parent | a3b4e5c815511aed75bee281831db941277496d8 (diff) |
rtl,rtl_tcp: add bias=0|1 parameter to switch off|on bias voltage on
gpio0
Diffstat (limited to 'lib')
-rw-r--r-- | lib/rtl/rtl_source_c.cc | 8 | ||||
-rw-r--r-- | lib/rtl_tcp/rtl_tcp_source_c.cc | 13 |
2 files changed, 19 insertions, 2 deletions
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() |