23.07.2013 Views

Java IO.pdf - Nguyen Dang Binh

Java IO.pdf - Nguyen Dang Binh

Java IO.pdf - Nguyen Dang Binh

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

public abstract void setRTS(boolean rts)<br />

public abstract boolean isRTS()<br />

17.4.3.3 CTS<br />

<strong>Java</strong> I/O<br />

Clear To Send, CTS, is the other half of hardware handshaking. The modem raises the voltage<br />

on this wire to tell the computer that it's ready to receive data. It drops the voltage when it's no<br />

longer ready to receive data.<br />

public abstract boolean isCTS()<br />

You cannot set the Clear To Send wire directly. Only the serial device can tell you when it is<br />

ready to receive. You cannot force it to be ready.<br />

17.4.3.4 DSR<br />

The modem raises the voltage on the DSR line, Data Set Ready, to indicate that it's turned on<br />

and operating. This line is also read-only.<br />

public abstract boolean isDSR()<br />

17.4.3.5 RI<br />

The modem raises the voltage on the RI wire, Ring Indicator, to tell the computer that the<br />

phone is ringing.<br />

public abstract boolean isRI()<br />

You cannot set the Ring Indicator bit directly. This is used only for one-way communication<br />

from the device back to the computer, not for the computer to send information to the device.<br />

(In other words, the computer can't tell the modem the phone is ringing.)<br />

17.4.3.6 CD<br />

The modem uses the CD wire, Carrier Detect, to tell the computer that it has successfully<br />

negotiated the low-level modem protocols with the modem on the other end of the connection.<br />

public abstract boolean isCD()<br />

You cannot set the Carrier Detect bit directly. This is used only for one-way communication<br />

from the device back to the computer, not for the computer to send information to the device.<br />

17.4.4 Serial Port Events<br />

The examples shown so far all depended on the computer taking the initiative. The computer<br />

tells the modem when to dial, the printer when to print, and so on. By analogy with network<br />

programming, this is client-based. However, there's another model for port programs, the<br />

server-based program. Just as an Internet server waits for an incoming connection, a program<br />

can wait for incoming faxes through a fax modem, incoming BBS connections through a<br />

modem, notifications of impending shutdown from an uninterruptable power supply, paperempty<br />

messages from a printer on a parallel port, and more. However, unlike the abstract<br />

network ports of Chapter 5, computers have no concept of binding to a serial port, at least<br />

449

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!