Re: [Libusbx-devel] asynchronous code in mufti-threading app

2012-09-17 Thread Pete Batard
On 2012.09.16 08:50, David Grant wrote: > On Sat, Sep 15, 2012 at 11:35 PM, John Chen > wrote: > Question: Does libusbx supports hotplug on Linux?? that's very > import to us. I dot not have to support hot plug in windows, but > I do need to suppor

Re: [Libusbx-devel] asynchronous code in mufti-threading app

2012-09-16 Thread Xiaofan Chen
On Sun, Sep 16, 2012 at 12:31 PM, John Chen wrote: > I followed your advice, installed LibUSBK, changed the driver from WinUSB > (v6.1.7600.16385) to libusbK (v3.0.4.0),libusb-win32 (v1.2.5.0), in both > cases, I can not even open the device, the error message is > LIBUSB_ERROR_NOT_SUPPORTED from

Re: [Libusbx-devel] asynchronous code in mufti-threading app

2012-09-16 Thread David Grant
On Sat, Sep 15, 2012 at 11:35 PM, John Chen wrote: > Oops! I forgot attache the trace file, here it is. > > > On Sat, Sep 15, 2012 at 9:31 PM, John Chen wrote: > >> Question: Does libusbx supports hotplug on Linux?? that's very import to >> us. I dot not have to support hot plug in windows, but

Re: [Libusbx-devel] asynchronous code in mufti-threading app

2012-09-15 Thread John Chen
Wow! I thought most of your guys are already retired or has millions of $ in retirement fund with no financial burden! I really admire your effort for spending your precious free time to help the community! Question: Does libusbx supports hotplug on Linux?? that's very import to us. I dot not have

Re: [Libusbx-devel] asynchronous code in mufti-threading app

2012-09-14 Thread Pete Batard
On 2012.09.14 04:42, John Chen wrote: > Pete, > I was wondering where you were? In a cubicle, where access to SF.net or personal e-mail accounts are actively prohibited, so that I can repay a mortgage... Freedom or money: pick one. > I have done the following: > 1) Download the latest from GIT >

Re: [Libusbx-devel] asynchronous code in mufti-threading app

2012-09-13 Thread Pete Batard
OK, a few things: 1. Testing with the latest git version would be nice. We added some modifications for timeout handling, and it's always good not to try to figure out that an issue is one that has already been addressed. I don't exactly expect yours to have been, but I wouldn't mind being sure.

Re: [Libusbx-devel] asynchronous code in mufti-threading app

2012-09-13 Thread John Chen
My OS is windows 7 64 bit. On Thu, Sep 13, 2012 at 1:10 AM, Xiaofan Chen wrote: > On Thu, Sep 13, 2012 at 12:18 PM, John Chen wrote: > > 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. > > > > What is th

Re: [Libusbx-devel] asynchronous code in mufti-threading app

2012-09-13 Thread Xiaofan Chen
On Thu, Sep 13, 2012 at 12:18 PM, John Chen wrote: > 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. > What is the OS used here? If you are using Windows XP 32 bit, try Windows Vista or 7 (32bit or 64bit) to

Re: [Libusbx-devel] asynchronous code in mufti-threading app

2012-09-12 Thread John Chen
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 wrote: > On Wed, Sep 12, 2012 at 8:49 PM, John Chen wrote: > >> This approach just crash the app: >> >> DWORD WINAPI

Re: [Libusbx-devel] asynchronous code in mufti-threading app

2012-09-12 Thread David Grant
On Wed, Sep 12, 2012 at 8:49 PM, John Chen 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_timeo

Re: [Libusbx-devel] asynchronous code in mufti-threading app

2012-09-12 Thread David Grant
On Wed, Sep 12, 2012 at 4:50 PM, John Chen wrote: > Oops! I was not understand " running multiple simultaneous event loops" > right, I thought in multi-threading app, of course you are running event > multiple time. > > Anyway, I created a new thread and it sees to fix the problem, but now I > am

