2. Chapter Goals
• Understand serial port terminology.
• Understand serial port capabilities.
• Understand serial port signals.
• Understand serial port configuration
• Understand serial port management.
• Understand modem connections and setup.
• Disabling serial port services.
• Understand new-technology serial ports.
3. Serial Ports
• Serial Ports
– Serial ports are universal I/O ports. They are available
on almost every computer.
– Serial ports are slow, but they are flexible.
– Serial ports can be used for terminal connections, printer
connections, network connections, modem connections,
keyboards, mice, and other input/output devices.
4. Serial Ports
• Serial Ports
– Serial ports use standard pin-outs for the connectors.
The most common of these standard is known as RS-
232.
• Proposed by the Electronic Industries Association (EIA).
• RS stands for Recommended Standard.
• RS-232 defines the pin-outs of the connectors and the
voltage levels allowed on each pin of a serial port
connection. RS-232 is functionally identical to the CCITT
V.24/V.28 standards.
• RS-232 defines two types of signals; Data signals, and
flow-control signals.
5. Serial Ports
• Serial Ports
• The RS-232 standard defines how the flow control signals
interact to manage the flow of data across a connection.
• The full functionality of the RS-232 standard is rarely supported,
as several of the signals are not required for simple
communications connections.
• Traditional RS-232 uses 22 gauge stranded, twisted-pair cable.
• RS-232 signal voltages are defined to be +/- 12 volts DC.
• RS-232 connections terminate in a 25 pin D-connector (also
known as a DB-25). The computer has the receptacle, while the
cable has a plug.
• According to the standard, RS-232 will drive a 50 foot cable at
9600 baud.
6. Serial Ports
• Newer standards have emerged since RS-232 became the
standard.
– RS-422/RS-423 use lower signaling voltages (+/- 5
volts DC) , and can drive longer lines.
– RS-422 is electrically compatible with CCITT
recommendation V.11.
– RS-423 is electrically compatible with CCITT
recommendation V.10.
– RS-449 is the standard which defines the pin-outs and
connector characteristics for the RS-422/RS-423
standards.
– MOST RS-422/RS-423 implementations will connect
directly to RS-232 devices and function properly.
7. Serial Ports
• RS-422 uses differential line drivers, and can drive
several kilometers of cable.
• RS-423 uses single-ended line drivers and can drive
up to a kilometer of cable.
• All of these standards use the same signals, so we will
focus most of our discussion on the RS-232
standards.
8. Serial Ports
• RS-232 defines two cabling configurations: DTE (Data
Terminal Equipment) and DCE (Data Communications
Equipment).
–These cabling configurations determine which
signals a device expects on what pins.
–Most computers, printers, and terminals are
DTE equipment.
–Modems are DCE equipment.
–Cables for terminals connections are different
from the cables used for modem connections!
9. Serial Ports
Pin Name Function Pin Name Function
1 FG Frame Ground 14 STD Secondary TD
2 TD Transmit Data 15 TC Transmit Clock
3 RD Receive Data SRD Secondary RD
4 RTS Request To Send 17 RC Receive Clock
5 CTS Clear To Send 18
6 DSR Data Set Ready 19 SRTS Secondary RTS
7 SG Signal Ground 20 DTR Data Terminal Ready
8 DCD Data Carrier Detect 21 SQ Signal Quality
9 + voltage 22 RI Ring Indicate
10 - voltage DRS Data Rate Selector
11 24 SCTE Clock Transmit External
12 SDCD Secondary DCD 25 Busy Busy
13 SCTS Secondary CTS
10. Serial Ports
• Although 25 pins are defined, many devices only use
a small subset (4 to 9 pins). These devices require a
software generated carrier signal.
4-pin connection
1 ------- 1 Frame Ground
2 ------- 2 Transmit Data
3 ------- 3 Receive Data
7 ------- 7 Signal Ground
11. Serial Ports
• Devices which provide for limited modem control use
9 pin connections.
9-pin connection
DB9 DB25
1 ------- 20 Data Terminal Ready
2 ------- 2 Transmit Data
3 ------- 3 Receive Data
4 ------- 8 Data Carrier Detect
5 ------- 7 Signal Ground
6 ------- 6 Data Set Ready
7 ------- 5 Clear To Send
8 ------- 4 Request To Send
12. Serial Ports
• Hardwired connections generally use a straight-
through connection.
Straight-Through Connection
1 ------- 1 Frame Ground
2 ------- 2 Transmit Data
3 ------- 3 Receive Data
4 ------- 4 Request To Send
5 ------- 5 Clear To Send
6 ------- 6 Data Set Ready
7 ------- 7 Signal Ground
8 ------- 8 Data Carrier Detect
20 ----- 20 Data Terminal Ready
13. Serial Ports
• Some devices require a null-modem cable. This cable
fools the device at each end on the link into thinking it
is receiving the proper modem control signals, while in
fact each device is generating it’s own modem control
signals.
Null Modem Connection
1 ------- 1 Frame Ground
2 ------- 3 Transmit Data
3 ------- 2 Receive Data
4 ------- 5 Request To Send
5 ------- 4 Clear To Send
6,8 ---- 20 Connect DSR/DCD to DTR
7 ------- 7 Signal Ground
20 ----- 6,8 Connect DTR to DSR/DCD
14. Serial Ports
• Some manufacturers have come out with alternate
connectors for use with RS-232 connections: Apple
uses a Mini-Din 8 connector, PC’s use DB-9
connectors, and some patch panels and other serial
equipment use telephone style RJ-45 connectors.
15. Serial Ports
• Working With Serial Devices
– When dealing with serial devices there are several complicating
factors:
• You must set the communication speed (baud rate) of the device
and the serial port.
• You must set the correct form of parity checking on the device
and the serial port.
• You must set the number of stop bits to be used on the device
and the serial port.
• You must set the word length on the device and the serial port.
16. Serial Ports
• Terminal Setup (Software)
– The built-in terminal devices on a UNIX workstation are
usually /dev/ttya (/dev/term/a) and /dev/ttyb (/dev/term/b).
• The modem control equivalents of ttya and ttyb are /dev/cua0
/dev/cua1.
– For any serial connection you must set up certain system
parameters:
• You must tell the system to listen for logins on a terminal port.
• Dial-up modems listen for logins, but they must also monitor
modem control signals to control the status of the link.
• Dial-out modems require setup information in /etc/remote so the
tip and cu commands know how to talk to the modem.
17. Serial Ports
• Serial Ports
– Most terminals are used as login devices by the users. The
sequence of events to start up a login session are:
• User enters login name at the getty prompt.
• Getty executes login
• login requests a password, and confirms it against /etc/passwd.
• login prints the message of the day from /etc/motd.
• login runs a shell and sets the TERM variable.
• The shell executes the appropriate startup files for the user.
• The shell prints the UNIX prompt and waits for input.
18. Serial Ports
• Managing Terminals
• When the user logs out, init takes over and starts a new getty
process.
• Getty reads configuration information from /etc/ttytab (BSD)
or /etc/inittab (ATT)
• /etc/ttytab contains entries which specify the terminal port, the
program to run on that port, the terminal type connected to the
port, {on|off} and possibly [secure].
– ttya “/usr/etc/getty std.9600” wyse50on
• The getty program checks /etc/gettytab to determine what the
“std.9600” entry means, and sets the line disciplines
appropriately.
– 2|std.9600|9600-baud::sp#9600:
19. Serial Ports
• Managing Terminals
– In the ATT model, getty uses the /etc/inittab file to
determine how to set the serial port.
– The /etc/inittab file consists of entries with the format
id:run-levels:action:process.
– A typical entry might be:
• 11:234:respawn:/etc/getty tty11 9600
– The getty program consults the /etc/gettydefs file to
determine how to set the port disciplines:
• 9600# B9600 HUPCL # B9600 SANE IXANY HUPCL #login:
#4800
– The format of the entries is:
label#initflags#finalflags#prompt#next
20. Serial Ports
• Managing Terminals
– The Service Access Facility (SAF) - is one method for
managing serial devices under Solaris. It is a suite of
commands which interacts with the serial device driver to
allow the system administrator to configure the port hardware,
and the port monitor software.
• The SAF allows you to
– Manage and troubleshoot TTY devices
– Manage and troubleshoot network print service
requests.
– Manage and troubleshoot the Service Access
Controller.
– Add and manage “listen” port monitor services.
– Add and manage ttymon port monitor services.
21. Serial Ports
• Managing Terminals
• The SAF is not a single program; it is a suite of programs and
background processes which control other programs which do all
of the work.
– The top-level SAF program is the Service Access
Controller (SAC).
» The SAC is initialized at system boot. It is started by the
scripts in the directory /etc/init.d.
» The SAC initializes the system environment by
interpreting the /etc/saf/_safconfig script. This script
allows the system administrator to customize the serial
port parameters for the machine.
22. Serial Ports
• Managing Terminals
» After the environment is set up, the SAC
interprets the /etc/saf/_sactab file to start and
customize the port monitors.
» Each port monitor is spawned as a new
process. The SAC maintains control of these
processes, and is therefore the parent process.
» Each child process started by the SAC invokes
the appropriate /etc/saf/port_monitor/_config
script to customize it’s own environment and
start any processes required to enable the
login process.
23. Serial Ports
• Managing Terminals
» Solaris implements two port monitors; ttymon,
and listen.
» ttymon is the program which monitors the serial
ports, and directs data to/from the ports to the
correct destination.
» The ttymon command uses the definitions in
the /etc/ttydefs file to set line disciplines and
baud rate for each port.
» Once the line disciplines are set, the ttymon
hands control of the port over to the login
process.
25. Serial Ports
• Managing Terminals
– The sacadm command is used to administer the SAC.
» sacadm allows the system administrator to add/remove
port monitors, start/stop port monitors, enable/disable
port monitors, install/replace configuration scripts,
install/replace port monitor configuration scripts, and
print port monitor information.
» sacadm accepts input from stdin, and uses this input to
control the SAC.
» Non-privileged users may use sacadm to request the
status of print jobs, port monitors, and system
configuration scripts.
26. Serial Ports
-a Add a port monitor
-c cmd Execute the command string cmd
-d Disable the port monitor pmtag
-e d Do not enable the new port monitor
x Do not start the new port monitor
-g request output or modify /etc/saf/pmtag/_config
-G request output or modify /etc/saf/_sysconfig
-k Stop port monitor pmtag
-l is used to request port monitor information
-L same as -l except use condensed format output
-n count Set the restart count to count
-p pmtag Specifies the tag associated with a port monitor
-r Remove port monitor pmtag
-s Start a port monitor pmtag
-t type Specifies the port monitor type
-v ver Specifies the version number of the port monitor
-x Tells the SAC to read its database file (_sactab)
-y Comment Include comment in the _sactab entry for port monitor pmtag
-z script With -g / -G to specifies location of configuration script
27. Serial Ports
• Managing Terminals
– The ttyadm command is used to format ttymon
administrative information for interpretation by the
sacadm and pmadm commands.
» The ttyadm command does not work with listen
monitors.
28. Serial Ports
• Managing Terminals
– Listen is the port monitor program which monitors the
network for service requests from other hosts.
– Listen monitors may also manage some network
services which are not controlled by the inet facility.
» For example the network printer services are controlled
by the listen port monitor.
» The sacadm, pmadm, and nlsadmin commands are used
to configure/administer the listen port monitor.
» We will discuss the listen port monitor in more detail in
the section on printers, and again in the networking
section.
30. Serial Ports
• Managing Terminals
– Admintool is another method for managing serial devices. It is a
point and click GUI which interfaces to the SAF commands for
you.
– Because admintool relies on the command line form of the
commands, and sometimes you want to do non-standard things,
it is best to discuss how to use the command line commands.
Once we understand them, we may never use them again...but
understanding them is important!
31. Serial Ports
• Managing Terminals
– In order to connect a hardwired terminal to the system we must
first:
• Set up the port monitor software.
– As root, use the sacadm command to enable login
services on the port.
– NOTE: You must use the bourne shell to execute the
sacadm commands, or they may fail or provide
unexpected results.
• Configure the terminal.
• Test the setup to determine if the setup is correct.
32. Serial Ports
• Managing Terminals
– To configure the software, first we check to see if a ttymon is
already running on the port:
• sacadm -l -t ttymon
– If no ttymon is running, set one up:
– sacadm -a -p zsmon -t ttymon -c /usr/lib/saf/ttymon -v ‘ttyadm -V’
• NOTE: The string zsmon is known as the Port Monitor Tag
(PMTAG)
33. Serial Ports
• Managing Terminals
– Check to see if a service running on the zsmon port monitor:
– pmadm -l
– If a service is running, remove it (Note, the SVCTAG is
generally the port name such as ttya. The preceding
command will tell which SVCTAG to use here).
• pmadm -r -p (PMTAG) -s (SVCTAG)
– Set the port line disciplines and start login for the terminal:
– pmadm -a -p zsmon -s (SVCTAG) -i root -fu -v
‘/usr/sbin/ttyadmin -V’ -m “‘/usr/sbin/ttyadm -l BAUDRATE -p
“MESSAGE” -d /dev/term/(PORT) -T vt100 -i ‘terminal
disabled’ -s /usr/bin/login -S -y’”
34. Serial Ports
• The stty command is a utility that allows the user, or administrator, to set
specific terminal port characteristics.
• Typical uses of the stty command include setting the baud rate, size of
the display, parity, and special characters (erase character, interrupt
character, redraw character, and so on).
• stty also allows the user to view the current settings of these (and other)
parameters.
• Viewing Port Settings Using stty
– The invocation of stty that allows the user to view port settings ison
of:
stty a or stty all or stty everything
• The second command lists several variants, because each version of
UNIX seems to have its own flag to cause stty to display this
information.
35. Serial Ports
• Terminal Problems and Solutions
– Most terminal problems are caused by one of:
• You forgot to make init re-read the configuration files.
Typing kill -1 1 (as root) will cause this to happen.
• Forgot to set soft carrier mode on 3 wire connections.
• Forgot to use the cu device for modem control
connections.
• Wrong type of cable (wrong pinout, null-modem instead
of straight through, bad cable)
• Port Monitor incorrectly configured.
• Wrong line discipline information at one end of the link
(parity, baud rate, stop bits).
• Bad port/terminal
36. Serial Ports
• Terminal Problems and Solutions
• Sometimes a program will wedge a terminal. Vi, and any other
screen oriented software can exit non-gracefully and cause the
terminal to be left in a strange state. Many times you can recover
from this.
– On BSD systems, type reset
– On ATT systems, type stty sane
– Sometimes the terminal will not accept a <CR>, so you have to
use <LF> or CTRL-J after the commands to get any action from
the system.
37. Modems
• Modem Control Signals
– Hard and Soft carrier
• UNIX systems expect to see the Data Carrier Detect signal (pin
8) active (+5VDC) when a device is connected and ready to
communicate.
• If the hardware actually expects pin 8 to be active, then the
device is said to be using “hard carrier”.
• Many systems employ software which pretends that the DCD
signal is active. These systems are using “soft carrier”.
• Soft carrier simplifies the wiring, and is often adequate for
terminal connections.
• Soft carrier is not adequate for modem connections, or for many
printer connections.
38. Modems
• Modem Control Signals
– The CTS/RTS signals are used to control data-flow between
the devices.
– Flow control is essential for modems, and is also very useful
for many printers.
• Many printers have limited data buffers. These printers have to
tell the computer to stop sending data while they drain their
buffers.
• Some printers use X-ON/X-OFF (Control-S, Control-Q) to signal
the computer when to stop/start sending data. This method is
not always reliable.
• Most printers prefer to use use the modem-control signals to
control data-flow.
39. Modems
• Modem Control
– When a device is wired for modem control operation, the
CTS/RTS signals define when each device may send data to
the other. If DCD is true, and:
• a device sets it’s Clear-To-Send signal to true, then it is
signaling the other end of the connection that it is ready to
receive data.
• a device sets it’s Request-To-Send signal to true, it is telling the
device at the other end of the connection that it is ready to send
data.
• If the Data Carrier Detect signal transitions to false, the carrier
has been lost, so the system should log the user out, and the
connection should be terminated.
40. Modems
• Managing Modems
– Modems take a little more setup information in the way of
configuration files.
– The /etc/remote file contains information used for dial-out
connections by the tip and cu programs. A typical entry might be:
• dial9600|9600 Baud
Hayes:dv=/dev/cul0:br#9600:cu=/dev/cul0:at=hayes:du:
• systema:pn=5551212:tc=dial9600
• monet:pn=@:tc=dial9600
– The /etc/phones file contains entries of the form:
• monet 8,,510,555-4567,,,,xxxx-xxx
• cc 5552530
41. Modems
• Managing Modems
– In order to connect a bi-directional modem to the system
we must first:
– Set the PROM monitor to enable modem control signals.
• eeprom ttya-ignore-cd=true
• eeprom ttya-rts-dtr-off=true
– Connect the modem to the port with a straight through
cable. DO NOT use a null-modem cable, nor should you
cross any of the pins in the modem cable.
42. Modems
• Managing Modems
• Set up the port monitor software.
– As root, use the sacadm command to enable login
services on the port.
– NOTE: You must use the bourne shell to execute
the sacadm commands, or they may fail or provide
unexpected results.
– To configure the software, first we check to see if a
ttymon is already running on the port:
• sacadm -l -t ttymon
– If no ttymon is running, set one up:
43. Modems
• Managing Modems
– sacadm -a -p zsmon -t ttymon -c /usr/lib/saf/ttymon -v ‘ttyadm -V’
• NOTE: The string zsmon is known as the Port Monitor
Tag (PMTAG)
– Check to see if a service running on the zsmon port
monitor:
– pmadm -l
– If a service is running, remove it (Note, the SVCTAG is
generally the port name such as ttya. The preceding
command will tell which SVCTAG to use here).
• pmadm -r -p (PMTAG) -s (SVCTAG)
– Set the port line disciplines and start login for the
44. Modems
• Managing Modems
– pmadm -a -p zsmon -s (SVCTAG) -i root -v ‘/usr/sbin/ttyadmin
-V’ -fu -m “‘/usr/sbin/ttyadm -p “MESSAGE” -d /dev/term/
(PORT) -s /usr/bin/login -l BAUDRATE -b -S n -m
ldterm,ttcompat’” -y “dial-in/out on serial port”
– Configure the modem.
– Test the setup to determine if the setup is correct.
45. Modems
• Using Dial-in Passwords
– Some versions of UNIX provide a dial-in password, an additional
aid for defending dial-in terminal access. The dial-in password is
controlled by two files, /etc/dialups and /etc/d_passwd.
• 1. Create /etc/dialups. This file contains a single entry per line
with the path of each dial-in modem line (e.g., /dev/term/a).
• 2. Create /etc/d_passwd. This file contains a single entry for each
possible shell a dial-in modem user might use.
The following is a sample d_passwd file.
/usr/lib/uucp/uucico: passwd-goes-here:
/usr/bin/csh: passwd-goes-here:
/usr/bin/ksh: passwd-goes-here:
/usr/bin/sh: passwd-goes-here:
• 3. Insert an encrypted password for each shell in place of the
passwd-goes-here strings shown previously.
46. PPP
• A host can be a PPP client or a PPP server.
– If your host is dialing out to another server, your host is a PPP client.
– If other hosts are dialing in to your system, your host is a PPP
server.
– Most operating systems provide tools for implementing both client
and server sides of PPP.
• The process a user goes through to establish a PPP link to a
typical PPP server includes the following steps.
– Dial into the server’s modem.
– Log in using a valid user name and password pair.
– At the shell prompt, issue the command ppp to start PPP on the
server.
– Start PPP on the user’s system.
47. PPP
• Windows Point-to-Point Protocol (PPP)
– The Microsoft PPP protocol is the Windows PPP client.
– The PPP protocol setup is part of the Network and Dialup
connections control panel.
• The selections under this wizard are somewhat
limited; the dial-up line can be a terminal-style dial-up,
a PPP dial-up, or a SLIP dial-up line.
• The NETWORK tab of the dial-up control panel allows
you to select between the PPP and SLIP connections.
48. PPP
• Linux includes the following utilities, used to configure the
client end of the PPP link.
– Kppp: The kppp utility is a PPP setup and dialer tool used
under the KDE desktop manager.
– WvDial: A PPP driver for Linux. This driver was designed
with an emphasis on simplicity.
– RP3: Short for RedHat PPP. RP3 includes a “wizard”
interface to guide the user through the
setup/configuration of the PPP link.
– Linuxconf: A generalized tool for configuring and
managing your Linux machine. Linuxconf includes a
utility to help configure PPP.
49. New Serial Ports
• Two new serial bus technologies have recently joined the
mainstream offerings on computer systems:
– the Universal Serial Bus (USB) and
– FireWire interfaces.
– These two interfaces are high-speed system
interconnects that support devices beyond modems and
terminals.
– Both interfaces allow you to add disks, tapes, and
network adapters to the system via the USB/FireWire
ports.
50. New Serial Ports
• USB Interface
• The intent of the USB architecture is to provide a
replacement for the aging serial and parallel ports on
existing computers.
– The traditional serial bus requires an IRQ, I/O space, and
memory space for each port, and only one device can plug into
each port. USB uses one IRQ no matter how many devices are in
use.
– USB cables consist of four wires.
• Two of the wires supply voltage and two are data signal wires.
• The bus operates at either 12 megabits per second or 1.5
megabits per second, depending on the attached device.
– The devices tell the bus what their speed is through the
voltage cables. High-speed devices shift the positive voltage
lead while slow-speed devices shift the negative voltage.
51. New Serial Ports
• FireWire Interface (IEEE 1394)
– The IEEE-1394 Serial Interface (FireWire) is a versatile, high-speed,
low-cost method of interconnecting a variety of personal computer
peripherals and consumer electronics devices.
– The IEEE-1394 bus was developed in 1986 as Apple Computer’s
alternative to the traditional COM ports, which had been used to
connect printers, modems, external fixed-disk drives, scanners, and
other peripherals to PCs.
– The FireWire interface delivers up to 200 Mbps of data/control
information.
– Versions that support 400 Mbps and a 1.2-Gbps (gigabits per
second) are under development.
52. Reference
• Good Reference for serial ports and Unix:
– http://www.stokely.com/unix.port.resources/tutorials.html
53. Summary
• Serial ports are low-speed communication channels provided by most
computer systems. The hardware and signaling used on these ports are
defined by standards, but the software employed by different operating
systems is not. This often leads to confusion on the part of an
administrator that has to deal with serial ports on many operating
environments.
• This chapter examined generic serial port standards and terminology, as
well as the configuration and management utilities supplied by Windows
and several flavors of UNIX operating systems. Also covered were
configuration and management procedures for using serial ports under
the point-to-point network protocol. The chapter also examined how to
disable serial port services on traditional serial ports.
• Whereas traditional serial ports are still used on most computer
systems, two new serial port offerings allow users to connect an entirely
new set of devices to the system using serial connections. The
Universal Serial Bus (USB) and FireWire (IEEE1394) busses are both
standards-driven serial interconnect bus specifications.