Re: [Libusbx-devel] [PATCH 0/2 for v1.0.13]: Add libusb_detach_kernel_driver_and_claim()

2012-09-12 Thread Hans de Goede
Hi, Note lots of s here to try and focus the discussion... On 09/12/2012 02:37 AM, Pete Batard wrote: > On 2012.09.11 09:25, Hans de Goede wrote: >> As said before, others have claim, others may get detach and I expect them >> to hit the same race-like issues too once they get detach ... > > T

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

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
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] Mac USB 3.0

2012-09-12 Thread Sean McBride
On Thu, 12 Jul 2012 16:08:51 -0700, Dave Camarillo said: >Hello, I was wondering what kinds testing has been done on Mac's with USB 3.0? We did cursory testing with our app (that currently ships with libusb 1.0.9rc3) and everything seemed fine, but it was only a quick test. Cheers, -- ___

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

[Libusbx-devel] Trouble with USB communication Windows

2012-09-12 Thread Eric Lundby
Hello, I have spent hours now trying to get communication working with a custom USB device on Windows using libusbx. I have communication working through a virtual com port so I believe the device is functioning as expected. My device reports that it has 3 interfaces (0, 1, 2) and a total of 5 op

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] Trouble with USB communication Windows

2012-09-12 Thread Tim Roberts
Eric Lundby wrote: > > I have spent hours now trying to get communication working with a > custom USB device on Windows using libusbx. I have communication > working through a virtual com port so I believe the device is > functioning as expected. > > My device reports that it has 3 interfaces (0, 1

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] Trouble with USB communication Windows

2012-09-12 Thread Eric Lundby
I'm not sure why it works like this but I found out what I was doing wrong shortly after posting my question. I was actually wasn't using the libusb driver (although I thought I tried this). I got it working by using the libusbK-inf-wizard.exe from libusbk. I replaced the driver with WinUSB.sys d

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 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 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] [PATCH 0/2 for v1.0.13]: Add libusb_detach_kernel_driver_and_claim()

2012-09-12 Thread Pete Batard
On 2012.09.12 10:51, Hans de Goede wrote: >> should we add a new API even if we >> expect at least one for the platforms we support never to have any use >> for it? > > Yes, I want libusbx to enable app writers to do whatever they envision > and their chosen platform makes possible, rather then off

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] [PATCH] Don't log an error message when cancel fails due to -ENODEV

2012-09-12 Thread Pete Batard
This patch and the doc/stderr update patch have now been pushed to mainline. I'm planning to add the fxload sample tomorrow, after a bit more testing on my end, and probably the controversial MaxPower -> bMaxPower one too, and then declare RC either tomorrow or Friday. I have also moved the pla

Re: [Libusbx-devel] [PATCH 0/2 for v1.0.13]: Add libusb_detach_kernel_driver_and_claim()

2012-09-12 Thread Orin Eman
On Wed, Sep 12, 2012 at 4:40 PM, Pete Batard wrote: > On 2012.09.12 10:51, Hans de Goede wrote: > >> should we add a new API even if we > >> expect at least one for the platforms we support never to have any use > >> for it? > > > > Yes, I want libusbx to enable app writers to do whatever they en

[Libusbx-devel] Urgent! Call libusb_handle_events_timeout_completed in multiple threading Asynchronous device I/O crash the application,

2012-09-12 Thread John Chen
Hi, I have the following code: 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
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 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 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 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