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 );
This commit is contained in:
parent
750a0b4549
commit
5410ee53b2
|
@ -101,6 +101,9 @@ namespace osmosdr {
|
||||||
* The device hint should be used to narrow down the search
|
* The device hint should be used to narrow down the search
|
||||||
* to particular transport types and/or transport arguments.
|
* 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
|
* \param hint a partially (or fully) filled in logical device
|
||||||
* \return a vector of logical devices for all radios on the system
|
* \return a vector of logical devices for all radios on the system
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -119,6 +119,11 @@ devices_t device::find(const device_t &hint)
|
||||||
{
|
{
|
||||||
boost::mutex::scoped_lock lock(_device_mutex);
|
boost::mutex::scoped_lock lock(_device_mutex);
|
||||||
|
|
||||||
|
bool fake = true;
|
||||||
|
|
||||||
|
if ( hint.count("nofake") )
|
||||||
|
fake = false;
|
||||||
|
|
||||||
devices_t devices;
|
devices_t devices;
|
||||||
|
|
||||||
#ifdef ENABLE_OSMOSDR
|
#ifdef ENABLE_OSMOSDR
|
||||||
|
@ -150,7 +155,7 @@ devices_t device::find(const device_t &hint)
|
||||||
devices.push_back( device_t(dev) );
|
devices.push_back( device_t(dev) );
|
||||||
#endif
|
#endif
|
||||||
#ifdef ENABLE_NETSDR
|
#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) );
|
devices.push_back( device_t(dev) );
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -159,11 +164,11 @@ devices_t device::find(const device_t &hint)
|
||||||
* in a graphical interface etc... */
|
* in a graphical interface etc... */
|
||||||
|
|
||||||
#ifdef ENABLE_RTL_TCP
|
#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) );
|
devices.push_back( device_t(dev) );
|
||||||
#endif
|
#endif
|
||||||
#ifdef ENABLE_FILE
|
#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) );
|
devices.push_back( device_t(dev) );
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
@ -102,14 +102,17 @@ std::string file_source_c::name()
|
||||||
return "IQ File Source";
|
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::vector<std::string> devices;
|
||||||
|
|
||||||
std::string args = "file='/path/to/your/file'";
|
if ( fake )
|
||||||
args += ",rate=1e6,freq=100e6,repeat=true,throttle=true";
|
{
|
||||||
args += ",label='Complex Sampled (IQ) File'";
|
std::string args = "file='/path/to/your/file'";
|
||||||
devices.push_back( args );
|
args += ",rate=1e6,freq=100e6,repeat=true,throttle=true";
|
||||||
|
args += ",label='Complex Sampled (IQ) File'";
|
||||||
|
devices.push_back( args );
|
||||||
|
}
|
||||||
|
|
||||||
return devices;
|
return devices;
|
||||||
}
|
}
|
||||||
|
|
|
@ -45,7 +45,7 @@ public:
|
||||||
|
|
||||||
std::string name();
|
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 );
|
size_t get_num_channels( void );
|
||||||
|
|
||||||
|
|
|
@ -151,13 +151,16 @@ std::string rtl_tcp_source_c::name()
|
||||||
return "RTL TCP Client";
|
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::vector<std::string> devices;
|
||||||
|
|
||||||
std::string args = "rtl_tcp=localhost:1234";
|
if ( fake )
|
||||||
args += ",label='RTL-SDR Spectrum Server'";
|
{
|
||||||
devices.push_back( args );
|
std::string args = "rtl_tcp=localhost:1234";
|
||||||
|
args += ",label='RTL-SDR Spectrum Server'";
|
||||||
|
devices.push_back( args );
|
||||||
|
}
|
||||||
|
|
||||||
return devices;
|
return devices;
|
||||||
}
|
}
|
||||||
|
|
|
@ -46,7 +46,7 @@ public:
|
||||||
|
|
||||||
std::string name();
|
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 );
|
size_t get_num_channels( void );
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue