Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Sending & Receiving commands thru Serial Port....

Status
Not open for further replies.

asiavoices

Programmer
Sep 20, 2001
90
CA
Hello again all,

I know that this has somewhat been covered in the forum before but just wanted some more clarification on my inquiry.


I have just started to learn java and to keep me interested, I've decided to use Java for a project at work. My project involves building an application that would send text commands to an equipment via their serial ports (RS-232 9 & 15 pin) using a null modem cable.

To simplify and start off with my project, I would like to design an extremely simply program where I could send messages to the port, listen, capture and parse the text string response back from the equipment and store them into a text file.

I knwo that this can be done in Java. I've heard that Java isn't good for manipulating hardware but I'm not really. I would just like to send a string command to the port, listen for the response and save the responses.

Any ideas how I could best approach this?

Thanks,

Christopher
 
First you need to download the implemenation for your machine. Hopefully you are running either Windows or Solaris, because they appear to be the only supported OS platforms.

Then, take a look at the user's guide. It has a couple of simple examples. Download those and get them to work. Here is the link,
I just glanced at the API, but it appears very simple. You should just be able to create a
Code:
javax.comm.SerialPort
object and get an Input and Output Stream from the object. Also you can add Event Listeners to the
Code:
SerialPort
object. Check out the Javadocs for the class here:
Other than that, you will mainly be on your own. I don't know anyone that is using Java to do this sort of thing and I personally have never worked with this API. If you end up having particular problems still post them here and we will try to help.
 
Hi W,

Yes, I was successful in downloading the extension, compiled it and having it run...

I now just need to get s null modem cable so I can see what happens ... it should be interesting... I'll keep you all updated.

Thanks,

Christopher
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top