Re: [Libusbx-devel] asynchronous code in mufti-threading app

2012-09-12 Thread John Chen
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

Re: [Libusbx-devel] asynchronous code in mufti-threading app

2012-09-12 Thread John Chen
Oops! I was not understand " running multiple simultaneous event loops" right, I thought in multi-threading app, of course you are running event multiple time. Anyway, I created a new thread and it sees to fix the problem, but now I am having a performance issue, in the new thread , I have while (

Re: [Libusbx-devel] asynchronous code in mufti-threading app

2012-09-12 Thread David Grant
On Wed, Sep 12, 2012 at 2:35 PM, John Chen wrote: > Tim, > > If I call the same code with one thread, it works without any problem. so > I believe it has something to do with how libusb work in multi-threading > code. > > Do you have any sample code how to handle multi-threading for libusb > asyn

Re: [Libusbx-devel] asynchronous code in mufti-threading app

2012-09-12 Thread John Chen
Tim, If I call the same code with one thread, it works without any problem. so I believe it has something to do with how libusb work in multi-threading code. Do you have any sample code how to handle multi-threading for libusb asynchronous operations? do I need to anything to protect call to lib

Re: [Libusbx-devel] asynchronous code in mufti-threading app

2012-09-12 Thread Tim Roberts
John Chen wrote: > Tim, I attache the usb debug trace and USB_Trace here. Yes, I did get > a timeout, but if you look at USBTrace.txt, it have the following: > > [libusb_get_next_timeout] no URB with timeout or all handled by OS; no > timeout! > do you need what it means? It looks like you are ru

Re: [Libusbx-devel] asynchronous code in mufti-threading app

2012-09-12 Thread Tim Roberts
John Chen wrote: > > Here is the problem > 1) in the following code. > ... > for some very simple multi-threading , it works, but in more > complicate case, the code stuck in the loop and I am getting the > following: > ... > somehow the callback is never called. We can't diagnose this. Ther

Re: [Libusbx-devel] asynchronous code in mufti-threading app

2012-09-12 Thread John Chen
Tim, Yes, LibUSBDevice::WriteCallback declared as static. Here is the problem 1) in the following code. int cnt=0; while (!userdata->ExitTransfer) { //I also added Lock here for the whole block here and to serialize the call to //libusb_handle_events_timeout_completed, but it still

Re: [Libusbx-devel] asynchronous code in mufti-threading app

2012-09-12 Thread Tim Roberts
John Chen wrote: > Hi, > My app needs be able to read & write (to different enpoint) at same > time, and my code is not working. but if I change the call to > Synchronous , everything works fine, could any one tell me what I did > wrong here? Is LibUSBDevice::WriteCallback declared as static? Wh

Re: [Libusbx-devel] asynchronous code in mufti-threading app

2012-09-12 Thread John Chen
Here is my callback void LIBUSB_CALL LibUSBDevice::WriteCallback(struct libusb_transfer *transfer) { CallBackData* data =(CallBackData*)transfer->user_data; data->ByteTransfered=transfer->actual_length; data->ErrorCode == transfer->status; data->ExitTransfer = true; cout << "__Call back

Re: [Libusbx-devel] asynchronous code in mufti-threading app

2012-09-12 Thread David Grant
On Tue, Sep 11, 2012 at 8:45 PM, John Chen wrote: > Hi, > My app needs be able to read & write (to different enpoint) at same time, > and my code is not working. but if I change the call to Synchronous > , everything works fine, could any one tell me what I did wrong here? > thx > > CallBackData

Re: [Libusbx-devel] asynchronous code in mufti-threading app

2012-09-12 Thread John Chen
no sure what my post is not showing up, I now post it again. On Tue, Sep 11, 2012 at 8:45 PM, John Chen wrote: > Hi, > My app needs be able to read & write (to different enpoint) at same time, > and my code is not working. but if I change the call to Synchronous > , everything works fine, coul