Well abortAllSubmissions shouldn't block forever.  Have you tried
debugging to find where abortAllSubmissions is blocking?

2008/11/2 Nurse, Brian <[email protected]>:
> I am using the Linux 1.0.1 implementation to communicate with a usb card
> reader. I am able to get things set up correctly and recieve data from the
> reader when a user swipes their card.
>
> I am using the blocking UsbPipe.syncSubmit call in a separate thread to get
> data from the reader and this works fine.
>
> My problem is that when I want to shut down my application cleanly, I am not
> able to shutdown the UsbPipe. If I just do a UsbPipe.close(), I get an
> exception thrown saying that I can't close a pipe with pending submissions.
> If I try to do a UsbPipe.abortAllSubmissions() this just blocks forever. If
> I try to send an interrupt to the thread containing the blocking call, it
> just seems to be ignored.
>
> My code to read the data from the input UsbPipe looks like this:
>
>         int bytesRead = 0;
>         while ((bytesRead == 0) && !m_StopFlag) {
>              DefaultUsbIrp irp = new DefaultUsbIrp(getReadBuffer());
>              irp.setAcceptShortPacket(true);
>              m_InputPipe.syncSubmit(irp);
>              bytesRead = irp.getActualLength();
>         }
>         if (!m_StopFlag) {
>             // incase buffer isn't full...
>             return createByteArray(getReadBuffer(), bytesRead);
>         }
>         return null;
> I also tried a variation with the asyncSubmit call but the number of bytes
> read was always 0 but I was able to shut down the UsbPipe cleanly this way
> via a UsbPipe.abortAllSubmissions().
>
>         int bytesRead = 0;
>         while ((bytesRead == 0) && !m_StopFlag) {
>              DefaultUsbIrp irp = new DefaultUsbIrp(getReadBuffer());
>              irp.setAcceptShortPacket(true);
>              m_InputPipe.asyncSubmit(irp);
>              bytesRead = irp.getActualLength();
>              if (bytesRead == 0) {
>                 Thread.yield();
>                 Thread.sleep(250);
>             }
>         }
> Any suggestions as to what I may be doing wrong would be appreciated.
>
> Brian
>
>
> -------------------------------------------------------------------------
> This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
> Build the coolest Linux based applications with Moblin SDK & win great
> prizes
> Grand prize is a trip for two to an Open Source event anywhere in the world
> http://moblin-contest.org/redirect.php?banner_id=100&url=/
> _______________________________________________
> javax-usb-devel mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/javax-usb-devel
>
>

------------------------------------------------------------------------------
_______________________________________________
javax-usb-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/javax-usb-devel

Reply via email to