Skip to content

Bugfix infinite timeout #390

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

Closed
wants to merge 4 commits into from
Closed
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
10 changes: 5 additions & 5 deletions src/tilt.c
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ int get_reply(libusb_device_handle* dev, freenect_context *ctx){
memset(buffer, 0, 512);
int transferred = 0;
int res = 0;
res = libusb_bulk_transfer(dev, 0x81, buffer, 512, &transferred, 0);
res = libusb_bulk_transfer(dev, 0x81, buffer, 512, &transferred, 100);
if (res != 0) {
FN_ERROR("get_reply(): libusb_bulk_transfer failed: %d (transferred = %d)\n", res, transferred);
} else if (transferred != 12) {
Expand Down Expand Up @@ -112,12 +112,12 @@ int update_tilt_state_alt(freenect_device *dev){
unsigned char buffer[256];
memcpy(buffer, &cmd, 16);

res = libusb_bulk_transfer(dev->usb_audio.dev, 0x01, buffer, 16, &transferred, 0);
res = libusb_bulk_transfer(dev->usb_audio.dev, 0x01, buffer, 16, &transferred, 250);
if (res != 0) {
return res;
}

res = libusb_bulk_transfer(dev->usb_audio.dev, 0x81, buffer, 256, &transferred, 0); // 104 bytes
res = libusb_bulk_transfer(dev->usb_audio.dev, 0x81, buffer, 256, &transferred, 250); // 104 bytes
if (res != 0) {
return res;
} else {
Expand Down Expand Up @@ -209,7 +209,7 @@ int freenect_set_tilt_degs_alt(freenect_device *dev, int tilt_degrees)
unsigned char buffer[20];
memcpy(buffer, &cmd, 20);

res = libusb_bulk_transfer(dev->usb_audio.dev, 0x01, buffer, 20, &transferred, 0);
res = libusb_bulk_transfer(dev->usb_audio.dev, 0x01, buffer, 20, &transferred, 250);
if (res != 0) {
FN_ERROR("freenect_set_tilt_alt(): libusb_bulk_transfer failed: %d (transferred = %d)\n", res, transferred);
return res;
Expand Down Expand Up @@ -281,7 +281,7 @@ FN_INTERNAL int fnusb_set_led_alt(libusb_device_handle * dev, freenect_context *
unsigned char buffer[20];
memcpy(buffer, &cmd, 20);

res = libusb_bulk_transfer(dev, 0x01, buffer, 20, &transferred, 0);
res = libusb_bulk_transfer(dev, 0x01, buffer, 20, &transferred, 100);
if (res != 0) {
FN_WARNING("fnusb_set_led_alt(): libusb_bulk_transfer failed: %d (transferred = %d)\n", res, transferred);
return res;
Expand Down
9 changes: 9 additions & 0 deletions src/usb_libusb10.c
Original file line number Diff line number Diff line change
Expand Up @@ -277,6 +277,14 @@ FN_INTERNAL int fnusb_open_subdevices(freenect_device *dev, int index)
if( res != 0 ){
FN_ERROR("Failed to set the LED of K4W or 1473 device: %d\n", res);
}else{

//we need to do this as it is possible that the device was not closed properly in a previous session
//if we don't do this and the device wasn't closed properly - it can cause infinite hangs on LED and TILT functions
libusb_reset_device(audioHandle);
libusb_close(audioHandle);

res = libusb_open(audioDevice, &audioHandle);
if( res == 0 ){
res = libusb_claim_interface(audioHandle, 0);
if( res != 0 ){
FN_ERROR("Unable to claim interface %d\n", res);
Expand All @@ -287,6 +295,7 @@ FN_INTERNAL int fnusb_open_subdevices(freenect_device *dev, int index)
libusb_close(audioHandle);
}
}
}
#else
//Legacy: For older versions of libusb we use this approach which doesn't do well when multiple K4W or 1473 devices are attached to the system.
//lets also set the LED ON
Expand Down