java serial I/O: handling USB serial connection/disconnection in a robust manner

Posted by Jason S on Stack Overflow See other posts from Stack Overflow or by Jason S
Published on 2010-01-26T21:52:08Z Indexed on 2010/03/12 9:27 UTC
Read the original article Hit count: 678

Filed under:
|
|
|

I'm using rxtx for serial I/O handling in Java with an FTDI2232H that provides a USB comm port. It works great, with one exception: if I unplug the USB cable, so that the COM port disappears at runtime, it spews exceptions left and right:

java.io.IOException: No error in nativeavailable
at gnu.io.RXTXPort.nativeavailable(Native Method)
at gnu.io.RXTXPort$SerialInputStream.read(RXTXPort.java:1427)
at gnu.io.RXTXPort$SerialInputStream.read(RXTXPort.java:1339)

and when I re-plug the cable in again, it does not recover.

Is there any way to get rxtx to work properly with USB comm port connection/disconnection? (I've tried to post to the rxtx mailing list but for some strange reason I cannot send messages even though I am subscribed to the list. I've emailed the list admin and have gotten no response.)

If not, is there another serial I/O framework that does?

© Stack Overflow or respective owner

Related posts about java

Related posts about rxtx