i got error in Raspberry pi . Arm64 environment
dhirajthaokar opened this issue · 5 comments
Exception in thread "Thread-9" java.lang.UnsatisfiedLinkError: 'long jssc.SerialNativeInterface.openPort(java.lang.String, boolean)'
at jssc.SerialNativeInterface.openPort(Native Method)
at jssc.SerialPort.openPort(SerialPort.java:158)
at com.intelligt.modbus.jlibmodbus.serial.SerialPortJSSC.open(SerialPortJSSC.java:58)
at com.intelligt.modbus.jlibmodbus.net.ModbusConnectionSerial.openImpl(ModbusConnectionSerial.java:60)
at com.intelligt.modbus.jlibmodbus.net.ModbusConnection.open(ModbusConnection.java:45)
at com.intelligt.modbus.jlibmodbus.slave.RequestHandlerSerial.run(RequestHandlerSerial.java:51)
at java.base/java.lang.Thread.run(Thread.java:829)
java program
serialParameters.setDevice("/dev/ttyS4");
serialParameters.setBaudRate(SerialPort.BaudRate.BAUD_RATE_9600);
serialParameters.setDataBits(8);
serialParameters.setParity(SerialPort.Parity.NONE);
serialParameters.setStopBits(1);
slave = ModbusSlaveFactory.createModbusSlaveRTU(serialParameters);
slave.setReadTimeout(1000);
Modbus.setLogLevel(Modbus.LogLevel.LEVEL_DEBUG);
MyOwnDataHolder dh = new MyOwnDataHolder();
You may want o upgrade jssc version to the latest released https://github.com/java-native/jssc/releases/tag/v2.9.5 because this stack trace indicates you are using a pretty old release before Arm64 support was added.
thanks for replay , can you explain little more. i used maven project . in program i registered lib.
System.setProperty("jssc.boot.library.path", "/usr/lib/jni/");
and in jni folder libjSSC.so present . so what exactly wrong with this?
If you use maven version, you should add the following dependency:
<dependency>
<groupId>io.github.java-native</groupId>
<artifactId>jssc</artifactId>
<version>2.9.5</version>
</dependency>
This will add to your project a jssc release with latest java AND binaries precompiled for arm64. Normally the binaries are extracted from our jar to folder under $HOME\.jssc
and loaded from there, but if you specify jssc.boot.library.path
, that means you mean to override the location and have put libraries manually under /usr/lib/jni/
. If that's the case - make sure you put the correct .so files there - the older version of jssc (version 2.8 - predating maven packaging) may be put there by any other library you are using, so make sure you have no duplicate dependencies.
Also, double check this:
at jssc.SerialNativeInterface.openPort(Native Method)
at jssc.SerialPort.openPort(SerialPort.java:158)
If your stacktrace looks like this, you are loading old jssc jar (2.9.1 or even older 2.8). You expect openPort call to be in line 210.
I don't think there is anything more to add to this one, so I'll close it. @dhirajthaokar feel free to comment or reopen if you feel otherwise.