Tim,
This is the device that is working on Windows and has been in production for
years (with Windows API calles), I am not develop the device, what I am
doing is use the device, simple read & write.

The exactly the same code work when running in single-threaded app.

when look at my libUSB code, did you see anything that should be changed?

I do not currently have a USB Analyze for Linux Right, but I did ran the
same code in Windows and it crashed the app, not sure if it will help here.
I attached my debug output and USB Trace here.

Please let me know if you see anything.

Thx a lot.

Here is my previous post:



Pete, 
I was wondering where you were? Anywhere I am so glad you could help me out
on this  here ::)
I have done the following:
1) Download the latest from GIT 
2) Uncomment //#define DEBUG_POLL_WINDOWS" (line 51). in poll_windows.c:  ,
added a debug printout of winusb_handle and transfer->endpoint
3) recompiled libusbx as a static library
4) set LIBUSB_DEBUG=4, run the app, generate trace, please see
LibUSBDebugTrace.txt
5) I also downloaded libusbk dirver, but I am not sure how to use it, right
now I am using zadig_v2.0.1.154
6) I also added a lot of my own logging here, hopefully it will be helpful.
Please let me know if you need anything else from.

Thanks a lot.

Here are some of the related code.



DWORD WINAPI LibUSBDevice::LoopEvent(void* lpParam)
{
        while (RunLoopCode)
        {
                try
                {                       
                        struct timeval tv = { 0, 50000 };
                        int completed =0;
                        //cout << "before  libusb_handle_events_timeout " << 
std::endl; 
                        cout << "**********" << msg << "Before call
libusb_handle_events_timeout_completed***********" << std::endl;
                        //int err = 
libusb_handle_events_timeout_completed(NULL, &tv,&completed
);
                        int err=libusb_handle_events_completed(NULL,&completed) 
;
                        cout << "**********" << msg << "after call
libusb_handle_events_timeout_completed, error # is " << err << "
****************" << std::endl;
        
                        if (err<0)
                        {
                                cout << "!!!!!!!!!!!!!!!!!!err calling done
libusb_handle_events_timeout!!!!!!!!!!!!" << std::endl; 
                        }       
                }
                catch (...)
                {
                        cout << "!!!!!!!!!!!!unexpected exception!!!!!" << 
std::endl;
                }

        }
        return 0;
}

ErrNo LibUSBDevice::BulkRead(   
                                const ULONG                     c_ulPipeNum,    
// IN
                                const uint                      c_uiLength,     
        // IN 
                                DWORD*              bytesRead,      // IN       
                                uint* pbBuffer,                 // IN
                                HANDLE cancelEvent)                     
{
        const ULONG endpoint=0x80+c_ulPipeNum*2;
        ...
        err=libusb_submit_transfer(transfer);
        while (!userdata->ExitTransfer) 
        {
                cout << "Bulk Read waiting the call back,c_ulPipeNum:" << 
c_ulPipeNum <<
"c_uiLength:"  << c_uiLength << "............" << std::endl;
                Sleep(1000);    //note : change this number to 100 does not 
make any
difference                                                                      
 
        }
        cout << ++cnt << "****************** BulkRead read call 
libusb_handle_events_timeout;data->ByteTransfered:" <<
userdata->ByteTransfered << 
                ";ErrorCode ****************** ;" << userdata-> ErrorCode << 
std::endl;
        ...
}



int LibUSBDevice::BulkWrite(
        const unsigned long                     c_ulPipeNum,    
        const unsigned int                      c_uiLength,             
        uint * pbBuffer,                                
        HANDLE cancelEvent)     
{

        const unsigned long endpoint=c_ulPipeNum*2;
        m_lastOSErrorCode=libusb_submit_transfer(transfer);
        ...
        while (!userdata->ExitTransfer) 
        {
                Sleep(100); 
                cout << "Bulk Write waiting the call back,c_ulPipeNum:" << 
c_ulPipeNum <<
"c_uiLength:"  << c_uiLength << "............" << std::endl;
        }
        
        cout << ++cnt << "********** Bulk Write  call 
libusb_handle_events_timeout**********" << std::endl;
        ...

LibUSBDebugTrace.txt
<http://libusbx.1081486.n5.nabble.com/file/n225/LibUSBDebugTrace.txt>  
USBTraceLog.txt
<http://libusbx.1081486.n5.nabble.com/file/n225/USBTraceLog.txt>  



--
View this message in context: 
http://libusbx.1081486.n5.nabble.com/Libusbx-devel-asynchronous-code-in-multi-threading-app-tp222p225.html
Sent from the libusbx mailing list archive at Nabble.com.

------------------------------------------------------------------------------
Don't let slow site performance ruin your business. Deploy New Relic APM
Deploy New Relic app performance management and know exactly
what is happening inside your Ruby, Python, PHP, Java, and .NET app
Try New Relic at no cost today and get our sweet Data Nerd shirt too!
http://p.sf.net/sfu/newrelic-dev2dev
_______________________________________________
libusbx-devel mailing list
libusbx-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/libusbx-devel

Reply via email to