Fazecast / jSerialComm

Platform-independent serial port access for Java
GNU Lesser General Public License v3.0
1.35k stars 287 forks source link

Serial port randomly hangs during close #299

Closed armando-65 closed 2 years ago

armando-65 commented 4 years ago

Hi all. I'm Armando and I'm using JSerialComm v. 2.6.0. I use the method “addDataListener” to assign a listener object to the data incoming from the serial port. The data comes in continuous mode from the serial port, about 1 Kb/sec. When I close the serial port, sometimes the application hangs. Taking a look to the source code of com.fazecast.jSerialComm.SerialPort and adding some lines to log, I noted that the applicatione hangs here:

                       serialEventThread.join(500);
                      if (serialEventThread.isAlive())
                             serialEventThread.interrupt();
                      // Commenting next lines fixed my problem
                      //serialEventThread.join();

Once I've commented the last line, the call to the method join(), the problem disappeared. I have the same issue in 3 PC Windows 10 and a ubuntu server. I'll be happy to give you further informations, if you need.

hedgecrw commented 3 years ago

Please test the attached library version on your non-Windows machine and see if it works any better for you. There have been a ton of recent changes that have not made it into an actual release yet. Thanks!

https://drive.google.com/file/d/1hH2hXCEj39WUN1iz3F1TzLrpNvUro_aL/view?usp=sharing

I will add a Windows-enabled version for testing soon as well.

hedgecrw commented 3 years ago

Please actually test using this version of the library (all OS's are now enabled): https://drive.google.com/file/d/1QzWPJg5MU_2YrnsB1MsOWeTbjYD84D2h/view?usp=sharing

hedgecrw commented 2 years ago

Closing as a duplicate of #297 which is actively being discussed/resolved.