I am using Hyperterminal to read an input from a sensor. This sensor sends out a string which should be in the form Value 6 digits or 5 digits and a decimal point(however it can come as 2 spaces and then 3 digits and one decimal) tab seperator Measurement unit("Ci","mCi" etc) tab seperator string eg(F-18 or C-11) tab Seperator tab CRLF strings end identifier.
If i monitor this input through Hyper terminal It reads it perfectly
0.00 kBq F-18 2D
However when I read it I get broken segments of the string most of the time and sometimes I get the correct string an example of what I can get back is shown below.
0.00 k□□□□□□□□□□□□□
Bq F-18 2D□□□□□□□□□
0.00 kBq F-18 □□□
0.002D
□□□□□□□□□□
The code I use is from the RXTX library.
public void serialEvent (SerialPortEvent event){
if (event.getEventType()== SerialPortEvent.DATA_AVAILABLE){
byte[] readBuffer = new byte[19];
try{
while (inputStream.available() > 0){
int numBytes = inputStream.read(readBuffer);
}
catch (IOException e) {}
input_line = new String (readBuffer);
inter.update(input_line);}}