From 0a4b9264a3a9d8d9a8e42887fdfc045f41be3963 Mon Sep 17 00:00:00 2001 From: Dimitri Stolnikov Date: Sat, 5 May 2012 17:40:23 +0200 Subject: [PATCH] rtl_source_c: add buffers argument --- grc/gen_osmosdr_blocks.py | 16 +++++++++++----- lib/rtl/rtl_source_c.cc | 16 +++++++++++++--- 2 files changed, 24 insertions(+), 8 deletions(-) diff --git a/grc/gen_osmosdr_blocks.py b/grc/gen_osmosdr_blocks.py index 901d9e4..36cfb73 100644 --- a/grc/gen_osmosdr_blocks.py +++ b/grc/gen_osmosdr_blocks.py @@ -99,6 +99,11 @@ self.\$(id).set_antenna(\$ant$(n), $n) The OsmoSDR $sourk.title() block: +While primarily being developed for the OsmoSDR hardware, this block also +supports the FunCube Dongle, Ettus UHD, rtl-sdr radios and cfile source. +By using the OsmoSDR block you can take advantage of a common software api in +your application(s) independent of the underlying radio hardware. + Output Type: This parameter controls the data type of the stream in gnuradio. @@ -109,7 +114,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_xtal=28.80001e6,tuner_xtal=26e6 ... + rtl=0 rtl=1 rtl=2,rtl_xtal=28.80001e6,tuner_xtal=26e6,buffers=64 ... uhd=0|name,mcr=52e6,nchan=2,subdev='\\\\'B:0 A:0'\\\\' ... osmosdr=0|name,mcr=64e6,nchan=5,port=/dev/ttyUSB0 ... file=/path/to/file.ext,freq=428e6,rate=1e6,repeat=true,throttle=true @@ -127,19 +132,20 @@ Freq. Corr.: The frequency correction factor in parts per million (ppm). Leave 0 if unknown. Gain: -Overall gain of the device's signal path. For the gain setting to apply the -manual gain mode must be enabled first for some devices (namely rtlsdr). +Overall gain of the device's signal path. For the new gain value to be applied, +the manual gain mode must be enabled first. Gain Mode: -Chooses between the manual (default) and automatc gain mode where appropriate. +Chooses between the manual (default) and automatic gain mode where appropriate. Currently, only rtlsdr devices support automatic gain mode. Antenna: For devices with only one antenna, this may be left blank. Otherwise, the user should specify one of the possible antenna choices. -See the OsmoSDR manual for more detailed documentation: +See the OsmoSDR project page for more detailed documentation: http://sdr.osmocom.org/trac/ +http://sdr.osmocom.org/trac/wiki/GrOsmoSDR """ diff --git a/lib/rtl/rtl_source_c.cc b/lib/rtl/rtl_source_c.cc index c2e3b88..f6c298c 100644 --- a/lib/rtl/rtl_source_c.cc +++ b/lib/rtl/rtl_source_c.cc @@ -43,7 +43,8 @@ using namespace boost::assign; -#define BUF_SIZE (16 * 32 * 512) +#define BUF_SIZE (16 * 32 * 512) +#define BUF_NUM 32 /* * Create a new instance of rtl_source_c and return @@ -91,7 +92,16 @@ rtl_source_c::rtl_source_c (const std::string &args) if (dict.count("tuner_xtal")) tuner_freq = (unsigned int)boost::lexical_cast< double >( dict["tuner_xtal"] ); - _buf_num = 32; + _buf_num = BUF_NUM; + + if (dict.count("buffers")) { + _buf_num = (unsigned int)boost::lexical_cast< double >( dict["buffers"] ); + if (0 == _buf_num) + _buf_num = BUF_NUM; + std::cerr << "Using " << _buf_num << " buffers of size " << BUF_SIZE << "." + << std::endl; + } + _buf = (unsigned short **) malloc(_buf_num * sizeof(unsigned short *)); for(unsigned int i = 0; i < _buf_num; ++i) @@ -112,7 +122,7 @@ rtl_source_c::rtl_source_c (const std::string &args) } if ( dev_index >= rtlsdr_get_device_count() ) - throw std::runtime_error("Device index out of bounds for rtlsdr."); + throw std::runtime_error("Wrong rtlsdr device index given."); std::cerr << "Using device #" << dev_index << " " << "(" << rtlsdr_get_device_name(dev_index) << ")"