CommPortModempublic class CommPortModem extends CommPortOpen Subclasses CommPortOpen and adds send/expect handling for dealing
with Hayes-type modems. |
Fields Summary |
---|
protected String | responseThe last line read from the serial port. | protected boolean | debugA flag to control debugging output. |
Constructors Summary |
---|
public CommPortModem(Frame f)
super(f);
|
Methods Summary |
---|
protected boolean | expect(java.lang.String exp)Read a line, saving it in "response".
response = is.readLine();
if (debug) {
System.out.print("<<< ");
System.out.print(response);
System.out.println();
}
return response.indexOf(exp) >= 0;
| protected void | send(java.lang.String s)Send a line to a PC-style modem. Send \r\n, regardless of
what platform we're on, instead of using println().
if (debug) {
System.out.print(">>> ");
System.out.print(s);
System.out.println();
}
os.print(s);
os.print("\r\n");
// Expect the modem to echo the command.
if (!expect(s)) {
System.err.println("WARNING: Modem did not echo command.");
}
// The modem sends an extra blank line by way of a prompt.
// Here we read and discard it.
String junk = is.readLine();
if (junk.length() != 0) {
System.err.print("Warning unexpected response: ");
System.err.println(junk);
}
|
|