Upload
swazz
View
222
Download
0
Embed Size (px)
Citation preview
8/7/2019 CN Serial Ports
http://slidepdf.com/reader/full/cn-serial-ports 1/53
8/7/2019 CN Serial Ports
http://slidepdf.com/reader/full/cn-serial-ports 2/53
Chapter Goals
� Understand serial port terminology.
� Understand serial port capabilities.
� Understand serial port signals.
� Understand serial port conf iguration
� Understand serial port management.
� Understand modem connections and setup.
� Disabling serial port services.
� Understand new-technology serial ports.
8/7/2019 CN Serial Ports
http://slidepdf.com/reader/full/cn-serial-ports 3/53
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 f lexible.
± Serial ports can be used f or terminal connections, printer
connections, network connections, modem connections,
keyboar ds, mice, and other input/output devices.
8/7/2019 CN Serial Ports
http://slidepdf.com/reader/full/cn-serial-ports 4/53
Serial Ports� Serial Ports
± Serial ports use standar d pin-outs f or the connectors.
The most common of these standar d is known as RS-232.
� Proposed by the Electronic Industries Association (EIA).
� RS stands f or Recommended Standar d.
� RS-232 def ines the pin-outs of the connectors and the
voltage levels allowed on each pin of a serial portconnection. RS-232 is f unctionally identical to the CCITTV.24/V.28 standar ds.
� RS-232 def ines two types of signals; Data signals, and f low-control signals.
8/7/2019 CN Serial Ports
http://slidepdf.com/reader/full/cn-serial-ports 5/53
Serial Ports� Serial Ports
� The RS-232 standar d def ines how the f low control signals
interact to manage the f low of data across a connection.
�The
f ull
f u
nctio
nality o
f the R
S-232 sta
ndar
dis rarely supporte
d,as several of the signals are not required f or simple
communications connections.
� Traditional RS-232 uses 22 gauge stranded, twisted-pair cable.
� RS-232 signal voltages are def ined to be +/- 12 volts DC.
�R
S-232 co
nnectio
ns termi
nate i
na 25 pi
n D
-conn
ector (alsoknown as a DB-25). The computer has the receptacle, while the
cable has a plug.
� Accor ding to the standar d, RS-232 will drive a 50 f oot cable at
9600 baud.
8/7/2019 CN Serial Ports
http://slidepdf.com/reader/full/cn-serial-ports 6/53
Serial Ports� Newer standar ds have emerged since RS-232 became the
standar d.
± 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 standar d which def ines the pin-outs and connector characteristics f or the RS-422/RS-423
standar ds.
± MOST RS-422/RS-423 implementations will connect
directly to RS-232 devices and f unction properly.
8/7/2019 CN Serial Ports
http://slidepdf.com/reader/full/cn-serial-ports 7/53
Serial Ports
� RS-422 uses diff erential 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 standar ds use the same signals, so we will
f ocus most of our discussion on the RS-232
standar ds.
8/7/2019 CN Serial Ports
http://slidepdf.com/reader/full/cn-serial-ports 8/53
Serial Ports� RS-232 def ines two cabling conf igurations: DTE (Data
Terminal Equipment) and DCE (Data Communications
Equipment).
±These cabling conf igurations determine which
signals a device expects on what pins.
±Most computers, printers, and terminals are
D
TE equipmen
t.±Modems are DCE equipment.
±Cables f or terminals connections are diff erent
f rom the cables used f or modem connections!
8/7/2019 CN Serial Ports
http://slidepdf.com/reader/full/cn-serial-ports 9/53
8/7/2019 CN Serial Ports
http://slidepdf.com/reader/full/cn-serial-ports 10/53
Serial Ports� Although 25 pins are def ined, many devices only use
a small subset (4 to 9 pins). These devices require a
sof tware generated carrier signal.
4-pin onne tion
1 ------- 1 Frame Ground
2 ------- 2 Transmit Data
3 ------- 3 Receive Data
7 ------- 7 Signal Ground
8/7/2019 CN Serial Ports
http://slidepdf.com/reader/full/cn-serial-ports 11/53
Serial Ports
� Devices which provide f or limited modem control use
9 pin connections.
9- i c cti
DB9 DB25
1 ------- 20 Data ermi al ea y
2 ------- 2 ra smit Data
3 ------- 3 eceive Data
4 ------- 8 Data Carrier Detect
5 ------- 7 ig al ro6 ------- 6 Data et ea y
7 ------- 5 Clear o e
8 ------- 4 eq est o e
8/7/2019 CN Serial Ports
http://slidepdf.com/reader/full/cn-serial-ports 12/53
Serial Ports� Har dwired connections generally use a straight-
through connection.
Straight-Through Conne tion
1 ------- 1 Frame Ground
2 ------- 2 Transmit Data
3 ------- 3 Receive Data
4 ------- 4 Re uest To Send5 ------- 5 lear To Send
6 ------- 6 Data Set Ready
7 ------- 7 Signal Ground
8 ------- 8 Data arrier Detect
20 ----- 20 Data Terminal Ready
8/7/2019 CN Serial Ports
http://slidepdf.com/reader/full/cn-serial-ports 13/53
Serial Ports� Some devices require a null-modem cable. This cable
f ools the device at each end on the link into thinking it
is receiving the proper mo
dem co
ntrol sig
nals, while i
n f act each device is generating it¶s own modem control
signals.N ll cti
1 ------- 1 rame ro
2 ------- 3 ra smit Data
3 ------- 2 eceive Data
4 ------- 5 eq est o e
5 ------- 4 Clear o e
6,8 ---- 20 Co ectDSR/DCD to DTR
7 ------- 7 Sig al ro
20 ----- 6,8 Co ectDTR to DSR/DCD
8/7/2019 CN Serial Ports
http://slidepdf.com/reader/full/cn-serial-ports 14/53
Serial Ports� Some manuf acturers have come out with alter nate
connectors f or 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.
8/7/2019 CN Serial Ports
http://slidepdf.com/reader/full/cn-serial-ports 15/53
Serial Ports
� Working With Serial Devices
± When dealing with serial devices there are several complicating
f actors:� You must set the communication speed (baud rate) of the device
and the serial port.
� You must set the correct f orm of parity checking on the device
and the serial port.
� You must set the number of stop bits to be used on the deviceand the serial port.
� You must set the wor d length on the device and the serial port.
8/7/2019 CN Serial Ports
http://slidepdf.com/reader/full/cn-serial-ports 16/53
Serial Ports� Terminal Setup (Sof tware)
± 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.
± or any serial connection you must set up certain system
parameters:
� You must tell the system to liste
n f or logi
ns o
na termi
nal port.
� Dial-up modems listen f or logins, but they must also monitor
modem control signals to control the status of the link.
� Dial-out modems require setup inf ormation in /et /remote so the
tip and u commands know how to talk to the modem.
8/7/2019 CN Serial Ports
http://slidepdf.com/reader/full/cn-serial-ports 17/53
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 passwor d, and conf irms it against /etc/passwd.
� login prints the message of the day f rom /et /motd.
� login runs a shell and sets the TERM variable.
� The shell executes the appropriate startup f iles f or the user.
� The shell prints the UNIX prompt and waits f or input.
8/7/2019 CN Serial Ports
http://slidepdf.com/reader/full/cn-serial-ports 18/53
Serial Ports� Managing Terminals
� When the user logs out, init takes over and starts a new getty
process.
� Getty reads conf iguration inf ormation f rom /et /ttytab (BSD) or
/et /inittab (ATT)
� /etc/ttytab contains entries which specif y the terminal port, the
program to run on that port, the terminal type connected to the
port, {on|off } and possibly [se ure].
± ttya ³/usr /et /getty std. 600´ wyse50on
� The getty program checks /etc/gettytab to determine what the
³std.9600´ entry means, and sets the line disciplines
appropriately.
± 2|std. 600| 600-baud::sp# 600:
8/7/2019 CN Serial Ports
http://slidepdf.com/reader/full/cn-serial-ports 19/53
Serial Ports� Managing Terminals
± In the ATT model, getty uses the /etc/inittab f ile todetermine how to set the serial port.
± The /etc/inittab f ile consists of entries with the f ormatid:run-levels:a tion:pro ess.
± A typical entry might be:
� 11:234:respawn:/et /getty tty11 600
± The getty program consults the /etc/gettydefs f ile todetermine how to set the port disciplines:� 9600# B9600 HUPCL # B9600 SA E IXA Y HUPCL #login:
#4800
± The f ormat of the entries is: label#initf lags#f inalf lags#prompt#next
8/7/2019 CN Serial Ports
http://slidepdf.com/reader/full/cn-serial-ports 20/53
8/7/2019 CN Serial Ports
http://slidepdf.com/reader/full/cn-serial-ports 21/53
Serial Ports� Managing Terminals
� The SA 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 SA program is the Service AccessController (SAC).
» The SAC is initialized at system boot. It is started by the
scripts in the directory /et /init.d.
» The SAC initializes the system environment by
interpreting the /et /saf /_saf onfig script. This script
allows the system administrator to customize the serial
port parameters f or the machine.
8/7/2019 CN Serial Ports
http://slidepdf.com/reader/full/cn-serial-ports 22/53
8/7/2019 CN Serial Ports
http://slidepdf.com/reader/full/cn-serial-ports 23/53
Serial Ports� Managing Terminals
» Solaris implements two port monitors; ttymon,
and listen.
» ttymon is the program which monitors the serialports, and directs data to/f rom the ports to the
correct destination.
» The ttymon command uses the def initions in
the /etc/ttydefsf ile to set li
ne
discipli
nes a
nd baud rate f or each port.
» Once the line disciplines are set, the ttymon
hands control of the port over to the login
process.
8/7/2019 CN Serial Ports
http://slidepdf.com/reader/full/cn-serial-ports 24/53
Serial Ports
8/7/2019 CN Serial Ports
http://slidepdf.com/reader/full/cn-serial-ports 25/53
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 mo
nitors, e
nable/
disableport monitors, install/replace conf iguration scripts,
install/replace port monitor conf iguration scripts, and print
port monitor inf ormation.
» sacadm accepts input f rom 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
conf iguration scripts.
8/7/2019 CN Serial Ports
http://slidepdf.com/reader/full/cn-serial-ports 26/53
8/7/2019 CN Serial Ports
http://slidepdf.com/reader/full/cn-serial-ports 27/53
Serial Ports� Managing Terminals
± The ttyadm command is used to f ormat ttymon
administrative inf ormation f or interpretation by the
sacadm and pmadm commands.» The ttyadm command does not work with listen
monitors.
8/7/2019 CN Serial Ports
http://slidepdf.com/reader/full/cn-serial-ports 28/53
Serial Ports� Managing Terminals
± Listen is the port monitor program which monitors the
network f or service requests f rom other hosts.
± Listen monitors may also manage some networkservices which are not controlled by the inet f acility.
» or example the network printer services are controlled
by the listen port monitor.
» The sacadm, pmadm, and nlsadmin commands are used
to conf igure/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.
8/7/2019 CN Serial Ports
http://slidepdf.com/reader/full/cn-serial-ports 29/53
The Service Access Controller
8/7/2019 CN Serial Ports
http://slidepdf.com/reader/full/cn-serial-ports 30/53
Serial Ports� Managing Terminals
± Admintool is another method f or managing serial devices. It is a
point and click GUI which inter f aces to the SA commands f or
you.
± Because admintool relies on the command line f orm of the
commands, and sometimes you want to do non-standar d 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!
8/7/2019 CN Serial Ports
http://slidepdf.com/reader/full/cn-serial-ports 31/53
Serial Ports� Managing Terminals
± In or der to connect a har dwired terminal to the system we must
f irst:
� Set up the port mo
nitor so
f tware.
± As root, use the sacadm command to enable login
services on the port.
± OTE: You must use the bour ne shell to execute the
sacadm commands, or they may f ail or provide
unexpected results.� Conf igure the terminal.
� Test the setup to determine if the setup is correct.
8/7/2019 CN Serial Ports
http://slidepdf.com/reader/full/cn-serial-ports 32/53
Serial Ports� Managing Terminals
± To conf igure the sof tware, f irst 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)
8/7/2019 CN Serial Ports
http://slidepdf.com/reader/full/cn-serial-ports 33/53
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 isgenerally 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 f or the terminal:
± pmadm -a -p zsmon -s (SVCTAG) -i root -f u -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¶´
8/7/2019 CN Serial Ports
http://slidepdf.com/reader/full/cn-serial-ports 34/53
Serial Ports
� The stty command is a utility that allows the user, or administrator, to set
specif ic 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 f lag to cause stty to display this
inf ormation.
8/7/2019 CN Serial Ports
http://slidepdf.com/reader/full/cn-serial-ports 35/53
Serial Ports� Terminal Problems and Solutions
± Most terminal problems are caused by one of :
� You f orgot to make init re-read the conf iguration f iles.
Typing kill -1 1 (as root) will cause this to happen.� Forgot to set sof t carrier mode on 3 wire connections.
� Forgot to use the cu device f or modem controlconnections.
� Wrong type of cable (wrong pinout, null-modem instead of straight through, bad cable)
� Port Monitor incorrectly conf igured.
� Wrong line discipline inf ormation at one end of the link(parity, baud rate, stop bits).
� Bad port/terminal
8/7/2019 CN Serial Ports
http://slidepdf.com/reader/full/cn-serial-ports 36/53
Serial Ports� Terminal Problems and Solutions
� Sometimes a program will wedge a terminal. Vi, and any other
screen oriented sof tware can exit non-gracef ully and cause the
terminal to be lef t in a strange state. Many times you can recover
f rom 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 af ter the comma
nds to get a
ny actio
n f romthe system.
8/7/2019 CN Serial Ports
http://slidepdf.com/reader/full/cn-serial-ports 37/53
Modems� Modem Control Signals
± Har d and Sof t 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 har dware actually expects pin 8 to be active, then the
device is said to be using ³har d carrier´.
� Many systems employ sof tware which pretends that the DCD
signal is active. These systems are using ³sof t carrier´.
� Sof t carrier simplif ies the wiring, and is of ten adequate f or
terminal connections.
� Sof t carrier is not adequate f or modem connections, or f or many
printer connections.
8/7/2019 CN Serial Ports
http://slidepdf.com/reader/full/cn-serial-ports 38/53
8/7/2019 CN Serial Ports
http://slidepdf.com/reader/full/cn-serial-ports 39/53
Modems� Modem Control
± When a device is wired f or modem control operation, the
CTS/RTS signals def ine 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 f alse, the carrier
has been lost, so the system should log the user out, and the
connection should be terminated.
8/7/2019 CN Serial Ports
http://slidepdf.com/reader/full/cn-serial-ports 40/53
Modems� Managing Modems
± Modems take a little more setup inf ormation in the way of
conf iguration f iles.
± The /etc/remote f ile contains inf ormation used f or dial-outconnections 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 f ile contains entries of the f orm:
� monet 8,,510,555-4567,,,,xxxx-xxx
� cc 5552530
8/7/2019 CN Serial Ports
http://slidepdf.com/reader/full/cn-serial-ports 41/53
8/7/2019 CN Serial Ports
http://slidepdf.com/reader/full/cn-serial-ports 42/53
Modems� Managing Modems
� Set up the port monitor sof tware.
± As root, use the sacadm command to enable login
services on the port.± OTE: You must use the bour ne shell to execute
the sacadm commands, or they may f ail or provide
unexpected results.
± To conf igure the sof tware, f irst we check to see if attymon is already running on the port:
� sacadm -l -t ttymon
± If no ttymon is running, set one up:
8/7/2019 CN Serial Ports
http://slidepdf.com/reader/full/cn-serial-ports 43/53
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 isgenerally the port name such as ttya. The preceding
command will tell which SVCTAG to use here).
� pmadm -r -p (PMTAG) -s (SVCTAG)
±S
et the port line
discipli
nes a
ndstart logi
n f or themodem:
8/7/2019 CN Serial Ports
http://slidepdf.com/reader/full/cn-serial-ports 44/53
Modems� Managing Modems
± pmadm -a -p zsmon -s (SVCTAG) -i root -v \ µ/usr/sbin/ttyadmin -
V¶ -f u -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´
± Conf igure the modem.
± Test the setup to determine if the setup is correct.
8/7/2019 CN Serial Ports
http://slidepdf.com/reader/full/cn-serial-ports 45/53
Modems
� Using Dial-in Passwords
± Some versions of UNIX provide a dial-in passwor d, an additionalaid f or def ending dial-in terminal access. The dial-in passwor d iscontrolled by two f iles, /etc/dialups and /etc/d_passwd .
� 1. Create /etc/dialups. This f ile contains a single entry per linewith 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 eachpossible 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 thepasswd-goes-here strings shown previously.
8/7/2019 CN Serial Ports
http://slidepdf.com/reader/full/cn-serial-ports 46/53
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 f or 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 f ollowing steps.
±D
ial into the server¶s mo
dem.
± Log in using a valid user name and passwor d pair.
± At the shell prompt, issue the command ppp to start PPP on the
server.
± Start PPP on the user¶s system.
8/7/2019 CN Serial Ports
http://slidepdf.com/reader/full/cn-serial-ports 47/53
PPP
� Windows Point-to-Point Protocol (PPP)
± The Microsof t 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 wizar d 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 allowsyou to select between the PPP and SLIP connections.
8/7/2019 CN Serial Ports
http://slidepdf.com/reader/full/cn-serial-ports 48/53
PPP
� Linux includes the f ollowing utilities, used to conf igure the
client end of the PPP link.
± K ppp: The kppp utility is a PPP setup and dialer tool
used under the KDE desktop manager.
± WvDial : A PPP driver f or Linux. This driver was designed
with an emphasis on simplicity.
± RP3: Short f or RedHat PPP. RP3 includes a ³wizar d´
inter f ace to guide the user through the
setup/conf iguration of the PPP link.
± Linuxconf : A generalized tool f or conf iguring and
managing your Linux machine. Linuxconf includes a
utility to help conf igure PPP.
8/7/2019 CN Serial Ports
http://slidepdf.com/reader/full/cn-serial-ports 49/53
New Serial Ports
� Two new serial bus technologies have recently joined the
mainstream off erings on computer systems:
± the Universal Serial Bus (USB) and
± FireWire inter f aces.± These two inter f aces are high-speed system
interconnects that support devices beyond modems and
terminals.
± Both inter f aces allow you to add disks, tapes, and network adapters to the system via the USB/FireWire
ports.
8/7/2019 CN Serial Ports
http://slidepdf.com/reader/full/cn-serial-ports 50/53
8/7/2019 CN Serial Ports
http://slidepdf.com/reader/full/cn-serial-ports 51/53
8/7/2019 CN Serial Ports
http://slidepdf.com/reader/full/cn-serial-ports 52/53
8/7/2019 CN Serial Ports
http://slidepdf.com/reader/full/cn-serial-ports 53/53