Shop OBEX P1 Docs P2 Docs Learn Events
Java and serial io — Parallax Forums

Java and serial io

WhelzornWhelzorn Posts: 256
edited 2007-11-09 01:00 in General Discussion
I'm attempting to use Java to send and receive data to/from a serial device. I've got an example from the rxtx library's website: rxtx.qbang.org/wiki/index.php/Two_way_communcation_with_the_serial_port. Problem is, I'm not really sure how to use it. I've never had the need to communicate with an external Java program like this. When I compile and run the example, it works just fine. It allows you to enter data into the text line, and it sends it out the serial port that was opened in the example code.
But what I need to do is send the example program data from another program, and have it send it out the serial port. It doesn't need to return data received on the serial port to the main program.
So I can create a new instance of the TwoWaySerialComm class with
TwoWaySerialComm twoWaySerialComm = new TwoWaySerialComm();


but I'm not sure how to write to that instance's OutputStream (declared in SerialWriter class).

If anyone's familiar with Java, I'd appreciate some insight. Thanks!

Comments

  • Kevin WoodKevin Wood Posts: 1,266
    edited 2007-11-09 01:00
    You'll need to use some form of inter-process communications between the 2 programs. So your serial interface program would connect to the other program, receive the data, then connect to the serial port and output the data.

    Here's more info on interprocess communications: en.wikipedia.org/wiki/Inter-process_communication

    I'm not a Java expert, but you should have no problem finding suitable Java classes to get something going.
Sign In or Register to comment.