mga masters, i have a little problem from converting the data came from a weighing scale(using rs232). kai bytes man ang input ma.receive sa COM1.
codes sa pagbasa nako sa data
Code:
try {
inputStream = serialPort1.getInputStream();
JOptionPane.showConfirmDialog(null, "Scanned----" + new String( inputStream+"" ) );
} catch ( IOException e ) {
System.out.println( e.getMessage() );
JOptionPane.showMessageDialog( null, e.getMessage() );
}
1st na timbang: (open in new tab lng ang img para maklaro)
2nd na timbang:
ma.notice nato ang changes dba from 1st na timbang to 2nd na timbang? (so perhaps it's working if i'm not mistaken)
pero di cya musulod sa codes na ako nang i.convert ang bytes into string/int. unsai sayup sako codes?
pero di sad niya ilabay sa exception.
Code:
try {
StringBuffer readBuffer = new StringBuffer();
int c = 0;
while ( ( c = inputStream.read() ) != 10 ) {
if ( c != 13 ) {
readBuffer.append( ( char ) c );
}
}
String scannedInput = readBuffer.toString();
//TimeStamp = new java.util.Date().toString();
JOptionPane.showMessageDialog( null, "scanned input received: " + scannedInput );
} catch ( Exception e ) {
JOptionPane.showMessageDialog( null, e.getMessage() );
}
anyone pls help kung kbw mo. tnx