Fazecast / jSerialComm

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

RaspberryPi support #1

Closed prampec closed 9 years ago

prampec commented 9 years ago

Hello! jSerialComm was told to be running on ARM based platforms. Now, as I try to run it on RapberryPi (Raspbian), I've get an error message: java.lang.UnsatisfiedLinkError: /tmp/tomcat7-tomcat7-tmp/libjSerialComm.so: /tmp/tomcat7-tomcat7-tmp/libjSerialComm.so: cannot open shared object file: No such file or directory (Possible cause: can't load IA 32-bit .so on a ARM-bit platform)

Can you please compile a version supporting Linux ARM for raspberry pi?! Thx!

hedgecrw commented 9 years ago

Ah yes...the ARM support is currently only for Android-based systems, but it doesn't look like a problem to compile for any ARM-based Linux distro, so I'll do that shortly. I just ordered a Raspberry Pi for actual testing, but until that time I can just send you a d/l link to the re-compiled version and let you try it out. Will post back when this is taken care of. Thanks for the heads up!

prampec commented 9 years ago

Okay. I will do a test, when you send me a link. Regards, Balazs

On Sun, Apr 5, 2015 at 10:44 PM, Will Hedgecock notifications@github.com wrote:

Ah yes...the ARM support is currently only for Android-based systems, but it doesn't look like a problem to compile for any ARM-based Linux distro, so I'll do that shortly. I just ordered a Raspberry Pi for actually testing, but until that time I can just send you a d/l link to the re-compiled version and let you try it out. Will post back when this is taken care of. Thanks for the heads up!

— Reply to this email directly or view it on GitHub https://github.com/Fazecast/jSerialComm/issues/1#issuecomment-89848575.

hedgecrw commented 9 years ago

Alright, no promises since I can't actually test the build myself, but try this version: https://dl.dropboxusercontent.com/u/3274122/jSerialComm-1.1.0.jar - And please comment back even if it works so I can close the issue. Thanks!

prampec commented 9 years ago

Unfortunately I've got a different error now (running from command line this time):

Exception in thread "main" java.lang.UnsatisfiedLinkError: /tmp/libjSerialComm.so: /tmp/libjSerialComm.so: cannot open shared object file: No such file or directory

No other exception is visible. This call prints "true": System.out.println(System.getProperty("os.arch").indexOf("arm") >= 0);

I've made a small trick to find out if this is a missing file issue. And it turned out it is not.

pi@raspbian/tmp $ ln -s libjSerialComm.so.KEEP libjSerialComm.so pi@raspbian /tmp $ java -classpath "path-to/classes:path-to/lib/jSerialComm-1.1.0.jar" hu.anhan.comm.JSerialCommTest Exception in thread "main" java.lang.UnsatisfiedLinkError: /tmp/libjSerialComm.so.KEEP: /tmp/libjSerialComm.so.KEEP: cannot open shared object file: No such file or directory at java.lang.ClassLoader$NativeLibrary.load(Native Method) at java.lang.ClassLoader.loadLibrary0(ClassLoader.java:1929) at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1814) at java.lang.Runtime.load0(Runtime.java:809) at java.lang.System.load(System.java:1083) at com.fazecast.jSerialComm.SerialPort.(SerialPort.java:132) at hu.myproj.JSerialCommTest.listPorts(JSerialCommTest.java:68) at hu.myproj.JSerialCommTest.main(JSerialCommTest.java:65) pi@raspbian /tmp $ ls -l libjSerialComm.so.KEEP -rw-r--r-- 1 pi pi 61305 Apr 6 19:53 libjSerialComm.so.KEEP pi@raspbian /tmp $ file libjSerialComm.so.KEEP libjSerialComm.so.KEEP: ELF 32-bit LSB shared object, ARM, version 1 (SYSV), dynamically linked, not stripped

On Mon, Apr 6, 2015 at 5:04 AM, Will Hedgecock notifications@github.com wrote:

