diff options
author | Dimitri Stolnikov <horiz0n@gmx.net> | 2013-12-10 16:59:01 +0100 |
---|---|---|
committer | Dimitri Stolnikov <horiz0n@gmx.net> | 2014-01-26 16:29:48 +0100 |
commit | 03f95329451ca1a981443103a145c416d3264c12 (patch) | |
tree | 23109348ae12af6e57a9d1f9e1eabb84c537304d | |
parent | 0e6a369df7736a1123783fbc63791c838da5832d (diff) |
device: implement "nofake" hint to exclude dummy devices from discovery
usage example:
osmosdr::device_t hint( "nofake" );
osmosdr::devices_t devs = osmosdr::device::find( hint );
-rw-r--r-- | include/osmosdr/osmosdr_device.h | 3 | ||||
-rw-r--r-- | lib/file/file_source_c.cc | 13 | ||||
-rw-r--r-- | lib/file/file_source_c.h | 2 | ||||
-rw-r--r-- | lib/osmosdr_device.cc | 11 | ||||
-rw-r--r-- | lib/rtl_tcp/rtl_tcp_source_c.cc | 11 | ||||
-rw-r--r-- | lib/rtl_tcp/rtl_tcp_source_c.h | 2 |
6 files changed, 28 insertions, 14 deletions
diff --git a/include/osmosdr/osmosdr_device.h b/include/osmosdr/osmosdr_device.h index 1f59751..126f368 100644 --- a/include/osmosdr/osmosdr_device.h +++ b/include/osmosdr/osmosdr_device.h @@ -101,6 +101,9 @@ namespace osmosdr { * The device hint should be used to narrow down the search * to particular transport types and/or transport arguments. * + * The device hint "nofake" switches off dummy devices created + * by "file" (and other) implementations. + * * \param hint a partially (or fully) filled in logical device * \return a vector of logical devices for all radios on the system */ diff --git a/lib/file/file_source_c.cc b/lib/file/file_source_c.cc index 059c2d1..ceb6dd1 100644 --- a/lib/file/file_source_c.cc +++ b/lib/file/file_source_c.cc @@ -101,14 +101,17 @@ std::string file_source_c::name() return "IQ File Source"; } -std::vector<std::string> file_source_c::get_devices() +std::vector<std::string> file_source_c::get_devices( bool fake ) { std::vector<std::string> devices; - std::string args = "file='/path/to/your/file'"; - args += ",rate=1e6,freq=100e6,repeat=true,throttle=true"; - args += ",label='Complex Sampled (IQ) File'"; - devices.push_back( args ); + if ( fake ) + { + std::string args = "file='/path/to/your/file'"; + args += ",rate=1e6,freq=100e6,repeat=true,throttle=true"; + args += ",label='Complex Sampled (IQ) File'"; + devices.push_back( args ); + } return devices; } diff --git a/lib/file/file_source_c.h b/lib/file/file_source_c.h index 4679b5a..e7bc067 100644 --- a/lib/file/file_source_c.h +++ b/lib/file/file_source_c.h @@ -45,7 +45,7 @@ public: std::string name(); - static std::vector< std::string > get_devices(); + static std::vector< std::string > get_devices( bool fake = false ); size_t get_num_channels( void ); diff --git a/lib/osmosdr_device.cc b/lib/osmosdr_device.cc index 6941a9d..55fa20d 100644 --- a/lib/osmosdr_device.cc +++ b/lib/osmosdr_device.cc @@ -119,6 +119,11 @@ devices_t device::find(const device_t &hint) { boost::mutex::scoped_lock lock(_device_mutex); + bool fake = true; + + if ( hint.count("nofake") ) + fake = false; + devices_t devices; #ifdef ENABLE_OSMOSDR @@ -150,7 +155,7 @@ devices_t device::find(const device_t &hint) devices.push_back( device_t(dev) ); #endif #ifdef ENABLE_NETSDR - BOOST_FOREACH( std::string dev, netsdr_source_c::get_devices( true ) ) + BOOST_FOREACH( std::string dev, netsdr_source_c::get_devices( fake ) ) devices.push_back( device_t(dev) ); #endif @@ -159,11 +164,11 @@ devices_t device::find(const device_t &hint) * in a graphical interface etc... */ #ifdef ENABLE_RTL_TCP - BOOST_FOREACH( std::string dev, rtl_tcp_source_c::get_devices() ) + BOOST_FOREACH( std::string dev, rtl_tcp_source_c::get_devices( fake ) ) devices.push_back( device_t(dev) ); #endif #ifdef ENABLE_FILE - BOOST_FOREACH( std::string dev, file_source_c::get_devices() ) + BOOST_FOREACH( std::string dev, file_source_c::get_devices( fake ) ) devices.push_back( device_t(dev) ); #endif diff --git a/lib/rtl_tcp/rtl_tcp_source_c.cc b/lib/rtl_tcp/rtl_tcp_source_c.cc index 392d98b..19747ff 100644 --- a/lib/rtl_tcp/rtl_tcp_source_c.cc +++ b/lib/rtl_tcp/rtl_tcp_source_c.cc @@ -149,13 +149,16 @@ std::string rtl_tcp_source_c::name() return "RTL TCP Client"; } -std::vector<std::string> rtl_tcp_source_c::get_devices() +std::vector<std::string> rtl_tcp_source_c::get_devices( bool fake ) { std::vector<std::string> devices; - std::string args = "rtl_tcp=localhost:1234"; - args += ",label='RTL-SDR Spectrum Server'"; - devices.push_back( args ); + if ( fake ) + { + std::string args = "rtl_tcp=localhost:1234"; + args += ",label='RTL-SDR Spectrum Server'"; + devices.push_back( args ); + } return devices; } diff --git a/lib/rtl_tcp/rtl_tcp_source_c.h b/lib/rtl_tcp/rtl_tcp_source_c.h index b452e68..aaeb515 100644 --- a/lib/rtl_tcp/rtl_tcp_source_c.h +++ b/lib/rtl_tcp/rtl_tcp_source_c.h @@ -46,7 +46,7 @@ public: std::string name(); - static std::vector< std::string > get_devices(); + static std::vector< std::string > get_devices( bool fake = false ); size_t get_num_channels( void ); |