views:

159

answers:

2

Hi,

I am using the javax.comm package to perform read and write operations on the SerialPort.

I have created an object of type InputStream as InputStream in;

My question is ....

  1. Irrespective of data availibility on the SerialPort, in.available() always returns a zero due to which I am not able to decide whether bytes are available or not.

If i use the in.read() directly, it seems to block the execution forever..

+4  A: 

The behaviour of SerialPort's InputStream is documented in the API. It describes how to set the threshold and timeout values to influence the blocking behaviour of the streams.

skaffman
A: 

I've done many applications using java comm and have had no problems with available() returning 0 when there are bytes ready to be read in. You may want to make sure that your baud rate, parity, flowcontrol, etc are all set correctly.

There's no reason to mess around with timeout values for blocking.

Nick