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 does not work.
       struct timeval tv = { 1, 0 };
       int completed =0;

      err = libusb_handle_events_timeout_completed(NULL, &tv,&completed );
    cout <<  ++cnt << "Bulk Transfer call
 libusb_handle_events_timeout,completed value is " << completed <<
std::endl;
 }

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:

1 Bulk Transfer call  libusb_handle_events_timeout,completed value is 0
2 Bulk Transfer call  libusb_handle_events_timeout,completed value is 0
3 Bulk Transfer call  libusb_handle_events_timeout,completed value is 0
....
400Bulk Transfer call  libusb_handle_events_timeout,completed value is 0
...
somehow the callback is never called.


2) If I  lock a shared critical_section in the beginning of the transfer
function,(That means I am running single thread, I am serialize the call)
it takes 4-5 calls for libusb_handle_events_timeout to call the callback
and exit the loop. this is the case even when 0 byte is read.

3) If I  lock a shared critical_section before the calls to
libusb_handle_events_timeout_completed, the behavior is worst than the
first Scenario,
it stuck even in a very simple case.

Any suggestions?
thx
 On Wed, Sep 12, 2012 at 9:49 AM, Tim Roberts <t...@probo.com> wrote:

> 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?
>
> What DO you see?  Is there an error, or does it simply never return?
> How many bytes are you trying to read?  What is the value of "endpoint"?
>
> --
> Tim Roberts, t...@probo.com
> Providenza & Boekelheide, Inc.
>
>
>
> ------------------------------------------------------------------------------
> 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

Reply via email to