Alright, no promises since I can't actually test the build myself, but try this version: https://dl.dropboxusercontent.com/u/3274122/jSerialComm-1.1.0.jar - And please comment back even if it works so I can close the issue. Thanks!

— Reply to this email directly or view it on GitHub https://github.com/Fazecast/jSerialComm/issues/1#issuecomment-89899128.

hedgecrw commented 9 years ago

Very interesting...last ditch effort, try the following: https://dl.dropboxusercontent.com/u/3274122/jSerialComm-1.1.0.jar

If this one doesn't work, I'll have to wait until I receive my own RPi for testing. Should arrive in the next couple of days. Thanks for working with me on this!

prampec commented 9 years ago

No luck. It is not about finding the .so file, but possibly missing some other dependency. (I have model RPi B) I've made a small test routine for you:

pi@raspbian /tmp/jarcontent $ cat /proc/cpuinfo | grep ARMv model name : ARMv6-compatible processor rev 7 (v6l) pi@raspbian /tmp/jarcontent $ more Test.java import java.io.File;

class Test { public static String SO_PATH = "/tmp/jarcontent/Linux/armv6/libjSerialComm.so"; public static void main(String[] args) throws Exception { File file = new File(SO_PATH); System.out.println("File " + SO_PATH + " isFile:" + file.isFile() + ", canRead:" + file.canRead()); System.load(SO_PATH); } } pi@raspbian /tmp/jarcontent $ javac Test.java pi@raspbian /tmp/jarcontent $ java Test File /tmp/jarcontent/Linux/armv6/libjSerialComm.so isFile:true, canRead:true Exception in thread "main" java.lang.UnsatisfiedLinkError: /tmp/jarcontent/Linux/armv6/libjSerialComm.so: /tmp/jarcontent/Linux/armv6/libjSerialComm.so: cannot open shared object file: No such file or directory at java.lang.ClassLoader$NativeLibrary.load(Native Method) at java.lang.ClassLoader.loadLibrary0(ClassLoader.java:1929) at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1814) at java.lang.Runtime.load0(Runtime.java:809) at java.lang.System.load(System.java:1083) at Test.main(Test.java:8)

Btw: I recommend you to rewrite your latest code about guessing the ARM version! You shouldn't use "exec" to find a string in a file.

On Wed, Apr 8, 2015 at 7:28 AM, Will Hedgecock notifications@github.com wrote:

Very interesting...last ditch effort, try the following: https://dl.dropboxusercontent.com/u/3274122/jSerialComm-1.1.0.jar

If this one doesn't work, I'll have to wait until I receive my own RPi for testing. Should arrive in the next couple of days. Thanks for working with me on this!

— Reply to this email directly or view it on GitHub https://github.com/Fazecast/jSerialComm/issues/1#issuecomment-90806397.

hedgecrw commented 9 years ago

Alright, I've learned far more about the various ARM architectures than I ever wanted to know, but I believe the following library will work:

https://dl.dropboxusercontent.com/u/3274122/jSerialComm-1.1.0.jar

I've tested this on an ARMv7 BeagleBone board with a Hard-FPU. It turns out that the most likely culprit we were experiencing is that ARM architectures with a hardware FPU actually use a different linker (ld-linux-armhf.so.3) than software FPU architectures (ld-linux.so.3), so that was the file it was unable to locate at runtime.

I've added support for either flavor of FPU architecture, so it shouldn't have issues linking any more. Please test this JAR, and let me know if it works on your RPi!

prampec commented 9 years ago

Right. It does not throw any exceptions at startup. However SerialPort.getCommPorts() still does not return any SerialPorts.

On Thu, Apr 9, 2015 at 10:06 PM, Will Hedgecock notifications@github.com wrote:

Alright, I've learned far more about the various ARM architectures than I ever wanted to know, but I believe the following library will work:

https://dl.dropboxusercontent.com/u/3274122/jSerialComm-1.1.0.jar

