I have no idea of what is happening to my code. i am getting no errors and no response as well. I am writing the data to the serialport and waiting for the response by activ
.available()
can not be used in inter-process communication (serial included), since it only checks if there is data available (in input buffers) in current process.
In serial communication, when you send a messaga and then immediately call available()
you will mostly get 0 as serial port did not yet reply with any data.
The solution is to use blocking read()
in a separate thread (with interrupt()
to end it):
Thread interrupt not ending blocking call on input stream read
To partially answer your question.
From the javadocs
The available method for class InputStream always returns 0.
http://download.oracle.com/javase/6/docs/api/java/io/InputStream.html#available()
So that part at least is as expected
By using a PrintStream you are suppressing exceptions that you need to know about in any request/response scenario.
Most probably you haven't even sent anything yet.