hackrf_source: attempt device enumeration with hackrf_device_list

Signed-off-by: Heikki Hannikainen <hessu@hes.iki.fi>
soapy_support
Heikki Hannikainen 8 years ago committed by Dimitri Stolnikov
parent 69181b0e85
commit 8e6ecd0644
  1. 39
      lib/hackrf/hackrf_source_c.cc

@ -368,30 +368,38 @@ std::vector<std::string> hackrf_source_c::get_devices()
{
std::vector<std::string> devices;
std::string label;
#if 0
for (unsigned int i = 0; i < 1 /* TODO: missing libhackrf api */; i++) {
std::string args = "hackrf=" + boost::lexical_cast< std::string >( i );
{
boost::mutex::scoped_lock lock( _usage_mutex );
label.clear();
if ( _usage == 0 )
hackrf_init(); /* call only once before the first open */
label = "HackRF Jawbreaker"; /* TODO: missing libhackrf api */
_usage++;
}
#if 1
hackrf_device_list_t *list = hackrf_device_list();
for (unsigned int i = 0; i < list->devicecount; i++) {
std::string args;
if (list->serial_numbers[i])
args = "hackrf=" + boost::lexical_cast< std::string >( list->serial_numbers[i] );
else
args = "hackrf=" + boost::lexical_cast< std::string >( i );
label = "HackRF ";
label += hackrf_board_id_name(hackrf_board_id( list->product_ids[i] ));
boost::algorithm::trim(label);
args += ",label='" + label + "'";
devices.push_back( args );
}
hackrf_device_list_free(list);
#else
{
boost::mutex::scoped_lock lock( _usage_mutex );
if ( _usage == 0 )
hackrf_init(); /* call only once before the first open */
_usage++;
}
int ret;
hackrf_device *dev = NULL;
ret = hackrf_open(&dev);
@ -414,6 +422,8 @@ std::vector<std::string> hackrf_source_c::get_devices()
ret = hackrf_close(dev);
}
#endif
{
boost::mutex::scoped_lock lock( _usage_mutex );
@ -423,7 +433,6 @@ std::vector<std::string> hackrf_source_c::get_devices()
hackrf_exit(); /* call only once after last close */
}
#endif
return devices;
}

Loading…
Cancel
Save