Use RXTX on RaspberryPi (source installation of RXTX)

The RXTXcomm package is used when the java serial port programming is connected to the electric energy meter to fetch data. This package relies on two files rxtxParallel.dll and rxtxSerial.dll on windows. However, when transplanting the program to the Raspberry Pi, I downloaded various versions of Linux on the Internet The librxtxSerial.so is not available because it does not support the Raspberry Pi arm architecture. Fortunately, I saw the following article on the Internet. After recompilation, a librxtxSerial.so file is automatically generated under ${java}/jre, and the program can Running up, the following is the original text:

When using the interface programming of RaspberryPi, the RXTX framework is used, but I searched the official website of RXTX and did not find the framework version corresponding to the Raspberry Pi system. The reason is very simple. The RaspberryPi processor uses the ARM architecture, while the general computer is x86 or x64 architecture, which is not applicable, so the RXTX source code can only be recompiled and installed in the system.

So I found this method on the Internet and recorded it (here I did not use the Raspberry Pi to download online, but use the memory card to decompress the downloaded zip file):

The latest stable version of RXTX is rxtx 2.1-7r2. First use wget to get the source code package and decompress it

1
2
3
cd  /tmp
wget http: //rxtx .qbang.org /pub/rxtx/rxtx-2 .1-7r2.zip
unzip rxtx-2.1-7r2.zip

If you directly MAKE compile and install, you may encounter the following two errors:

错误1:/tmp/rxtx-2.1-7r2/./src/I2CImp.c:135: error: ‘UTS_RELEASE’ undeclared (first use in this function)

This is due to the lack of'UTS_RELEASE' information in version.h, which needs to be added manually. First get the version information of the current system:

1
uname  -r

Then add in /usr/include/linux/version.h

1
#define UTS_RELEASE "3.10.24+"

3.10.24+ is the version number obtained in the previous step

错误2:libtool: install: armv6l-unknown-linux-gnu/librxtxRS485.la’ is not a directory

This error will appear in the operating environment of JDK1.6 and above, you need to modify the configure file. Found in the configure file

1
1.2*|1.3*|1.4*|1.5*

Just add the current JDK version number after this line, such as

1
1.2*|1.3*|1.4*|1.5*|1.6*|1.7*|1.8*

After completing the above two modifications, you can compile and install normally. If you see Libraries have been installed in:/usr/lib/jvm/jdk-7-oracle-armhf/jre/lib/arm, the RXTX installation has been successful.


Guess you like

Origin blog.csdn.net/qq_36961530/article/details/80392644