Fazecast / jSerialComm

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

Fast reopen of a comm port fails #298

Closed doggy-dev closed 3 years ago

doggy-dev commented 4 years ago

If I open/close/open a comm port in only a couple of seconds (like 4s) then the SerialPort.openPort() returns false. My application runs under Linux. I'm happy to provide any further information if needed.

hedgecrw commented 3 years ago

Please test the attached library version 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

doggy-dev commented 3 years ago

Hello, thanks for the fix, but I must have solved the problem in some other way. I can't remember anymore. Because of pressing matters on other projects I'll not be able to test the fix.

hedgecrw commented 3 years ago

No worries, there are other issues in here dealing with closing/reopening a port, so this should get verified through those items.

A note for future users who see this thread, rapid closing/opening of a port is almost guaranteed to cause openPort() to return false every once in awhile. The reason is that calling closePort() actually hands off shutting down the port to a low-level driver installed on your OS which usually takes some amount of time to complete after returning from the application call. If openPort() is called again while the driver is still busy with a previous close task, the open call will fail. This is unavoidable in jSerialComm...a more serious bug is if openPort() always fails after a successful call to closePort().

Thanks!