The timeout value for libusb_fill_bulk_transfer used to be 3 seconds,
now I set it to 15 seconds, it does not make any difference.
On Wed, Sep 12, 2012 at 9:00 PM, David Grant <davidgr...@gmail.com> wrote:
> On Wed, Sep 12, 2012 at 8:49 PM, John Chen <john...@gmail.com> wrote:
>
>> This approach just crash the app:
>>
>> DWORD WINAPI LibUSBDevice::LoopEvent(void* lpParam)
>> {
>> while (RunLoopCode)
>> {
>> try
>> {
>> Sleep(100);
>> struct timeval tv = { 1, 0 };
>> int completed =0;
>> //cout << "before libusb_handle_events_timeout " << std::endl;
>> int err = libusb_handle_events_timeout_completed(NULL, &tv,&completed );
>> //cout << "after libusb_handle_events_timeout " << std::endl;
>> if (err<0)
>> {
>> cout << "!!!!!!!!!!!!!!!!!!err calling done
>> libusb_handle_events_timeout!!!!!!!!!!!!" << std::endl;
>> }
>> }
>> catch (...)
>> {
>> cout << "!!!!!!!!!!!!unexpected exception!!!!!" << std::endl;
>> }
>>
>> }
>> return 0;
>> }
>>
>> This is in a seperator thread, which is always running, other threads
>> will call libusb_submit_transfer to submit read and write request
>> simultaneously.
>>
>> it crash the app, the stack trace are as following:
>>
>> winusb_abort_transfers+0xf6 [c:\program
>> files\libusbx-1.0.12\libusb\os\windows_usb.c @ 2863]
>> windows_abort_transfers+0x41 [c:\program
>> files\libusbx-1.0.12\libusb\os\windows_usb.c @ 1929]
>> windows_cancel_transfer+0x51 [c:\program
>> files\libusbx-1.0.12\libusb\os\windows_usb.c @ 1941]
>> libusb_cancel_transfer+0x54 [c:\program files\libusbx-1.0.12\libusb\io.c
>> @ 1358]
>> handle_timeout+0x35 [c:\program files\libusbx-1.0.12\libusb\io.c @ 1770]
>> handle_timeouts_locked+0x110 [c:\program files\libusbx-1.0.12\libusb\io.c
>> @ 1814]
>> handle_timeouts+0x38 [c:\program files\libusbx-1.0.12\libusb\io.c @ 1823]
>> handle_events+0x258 [c:\program files\libusbx-1.0.12\libusb\io.c @ 1897]
>> libusb_handle_events_timeout_completed+0x9e [c:\program
>> files\libusbx-1.0.12\libusb\io.c @ 2029]
>> LibUSBDevice::LoopEvent+0x62 [c:\USB\usb_io_native\libusbdevice.cpp @ 108]
>> KERNEL32!BaseThreadInitThunk+0xd
>> ntdll!RtlUserThreadStart+0x21
>> Asynchronous device I/O
>>
>> specifically, the following code:
>> if (!WinUsb_AbortPipe(winusb_handle, transfer->endpoint)) {
>> in windows_usb.c crash the app.
>>
>>
>>
> I'm not sure why it's crashing, but what is happening here is that in
> libusb_fill_bulk_transfer you are setting a timeout on the transfer, and
> that timeout has expired with no response from the device, so libusb is
> cancelling the transfer. You could try setting it higher. When we use
> libusb we always set that timeout (the transfer's timeout) to infinite and
> the transfer timeout is handling at a higher level, so I don't really have
> much experience with that.
>
> Dave
>
>
> ------------------------------------------------------------------------------
> Live Security Virtual Conference
> Exclusive live event will cover all the ways today's security and
> threat landscape has changed and how IT managers can respond. Discussions
> will include endpoint security, mobile security and the latest in malware
> threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
> _______________________________________________
> libusbx-devel mailing list
> libusbx-devel@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/libusbx-devel
>
>
------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and
threat landscape has changed and how IT managers can respond. Discussions
will include endpoint security, mobile security and the latest in malware
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
libusbx-devel mailing list
libusbx-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/libusbx-devel