hackrf device enumeration: Use only 6 characters of serial (should be unique per user?) and append it in device name

Signed-off-by: Heikki Hannikainen <hessu@hes.iki.fi>
soapy_support
Heikki Hannikainen 8 years ago committed by Dimitri Stolnikov
parent 592a814bdb
commit 485b02e615
  1. 11
      lib/hackrf/hackrf_source_c.cc

@ -382,18 +382,19 @@ std::vector<std::string> hackrf_source_c::get_devices()
hackrf_device_list_t *list = hackrf_device_list();
for (unsigned int i = 0; i < list->devicecount; i++) {
label = "HackRF ";
label += hackrf_usb_board_id_name( list->usb_board_ids[i] );
std::string args;
if (list->serial_numbers[i]) {
std::string serial = boost::lexical_cast< std::string >( list->serial_numbers[i] );
if (serial.length() > 16)
serial = serial.substr(serial.length() - 16, 16);
if (serial.length() > 6)
serial = serial.substr(serial.length() - 6, 6);
args = "hackrf=" + serial;
label += " " + serial;
} else
args = "hackrf"; /* will pick the first one, serial number is required for choosing a specific one */
label = "HackRF ";
label += hackrf_usb_board_id_name( list->usb_board_ids[i] );
boost::algorithm::trim(label);
args += ",label='" + label + "'";

Loading…
Cancel
Save