Java Reference
In-Depth Information
former is a software protocol while the latter is implemented in hardware. The
methods
void setFlowControlMode (int protocol)
int getFlowControlMode ()
provide for setting and getting the flow control mode. The protocol value sets
both input and output protocols with a bitwise AND of the constants in the
SerialPort class:
FLOWCONTROL - NONE
FLOWCONTROL - XONXOFF - IN
FLOWCONTROL - XONXOFF - OUT
FLOWCONTROL - RTSCTS - IN
FLOWCONTROL - RTSCTS - OUT
The set method throws the UnsupportedCommOperationException
if the protocol value is invalid.
23.4.6 Serial line connections
In Table 23.1 the Function column indicates the purpose of each pin for the case
of a computer connected to a modem. The serial line sends and receives only one
bit at a time but it uses separate lines for transmission and reception and it uses
six other lines (not counting the ground line) for setting up the protocol for the
communications.
The class CommPort provides methods to access the six control lines. For the
two output control wires, DTR and RTS, there are methods both to set the line
and to find the current setting:
void setDTR (boolean val)
boolean isDTR ()
void setRTS (boolean val)
boolean isRTS ()
For the other four input control lines, there are methods to find their current state:
boolean isCTS ()
boolean isDSR ()
boolean isRI ()
boolean isCD ()
For connecting to devices other than modems, it is often unnecessary to use all
of these control lines. In the serial line demonstration program below only the
CTS and RTS (plus the ground line) lines are active.
Note that when you start to set up serial connections, you will find that the
cables and connectors vary according to whether you connect a computer to a
Search WWH ::




Custom Search