| Author |
Message |
StarBuck Novice Poster

Joined: 21 Jan 2008 Posts: 35 Location: Skopje
|
Posted: Sat Jan 26, 2008 1:06 am Post subject: Java IO |
|
|
Does anyone have good experience in Java Input-Output libraries, more specifically serial communication?
I need some help in reading data from a serial port (com port) into a java application...
So far I've been able to open up a talk-listen connection with the input device, but I've got no luck with the "listen" part  _________________ [img:d0a44f4fbc]http://img210.imageshack.us/img210/8986/buckco0.gif[/img:d0a44f4fbc] |
|
| Back to top |
|
| |
exsanguination Forum Regular
Joined: 27 Apr 2005 Posts: 412 Location: Australia
|
Posted: Tue Jan 29, 2008 5:28 pm Post subject: |
|
|
Have you found this chapter on serial port programming??
http://java.sun.com/developer/.....ook/11.pdf
Basically you open up the correct COMPort, cast it to SerialPort, set the appropriate properties using setSerialPortParams, and then using the COMPort object you can use the getInputStream and getOutputStream methods to open up the streams and use them in exactly the same way you would for File IO.
If you need to be notified when data is available to read, then you need to implement the SerialPortEventListener interface and on your SerialPort object use the method notifyOnDataAvailable(boolean) and then add you event listener using the addEventListener(SerialPortEventListener) method. |
|
| Back to top |
|
| |
StarBuck Novice Poster

Joined: 21 Jan 2008 Posts: 35 Location: Skopje
|
Posted: Wed Jan 30, 2008 3:22 am Post subject: |
|
|
thanks a lot for the paper man, I'll try it out as soon as I can and I'll let you know how it works out  _________________ [img:d0a44f4fbc]http://img210.imageshack.us/img210/8986/buckco0.gif[/img:d0a44f4fbc] |
|
| Back to top |
|
| |
|
|
|