From 755ff8298442b58b390f9336bd80d6fa39c71f7e Mon Sep 17 00:00:00 2001 From: Evgeni Raikhel Date: Wed, 6 Jun 2018 12:37:23 +0300 Subject: [PATCH 1/2] Fix duplicated serial numbers on MacOS. Also adresses no SR300 available, MacOS and libuvc in general. tracked on DSO-9231 --- src/libuvc/libuvc.cpp | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/src/libuvc/libuvc.cpp b/src/libuvc/libuvc.cpp index 3a1da3d568..481b585609 100644 --- a/src/libuvc/libuvc.cpp +++ b/src/libuvc/libuvc.cpp @@ -113,16 +113,16 @@ namespace librealsense { // Obtain libusb_device_handle for each device libusb_device ** list = nullptr; - int status = libusb_get_device_list(usb_context, &list); + auto devices = libusb_get_device_list(usb_context, &list); - if(status < 0) - throw linux_backend_exception(to_string() << "libusb_get_device_list(...) returned " << libusb_error_name(status)); + if(devices < 0) + throw linux_backend_exception(to_string() << "libusb_get_device_list(...) returned " << libusb_error_name(devices)); - for(int i=0; i < status; ++i) + for(int i=0; i < devices; ++i) { libusb_device * usb_device = list[i]; libusb_config_descriptor *config; - status = libusb_get_active_config_descriptor(usb_device, &config); + auto status = libusb_get_active_config_descriptor(usb_device, &config); if(status == 0) { auto parent_device = libusb_get_parent(usb_device); @@ -139,6 +139,10 @@ namespace librealsense libusb_free_config_descriptor(config); } + else if (status < 0) + { + throw linux_backend_exception(to_string() << "libusb_get_active_config_descriptor(...) returned " << libusb_error_name(status)); + } } libusb_free_device_list(list, 1); } From b3f3ffe6c75b402091dc8377bac7964f33058329 Mon Sep 17 00:00:00 2001 From: icarpis Date: Wed, 6 Jun 2018 16:46:15 +0300 Subject: [PATCH 2/2] Correct libusb registration flow - prevent throws --- src/libuvc/libuvc.cpp | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/libuvc/libuvc.cpp b/src/libuvc/libuvc.cpp index 481b585609..8cabb5383d 100644 --- a/src/libuvc/libuvc.cpp +++ b/src/libuvc/libuvc.cpp @@ -139,10 +139,6 @@ namespace librealsense libusb_free_config_descriptor(config); } - else if (status < 0) - { - throw linux_backend_exception(to_string() << "libusb_get_active_config_descriptor(...) returned " << libusb_error_name(status)); - } } libusb_free_device_list(list, 1); }