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

Allow retires for USB claim interface + Increase FW update UT stability #10152

Merged
merged 4 commits into from
Jan 16, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
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
31 changes: 28 additions & 3 deletions src/libusb/handle-libusb.h
Original file line number Diff line number Diff line change
Expand Up @@ -93,11 +93,36 @@ namespace librealsense

usb_status claim_interface(uint8_t interface)
{

auto sts = libusb_claim_interface(_handle, interface);
if(sts != LIBUSB_SUCCESS)

if (sts != LIBUSB_SUCCESS)
{
auto rs_sts = libusb_status_to_rs(sts);
LOG_ERROR("failed to claim usb interface: " << (int)interface << ", error: " << usb_status_to_string.at(rs_sts));
// If we try to claim the USB device and get 'USB_STATUS_BUSY' error we will
// retry 2 times more with some short delay between each try
if( sts == LIBUSB_ERROR_BUSY )
{
auto retry_counter = 2;
do
{
LOG_WARNING( "failed to claim usb interface, interface "
<< (int)interface << ", is busy - retrying..." );
std::this_thread::sleep_for( std::chrono::milliseconds( 10 ) );

sts = libusb_claim_interface( _handle, interface );
if( sts == LIBUSB_SUCCESS )
{
LOG_DEBUG( "retrying success, interface = " << (int)interface );
return RS2_USB_STATUS_SUCCESS;
}
}
while( sts == LIBUSB_ERROR_BUSY && --retry_counter > 0 );
}

auto rs_sts = libusb_status_to_rs(sts);
LOG_ERROR( "failed to claim usb interface: "
<< (int)interface << ", error: "
<< usb_status_to_string.at( rs_sts ) );
return rs_sts;
}

Expand Down
2 changes: 1 addition & 1 deletion tools/fw-update/rs-fw-update.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ void list_devices(rs2::context ctx)
int main(int argc, char** argv) try
{
#ifdef BUILD_EASYLOGGINGPP
rs2::log_to_console(RS2_LOG_SEVERITY_ERROR);
rs2::log_to_console(RS2_LOG_SEVERITY_WARN);
maloel marked this conversation as resolved.
Show resolved Hide resolved
#endif

rs2::context ctx;
Expand Down