Challenges and alternative research of Java serial communication library RXTX

Target

For those who want to communicate serially with Java. I myself am a software shop because IoT has become popular in recent years! Even though I'm an amateur! I'm having a hard time starting electronic work (laughs) The text is written as a simple memorandum, so I think there are some deficiencies or deficiencies, but please read it if you like.

environment

At the time of the survey, the first priority is to work in a Windows 10 64bit environment. The development environment is as follows.

RXTX When you want to communicate serially with Java, google usually hits the RXTX library. RXTX consists of two libraries, a Java library and a C / C ++ native library, which can be downloaded from the following. It is necessary to switch the native library depending on the platform such as Windows 32bit, Windows 64bit, Linux, mac.

RXTX Challenges

I am using RXTX and face the following challenges: (Maybe there are others?)

  1. Not maintained for more than 10 years
  2. Subspecies version (2.2) and native library are also distributed on various sites with slightly different versions, and are not managed and unified.
  3. Due to the influence of the native library, even though I wrote it in Java, it becomes platform-dependent.

Alternate library

If you have the above problems, you will be shy when you try to communicate serially. .. .. "But I'm not the only one in trouble with RXTX! There must be a brave man trying to do something about it!" So, I tried to look over two things. When I ran the sample, it worked smoothly on Windows 10 64bit, so I will introduce it.

purejavacomm

When I read the explanation, it seems that JNA (Java Native Access) was used to realize serial communication while ensuring platform independence. I understand that the native library in RXTX has been replaced by JNA. The APIs are similar, as it says they are RXTX conscious.

Since 1.0.3 was released on 2019-01, it seems that they are doing maintenance. (The maven repository at the time of writing was the latest 1.0.2)

jSerialComm

This also seems to be made as an alternative to RXTX, and the API is similar. The native library is built in the jar, and it seems that the library used is loaded for each platform at startup. In addition to Windows / Linux, it is said that it also supports ARM processors, and it seems to work with Raspberry Pi. (If you look at the source code, the keyword Android is also included, so it may work on Android as well?)

The latest version of maintenance is released on 2018-12.

Evaluation

When I actually ran the sample, both purejavacomm and jSerialComm were available from the maven repository. It worked without being aware of the native library.

From the viewpoint of cooperation with other libraries, libraries that cooperate with netty are open to the public.

In terms of maintenance and support, purejavacomm seems to be good, but it is regrettable that netty-transport-purejavacomm --github.com is not in the maven repository. By the way. Netty-Transport-jSerialComm --github.com is introduced on the netty head family site, and it is easy to use because you can use the maven repository.

Future tasks

In the future, I would like to post a sample using purejavacomm and jSerialComm.

(2019-02-19) Posted.

-Serial communication sample using purejavacomm -Serial communication sample using jSerialComm

Recommended Posts

Challenges and alternative research of Java serial communication library RXTX
Advantages and disadvantages of Java
Java cache library and Eviction Policy
[Java] Judgment of identity and equivalence
Parse and objectize JSON using the @JsonProperty annotation of the Java library Jackson
[Java] Inheritance and structure of HttpServlet class
[Java / Swift] Comparison of Java Interface and Swift Protocol
Summary of Java Math.random and import (Calendar)
[Java] Contents of Collection interface and List interface
Basics of java basics ② ~ if statement and switch statement ~
Discrimination of Enums in Java 7 and above