Java Connect To Serial Port

  1. Java Connect To Serial Port In Ubuntu From Cli
  2. Java Access To Serial Port
  3. Java Serial Port Github

Communicate with Arduino through Java Arduino can send message to the serial port, use Java to get the serial messages. Code on Arduino: void setup. The official API for serial communication in Java is the JavaComm API. This API is not part of the standard Java 2 version. Instead, an implementation of the API has to be downloaded separately. Unfortunately, JavaComm has not received much attention from Sun, and hasn't been really maintained for a long time.

Port
Active6 years ago

Im making a java GUI on Netbeans to run on a computer that will be connecting to device through a serial port. This GUI is to show the user information that will be stored in the other device. Like a text file or to retrieve some data from the device's sensors. I just finished the outline of the interface and now it is the harder part as this is the first time dealing with serial ports. The other device is a beagleboard.I am a little unsure on where to even start, as I have looked in this forum but nothing seems to relate to my question exactly. I assume I should establish a connection through the port with the device and send the requests for the info as the user requests.

Any advices?Should the connection be established in a separate java class of the program? The gui is made up of a main JFrame and two auxiliary ones and I (plan) have a button to estabish the connection in the main frame basically.

Thanks in advance,Alex

MPelletier
11.9k11 gold badges72 silver badges118 bronze badges
alex91alex91

1 Answer

Should the connection be established in a separate java class of the program?

Yes. One java class should be sufficient to establish the connection, send messages to the beagleboard, and receive responses.

I assume I should establish a connection through the port with the device and send the requests for the info as the user requests.

Yes. You would format the requests in whatever format the beagleboard requires.

Here's a class I put together to make sure a single instance of the Java application ran. You would modify this for your communications.

JavaGilbert Le BlancGilbert Le Blanc
39k5 gold badges51 silver badges97 bronze badges

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

Active5 years, 1 month ago

I'm begginner in Java, I'm writing ('FLASH').getbytes() like this to serialport.

After I'll get FLASH_OK as response, again I've to send file request. After that I'll get response as FILE_OK then I have read file up to end of the file.

I'm not getting how to do this, so please help me.

Thanks for reply.

Java Connect To Serial Port In Ubuntu From Cli

informatik01
13.6k8 gold badges58 silver badges94 bronze badges

Java Access To Serial Port

rajat

2 Answers

jSSC is a stable serial IO java library, take a look at following examples:

  • writing data to serial port
  • reading data from serial port
informatik01
13.6k8 gold badges58 silver badges94 bronze badges
linskilinski
4,4813 gold badges16 silver badges31 bronze badges

Looks like to need a SerialPortReader which needs to implement a SerialPortEventListener

VonCVonC

Java Serial Port Github

896k330 gold badges2913 silver badges3503 bronze badges