java serial I/O: handling USB serial connection/disconnection in a robust manner
- by Jason S
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?