Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix duplicated serial numbers on MacOS #1841

Merged
merged 2 commits into from
Jun 10, 2018
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 9 additions & 5 deletions src/libuvc/libuvc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -139,6 +139,10 @@ namespace librealsense

libusb_free_config_descriptor(config);
}
else if (status < 0)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would avoid throwing from foreach_device block, since it will prevent you from discovering all devices.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I will remove it, as it throws on MacOS, and use the previous logic (no action)

{
throw linux_backend_exception(to_string() << "libusb_get_active_config_descriptor(...) returned " << libusb_error_name(status));
}
}
libusb_free_device_list(list, 1);
}
Expand Down