Closed gchauvet closed 4 years ago
Note: same issue in a non threaded execution way
The crash-JVM-upon-USB-disconnect is has been an issue with RXTX for years (I ran into it in 2009 and 2010) and has never been properly addressed to my knowledge. It's the reason why I stopped using RXTX completely and migrated to PureJavaComm which does not have this issue.
I hope someone is able to fix this issue.
The work around i have used for a long time for this is:
I have a consumer serial device i ship with this lib, and the use case of pulling it before disconnecting was a primary concern. I have never dived into the JNI to attempt to put this robustness into the place where the error occurs, but this workaround provides the expected results for my application.
when you detect the disconnect, set the stream to null and disconnect
It's been several years since I was working with RXTX or NRJavaSerial, but from what I remember, this was possible in certain cases and not possible in others -- again, see http://marc.info/?l=rxtx&m=128896796230399&w=2. Low data rates (NOT baud rates -- you can have a 4.375Mbaud connection and only send a few hundred bytes per second if you want) made it easier to catch and recover; high data rates made it harder. There was a guy on the RXTX mailing list (Mariusz) that claimed he could always workaround the disconnect crash issue, but he was using low data rates and I was using high data rates. I was able to reproduce his method on low data rates, but unfortunately never got around to exploring in detail before I left my previous job along with my sample code.
Using PureJavaComm solve my issue :+1: But I've small differences : timeout threshold works like Linux. I define it at 500ms as describe here
this issue resolved as part of #75
Dear NRJavaSerial devs,
We have an issue with NRJavaSerial library who crash our JRE (1.6.31-33, compulsory). This issue occurs on physical or virtual serial port (same behaviour).
Below a full sample to the our issue:
Now we test our hardware connected on a COM4 physical serial port:
JVM crash report: