hackrf_source: Truncate serial numbers to 16 chars when enumerating, parse USB board IDs correctly

Signed-off-by: Heikki Hannikainen <hessu@hes.iki.fi>
This commit is contained in:
Heikki Hannikainen 2015-02-24 12:31:46 +02:00 committed by Dimitri Stolnikov
parent 8e6ecd0644
commit 592a814bdb
1 changed files with 8 additions and 5 deletions

View File

@ -383,13 +383,16 @@ std::vector<std::string> hackrf_source_c::get_devices()
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 );
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);
args = "hackrf=" + serial;
} else
args = "hackrf"; /* will pick the first one, serial number is required for choosing a specific one */
label = "HackRF ";
label += hackrf_board_id_name(hackrf_board_id( list->product_ids[i] ));
label += hackrf_usb_board_id_name( list->usb_board_ids[i] );
boost::algorithm::trim(label);