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.
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
MPelletier1 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.
Gilbert Le BlancGilbert Le BlancNot the answer you're looking for? Browse other questions tagged javauser-interfaceconnectionserial-port or ask your own question.
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
informatik01Java Access To Serial Port
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
Looks like to need a SerialPortReader
which needs to implement a SerialPortEventListener