I've tested this on an ARMv7 BeagleBone board with a Hard-FPU. It turns out that the most likely culprit we were experiencing is that ARM architectures with a hardware FPU actually use a different linker (ld-linux-armhf.so.3) than software FPU architectures (ld-linux.so.3), so that was the file it was unable to locate at runtime.

I've added support for either flavor of FPU architecture, so it shouldn't have issues linking any more. Please test this JAR, and let me know if it works on your RPi!

— Reply to this email directly or view it on GitHub https://github.com/Fazecast/jSerialComm/issues/1#issuecomment-91343166.

hedgecrw commented 9 years ago

Are you trying to use the USB port as a serial device, or are you actually using the physical GPIO pins? If you're using USB, no ports will show up unless you actually plug a USB-to-serial device into the USB port. (I just tested the library using my own RPi that just arrived in the mail, and it seems to be working fine for USB).

If you're using the pins, it looks like those are enumerated using a different designation than standard Linux serial ports (something like /dev/ttyAMA0 on RPi), so I'll have to check and see how exactly the board is handling serial I/O in this case.

prampec commented 9 years ago

Both of them. USB-to-Serial (Arduino) was connected, and internal serial was also available.

On Fri, Apr 10, 2015 at 12:12 AM, Will Hedgecock notifications@github.com wrote:

Are you trying to use the USB port as a serial device, or are you actually using the physical GPIO pins? If you're using USB, no ports will show up unless you actually plug a USB-to-serial device into the USB port. (I just tested the library using my own RPi that just arrived in the mail, and it seems to be working fine for USB).

If you're using the pins, it looks like those are enumerated using a different designation than standard Linux serial ports (something like /dev/ttyAMA0 on RPi), so I'll have to check and see how exactly the board is handling serial I/O in this case.

— Reply to this email directly or view it on GitHub https://github.com/Fazecast/jSerialComm/issues/1#issuecomment-91369093.

hedgecrw commented 9 years ago

Alright, finally had the chance to update all of this the right way and do a decent amount of testing using several different ARM-based devices (two RPi2's and a BeagleBone, all connected to various USB-based serial devices including an Arduino).

Please check the latest build (https://dl.dropboxusercontent.com/u/3274122/jSerialComm-1.1.1.jar) and ensure that it works for you. If for some reason it's still not enumerating ports, try running your program either as root or using sudo to make sure that it's not just a device permissions issue. If that solves the problem, look at the Troubleshooting Wiki #3 (https://github.com/Fazecast/jSerialComm/wiki/Troubleshooting) for a way to permanently resolve that issue. Thanks for your patience!

prampec commented 9 years ago

Sorry to say, but enumerating on ports still results empty list on rPi model B. I have both the ttyAMA0, and a ttyUSB0 available. Also tried with sudo. (Works well with other java serial solutions.)

On Tue, Apr 21, 2015 at 7:15 PM, Will Hedgecock notifications@github.com wrote:

Alright, finally had the chance to update all of this the right way and do a decent amount of testing using several different ARM-based devices (two RPi2's and a BeagleBone, all connected to various USB-based serial devices including an Arduino).

Please check the latest build ( https://dl.dropboxusercontent.com/u/3274122/jSerialComm-1.1.1.jar) and ensure that it works for you. If for some reason it's still not enumerating ports, try running your program either as root or using sudo to make sure that it's not just a device permissions issue. If that solves the problem, look at the Troubleshooting Wiki #3 ( https://github.com/Fazecast/jSerialComm/wiki/Troubleshooting) for a way to permanently resolve that issue. Thanks for your patience!

— Reply to this email directly or view it on GitHub https://github.com/Fazecast/jSerialComm/issues/1#issuecomment-94877070.

hedgecrw commented 9 years ago

If you get a chance, would you mind trying the most recent version of the library (1.3.1) to see if this bug has been resolved? If it's still not enumerating, would you mind going into the /sys/devices directory and posting the results of du -a | grep ttyUSB and du -a | grep ttyAMA? Thanks!

hedgecrw commented 9 years ago

Closing due to inactivity and an inability to reproduce using current version 1.3.x.