|
|
@ -559,14 +559,15 @@ rtlsdr_device_t *find_known_device(uint16_t vid, uint16_t pid) |
|
|
|
uint32_t rtlsdr_get_device_count(void) |
|
|
|
uint32_t rtlsdr_get_device_count(void) |
|
|
|
{ |
|
|
|
{ |
|
|
|
int i; |
|
|
|
int i; |
|
|
|
|
|
|
|
libusb_context *ctx; |
|
|
|
libusb_device **list; |
|
|
|
libusb_device **list; |
|
|
|
uint32_t device_count = 0; |
|
|
|
uint32_t device_count = 0; |
|
|
|
struct libusb_device_descriptor dd; |
|
|
|
struct libusb_device_descriptor dd; |
|
|
|
ssize_t cnt; |
|
|
|
ssize_t cnt; |
|
|
|
|
|
|
|
|
|
|
|
libusb_init(NULL); |
|
|
|
libusb_init(&ctx); |
|
|
|
|
|
|
|
|
|
|
|
cnt = libusb_get_device_list(NULL, &list); |
|
|
|
cnt = libusb_get_device_list(ctx, &list); |
|
|
|
|
|
|
|
|
|
|
|
for (i = 0; i < cnt; i++) { |
|
|
|
for (i = 0; i < cnt; i++) { |
|
|
|
libusb_get_device_descriptor(list[i], &dd); |
|
|
|
libusb_get_device_descriptor(list[i], &dd); |
|
|
@ -577,7 +578,7 @@ uint32_t rtlsdr_get_device_count(void) |
|
|
|
|
|
|
|
|
|
|
|
libusb_free_device_list(list, 0); |
|
|
|
libusb_free_device_list(list, 0); |
|
|
|
|
|
|
|
|
|
|
|
libusb_exit(NULL); |
|
|
|
libusb_exit(ctx); |
|
|
|
|
|
|
|
|
|
|
|
return device_count; |
|
|
|
return device_count; |
|
|
|
} |
|
|
|
} |
|
|
@ -585,15 +586,16 @@ uint32_t rtlsdr_get_device_count(void) |
|
|
|
const char *rtlsdr_get_device_name(uint32_t index) |
|
|
|
const char *rtlsdr_get_device_name(uint32_t index) |
|
|
|
{ |
|
|
|
{ |
|
|
|
int i; |
|
|
|
int i; |
|
|
|
|
|
|
|
libusb_context *ctx; |
|
|
|
libusb_device **list; |
|
|
|
libusb_device **list; |
|
|
|
struct libusb_device_descriptor dd; |
|
|
|
struct libusb_device_descriptor dd; |
|
|
|
rtlsdr_device_t *device = NULL; |
|
|
|
rtlsdr_device_t *device = NULL; |
|
|
|
uint32_t device_count = 0; |
|
|
|
uint32_t device_count = 0; |
|
|
|
ssize_t cnt; |
|
|
|
ssize_t cnt; |
|
|
|
|
|
|
|
|
|
|
|
libusb_init(NULL); |
|
|
|
libusb_init(&ctx); |
|
|
|
|
|
|
|
|
|
|
|
cnt = libusb_get_device_list(NULL, &list); |
|
|
|
cnt = libusb_get_device_list(ctx, &list); |
|
|
|
|
|
|
|
|
|
|
|
for (i = 0; i < cnt; i++) { |
|
|
|
for (i = 0; i < cnt; i++) { |
|
|
|
libusb_get_device_descriptor(list[i], &dd); |
|
|
|
libusb_get_device_descriptor(list[i], &dd); |
|
|
@ -610,7 +612,7 @@ const char *rtlsdr_get_device_name(uint32_t index) |
|
|
|
|
|
|
|
|
|
|
|
libusb_free_device_list(list, 0); |
|
|
|
libusb_free_device_list(list, 0); |
|
|
|
|
|
|
|
|
|
|
|
libusb_exit(NULL); |
|
|
|
libusb_exit(ctx); |
|
|
|
|
|
|
|
|
|
|
|
if (device) |
|
|
|
if (device) |
|
|
|
return device->name; |
|
|
|
return device->name; |
|
|
|