Java Read Usb Serial Port

 Posted admin
Active3 years, 4 months ago

Possible Duplicate:
Java Serial Communication on Windows

  • The serial port is a nine pin I/O port that exists on many PCs and can be emulated through USB. Issues related to the Serial library on different platforms are documented on the Processing Wiki. The source code is available on the processing GitHub repository. When sending data to the console, such as via print() or println().
  • Read the JavaComm and/or RxTx installation instruction (and follow it). SerialPundit is another feature rich library for accessing serial port in Java. It includes features like detecting when a USB-UART device like FTDI232 has been plugged into system, automatically identifies operating system and CPU architecture, does not require any.

Friends,I want to connect and transfer data to COM PORT (either virtual or original) in JAVA?

Community
Srinivasan__Srinivasan__
5112 gold badges8 silver badges20 bronze badges

marked as duplicate by Lawrence Dol, Kate Gregory, andrewsi, cmbuckley, MacNov 26 '12 at 21:00

JPanel; /** * Read from a Serial port, notifying when data arrives. * Simulation of part of an event-logging service. * @version $Id: SerialReadByEvents.java,v 1.4 2004/04/11 23:50:40 ian Exp $ * @author Ian F. Darwin, */ public class SerialReadByEvents extends CommPortOpen implements.

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

3 Answers

This question has been asked and answered many times:

to reference a few.

Personally I recommend SerialPort from http://serialio.com - it's not free, but it's well worth the developer (no royalties) licensing fee for any commercial project. Sadly, it is no longer royalty free to deploy, and SerialIO.com seems to have remade themselves as a hardware seller; I had to search for information on SerialPort.

From personal experience, I strongly recommend against the Sun, IBM and RxTx implementations, all of which were unstable in 24/7 use. Refer to my answers on some of the aforementioned questions for details. To be perfectly fair, RxTx may have come a long way since I tried it, though the Sun and IBM implementations were essentially abandoned, even back then.

A newer free option that looks promising and may be worth trying is jSSC (Java Simple Serial Connector), as suggested by @Jodes comment.

Community
Lawrence DolLawrence Dol

Java Serial Port Example

48.3k23 gold badges125 silver badges178 bronze badges

The Java Communications API (also known as javax.comm) provides applications access to RS-232 hardware (serial ports): http://www.oracle.com/technetwork/java/index-jsp-141752.html

Nayuki
14.6k5 gold badges40 silver badges65 bronze badges
Robert HarveyRobert HarveyJava
153k38 gold badges294 silver badges433 bronze badges

An alternative to javax.comm is the rxtx library which supports more platforms than javax.comm.

freespacefreespace
14.1k3 gold badges32 silver badges53 bronze badges

Not the answer you're looking for? Browse other questions tagged javaserial-port or ask your own question.

Copyright 2017 Brian Yao Li

Licensed under the Apache License, Version 2.0 (the 'License');you may not use this file except in compliance with the License.You may obtain a copy of the License at

Unless required by applicable law or agreed to in writing, softwaredistributed under the License is distributed on an 'AS IS' BASIS,WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.See the License for the specific language governing permissions andlimitations under the License.

This is a working example of Java RxTx in Windows 10 with USB virtual COM ports.

Java is platform-independent. It can work in Windows, MacOS, Linux, and even embedded systems like Raspberry Pi. This feature of Java, however, makes it difficult to work with UART (Universal Asynchronous Receiver and Transmitter), which is hardware dependent. The RxTx library was developed to tackle this problem and has been proven very useful (http://rxtx.qbang.org/wiki/index.php/Main_Page).

We are working on a project in which the Raspberry Pi would communicate with a ZigBee coordinator via UART. To start with, we tried the RxTx in a Windows 10 computer. The RxTx for x64 compiled binaries can be downloaded from Mfizz RxTx page (http://fizzed.com/oss/rxtx-for-java). The starting point is one of the code examples, 'Two way communication with the serial port'.

Unfortunately, the example didn't succeed in our first go. After an intensive investigation and some experiments, the problem was found and solved. Based on the example, we have further developed the program so that it is more robust and ready to build in other project. We'd like to share this with the public community.

A few words on UART. The traditional COM port in a computer is a UART. It is now obsolete and replaced by USB. By using the USB, an embedded peripheral can not only communicate with the host computer but also obtain the power supply from the host. The generic USB would provide a virtual COM port in the host which still uses the UART protocol.