Fazecast / jSerialComm

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

SerialPort.getCommPort(<portName>) failing when invoked from multiple JRE instances #412

Closed peter-jacobs-tpl closed 2 years ago

peter-jacobs-tpl commented 2 years ago

OS: Windows 10 and 11

JSerialComm version: 2.9.0 and 2.9.1

The following exception occurs when the third instance of an application using JSerialComm loads:

java.lang.UnsatisfiedLinkError: com.fazecast.jSerialComm.SerialPort.retrievePortDetails()V at com.fazecast.jSerialComm.SerialPort.retrievePortDetails(Native Method)

The first and second instances work as expected. All are configured to use a unique and valid COM port. It doesn't matter in which order they are started, the third always fails.

Workaround: regress to JSerialComm 2.8.5.

peter-jacobs-tpl commented 2 years ago

Forgot to mention the following:

Java version 8, 32 bit.

NorbertSandor commented 2 years ago

Use this system property with a unique application ID for each application instance: -Dfazecast.jSerialComm.appid=xyz

Documentation: https://github.com/Fazecast/jSerialComm/blob/master/README.md#usage

If you intend to use the library in multiple applications simultaneously, please make sure to set the fazecast.jSerialComm.appid property before accessing the SerialPort class so that applications don't accidentally delete each others' temporary files during boot-up:

System.setProperty("fazecast.jSerialComm.appid", "YOUR_APPLICATION_IDENTIFIER")