-1

I am very new to java and for one of my project, I am trying to send a string to a serial port using java(First open the serial port), I found some libraries RxTx. Comm. Could anybody suggest me possible code example or some recently upgraded libraries?

Thank you in advance.

Smith
  • 27
  • 1

3 Answers3

1

RxTx is already very old and not always easy to understand and use. JSSC is also outdated, if you use JSSC under Windows 10 and Java 9 your app will crash. I would recommend jSerialComm

0

Another recent library is Javino middleware. You'll have to program on both sides (Arduino and Java). It works like that:

Your Java code will be like that:

Javino j = new Javino();
String receivedMessage = new String();
if (j.requestData("COM3","hi")) 
    receivedMessage = j.getData();

And your Arduino code (inside main loop):

if(javino.availablemsg()){
     msg = javino.getmsg();
}

if (msg=="hi") {
    javino.sendmsg("Your Value");
}

msg = "";

It is simple to use and install.

Pantoja
  • 16
  • 2
0

Nobody seems to notice the JSerial-library? You can quickly test if this software works for You, by downloading 3 jar files (7th IDE JSerial) into the same directory. Adapt the program at the bottom of this side for Your needs. Of course You must set the PORT to correct values.

"COM9" 115200 8 0 1 0  6 PORT a!  (* help port *)
portopen
"my string to send" portwrite
portread type
portclose
Kaplan
  • 1