Sending and receiving strings from COM-port via jSSC in Java. I am trying to use this method from a web page to send a query on a serial port and receive response. However there could be multiple requests at one time. So I want to write this data to device and both read/write data should be displayed. Alternate to jssc. Java/Arduino - Read data from the Serial Port. Then I use Serial.read and Serial.write when I need it. Serial.write works great, Arduino gets the data and show it in a LCD Display. Java: select serial port to read Arduino Uno. PHP serial port data return from Arduino. I know this is an old question but I have created a Java package and native library to allow serial port read and write, currently in synchronous mode only. It's open source and available on GitHub: j232 - The Java source code. Libj232 - j232's native library. The wiki page is here. Note this is a.
Active4 years, 7 months ago
We make use of a java application that manages a pinpad via the serial port.This works perfectly on windows with the Sun Comm.jar, the supplied dll and the properties file.
Now we are attempting to use this solution on Linux (actually it does run on various other flavours of linux out in the field) - with Ubuntu server mode.
After much attempts - blood, sweat and almost tears we have this scenario:
Java version 1.4.2_17Linux - UbuntuComm libs - Comm3 supplied by sun with the default driver specified
An external comm test shows the comm ports: /dev/ttyS0 and /dev/ttyS1But the java application says unable to open port /dev/ttyS1
(using the RXRT files produces invalid port errors)
Has anyone been able to use java 1.4.2 on linux for serial port communication and found a solution that I could apply in my scenario?
greatly appreciated
Phill
mtrw24.3k66 gold badges5050 silver badges6565 bronze badges
Phillip GibbPhillip Gibb29711 gold badge22 silver badges1313 bronze badges
5 Answers
I know this is an old question but I have created a Java package and native library to allow serial port read and write, currently in synchronous mode only.
It's open source and available on GitHub:
j232 - The Java source code
libj232 - j232's native library.
The wiki page is here.
C# Serial Port Read
Note this is a Linux only package and library.
KerryKerry4,33566 gold badges4444 silver badges8282 bronze badges
Make sure that you are using a user with permissions to access the serial ports. Some distributions put the serial ports in the uucp group, so make sure that the user belongs to that group.
jassuncaojassuncao3,87222 gold badges2525 silver badges3434 bronze badges
It's been a while since I've done this. I remember that you can't just open /dev/ttyS0 as a file and I/O to it.
I remember having the same problem with Sun IO jars also.
The solution I remember settling on was to create a small command-line program in C that echoed stdin to the serial port and serial port in to stdout. Then, I launched this program from my java process. I don't have the code but there are lots of examples on the web for c programs that write to linux serial ports.
Jonathan HessJonathan Hess
We've been using the SerialIO libraries for Java serial communications on both Windows and Linux for several years now with great results (and no, I don't work for them :-)):
Read And Write
The libraries do not autodetect the available serial ports on Linux though - you have to manually configure them.
tonystonys
We did not change much,nothing in the libraries used.but removing the use of an EventListener on the serial port object fixed the problem.
This actually allowed for our code to work on linux (jre1.4.2, slackware and Suns Comm3 drivers) where this was not a problem on windows - strange.
Phill
Phillip GibbPhillip Gibb29711 gold badge22 silver badges1313 bronze badges