1
0
mirror of https://github.com/f4exb/sdrangel.git synced 2026-06-02 06:04:39 -04:00

HackRF: open device by serial number

This commit is contained in:
f4exb
2017-04-14 02:09:36 +02:00
parent 01b2c42a5f
commit 0a29f34b94
4 changed files with 32 additions and 7 deletions
+27
View File
@@ -33,6 +33,33 @@ hackrf_device *DeviceHackRF::open_hackrf(int sequence)
return open_hackrf_from_sequence(sequence);
}
hackrf_device *DeviceHackRF::open_hackrf(const char * const serial)
{
hackrf_error rc;
// TODO: this may not work if several HackRF Devices are running concurrently. It should be handled globally in the application
rc = (hackrf_error) hackrf_init();
if (rc != HACKRF_SUCCESS)
{
fprintf(stderr, "DeviceHackRF::open_hackrf: failed to initiate HackRF library %s\n", hackrf_error_name(rc));
return 0;
}
hackrf_device *hackrf_ptr;
rc = (hackrf_error) hackrf_open_by_serial(serial, &hackrf_ptr);
if (rc == HACKRF_SUCCESS)
{
return hackrf_ptr;
}
else
{
return 0;
}
}
hackrf_device *DeviceHackRF::open_hackrf_from_sequence(int sequence)
{
hackrf_device_list_t *hackrf_devices = hackrf_device_list();