@@ -188,13 +188,20 @@ private int transfer(final DeviceHandle handle,
188188 final UsbEndpointDescriptor descriptor , final int type ,
189189 final ByteBuffer buffer ) throws UsbException
190190 {
191+ final byte address = descriptor .bEndpointAddress ();
192+ final int timeout = getConfig ().getTimeout ();
193+ final boolean in = this .pipe .getUsbEndpoint ().getDirection () ==
194+ UsbConst .ENDPOINT_DIRECTION_IN ;
191195 final IntBuffer transferred = IntBuffer .allocate (1 );
192196 int result ;
193197 if (type == UsbConst .ENDPOINT_TYPE_BULK )
194198 {
195- result = LibUsb .bulkTransfer (handle ,
196- descriptor .bEndpointAddress (), buffer , transferred ,
197- getConfig ().getTimeout ());
199+ do
200+ {
201+ result = LibUsb .bulkTransfer (handle , address , buffer ,
202+ transferred , timeout );
203+ }
204+ while (in && result == LibUsb .ERROR_TIMEOUT && !this .aborting );
198205 if (result < 0 )
199206 {
200207 throw new LibUsbException (
@@ -203,9 +210,12 @@ private int transfer(final DeviceHandle handle,
203210 }
204211 else if (type == UsbConst .ENDPOINT_TYPE_INTERRUPT )
205212 {
206- result = LibUsb .interruptTransfer (handle ,
207- descriptor .bEndpointAddress (), buffer , transferred ,
208- getConfig ().getTimeout ());
213+ do
214+ {
215+ result = LibUsb .interruptTransfer (handle , address , buffer ,
216+ transferred , timeout );
217+ }
218+ while (in && result == LibUsb .ERROR_TIMEOUT && !this .aborting );
209219 if (result < 0 )
210220 {
211221 throw new LibUsbException (
0 commit comments