Receiving data through serial port in Java

Status
Not open for further replies.

Sputnik

Full Member level 3
Joined
Oct 19, 2004
Messages
150
Helped
4
Reputation
8
Reaction score
1
Trophy points
1,298
Location
South Africa
Activity points
1,667
I have written a program that can send data out the serial port. But now I want to receive on the same computer. I have made a loopback serial connection. When I try to use whatever.readLine() I don't get any compilation errors, but the program hangs on that line (ie. not freezes, but doesn't continue). The only successful method I've found to use is to use whatever.read() which reads a byte at a time which is being incredibley slow (for a Pentium I).

I initialise the reader in the following way:
Code:
DataInputStream is = new DataInputStream(port.getInputStream());
BufferedReader input = new BufferedReader (new InputStreamReader(is));
...
Does anyone have a better method for reading from the serial port?

If anything is unclear, just ask.

Sputnik :idea:
 

Status
Not open for further replies.

Similar threads

Cookies are required to use this site. You must accept them to continue using the site. Learn more…