From 3ea0b388109bb8086418dbca62337cc18da420d7 Mon Sep 17 00:00:00 2001 From: Dimitri Stolnikov Date: Sun, 20 May 2012 12:30:28 +0200 Subject: introduce device discovery api This API allows to acquire a list of devices connected to the host and creates an argument string ready to be passed to a source object for cunstruction. Each device_t entry contains a "label" entry, which holds the generic device name which may be shown to the user for device selection. For certain radio hardware extended entries ("name", "serial", "type") may be available to make bijective device addressing possible. The argument string for target types "rtl_tcp" and "file" might be constructed using the osmosdr::device_t class facilities. Example: #include #include osmosdr::devices_t devs = osmosdr::device::find(); BOOST_FOREACH(osmosdr::device_t &dev, devs) // try to create each dev osmosdr_source_c_sptr src = osmosdr_make_source_c(dev.to_string()); --- lib/osmosdr_source_c_impl.cc | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'lib/osmosdr_source_c_impl.cc') diff --git a/lib/osmosdr_source_c_impl.cc b/lib/osmosdr_source_c_impl.cc index 0c43f74..129701e 100644 --- a/lib/osmosdr_source_c_impl.cc +++ b/lib/osmosdr_source_c_impl.cc @@ -96,7 +96,8 @@ osmosdr_source_c_impl::osmosdr_source_c_impl (const std::string &args) std::vector< std::string > dev_list; #ifdef ENABLE_OSMOSDR - // TODO: implement + BOOST_FOREACH( std::string dev, osmosdr_src_c::get_devices() ) + dev_list.push_back( dev ); #endif #ifdef ENABLE_FCD BOOST_FOREACH( std::string dev, fcd_source::get_devices() ) @@ -133,10 +134,10 @@ osmosdr_source_c_impl::osmosdr_source_c_impl (const std::string &args) if ( dict.count("osmosdr") ) { osmosdr_src_c_sptr src = osmosdr_make_src_c( arg ); -// for (size_t i = 0; i < src->get_num_channels(); i++) -// connect(src, i, self(), channel++); + for (size_t i = 0; i < src->get_num_channels(); i++) + connect(src, i, self(), channel++); -// _devs.push_back( src.get() ); // FIXME: implement interface + _devs.push_back( src.get() ); } #endif -- cgit v1.2.3