Weird IO Problem
0 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   ken_carey
Posted On:   Monday, April 19, 2004 09:34 AM

Hello, I am getting very strange results when I attempt to read in a barcode using the COM port . Here's the code and here's what's outputing on screen : for (; ; ) { byte[] readBuffer = new byte[20]; int numBytes = inStream.read(readBuffer); System.out.println("Number of Bytes Read : " + numBytes); String temp = new String(readBuffer); System.out.println("Employee ID No. : " + temp); } When I scan a barcode it sends a 7 digit number to the serial port com1 . Here is what is actually happening though for a single scan of the bardco   More>>

Hello,

I am getting very strange results when I attempt to read in a barcode using the COM port .



Here's the code and here's what's outputing on screen :



for (; ; ) {



byte[] readBuffer = new byte[20];


int numBytes = inStream.read(readBuffer);



System.out.println("Number of Bytes Read : " + numBytes);

String temp = new String(readBuffer);

System.out.println("Employee ID No. : " + temp);


}





When I scan a barcode it sends a 7 digit number to the serial port com1 .


Here is what is actually happening though for a single scan of the bardcode.


The barcode number here is 7733343


Output :



Number of Bytes Read: 1

Employee ID No. : 7

Number of Bytes Read: 7

Employee ID No. : 733343 .



What is happening with the first digit and why does it still give 7 as the number of bytes read in and only actually read 6 digits.??



Cheers.

   <<Less
About | Sitemap | Contact