diff -u libnxt.orig/main_jlibnxt.c libnxt/main_jlibnxt.c --- libnxt.orig/main_jlibnxt.c 2010-01-19 10:43:16.096079000 +0100 +++ libnxt/main_jlibnxt.c 2010-01-19 10:47:03.754465000 +0100 @@ -36,6 +36,13 @@ #define ETIMEDOUT 116 #endif +#if defined(__sun) +/* Enable workaround for broken usb timeout handling on + * Solaris. Currently only disables flushing of bulk endpoint on nxt_open + * and close. + */ +#define LIBUSB_TIMEOUT_BROKEN +#endif enum nxt_usb_ids { VENDOR_LEGO = 0x0694, @@ -169,10 +176,12 @@ return 0; } +#if !defined(LIBUSB_TIMEOUT_BROKEN) // Discard any data that is left in the buffer /* TODO: Check error code here, bad things may happen if not timeout */ while (usb_bulk_read(hdl, 0x82, buf, sizeof(buf), 1) > 0) ; +#endif return (long)hdl; } @@ -184,9 +193,11 @@ char buf[64]; struct usb_dev_handle *hdl = (struct usb_dev_handle *) hhdl; +#if !defined(LIBUSB_TIMEOUT_BROKEN) // Discard any data that is left in the buffer while (usb_bulk_read(hdl, 0x82, buf, sizeof(buf), 1) > 0) ; +#endif // Release interface. This is a little iffy we do not know which interface // we are actually using. Releasing both seems to work... but...