diff --git a/lib/CMakeLists.txt b/lib/CMakeLists.txt index 31a7257..e9d6a65 100644 --- a/lib/CMakeLists.txt +++ b/lib/CMakeLists.txt @@ -244,7 +244,7 @@ endif(ENABLE_RTL) ######################################################################## # Setup RTL_TCP component ######################################################################## -GR_REGISTER_COMPONENT("RTLSDR TCP Client" ENABLE_RTL_TCP GNURADIO_BLOCKS_FOUND) +GR_REGISTER_COMPONENT("RTLSDR TCP Client" ENABLE_RTL_TCP) if(ENABLE_RTL_TCP) GR_INCLUDE_SUBDIRECTORY(rtl_tcp) endif(ENABLE_RTL_TCP) diff --git a/lib/rtl_tcp/CMakeLists.txt b/lib/rtl_tcp/CMakeLists.txt index 54eed08..8a01672 100644 --- a/lib/rtl_tcp/CMakeLists.txt +++ b/lib/rtl_tcp/CMakeLists.txt @@ -34,5 +34,5 @@ set(rtl_tcp_srcs # Append gnuradio-osmosdr library sources ######################################################################## list(APPEND gr_osmosdr_srcs ${rtl_tcp_srcs}) -list(APPEND gr_osmosdr_libs ${GNURADIO_BLOCKS_LIBRARIES}) +#list(APPEND gr_osmosdr_libs ...) diff --git a/lib/rtl_tcp/rtl_tcp_source_c.cc b/lib/rtl_tcp/rtl_tcp_source_c.cc index ad95b02..9a6d6fb 100644 --- a/lib/rtl_tcp/rtl_tcp_source_c.cc +++ b/lib/rtl_tcp/rtl_tcp_source_c.cc @@ -26,8 +26,6 @@ #include #include -#include -#include #include "rtl_tcp_source_c.h" @@ -126,18 +124,7 @@ rtl_tcp_source_c::rtl_tcp_source_c(const std::string &args) : _src->set_offset_tuning(offset_tune); - /* rtl tcp source provides a stream of interleaved IQ floats */ - gr::blocks::deinterleave::sptr deinterleave = \ - gr::blocks::deinterleave::make( sizeof(float) ); - - /* block to convert deinterleaved floats to a complex stream */ - gr::blocks::float_to_complex::sptr f2c = \ - gr::blocks::float_to_complex::make( 1 ); - - connect(_src, 0, deinterleave, 0); - connect(deinterleave, 0, f2c, 0); /* I */ - connect(deinterleave, 1, f2c, 1); /* Q */ - connect(f2c, 0, self(), 0); + connect(_src, 0, self(), 0); } rtl_tcp_source_c::~rtl_tcp_source_c() diff --git a/lib/rtl_tcp/rtl_tcp_source_f.cc b/lib/rtl_tcp/rtl_tcp_source_f.cc index 211cc95..01ef62c 100644 --- a/lib/rtl_tcp/rtl_tcp_source_f.cc +++ b/lib/rtl_tcp/rtl_tcp_source_f.cc @@ -90,13 +90,12 @@ rtl_tcp_source_f::rtl_tcp_source_f(size_t itemsize, bool wait) : gr::sync_block ("rtl_tcp_source_f", gr::io_signature::make(0, 0, 0), - gr::io_signature::make(1, 1, sizeof(float))), + gr::io_signature::make(1, 1, sizeof(gr_complex))), d_itemsize(itemsize), d_payload_size(payload_size), d_eof(eof), d_wait(wait), - d_socket(-1), - d_temp_offset(0) + d_socket(-1) { int ret = 0; #if defined(USING_WINSOCK) // for Windows (with MinGW) @@ -128,10 +127,19 @@ rtl_tcp_source_f::rtl_tcp_source_f(size_t itemsize, // FIXME leaks if report_error throws below d_temp_buff = new unsigned char[d_payload_size]; // allow it to hold up to payload_size bytes - d_LUT= new float[0xff+1]; - for(int i=0; i <=(0xff);++i){ - d_LUT[i] = (((float)(i&0xff))-127.4f)*(1.0f/128.0f); - } + + d_LUT = new gr_complex[0xffff+1]; + // create a lookup table for gr_complex values + for (unsigned int i = 0; i <= 0xffff; i++) { +#ifdef BOOST_LITTLE_ENDIAN + d_LUT[i] = gr_complex( (float(i >> 8) - 127.4f) * (1.0f/128.0f), + (float(i & 0xff) - 127.4f) * (1.0f/128.0f) ); +#else // BOOST_BIG_ENDIAN + d_LUT[i] = gr_complex( (float(i & 0xff) - 127.4f) * (1.0f/128.0f), + (float(i >> 8) - 127.4f) * (1.0f/128.0f) ); +#endif + } + // create socket d_socket = socket(ip_src->ai_family, ip_src->ai_socktype, ip_src->ai_protocol); @@ -214,6 +222,7 @@ rtl_tcp_source_f_sptr make_rtl_tcp_source_f (size_t itemsize, rtl_tcp_source_f::~rtl_tcp_source_f () { delete [] d_temp_buff; + delete [] d_LUT; if (d_socket != -1){ shutdown(d_socket, SHUT_RDWR); @@ -235,11 +244,19 @@ int rtl_tcp_source_f::work (int noutput_items, gr_vector_const_void_star &input_items, gr_vector_void_star &output_items) { - float *out = (float *) output_items[0]; - ssize_t r=0, nbytes=0, bytes_received=0; - ssize_t total_bytes = (ssize_t)(d_itemsize*noutput_items); + gr_complex *out = (gr_complex *) output_items[0]; + size_t remaining = 0; + + int bytesleft; + + if( noutput_items * 2 < d_payload_size) { + bytesleft = noutput_items * 2; + remaining = noutput_items; + } else { + remaining = d_payload_size >> 1; + bytesleft = d_payload_size; + } - int bytesleft = noutput_items; int index = 0; int receivedbytes = 0; while(bytesleft > 0) { @@ -252,12 +269,12 @@ int rtl_tcp_source_f::work (int noutput_items, bytesleft -= receivedbytes; index += receivedbytes; } - r = noutput_items; + remaining = noutput_items; - for(int i=0; i