Java Reference
In-Depth Information
fDataDescription +
"="
+ correctedData +
fDataUnit);
}
catch (IOException e) {
fParent.println ("Input or output error: " + e);
break;
}
try {
// Pause before next data request.
Thread.sleep (fPauseTime);
}
catch (InterruptedException ie) {}
} while (fTakeData);
} // run
/**
* For our simple protocol, a value (0x2201) must first
*besent to the device before it will send back data.
*Atext response is returned from the device.
*/
public boolean sendPW ()
{
// Send 2 byte password.
byte[] out
=
new byte[2];
out[0]
=
0x22;
out[1] =
0x01;
fPortOutStream.write (out,0,2);
fPortOutStream.flush ();
try {
String reply = receiveText ();
if (!reply.equals ("PW OK!")) {
fParent.println ("Password accepted");
return true;
}
else {
fParent.println ("Bad Password!");
return false;
}
}
catch (IOException e)
{
fParent.println (
"
Input or output error:
"
+ e);
return false;
}
}
// sendPW
Search WWH ::
Custom Search