home *** CD-ROM | disk | FTP | other *** search
/ Hackers Toolkit v2.0 / Hackers_Toolkit_v2.0.iso / HTML / archive / Unix / HOWTOs / TEXT-TER < prev    next >
Text File  |  1999-11-04  |  172KB  |  3,829 lines

  1.   Text-Terminal-HOWTO
  2.   David S. Lawyer
  3.   v0.05, June 1998
  4.  
  5.   This document explains what text terminals are, how they work, how to
  6.   install and configure them, and provides some info on how to repair
  7.   them.  It may be of some use even if you don't have a terminal manual.
  8.   While it's written for real terminals on a Linux system, some of it is
  9.   also applicable to terminal emulation and/or other Unix-like systems.
  10.   ______________________________________________________________________
  11.  
  12.   Table of Contents
  13.  
  14.  
  15.  
  16.  
  17.  
  18.  
  19.  
  20.  
  21.  
  22.  
  23.  
  24.  
  25.  
  26.  
  27.  
  28.  
  29.  
  30.  
  31.  
  32.  
  33.  
  34.  
  35.  
  36.  
  37.  
  38.  
  39.  
  40.  
  41.  
  42.  
  43.  
  44.  
  45.  
  46.  
  47.  
  48.  
  49.  
  50.  
  51.  
  52.  
  53.  
  54.  
  55.  
  56.  
  57.  
  58.  
  59.  
  60.  
  61.  
  62.  
  63.  
  64.  
  65.  
  66.  
  67.   1. Introduction
  68.  
  69.      1.1 Copyright, Disclaimer, and Author
  70.         1.1.1 Copyright
  71.         1.1.2 Disclaimer
  72.         1.1.3 Author Contact
  73.      1.2 What is a Terminal ?
  74.      1.3 Dumb Terminals
  75.      1.4 Types of Terminals
  76.         1.4.1 Text Terminals
  77.         1.4.2 Graphics Terminals
  78.         1.4.3 Serial Line Graphics Terminals
  79.         1.4.4 Fast Graphics Terminals (often known by other names)
  80.         1.4.5 Quasi-Terminals (= Quasi-Computers)
  81.         1.4.6 Terminal Emulation
  82.      1.5 Terminology
  83.  
  84.   2. Quick Install
  85.  
  86.   3. Why Use a Terminal ?
  87.  
  88.      3.1 Introduction
  89.      3.2 Lower Hardware Costs
  90.      3.3 Control of Software
  91.      3.4 Hardware Upgrades
  92.      3.5 Other Advantages of Terminals
  93.      3.6 Major Disadvantages of Terminals
  94.      3.7 Are Text Terminals Obsolete ?
  95.  
  96.   4. Overview of How Terminals Work (in Linux)
  97.  
  98.      4.1 Device Names
  99.      4.2 Login/Logout
  100.      4.3 Half/Full Duplex
  101.      4.4 Terminal Memory
  102.      4.5 Commands for the Terminal
  103.      4.6 Lack of Standardization Solved by Terminfo
  104.      4.7 The Interface
  105.      4.8 Emulation
  106.      4.9 The Console
  107.  
  108.   5. Terminal Special Files: /dev/tty... etc.
  109.  
  110.      5.1 Serial Port Terminals
  111.      5.2 Pseudo Terminals
  112.      5.3 The Controlling Terminal /dev/tty
  113.      5.4 /dev/ttyI? "Terminals"
  114.      5.5 The Console: /dev/tty?
  115.      5.6 Creating a Device with mknod
  116.  
  117.   6. Some Details on How Terminals Work
  118.  
  119.      6.1 Terminal Memory
  120.      6.2 Early Terminals
  121.      6.3 Control Codes and Escape Sequences
  122.         6.3.1 Control Codes
  123.         6.3.2 Escape Sequences
  124.  
  125.   7. Special Capabilities of Some Terminals
  126.  
  127.      7.1 Color
  128.      7.2 Dual Sessions
  129.      7.3 Printer/Auxiliary Port
  130.      7.4 Character-Sets
  131.      7.5 Fonts
  132.      7.6 Keyboards & Special Keys
  133.      7.7 The Linux Console
  134.         7.7.1 Make a Terminal the Console
  135.  
  136.   8. Notes by Brand Name
  137.  
  138.      8.1 CIT
  139.      8.2 IBM
  140.      8.3 Teletypes
  141.      8.4 VT (DEC)
  142.  
  143.   9. Serial Communications on EIA-232 (RS-232)
  144.  
  145.      9.1 Introduction
  146.      9.2 Voltages
  147.         9.2.1 Voltage for a Bit
  148.         9.2.2 Voltage Sequence for a Byte
  149.      9.3 Parity Explained
  150.      9.4 Forming a Byte (Framing)
  151.      9.5 Limitations of EIA-232
  152.         9.5.1 Low Speed & Short Distance
  153.         9.5.2 Successors to EIA-232
  154.         9.5.3 Line Drivers
  155.      9.6 Synchronization & Synchronous
  156.         9.6.1 How "Asynchronous" is Synchronized
  157.         9.6.2 Defining Asynchronous vs Synchronous
  158.         9.6.3 Synchronous Communication
  159.      9.7 Block Mode
  160.         9.7.1 Introduction
  161.         9.7.2 Types of Block Modes, Forms
  162.         9.7.3 Efficiency
  163.      9.8 EIA-232 (RS-232) Books
  164.  
  165.   10. Flow Control (Handshaking)
  166.  
  167.      10.1 Why Is Flow Control Needed ?
  168.      10.2 Overrunning a Serial Port
  169.      10.3 Stop Sending
  170.      10.4 Resume Sending
  171.      10.5 Hardware Flow Control (RTS/CTS etc.)
  172.         10.5.1 RTS/CTS and DTR Flow Control
  173.         10.5.2 Interfacing DTR with RTS/CTS flow control
  174.         10.5.3 Old RTS/CTS Handshaking Is Different
  175.         10.5.4 Reverse Channel
  176.      10.6 Is Hardware Flow Control Done by Hardware ?
  177.      10.7 Obsolete ETX/ACK Flow Control
  178.  
  179.   11. Physical Connection
  180.  
  181.      11.1 Direct Cable Connection.
  182.         11.1.1 Multiport I/O Cards (Adapters)
  183.         11.1.2 Length Limitations
  184.         11.1.3 Type of Cable
  185.         11.1.4 A Kludge using Twisted-Pair Cable
  186.         11.1.5 Cable Grounding
  187.      11.2 Modem Connection
  188.         11.2.1 Dialing Out From a Terminal
  189.         11.2.2 Terminal Gets Dialed Into
  190.         11.2.3 Modem Commands
  191.      11.3 Terminal Server Connection
  192.      11.4 Making or Modifying a Cable
  193.         11.4.1 Buy or Make ?
  194.         11.4.2 Connectors & Pins
  195.  
  196.   12. Set-Up (Configure) for both Computer & Terminal
  197.  
  198.      12.1 Introduction
  199.      12.2 Terminal Set-Up
  200.      12.3 At the Computer
  201.         12.3.1 Inittab
  202.         12.3.2 Stty & Setserial
  203.         12.3.3 Setserial
  204.         12.3.4 Where to Run Setserial ?
  205.         12.3.5 Stty
  206.         12.3.6 Where to Put the Stty Command ?
  207.         12.3.7 Terminfo & Termcap (brief)
  208.      12.4 Communication Interface Settings
  209.         12.4.1 Speed
  210.         12.4.2 Parity
  211.         12.4.3 Bits/Character
  212.         12.4.4 Which Flow Control ?
  213.      12.5 Rarely Needed /etc/ttytype File
  214.      12.6 Login Restrictions
  215.      12.7 Run Command Only If TERM=my_term_type
  216.  
  217.   13. Terminfo and Termcap (detailed)
  218.  
  219.      13.1 Introduction
  220.      13.2 Terminfo Database
  221.         13.2.1 Terminfo Compiler (tic)
  222.         13.2.2 Look at Your Terminfo
  223.         13.2.3 Deleting Data Not Needed
  224.      13.3 Initialization
  225.      13.4 TERM Variable
  226.      13.5 Termcap Documents
  227.  
  228.   14. Using the Terminal
  229.  
  230.      14.1 Introduction
  231.      14.2 Starting Up the Terminal
  232.      14.3 Terminal Device Driver
  233.      14.4 Corrupted Terminal Interface
  234.         14.4.1 Symptoms
  235.         14.4.2 Sent Terminal Binary Characters
  236.         14.4.3 Abnormally Exit a Program
  237.      14.5 Special (Control) Characters
  238.         14.5.1 Command-Line Editing
  239.         14.5.2 Interrupting (& Quit, Suspend, EOF, Flush)
  240.         14.5.3 Scrolling
  241.         14.5.4 Take Next Character Literally
  242.      14.6 Inspecting the Interface
  243.      14.7 Changing the Terminal Settings
  244.         14.7.1 setterm
  245.         14.7.2 tput
  246.         14.7.3 echo
  247.         14.7.4 Saving Changes
  248.  
  249.   15. Trouble-Shooting (software)
  250.  
  251.      15.1 Terminal Was Working OK
  252.      15.2 Terminal Newly Installed
  253.      15.3 Is the Terminal OK ?
  254.      15.4 Missing Text
  255.      15.5 Getty Respawning Too Rapidly
  256.         15.5.1 No Modem Control Voltage
  257.         15.5.2 Key Shorted
  258.      15.6 Fails Just After Login
  259.      15.7 Can't Login
  260.      15.8 Garbled Login Prompt
  261.      15.9 No Sign of any Login Prompt
  262.         15.9.1 Diagnose Problem from the Console
  263.         15.9.2 Measure Voltages
  264.      15.10 Serial Test Equipment
  265.         15.10.1 Breakout Gadgets, etc.
  266.         15.10.2 Measuring Voltages
  267.         15.10.3 Taste Voltage
  268.  
  269.   16. Repair & Diagnose
  270.  
  271.      16.1 Repair Books & Websites
  272.         16.1.1 Books
  273.         16.1.2 Websites
  274.      16.2 Safety
  275.      16.3 Appearance of Display
  276.      16.4 Diagnose
  277.         16.4.1 Terminal Made a Noise
  278.         16.4.2 Terminal Made No Noise
  279.      16.5 Capacitors
  280.      16.6 Keyboards
  281.         16.6.1 Interchangeability
  282.         16.6.2 How They Work
  283.         16.6.3 One Press Types 2 Different Characters
  284.         16.6.4 Modern vs Old Keyboards
  285.         16.6.5 Keyboard Doesn't Work At All
  286.         16.6.6 Typing b Displays bb, etc. (doubled)
  287.         16.6.7 The Keyboard Types By Itself
  288.         16.6.8 Liquid Spilled on the Keyboard
  289.         16.6.9 Cleaning Keyboard Contacts
  290.            16.6.9.1 Keyboards with Membranes
  291.            16.6.9.2 Keyboards with Individual Switches
  292.  
  293.   17. Appendix
  294.  
  295.      17.1 List of Linux Terminal Commands
  296.         17.1.1 Sending a Command to the Terminal
  297.         17.1.2 Configuring the Terminal Device Driver
  298.         17.1.3 Terminfo
  299.         17.1.4 Other
  300.      17.2 The Internet and Books
  301.         17.2.1 Terminal Info on the Internet
  302.         17.2.2 Books Related to Terminals
  303.         17.2.3 Entire Books on Terminals
  304.         17.2.4 Books with Chapters on Terminals
  305.  
  306.  
  307.   ______________________________________________________________________
  308.  
  309.   1.  Introduction
  310.  
  311.   For a quick attempt to install a terminal see ``Quick Install''.
  312.  
  313.  
  314.   1.1.  Copyright, Disclaimer, and Author
  315.  
  316.   1.1.1.  Copyright
  317.  
  318.   Copyright 1998 by David S. Lawyer.  Please freely copy and distribute
  319.   this document.  Let me know (if you can locate me and if I'm alive) if
  320.   you significantly modify it.  If certain words are trademarks, the
  321.   context should make it clear to whom they belong.  For example "MS
  322.   Windows NT" implies that "Windows NT" belongs to Microsoft (MS). Mac
  323.   is by Apple Computer.
  324.  
  325.  
  326.   1.1.2.  Disclaimer
  327.  
  328.   Much of the info in this HOWTO was obtained from the Internet and may
  329.   be unreliable (although I've done some double checking in some cases).
  330.   While I haven't intentionally tried to mislead you, there are likely a
  331.   number of errors in this document.  Please let me know about them.  It
  332.   should be obvious that I cannot be held legally responsible for them.
  333.  
  334.  
  335.   1.1.3.  Author Contact
  336.  
  337.   My email in 1998 is bf347@lafn.org.  Please let me know of any errors
  338.   in facts, opinions, logic, spelling, grammar, clarity, links, etc.  I
  339.   realize that this document needs some improvement so I hope to revise
  340.   it about once a month .  Please send me any info that you think
  341.   belongs in this document.
  342.  
  343.  
  344.   1.2.  What is a Terminal ?
  345.  
  346.   A terminal consists of a screen and keyboard that one uses to
  347.   communicate remotely with a (host) computer.  One uses it just like it
  348.   was a personal computer but the terminal is remote from the host
  349.   computer (on the other side of the room or even on the other side of
  350.   the world).  Programs execute on the host computer but the results
  351.   display on the terminal screen.  Its computational ability is
  352.   relatively low (otherwise it would be a computer and not a terminal).
  353.   This computational ability is generally limited to the ability to
  354.   display what is sent to it (possibly including full-screen graphics).
  355.  
  356.   In the days of mainframes from the mid 1970's to the mid 1980's, most
  357.   people used terminals to communicate with computers.  They typed in
  358.   programs, ran programs, wrote documents, issued printing commands,
  359.   etc.  A cable connected the terminal to the computer (often
  360.   indirectly).  It was called a terminal since it was located at the
  361.   terminal end of this cable.
  362.  
  363.   If you've been using Linux (except for X-Window use) with a computer
  364.   monitor and keyboard you already know what a terminal is because you
  365.   have been using one (or more precisely a "virtual terminal").  The
  366.   monitor (along with the keyboard) is called the console, but it
  367.   emulates a terminal.
  368.  
  369.   A real terminal is different from a monitor because it's a different
  370.   electronic setup.  A text terminal is often connected to a serial port
  371.   of the computer via a long cable.  Thus, in contrast to a monitor
  372.   which is usually located right next to the computer, a terminal may be
  373.   quite a distance away from its host computer.  The video card inside a
  374.   computer stores the video image seen on the monitor screen.  For a
  375.   terminal, the equivalent of this video card is built right into the
  376.   terminal but since text terminals are often monochrome without much
  377.   graphics, the capabilities of its "video card" are rather weak.  Also,
  378.   most text terminals do not have mice.
  379.  
  380.   In network terminology, one might think that the terminal is the
  381.   client and the host computer the server.  This is not actually true
  382.   since the only "service" the host provides is to receive every letter
  383.   typed at the keyboard and react to this just like a computer would.
  384.   The terminal is like a window into the computer just like a monitor
  385.   is.  You may have already used virtual terminals in Linux (by pressing
  386.   Alt-F2, etc.).  A real terminal is just like running such a virtual
  387.   terminal on its own screen and keyboard.  In contrast to using a
  388.   virtual terminal at the console (monitor), this allows another person
  389.   to sit at the real terminal and use the computer simultaneously with
  390.   others.
  391.  
  392.  
  393.   1.3.  Dumb Terminals
  394.  
  395.   There are various conflicting definitions of "dumb terminal", but as
  396.   time goes by, more and more terminals are called dumb.  This document
  397.   mainly covers text terminals which display only text on the screen.
  398.   It might be titled "Dumb-Terminal-HOWTO" but in some computer
  399.   magazines any terminal, no matter how smart, including ones which
  400.   present a full graphical user interface (GUI), are called dumb.  If
  401.   all terminals are "dumb" then there is no point of prefixing the word
  402.   "dumb" to terminal (except as a sales pitch to sell computers or the
  403.   like in place of "smart" terminals).  Due to the ambiguous meaning of
  404.   "dumb terminal" it is not classified here as a type of terminal.
  405.  
  406.  
  407.   1.4.  Types of Terminals
  408.  
  409.   1.4.1.  Text Terminals
  410.  
  411.   For a text terminal, a 2-way flow of information between the computer
  412.   and the terminal takes place over the cable that connects them
  413.   together.  This flow is in ASCII bytes where each byte usually
  414.   represents a character.  Bytes typed at the keyboard go to the
  415.   computer and most bytes from the computer are displayed on the
  416.   terminal screen.  Special bytes (or sequences of bytes) from the
  417.   computer tell the terminal where to move the cursor to, what to erase,
  418.   where to begin and end underlining and/or blinking and/or bold, etc.
  419.   There are often hundred of such special commands and many terminals
  420.   can even change fonts.
  421.  
  422.   The communication uses characters (letters) encoded using a code chart
  423.   for the character set being used.  Usually, the first 128 bytes out of
  424.   256 possible bytes use ASCII codes.  Terminals for unix-like systems,
  425.   normally connect to computers via a cable running between the
  426.   asynchronous serial ports (per RS-232-C = EIA-232-D) of the host
  427.   computer and terminal.  Sometimes the connection is via modem or
  428.   terminal server, etc.
  429.  
  430.   Other names for text terminals are "serial terminal", "character-cell
  431.   terminal", "ASCII terminal", "ANSI terminal", "asynchronous terminal",
  432.   "data terminal", "video terminal" and "video display terminal" (VDT).
  433.   In olden days "video display unit" (VDU) was used for terminals but
  434.   strictly speaking, it excludes the keyboard.
  435.  
  436.   Old IBM mainframe terminals use "block mode".  The characters you type
  437.   are temporarily retained in the terminal memory (and may possibly be
  438.   edited by a built-in editor at the terminal).  Then when the send key
  439.   (or the like) is pressed, a block of characters (sometimes just a line
  440.   of characters) is sent to the computer all at once.  Such terminals
  441.   are not feasible to use with Linux.  They are actually block devices
  442.   (and not character devices).  See section ``Block Mode''.
  443.  
  444.  
  445.   1.4.2.  Graphics Terminals
  446.  
  447.   To a limited degree some ASCII symbols can provide graphics on text
  448.   terminals.  One may form  arrows: <--- and draw boxes with _ and |.
  449.   With special graphic character sets, even more is possible.  None of
  450.   these are really graphics terminals.  However, the term "graphics
  451.   terminal" is sometimes applied to all text-only terminals since text
  452.   is a limited form of graphics.
  453.  
  454.   There are two basic types of graphics displays: raster and vector
  455.   (rarely used).  Raster graphics (bit-mapped) puts dots on the screen
  456.   by horizontal scan lines drawn by an electron beam (or by energizing
  457.   pixels or dots on a flat screen.  Vector graphic displays use smart
  458.   electronics to draw lines and curves with an electron beam that can
  459.   move in any direction.  Vector graphics draws high quality lines
  460.   without zig-zags but is both rare and expensive.  Raster graphics is
  461.   almost universally used today.  For PC's, images encoded in vector
  462.   graphic format are sometimes used but they are translated to raster
  463.   graphics format for display (with a drop in image quality).
  464.  
  465.  
  466.   1.4.3.  Serial Line Graphics Terminals
  467.  
  468.   Most of this document also applies to these.  Most of these can also
  469.   function as text terminals.  The protocalls for such graphics include:
  470.   Tektronix Vector Graphics, ReGIS (DEC), Sixel (DEC), and NAPLPS (North
  471.   American Presentation Level Protocall Syntax).  All of these are
  472.   monochrome ??
  473.  
  474.  
  475.   1.4.4.  Fast Graphics Terminals (often known by other names)
  476.  
  477.   None of these covered in this document.  A terminal that deserves to
  478.   be called smart is a graphics terminal which can rapidly display full-
  479.   screen graphics just like a PC monitor.  It will also have a mouse.
  480.   Bytes sent to it often represent bit-maps for pictures (and other
  481.   graphics).  It will often use a high-speed connection to the computer
  482.   using twisted pair or coax cable.  X-Window terminals are such
  483.   devices.
  484.  
  485.   For displaying a MS-Windows GUI there are at various types of
  486.   interfaces and terminals: Winterm using WinFrame software from Citrix
  487.   is one.  Another (based in part on Citrix's code) is Hydra (code name)
  488.   by Microsoft, also known as "Windows Terminal Server" which works with
  489.   versions 4 or higher of MS Windows NT.  Citrix uses its ICA protocall,
  490.   and has created an add-on to Hydra known as pICAsso so that WinFrame
  491.   (ICA) based terminals can use the Hydra system.  Hydra is also
  492.   multiuser.  There is also the "MultiConsole Personal Terminal" by
  493.   Unbounded Technologies and Tektronix has its multi-user interface but
  494.   will now support Hydra.  A magazine article in 1997 called Winterm a
  495.   "dumb terminal" but it's really pretty smart.  Such terminals are
  496.   often called "thin clients", but some thin clients are more that just
  497.   terminals as they can execute Java code sent to them, etc.
  498.  
  499.  
  500.   1.4.5.  Quasi-Terminals (= Quasi-Computers)
  501.  
  502.   "Quasi" is my terminology (not standard).  These are neither true
  503.   computers nor terminals but are something in-between.  Network
  504.   Computers (NC's) are computers with a CPU but no hard Disk.  They are
  505.   full-graphics and connect to a server computer.  They are different
  506.   from terminals since the programs they run execute on their own CPU
  507.   chips.  Java code may be sent to them for execution.  They should work
  508.   on IP networks and might work under a server running Linux.  Wintel
  509.   established a "NetPC" which, unlike the NC, is almost a PC computer.
  510.   However, it has no removable disks so users can't install their own
  511.   software or obtain copies of anything.
  512.  
  513.  
  514.   1.4.6.  Terminal Emulation
  515.  
  516.   Since a PC has a screen and keyboard (as does a terminal) but also has
  517.   much more computing power, it's easy to use some of this computing
  518.   power to make the PC computer behave like a text terminal.  Software
  519.   to do this is widely available and comes built-in with recent versions
  520.   of MS Windows.  An emulation program is often combined with a modem
  521.   dialing program (such as Minicom for Linux) so that one may (for
  522.   example) dial up public libraries to use their catalogs and indexes,
  523.   (or even read magazine articles).  The terminal emulated is often the
  524.   old VT100 (text terminal).  Sometimes the emulation is not 100%
  525.   perfect but this usually causes few problems.
  526.  
  527.   A real terminal is often nicer to use than emulating one.  It usually
  528.   costs less, often has better resolution for text, and has no disk
  529.   drives to make annoying noises.  Some real terminals can emulate
  530.   various models of terminals but it's still a real terminal.
  531.  
  532.  
  533.   1.5.  Terminology
  534.  
  535.   Configuration means the same as set-up.  While Linux commands take
  536.   options (using - symbols), options in a broader sense include various
  537.   other types of choices.  Install in the broad sense includes setting
  538.   up (configuring) software and hardware.  A statement that I'm
  539.   uncertain about ends with 2 question marks: ??  Let me know if you
  540.   know that it's correct (or in error).
  541.  
  542.  
  543.   2.  Quick Install
  544.  
  545.   This is a quick procedure to install a terminal without going through
  546.   a ``Setup'' procedure for both the terminal and the host computer.  It
  547.   probably will not work right if the terminal happens to have been set
  548.   up incompatible with the computer.  If you don't understand some of it
  549.   you'll need to consult other parts of this document for more info.
  550.  
  551.   To install a terminal, first look in /etc/termcap or terminfo.src to
  552.   find an entry for it (see ``Terminfo and Termcap (detailed)'').  You
  553.   might try "vt100" if you can't find anything suitable.  Figure out
  554.   what serial port you'll connect it to and what the tty designation is
  555.   for that port (e.g. ttyS1, see ``Device Names''.  As the root user,
  556.   edit /etc/inittab and add a getty command next to the other getty
  557.   commands.  The format of the getty command depends on which getty
  558.   program you use (see Serial-HOWTO 4.1 & 7.2 and/or type "man getty").
  559.   For getty parameters use the terminfo (or termcap) name (such as
  560.   vt100) for your terminal.  Type in a baud-rate that the terminal
  561.   supports.  But if you set the baud too high you may need to use
  562.   (See``Flow Control'').
  563.  
  564.   Then physically connect the serial ports of the terminal and computer
  565.   together with a null-modem cable and turn on the terminal.  Don't
  566.   expect most ready-made cables to be wired correctly for hardware flow
  567.   control.  Make sure the baud-rate of the terminal is set the same as
  568.   you gave to getty.  Then at the computer console type "init q" to
  569.   apply the changes you made to the inittab file.  You should now see a
  570.   login prompt at the terminal.  If you don't, tap the terminal's return
  571.   key.  If this doesn't work read more of this document and/or see
  572.   ``Trouble-Shooting''.
  573.  
  574.  
  575.   3.  Why Use a Terminal ?
  576.  
  577.   3.1.  Introduction
  578.  
  579.   PC's are so powerful today that one such computer can often support
  580.   several persons using it at once, especially if they are doing low-
  581.   load tasks such as text editing, data entry, etc.  One way to do this
  582.   is to connect a number of terminals to a single computer (host
  583.   computer) by modems or direct cable connection.  To do this, one needs
  584.   a multi-user operating system such as Linux.  This has been called
  585.   "time sharing" but it's not good terminology today since "distributed"
  586.   computing over a network is also a type of time sharing.  It might be
  587.   better described as "centralized" computing.  But the central computer
  588.   may be connected to the rest of the world via a network over which
  589.   terminal users may communicate with, so it's not really "centralized"
  590.   either.
  591.  
  592.   Terminals have seldom been used with PC's because the popular
  593.   operating systems used for them (Windows, DOS, and Mac) were not
  594.   multiuser until 1998 (available for MS Windows NT) and previously
  595.   could not support terminals.  Now that Linux, a multiuser operating
  596.   system, is freely available for PC's, the use of terminals with PC's
  597.   becomes more feasible.  The drawback is that text terminals are not
  598.   smart enough to support the type of graphical user interface (GUI)
  599.   that many computer users today normally expect.
  600.  
  601.  
  602.   3.2.  Lower Hardware Costs
  603.  
  604.   If several people use the same computer as the same time, there is a
  605.   reduction in the amount of hardware needed for the same level of
  606.   service.  One type of savings is due to code sharing.  The application
  607.   files on hard disks are shared as well as shared libraries in memory
  608.   (even when people are running different programs provided they use
  609.   some of the same functions in their code).  Another type of savings is
  610.   due to reduction of peak load.  The hardware of a single PC may be
  611.   idle most of the time as people slowly type in information, think,
  612.   talk, or are away from their desks.  Having several people on the same
  613.   computer at once makes good use of much of this idle time which would
  614.   otherwise be wasted.
  615.  
  616.   These savings are substantial.  One may roughly estimate that for 9
  617.   persons (8 terminals & 1 console) the shared PC only needs about 3
  618.   times as much capacity (in memory, disk storage, CPU(s), etc.) as a
  619.   single PC in order to provide the same level of service per person (9
  620.   times as much service overall).  Thus the computational hardware for
  621.   such a shared system should only cost about 1/3 as much per user.
  622.   However, the cost of the display hardware (CRT's, keyboards, video
  623.   electronics, etc.) is about the same for both cases.  The terminals
  624.   have the added cost of requiring additional serial ports at the host
  625.   computer.
  626.  
  627.   For a fair comparison with PC's, the terminals should have the same
  628.   capabilities as the PC monitors.  Unfortunately, color graphic
  629.   terminals for Linux (X-windows) with high speed communication is a
  630.   niche market with high prices so in this case there may not be much
  631.   (if any) savings in hardware costs.  But for text terminals the
  632.   savings will be substantial.
  633.  
  634.  
  635.   3.3.  Control of Software
  636.  
  637.   For centralized computing, software (and the updates to software) only
  638.   need be installed on one host computer instead of several.  The person
  639.   in charge of this computer may control the software which is installed
  640.   on it.  This is advantageous if the person controlling the host
  641.   computer does an excellent job and knows about the needs and
  642.   preferences of the other users.  Users can be prevented from playing
  643.   games or surfing the Internet by not installing the software (or by
  644.   otherwise restricting access to it).  Whether or not centralized
  645.   control is desirable depends on the situation.
  646.  
  647.  
  648.   3.4.  Hardware Upgrades
  649.  
  650.   With terminals, the computer hardware upgrades take place on only one
  651.   computer instead of many.  This saves installation labor effort.
  652.   While the cost of the hardware for the host computer upgrade will be
  653.   more than that for a single PC (since the host needs more computing
  654.   power than a PC), the cost will be significantly less than upgrading a
  655.   number of PC's being used instead of terminals.
  656.  
  657.  
  658.  
  659.  
  660.  
  661.   3.5.  Other Advantages of Terminals
  662.  
  663.  
  664.   1. The elimination of noise from fans and disk drives provided the
  665.      terminals are not close to the computer.
  666.  
  667.   2. The users of the terminals can share data and files and even send
  668.      e-mail to each other.  It's similar to a local network.
  669.  
  670.  
  671.   3.6.  Major Disadvantages of Terminals
  672.  
  673.  
  674.  
  675.   1. For the case of a text terminal, it has no high-speed graphic
  676.      display (or high resolution graphics) although it can sometimes use
  677.      graphic character sets to draw lines, etc.  This lack limits the
  678.      software that may be used on it.
  679.  
  680.   2. If the host computer goes down, then no one can use the terminals
  681.      either (unless there is another computer to connect to).
  682.  
  683.  
  684.   3.7.  Are Text Terminals Obsolete ?
  685.  
  686.   Text terminals are technologically obsolete because for a slightly
  687.   higher cost of hardware, one could build a smart terminal (with the
  688.   same quality of display).  This wasn't always the the case since
  689.   around 1980 memory cost thousands of dollars per megabyte.  Today with
  690.   low costs for memory and processors, one could make a text terminal
  691.   smart for only about a 10% or 20% increase in cost.
  692.  
  693.   The reasons that text terminals are not yet obsolete are:
  694.  
  695.   ╖  Many people don't need full screen graphics.
  696.  
  697.   ╖  The only smart terminal for Linux is an X-Window terminal which may
  698.      cost more than a PC running Linux.
  699.  
  700.   ╖  Used text terminals are often very low in cost, yet can give access
  701.      to a much newer (and powerful) computer.
  702.  
  703.  
  704.   4.  Overview of How Terminals Work (in Linux)
  705.  
  706.   See also section ``Some Details on How Terminals Work''
  707.  
  708.  
  709.   4.1.  Device Names
  710.  
  711.   Each terminal is connected to a serial port on the host computer
  712.   (often just a PC).  The ports have names: ttyS0, ttyS1, ttyS2 etc.
  713.   These are represented by special files found in the /dev (device)
  714.   directory.  /dev/ttyS0 corresponds to COM1 in DOS or Windows.  ttyS1
  715.   is COM2, etc.  See ``Terminal Devices'' for more details.
  716.  
  717.  
  718.   4.2.  Login/Logout
  719.  
  720.   When the host computer starts up it runs the program getty (see
  721.   Serial-HOWTO 4.1 & 7.2) on each serial port which has a terminal on it
  722.   (as specified in the file etc/inittab).  The getty program runs the
  723.   "login" program to log people in.  A "login:" prompt appears on the
  724.   screen.  People at the terminals log in (after giving their passwords)
  725.   and then have access to the computer.  When it's time to shut the
  726.   terminal down, one normally logs out and turns the terminal off.  See
  727.   ``Login Restrictions'' regarding restricting logins (including
  728.   allowing the root user to log in at terminal).
  729.  
  730.  
  731.   4.3.  Half/Full Duplex
  732.  
  733.   If one watches someone typing at a terminal, the letters one types
  734.   simultaneously appear on the screen.  A naive person might think that
  735.   what one types is being sent directly from the keyboard to the screen
  736.   with a copy going to the computer (called half-duplex).  What is
  737.   usually going on is that what is typed at the keyboard is directly
  738.   sent only to the host computer (called full-duplex) which in turn
  739.   echos back to the terminal each character it receives.  In some cases
  740.   (such as passwords or terse editor commands) the typed letters are not
  741.   echoed back.
  742.  
  743.  
  744.   4.4.  Terminal Memory
  745.  
  746.   The image on a CRT tube will fade away almost instantly unless it is
  747.   frequently redrawn on the screen by a beam of electrons shot onto the
  748.   face of the tube.  Since text sent to a terminal needs to stay on the
  749.   screen, the image on the screen must be stored in the memory chips of
  750.   the terminal and the electron beam must repeatedly scan the screen
  751.   (say 60 times per second) to maintain the image.  See ``Terminal
  752.   Memory'' for more details.
  753.  
  754.  
  755.   4.5.  Commands for the Terminal
  756.  
  757.   The terminal is under the control of the computer.  The computer not
  758.   only sends the terminal text to display on the screen but also sends
  759.   the terminal commands which are acted on.  These are ``control codes''
  760.   (bytes) and ``escape sequences''.  For example, the CR (carriage
  761.   return) control code moves the cursor the the left hand edge of the
  762.   screen.  A certain escape sequence (several bytes where the first byte
  763.   is the "escape" control code) can move the cursor to the location on
  764.   the screen specified by parameters placed inside the escape sequence.
  765.  
  766.   The ``first terminals'' had only a few such commands but modern
  767.   terminals have hundreds of them.  The appearance of the display may be
  768.   changed for certain regions: such as bright, dim, underline, blink,
  769.   and reverse video.   A speaker in a terminal can "click" when any key
  770.   is pressed or beep if a mistake has occurred.  Function keys may be
  771.   programmed for special meanings.  Various fonts may exist.  The
  772.   display may be scrolled up or down.  Specified parts of the screen may
  773.   be erased.  Various types of flow control may be used to stop the flow
  774.   of data when bytes are being sent to the terminal faster than the
  775.   terminal can handle them.  There are many more as you will see from
  776.   looking over a terminal manual.
  777.  
  778.  
  779.   4.6.  Lack of Standardization Solved by Terminfo
  780.  
  781.   While terminals made for the US all used the same ASCII code for the
  782.   alphabet (except for IBM terminals which used EBCDIC), they
  783.   unfortunately did not all use the same escape sequences.  This
  784.   happened even after various ANSI (and ISO) standards were established
  785.   since these standards were never quite advanced enough.  Furthermore,
  786.   older terminals often lacked the capabilities of newer terminals.
  787.   This might cause problems.  For example, the computer might send a
  788.   terminal an escape sequence telling it to split the screen up into two
  789.   windows of specified size, not realizing that the terminal was
  790.   incapable of doing this.
  791.  
  792.  
  793.   To overcome these problems a database called "termcap" (now
  794.   "terminfo") was established.  This database resides in certain files
  795.   on the computer and has a section of it (sometimes an entire file) for
  796.   each model of terminal.  For each model (such as VT100) a list of
  797.   capabilities is provided including the available escape sequences to
  798.   use, etc.  See Section ``Termcap and Terminfo (detailed)'' for more
  799.   details.  Application programs may utilize this database by calling
  800.   certain C-Library programs.  One large set of such programs (over 200)
  801.   is named "ncurses" and are listed on the manual page for ncurses.
  802.  
  803.  
  804.   4.7.  The Interface
  805.  
  806.   The environment variable TERM is the type of terminal Linux thinks you
  807.   are using.  Application programs use this to look up the capabilities
  808.   in the terminfo database so TERM needs to be set correctly.   But
  809.   there is more to a correct interface than the computer knowing about
  810.   the capabilities of the terminal.
  811.  
  812.   For bytes to flow from the computer to the terminal the terminal must
  813.   be set to receive the bytes at the same baud rate (bits per second) as
  814.   they are sent out from the terminal.  If the terminal is set to
  815.   receive at 19,200 baud and the computer sends out characters at 9600
  816.   baud, only garbage (or perhaps nothing) will be seen on the screen.
  817.   One selects the baud rate for a terminal (as well as many other
  818.   features) from the terminals "set-up" menus at the terminal.  Most
  819.   terminals have a large number of options in their "set-up" menus.
  820.   Computer serial port software has options also and these options must
  821.   be set up in a compatible way.
  822.  
  823.  
  824.   4.8.  Emulation
  825.  
  826.   Most terminals today have more than one personality (or emulation).
  827.   The terminal model numbers of terminals formerly made by DEC (Digital
  828.   Equipment Corporation) start with VT (e.g. VT100).  Many other
  829.   terminals which are not VT100 may be set up to emulate a VT100.  Wyse
  830.   is a major terminal manufacturer and most of their terminals can
  831.   emulate various DEC terminals such at VT100 and VT220.  Thus if you
  832.   want to, say, use a VT320 terminal you may either use a real VT320 in
  833.   "native" personality or possibly use some other terminal capable of
  834.   emulating a VT320.  The "native" personalities usually have more
  835.   capabilities so, other things being equal, "native" is usually the
  836.   best to use.
  837.  
  838.   The most common type of emulation is to use a PC like it was a
  839.   terminal.  Programs loaded into the PC's memory permits this.  In
  840.   Linux (unless you're in X-windows) the PC monitor (called the console)
  841.   emulates a terminal.  Even certain windows within X-windows emulate
  842.   terminals.
  843.  
  844.  
  845.   4.9.  The Console
  846.  
  847.   On a PC, the monitor is known as the console.  It emulates a terminal
  848.   of type "Linux".  One logs onto it as a virtual terminal.  See ``The
  849.   Console: /dev/tty?''.  It receives messages from the kernel regarding
  850.   booting and shutdown progress.  One may have the messages that
  851.   normally go to the console, go the a terminal by patching and
  852.   recompiling Linux. (see ``Make a Terminal the Console'').
  853.  
  854.  
  855.   5.  Terminal Special Files: /dev/tty... etc.
  856.  
  857.   "tty" is an abbreviation for "Teletype".  The first terminals were
  858.   Teletypes (like remotely controlled typewriters).  See subsection
  859.   ``Teletypes''.
  860.  
  861.  
  862.   5.1.  Serial Port Terminals
  863.  
  864.   The computer considers the terminal on a serial port to be a "device".
  865.   For each such terminal there is a special file in the /dev (device)
  866.   directory.  /dev/ttyS0 is the special file for the serial port known
  867.   as COM1 in the DOS/Windows world.  To send text to a terminal you may
  868.   redirect standard output of some command-line command to the
  869.   appropriate special file.  For example typing "echo test > /dev/ttyS1"
  870.   at the command prompt should send the word "test" to the terminal on
  871.   COM2 (provided you have write permission on /dev/ttyS1).  Similarly,
  872.   typing "cat my_file > /dev/ttyS0" will send the contents of the file
  873.   my_file to COM1 (ttyS0).
  874.  
  875.   In addition to ttyS0 (/dev/ttyS0), ttyS1, ttyS2, etc. (the "S" stands
  876.   for Serial port) there is also a "cua" series: cua0, cua1, cua2, etc.
  877.   cua0 is the same port as ttyS0, etc.  The "cu" of cua stands for
  878.   CalloUt.  The ttyS series are Posix compliant while using cua may
  879.   permit the opening of a port that the modem control lines say is not
  880.   ready.  It's claimed that the cua series is only included for
  881.   backwards compatibility so you should probably use the ttyS series.
  882.  
  883.  
  884.   5.2.  Pseudo Terminals
  885.  
  886.   Pseudo terminals have no unique physical connector on the computer.
  887.   They are used to emulate a serial port.  For example, if someone
  888.   connects via telnet to your computer over a network, they may wind up
  889.   connected to the device /dev/ptyp2 (a pseudo terminal port).  In X-
  890.   Windows, the terminal emulator program, xterm, uses pseudo terminals.
  891.   Ham radio programs under Linux also use them.  Using certain
  892.   application software it is possible to have 2 or more pseudo terminals
  893.   attached to the same physical serial port.
  894.  
  895.   Pseudo terminals come in pairs such as ttyp3 and ptyp3.  The pty... is
  896.   the master or controlling terminal and the tty... is the slave.  ttyq5
  897.   is also a pseudo terminal as is ttysc (c is a hexadecimal digit).
  898.   More precisely, pseudo master terminals are /dev/pty[p-s]n and the
  899.   corresponding slaves are /dev/tty[p-s]n where n is a hexadecimal
  900.   digit.
  901.  
  902.  
  903.   5.3.  The Controlling Terminal /dev/tty
  904.  
  905.   /dev/tty stands for the controlling terminal (if any) for the current
  906.   process (the process that uses "/dev/tty" in a command).  To find out
  907.   which tty's are attached to which processes use the "ps -a" command at
  908.   the shell prompt (command line).  Look at the "tty" column.  For the
  909.   shell process you're in, /dev/tty is the terminal you are now using.
  910.   Type "tty" at the shell prompt to see what it is (see manual pg.
  911.   tty(1)).  /dev/tty is something like a link to the actually terminal
  912.   device name with some additional features for C-programmers: see the
  913.   manual page tty(4).
  914.  
  915.  
  916.   5.4.  /dev/ttyI? "Terminals"
  917.  
  918.   ? stands for an integer.  One use of these in Linux is with the ISDN
  919.   driver package: isdn4linux.  The ttyI? is something like ttyS?.  There
  920.   is also a cui?  which is something like cua?.  The ttyI and cui
  921.   emulate modems and may be given modem commands.
  922.  
  923.  
  924.  
  925.   5.5.  The Console: /dev/tty?
  926.  
  927.   In Linux the PC monitor is called the console and has several device
  928.   special files associated with it: tty0, tty1, tty2, etc.  When you log
  929.   in you are on tty1.  To go to tty2 press Alt-F2.  tty1, tty2, etc. are
  930.   "virtual terminals" (sometimes called "virtual consoles").  You may
  931.   log in to different virtual terminals and thus have a few different
  932.   sessions with the computer going on at the same time.  You switch
  933.   between them using the Alt-F?  key where "?" is the virtual-terminal
  934.   number you want.  The console is also known as /dev/tty0 and system
  935.   messages may go to that device and display on your console.  Only the
  936.   system or the root user may write to /dev/tty0 to which /dev/console
  937.   is sometimes linked.  System messages may also be written directly to
  938.   the hardware address of the serial port card, thus bypassing
  939.   /dev/tty0.  For more info on the console see ``The Linux Console''.
  940.  
  941.  
  942.   5.6.  Creating a Device with mknod
  943.  
  944.   The /dev directory comes supplied with many device special files.  If
  945.   you need something that's not there you may try to create it with the
  946.   "mknod" command.  See the manual page tty(4) for how to do this for
  947.   serial ports.  To use mknod you must know the major and minor device
  948.   numbers.  You might be able to infer the numbers you need by using the
  949.   "ls -l" command in the /dev directory.  It will display the major and
  950.   minor numbers of existing special files.
  951.  
  952.  
  953.   6.  Some Details on How Terminals Work
  954.  
  955.   If you know little about terminals, suggest you read the first
  956.   section: ``Introduction'' and also read ``Overview of How Terminals
  957.   Work''.
  958.  
  959.  
  960.   6.1.  Terminal Memory
  961.  
  962.   The terminal screen refreshes itself at perhaps 60 times per second
  963.   from an image stored in the memory of the terminal.  For a PC the
  964.   monitor's image is stored on the video card inside the computer but
  965.   for a terminal, the equivalent of the video card is inside the
  966.   terminal.  For a text terminal the storage of the image uses little
  967.   memory.  Instead of putting every dot (pixel) on the screen into
  968.   memory and requiring the storage of about a quarter-million dots, a
  969.   much more efficient method of storage is used.
  970.  
  971.   A screen-full of text may be represented inside the terminal memory by
  972.   ASCII bytes, one for each character on the screen.   An entire screen
  973.   only takes about 2K ASCII bytes.  To display these characters, the
  974.   terminal must also know the bit-map (the shape) of each of the almost
  975.   100 printable ASCII characters.  With a bit-map of a character using
  976.   say 15 bytes, only about 1.5K of memory is needed for the bit-maps of
  977.   all the ASCII characters (the font).  This ASCII text and font memory
  978.   is scanned so that the resulting image is put on the screen about 60
  979.   times each second.  This is a form of shared memory where a single
  980.   bit-map of a letter such as the letter e, is shared by all of the many
  981.   letter e's which appear on a screenfull of text.  Low memory
  982.   requirements meant low costs to produce monitors in the early 1980's
  983.   when the cost of memory was several thousand times higher than it is
  984.   today (costing then several dollars per kilobyte).
  985.  
  986.  
  987.   6.2.  Early Terminals
  988.  
  989.   The first terminals were something like remotely controlled
  990.   typewriters which could only "display" (print on paper) the character
  991.   stream sent to them from the computer.  The earliest models were
  992.   called ``Teletypes''.  Early terminals could do a line feed and a
  993.   carriage return just like a typewriter and ring a bell when a bell
  994.   character was received.  Due to the lack of significant capabilities
  995.   this was the first type of terminal to be labeled "dumb".  This type
  996.   of terminal interface (using a terminal type called "dumb") is
  997.   sometimes used today when the computer can't figure out what kind of a
  998.   terminal it is communicating with.
  999.  
  1000.  
  1001.   6.3.  Control Codes and Escape Sequences
  1002.  
  1003.   Terminals have many capabilities some of which are always present and
  1004.   some of which require commands from the computer to change or
  1005.   activate.  To exercise all these capabilities under the control of the
  1006.   computer requires that special codes be established so that the
  1007.   computer can tell the terminal what to do.  There are two major type
  1008.   of such codes: control codes (control characters) and escape
  1009.   sequences.
  1010.  
  1011.  
  1012.   6.3.1.  Control Codes
  1013.  
  1014.   The control codes (or control characters) consist of the first 32
  1015.   bytes of the ASCII alphabet.  They include the following: carriage-
  1016.   return (cursor to far left), line-feed (cursor down one line),
  1017.   backspace, escape-character, tab, and bell.  They do not normally show
  1018.   on the screen.  There is usually a command which you may give to your
  1019.   terminal which will result in them being displayed when they are
  1020.   received by the terminal.  It's called something like "Control
  1021.   Characters Visible".  If you do this then the display may look a mess
  1022.   since escape sequences, which all start with the ESC (escape) control
  1023.   character, are no longer executed.  Words which should appear at the
  1024.   top or bottom of the screen will show up in other locations.  The
  1025.   escape sequences to reposition the cursor display on the screen but
  1026.   the cursor doesn't move to where the escape sequence says.
  1027.  
  1028.  
  1029.   6.3.2.  Escape Sequences
  1030.  
  1031.   Since there are not nearly enough control codes to do everything, many
  1032.   escape sequences are used.  They consist of the "escape" (ESC) control
  1033.   character followed by a sequence of ordinary characters.  Upon
  1034.   receiving an escape character, the terminal examines the characters
  1035.   following it so that it may interpret the sequence and carry out the
  1036.   intended command from the computer.  Once it recognizes the end of a
  1037.   valid sequence, further characters received just display on the screen
  1038.   (unless they are control codes or more escape sequences).  Some escape
  1039.   sequences may take parameters (or arguments) such as the coordinates
  1040.   on the screen to move the cursor to.  The parameters become a part of
  1041.   the escape sequence.
  1042.  
  1043.   A list of the escape sequences for your terminal should be in the
  1044.   manual for the terminal.  Except for very old terminals, there may be
  1045.   two or three hundred such sequences.  If you don't have a manual it's
  1046.   not easy to find them.  For vt100, the sequences are available on the
  1047.   Internet.  By searching the Internet for one sequence (such as ESC[5m)
  1048.   you may come across a long list of them.  One way to determine some of
  1049.   them is to find the termcap (terminfo) for the terminal and mentally
  1050.   decode it.  See ``Terminfo and Termcap (detailed)'' in this document
  1051.   and/or the ``Termcap Manual'' on the Internet.  Unfortunately, the
  1052.   termcap (terminfo) for a terminal often does not list all of the
  1053.   escape sequences which the terminal has available for use, but
  1054.   fortunately, the most important ones are usually there.
  1055.  
  1056.  
  1057.   7.  Special Capabilities of Some Terminals
  1058.  
  1059.   7.1.  Color
  1060.  
  1061.   While the common monochrome terminal is not a color terminal it may
  1062.   have a fixed "color" display other than white such as green or amber.
  1063.   All terminals have black (electron beam turned off = zero brightness).
  1064.   A real color terminal can change the color of the text and background
  1065.   to many different colors while a monochrome terminal can only change
  1066.   the brightness of a fixed color.
  1067.  
  1068.   However, changing the brightness, etc. gives a lot of possibilities.
  1069.   For example, a black and white (monochrome) terminal can have white,
  1070.   grey, and black by varying the brightness.  Some words can be black on
  1071.   a light grey background while other are highlighted by black on white.
  1072.   In addition there is white on black, underlining, and blinking.
  1073.  
  1074.   Color works like the color on a computer monitor or TV screen.  The
  1075.   CRT has three colors of dots on it with each color controlled by its
  1076.   own electron beam (3 beams).  Monochrome has inherently better
  1077.   resolution since it doesn't depend on dots permanently fixed on the
  1078.   screen.  For text terminals the only use of color is to differentiate
  1079.   text and this advantage is not always worth the cost of worse
  1080.   resolution.  Thus monochrome may be better since it also costs less.
  1081.  
  1082.  
  1083.   7.2.  Dual Sessions
  1084.  
  1085.   For this the terminal has two serial ports.  Each port is connected to
  1086.   a serial port on a different computer.  Thus one may log in to two
  1087.   different computers with each session displaying in a split-screen
  1088.   window.   Alternatively, each session may run full-screen with a "hot"
  1089.   key (or the like) to switch between sessions.  One could also connect
  1090.   to two different serial ports on the same computer and log in twice
  1091.   (similar to "virtual terminals" at the console).
  1092.  
  1093.  
  1094.   7.3.  Printer/Auxiliary Port
  1095.  
  1096.   The terminal has two serial ports as above but the two ports are not
  1097.   identical in behavior.  If a printer is connected to the printer or
  1098.   auxiliary port, then pressing certain keys will print the screen.  One
  1099.   may also have everything that displays on the screen go also to the
  1100.   printer.  If the port is an auxiliary port one may connect this to
  1101.   another computer and almost have dual sessions as above.  However, the
  1102.   video memory inside the terminal may not retain both sessions so you
  1103.   may need to refresh the screen when switching to the other session.
  1104.   There will likely not be a hot key either but possibly a programmable
  1105.   function key may be programmed to do this.
  1106.  
  1107.   There exists various key combinations and escape sequences for
  1108.   controlling such a port.  It may be difficult to find out how to use
  1109.   this port without having a terminal manual.
  1110.  
  1111.  
  1112.   7.4.  Character-Sets
  1113.  
  1114.   A character-set is normally represented by a list (or table or chart)
  1115.   of characters along with the byte code assigned to each character.
  1116.   The codes for a byte range from 0 to 255 (00 to FF in hexadecimal).
  1117.   In MS-DOS, character-set tables are called "code-pages".  You should
  1118.   examine such a table if you're not familiar with them.  They are
  1119.   sometimes included in printer and terminal manuals but may be
  1120.   difficult to find.
  1121.  
  1122.  
  1123.   ASCII is one of the most common character-sets used on text terminals.
  1124.   It is a 7-bit code but can be made into 8-bit if the first bit (high
  1125.   order bit) is always set to 0.  Other character-sets are usually
  1126.   available (except on very old terminals where the only choice is
  1127.   ASCII).  The first half of most character-sets are the conventional
  1128.   ASCII characters and the second half (the characters with the high-
  1129.   order bit set to 1) belong to a wide variety of character-sets.
  1130.   Character sets are often ISO standards.  To get a non-ASCII character
  1131.   set on a terminal, you likely need to download a soft-font for that
  1132.   character-set into the memory of the terminal.
  1133.  
  1134.   Besides ASCII, there are some other common character-sets, all 8-bit.
  1135.   CP stands for Code Page character sets invented by IBM: CP-437 (DOS
  1136.   ECS), CP-850 (Multilingual Latin 1 --not the same as ISO Latin-1),
  1137.   ISO-8859-1 (Latin-1), ANSI (derived from Latin-1).  MS Windows uses
  1138.   ANSI while the Internet often uses Latin-1.  There are several
  1139.   ISO-8859 character sets in addition to Latin-1.  These include Greek
  1140.   (-7), Arabic (-6), Eastern European (-2), and Russian (-5).  There are
  1141.   many others.  For example, KOI8-R is more commonly used for Russian
  1142.   than IS0-8859-5.  Unicode is a very large character-set where each
  1143.   character is represented by 2 bytes instead on just one byte.
  1144.  
  1145.   Websites re character-sets are:
  1146.  
  1147.   ╖  <http://www.cc.columbia.edu/kermit/charsets.html> for a short
  1148.      listing of various character-set names.
  1149.  
  1150.   ╖  <http://www.pku.edu.cn/on_line/w3html/International/Overview.html>
  1151.      for info on character-sets and the Internet.
  1152.  
  1153.   ╖  <http://www.w3.org/International/O-charset-lang.html>
  1154.  
  1155.   ╖  <http://vancouver-webpages.com/multilingual/>
  1156.  
  1157.      Once you've found the character set name (or number) you are
  1158.      interested in, you may search for more info about it on the
  1159.      Internet.
  1160.  
  1161.  
  1162.   7.5.  Fonts
  1163.  
  1164.   Most terminals made after the mid 1980's can accept downloaded soft-
  1165.   font.  This means that they can display almost any character set
  1166.   provided that you can find the soft-font for it.  If you can't find
  1167.   the needed soft-font, you can always create your own.  A font editor
  1168.   for this is called BitFontEdit (written by the author of this
  1169.   document) and might be found at
  1170.   <http://www.cs.utk.edu/~shuford/terminal_index.html>
  1171.  
  1172.  
  1173.   7.6.  Keyboards & Special Keys
  1174.  
  1175.   Terminal keyboards often have a number of keys that one doesn't find
  1176.   on a PC keyboard.  Few (if any) actual terminals will have all of
  1177.   these keys and most will have additional keys not listed here.  Some
  1178.   have a large number of special purpose keys such as terminals made for
  1179.   use with cash registers.  There are often many more key meanings than
  1180.   shown here since these keys often have extended meanings when used in
  1181.   conjunction with other keys (such as shift and control).
  1182.  
  1183.  
  1184.   ╖  BREAK sends a very long 0 bit (+12 V) of duration 300 to 700
  1185.      milliseconds to the host.  The host may interrupt if its stty has
  1186.      set brkint or ignore it if ignbrk is set.
  1187.  
  1188.  
  1189.   ╖  NO SCROLL stops the screen from scrolling like ^S does.  Depressing
  1190.      it again resumes scrolling.  Uses flow control signals to do this.
  1191.  
  1192.   ╖  REPEAT if held down with an other key, forces repeated output of
  1193.      that other key even if the auto-repeat option is set to off.
  1194.  
  1195.   ╖  LINE FEED sends the line feed character ^J to the host.  Seldom
  1196.      used.
  1197.  
  1198.   ╖  SET-UP allows the manual configuration of the terminal via menus.
  1199.      Sometimes purposely disabled by putting a block under it so it
  1200.      can't be pressed down.
  1201.  
  1202.   ╖  LOCAL disconnects the terminal from the host.  In local, what one
  1203.      types goes directly to the screen.  Useful for testing.
  1204.  
  1205.   ╖  RETURN is the same as the "enter" key on a PC.  It usually sends a
  1206.      carriage return to the host which normally get translated to a new-
  1207.      line character by the host's device driver.  On some terminals it
  1208.      may be set up to send something else.
  1209.  
  1210.   ╖  F1, F2, ... or PF1, PF2, ... are function keys which usually may be
  1211.      programmed to send out a sequence of bytes (characters).
  1212.  
  1213.  
  1214.   7.7.  The Linux Console
  1215.  
  1216.   The console for a PC Linux system is the computer monitor  It emulates
  1217.   a terminal of type "Linux".  The emulation is flexible and has
  1218.   features which go well beyond those of the vt100 terminal it emulates.
  1219.   These include the ability to use custom fonts and easily remap the
  1220.   keyboard (without patching the source code and recompiling the kernel
  1221.   as is required for the case of a real terminal).  These extra features
  1222.   reside in the console driver software and not in the emulation
  1223.   software but the results are like it was part of the emulation.  Many
  1224.   commands exist (see Keyboard-and-Console-HOWTO, formerly just
  1225.   Keyboard-HOWTO) to utilize these added features.   Real terminals,
  1226.   which use neither scan codes nor VGA cards, unfortunately can't use
  1227.   most of these features.  One may recompile Linux to make a terminal
  1228.   receive the messages which normally go to the console (see ``Make a
  1229.   Terminal the Console'').
  1230.  
  1231.  
  1232.   7.7.1.  Make a Terminal the Console
  1233.  
  1234.   Many messages from the system are normally only sent to the console.
  1235.   While the messages generated at boot-time appear on the console, they
  1236.   may also be seen on a terminal after the boot succeeds by typing the
  1237.   command: dmesg.  If the boot fails this will not be of any use, so you
  1238.   may want to have a terminal display the messages during the booting.
  1239.  
  1240.   It's possible to patch the Linux kernel to do this and recompile it.
  1241.   This will send a terminal the messages which are normally sent only to
  1242.   the console.  It doesn't fully make the terminal into a console since
  1243.   one can't remap the keyboard nor change colors like most consoles can.
  1244.   The Linux Journal in April 1997 had an article on this.  To patch the
  1245.   Linux kernel add a couple of #defines at the start of
  1246.   src/linux/drivers/char/console.c:
  1247.  
  1248.  
  1249.   ______________________________________________________________________
  1250.   <item> #define CONFIG_SERIAL_ECHO
  1251.   <item> #define SERIAL_ECHO_PORT 0x2f8  /* Serial port address  */
  1252.   ______________________________________________________________________
  1253.  
  1254.  
  1255.   If you currently use the console to select which operating system to
  1256.   boot (using LILO), but would like to do this from a terminal, then you
  1257.   need to add a line to the /etc/lilo.conf file.   See the manual page
  1258.   for lilo.conf and search for "serial=".
  1259.  
  1260.  
  1261.   8.  Notes by Brand Name
  1262.  
  1263.   This section may eventually become so large that it will become a
  1264.   separate document (or a separate file for each terminal brand).  This
  1265.   would be of use for the many cases where one lacks manuals for their
  1266.   terminals.  You could help by writing up some info for the terminal
  1267.   you use and e-mailing it to me.  Sometimes, useful information for a
  1268.   certain model may be found in the comments of the terminfo (or
  1269.   termcap) entry in the file /etc/termcap or terminfo.src.
  1270.  
  1271.  
  1272.   8.1.  CIT
  1273.  
  1274.   CIT terminals were made in Japan in the 1980's for CIE Terminals.
  1275.   They ceased to be imported in the late 1980's.  The company, CIE,
  1276.   still makes CItoh printers (in 1997) but has no parts for its
  1277.   abandoned terminals.  Ernie at (714) 453-9555 in Irvine CA sells (in
  1278.   1997) some parts for models 224, 326, etc. but has nothing for the 80
  1279.   and 101.  (The document you are now reading was written mostly on the
  1280.   101e.)
  1281.  
  1282.   To save the Set-Up parameters press ^S when in Set-Up mode.  cit80:
  1283.   Contrast: knob on rear of terminal, cit101e: Brightness: use up/down
  1284.   arrow keys in Set-Up mode.
  1285.  
  1286.  
  1287.   8.2.  IBM
  1288.  
  1289.   Don't confuse IBM terminals with IBM PC monitors.  Many IBM terminals
  1290.   don't use ASCII but instead use an 8-bit EBCDIC code.  It's claimed
  1291.   that in EBCDIC the bit order of transmission is reversed from normal
  1292.   with the high-order bit going first.  The IBM mainframe communication
  1293.   standards are a type of synchronous communication in block mode (sends
  1294.   large packets of characters).  Two standards are "BISYNC" and "SNA"
  1295.   (which includes networking standards).  Many of their terminals
  1296.   connect with coax cable (RG62A/U) and naive persons may think the
  1297.   "BNC" connecter on the terminal is for ethernet (but it's not).
  1298.  
  1299.   While this IBM system is actually  more efficient than what is
  1300.   normally used in Linux, terminals meeting this IBM standard will not
  1301.   currently work with Linux.  However, some IBM terminals are
  1302.   asynchronous ASCII terminals and should work with Linux on PC's.  The
  1303.   numbers 31xx may work with the exception that 317x and 319x are not
  1304.   ASCII terminals.  Before getting an IBM terminal, make sure there is a
  1305.   termcap (terminfo) for it.  If their isn't, it likely will not work
  1306.   with Linux.  Even if there is a terminfo, it may not work.  For
  1307.   example, there is a termcap for 327x but the 3270 is an EBCDIC
  1308.   synchronous terminal.
  1309.  
  1310.   The 3270 series includes the 3278 (late 1970's), 3279 with color and
  1311.   graphics, and the 3274 terminal controller (something like the 3174).
  1312.   They may be used for both BISYNC and SNA.  The 3290 has a split screen
  1313.   (splits into quarters).
  1314.  
  1315.   The synchronous IBM terminals don't connect directly to the IBM
  1316.   mainframe, but connect to a "terminal controller" (sometimes called
  1317.   "cluster controller" or "communication controller").  Some of these
  1318.   controllers can convert a synchronous signal to asynchronous so that
  1319.   in this case a synchronous terminal could indirectly connect to a
  1320.   unix-like host computer via its serial port.  But there is still a
  1321.   major problem and that is block transmission.  See section ``Block
  1322.   Mode''.
  1323.  
  1324.  
  1325.   8.3.  Teletypes
  1326.  
  1327.   These are antiques and represent the oldest terminals.  They are like
  1328.   remotely controlled typewriters but are large and noisy.  Made by the
  1329.   Teletype Corp., the first models were made in the 1920's and predate
  1330.   the computer by over 30 years.  Early models used electro-mechanical
  1331.   relays and rotating distributors instead of electronics.  Their Baudot
  1332.   code was only 5-bits per character as compared to 7-bit ASCII.  See
  1333.   the book "Small Computer Systems Handbook" by Sol Libes, Hayden Books,
  1334.   1978: pp. 138-141 ("Teletypes").
  1335.  
  1336.  
  1337.   8.4.  VT (DEC)
  1338.  
  1339.   Digital Equipment Corporation made the famous VT series of terminals
  1340.   including the commonly emulated VT100.  In 1995 they sold their
  1341.   terminal business to SunRiver which is now named Boundless
  1342.   Technologies.  More information is available at Shuford's Website.
  1343.   Information on current products is available from the Boundless
  1344.   website.  See ``Terminal Info on the Internet''.
  1345.  
  1346.   VT220: Some have a BNC connector for video output (not for input).
  1347.  
  1348.  
  1349.   9.  Serial Communications on EIA-232 (RS-232)
  1350.  
  1351.   9.1.  Introduction
  1352.  
  1353.   Text terminals on Unix-like systems (and on PC's) are usually
  1354.   connected to an asynchronous 232 serial port of a computer.  It's
  1355.   usually a RS-232-C, EIA-232-D, or EIA-232-E.  These three are almost
  1356.   the same thing.  The original RS prefix became EIA (Electronics
  1357.   Industries Association) and later EIA/TIA after EIA merged with TIA
  1358.   (Telecommunications Industries Association).  The EIA-232 spec
  1359.   provides also for synchronous (sync) communication but the hardware to
  1360.   support sync is almost always missing on PC's.  The RS designation is
  1361.   obsolete but is still in use.  EIA will be used in this article.
  1362.  
  1363.   Older terminals use the 7-bit ASCII code for characters but most
  1364.   terminals made after 1990 permit other character sets which use 8-bit
  1365.   characters (256 possible characters).  In order to deal with terminals
  1366.   you should also read the relevant parts of the Serial-HOWTO and look
  1367.   at an ASCII code table.
  1368.  
  1369.   The serial port is more than just a physical connector on the back of
  1370.   a computer or terminal.  It includes the associated electronics which
  1371.   must produce signals conforming to the EIA-232 specification.  The
  1372.   standard connector has 25 pins, most of which are unused.  An
  1373.   alternative connector has only 9 pins.  One pin is used to send out
  1374.   data bytes and another to receive data bytes.  Another pin is a common
  1375.   signal ground.  The other "useful" pins are used mainly for signalling
  1376.   purposes with a steady negative voltage meaning "off" and a steady
  1377.   positive voltage meaning "on".
  1378.  
  1379.   The UART (Universal Asynchronous Receiver-Transmitter) chip does most
  1380.   of the work.  Today, the functionality of this chip is usually built
  1381.   into another chip.
  1382.  
  1383.  
  1384.  
  1385.  
  1386.  
  1387.   9.2.  Voltages
  1388.  
  1389.   9.2.1.  Voltage for a Bit
  1390.  
  1391.   At the EIA-232 serial port, voltages are bipolar (positive or negative
  1392.   with respect to ground) and should be about 12 volts in magnitude
  1393.   (some are 5 or 10 volts).   For the transmit and receive pins +12
  1394.   volts is a 0-bit (sometimes called "space") and -12 volts is a 1-bit
  1395.   (sometimes called "mark").  This is known as inverted logic since
  1396.   normally a 0-bit is both false and negative while a one is normally
  1397.   both true and positive.  Although the receive and transmit pins are
  1398.   inverted logic, other pins (modem control lines) are normal logic with
  1399.   a positive voltage being true (or "on" or "asserted") and a negative
  1400.   voltage being false (or "off" or "negated").  Zero voltage has no
  1401.   meaning (except that it is an error).
  1402.  
  1403.   A range of voltages is allowed.  The specs say the magnitude of a
  1404.   transmitted signal should be between 5 and 15 volts but must never
  1405.   exceed 25 V.  Any voltage received under 3 V is undefined (but some
  1406.   terminals will accept a lower voltage as valid).  One sometimes sees
  1407.   erroneous claims that the voltage is commonly 5 volts (or even 3
  1408.   volts) but it's usually 10-12 volts.  If you are using a EIA-422 port
  1409.   on a Mac computer as an EIA-232 (requires a special cable) or EIA-423
  1410.   then the voltage will actually be only 5 V.  The discussion here
  1411.   assumes 12 V.  There is much confusion about voltages on the Internet
  1412.   and at least one book erroneously claims that a positive voltage is a
  1413.   1-bit, unaware that EIA-232 uses inverted logic for transmitted data.
  1414.  
  1415.   Note that normal computer logic normally is 5 volts (often even less)
  1416.   so that if you try to use test equipment designed for testing 5 volt
  1417.   computer logic (TTL) on the 12 volts of a serial port, it may damage
  1418.   the test equipment.
  1419.  
  1420.  
  1421.   9.2.2.  Voltage Sequence for a Byte
  1422.  
  1423.   The transmit pin (#2) is held at -12 V (mark) at idle when nothing is
  1424.   being sent.  To start a byte it jumps to +12 V (space) for the start
  1425.   bit and remains at +12 V for the duration (period) of the bit.  Next
  1426.   comes the low-order bit of the data byte.  If it's a 0-bit nothing
  1427.   changes and the line remains at +12 V for another bit-period.  Then
  1428.   comes the next bit, etc.  Finally, a parity bit may be sent and then a
  1429.   -12 V (mark) stop bit.  The line remains at -12 V (idle) until the
  1430.   next start bit.  Note that there is no return to 0 volts and thus
  1431.   there is no simple way (except by a synchronizing signal) to tell
  1432.   where one bit ends and the next one begins for the case where 2
  1433.   consecutive bits are the same polarity (both zero or both one).
  1434.  
  1435.   A 2nd stop bit would also be -12 V, just the same as the first stop
  1436.   bit.  Since there is no signal to mark the boundaries between these
  1437.   bits, the only effect of the 2nd stop bit is that the line must remain
  1438.   at -12 V idle a little longer.  The receiver has no way of detecting
  1439.   the difference between a 2nd stop bit and a longer idle time between
  1440.   bytes.  Thus communications works OK if one end uses one stop bit and
  1441.   the other end uses 2 stop bits, but using only one stop bit is
  1442.   obviously faster.  In rare cases 1 1/2 stop bits are used.  This means
  1443.   that the line is kept at -12 V for 1 1/2 time periods (like a stop bit
  1444.   50% wider than normal).
  1445.  
  1446.  
  1447.   9.3.  Parity Explained
  1448.  
  1449.   Characters are normally transmitted with either 7 or 8 bits (of data).
  1450.   An additional parity bit may (or may not) be appended to this
  1451.   resulting in a byte length of 7, 8 or 9 bits.  Some terminal emulators
  1452.   and older terminals do not allow 9 bits.
  1453.   The parity may be set to odd, even or none (mark and space parity may
  1454.   be options on some terminals).  With odd parity, the parity bit is
  1455.   selected so that the number of 1-bits in a byte, including the parity
  1456.   bit, is odd.  If a such a byte gets corrupted by a bit being flipped,
  1457.   the result is an illegal byte of even parity.  This error will be
  1458.   detected and if it's an incoming byte to the terminal an error-
  1459.   character symbol will appear on the screen.  Even parity works in a
  1460.   similar manner with all legal bytes (including the parity bit) having
  1461.   an even number of 1-bits.  During set-up, the number of bits per
  1462.   character usually means only the number of data bits per byte (7 for
  1463.   true ASCII and 8 for various ISO character sets).
  1464.  
  1465.   A "mark" is a 1-bit (or logic 1) and a "space" is a 0-bit (or logic
  1466.   0).  For mark parity, the parity bit is always a one-bit.  For space
  1467.   parity it's always a zero-bit.  Mark or space parity only wastes
  1468.   bandwidth and should be avoided when feasible.  "No parity" means that
  1469.   no parity bit is added.   For terminals that don't permit 9 bit bytes,
  1470.   "no parity" must be selected when using 8 bit character sets since
  1471.   there is no room for a parity bit.
  1472.  
  1473.  
  1474.   9.4.  Forming a Byte (Framing)
  1475.  
  1476.   In serial transmission of bytes via EIA-232 ports, the low-order bit
  1477.   is always sent first.  Serial ports on PC's use asynchronous
  1478.   communication where there is a start bit and a stop bit to mark the
  1479.   beginning and end of a byte.  This is called framing and the framed
  1480.   byte is sometimes called a frame.  As a result a total of 9, 10, or 11
  1481.   bits are sent per byte with 10 being the most common.   8-N-1 means 8
  1482.   data bits, No parity, 1 stop bit.  This adds up to 10 bits total when
  1483.   one counts the start bit.  One stop bit is almost universally used.
  1484.   At 110 bits/sec (and sometimes at 300 bits/sec) 2 stop bits were once
  1485.   used but today the 2nd stop bit is used only in very unusual
  1486.   situations (or by mistake since it seemingly still works OK that way).
  1487.  
  1488.  
  1489.   9.5.  Limitations of EIA-232
  1490.  
  1491.   9.5.1.  Low Speed & Short Distance
  1492.  
  1493.   The conventional EIA-232 serial port is inherently low speed and is
  1494.   severely limited in distance.  Ads often read "high speed" but it can
  1495.   only work at high speed over very short distances such as to a modem
  1496.   located right next to the computer.  All of the wires use a common
  1497.   ground return so that twisted-pair technology (needed for high speeds)
  1498.   can't be used without additional hardware.  However some computers and
  1499.   terminals have more modern interfaces.  See ``Successors to EIA-232''.
  1500.  
  1501.   It is somewhat tragic that the RS-232 standard from 1969 did not use
  1502.   twisted pair technology which could operate about a hundred times
  1503.   faster.  Twisted pairs have been used in telephone cables since the
  1504.   late 1800's.  In 1888 (over 110 years ago) the "Cable Conference"
  1505.   reported its support of twisted-pair (for telephone systems) and
  1506.   pointed out its advantages.  But over 80 years after this approval by
  1507.   the "Cable Conference", RS-232 failed to utilize it.   Since RS-232
  1508.   was originally designed for connecting a terminal to a low speed modem
  1509.   located nearby, the need for high speed and longer distance
  1510.   transmission was apparently not recognized.
  1511.  
  1512.  
  1513.   9.5.2.  Successors to EIA-232
  1514.  
  1515.   A number of EIA standards have been established for higher speeds and
  1516.   longer distances using twisted-pair (balanced) technology.  Balanced
  1517.   transmission can sometimes be a hundred times faster than unbalanced
  1518.   EIA-232.  For a given speed, the distance (maximum cable length) may
  1519.   be many times longer with twisted pair.  But PC-s keep being made with
  1520.   the "obsolete" EIA-232 since it works OK with modems connected to slow
  1521.   telephone lines, and it works OK with mice.
  1522.  
  1523.   One exception is Apple's Mac computer with its EIA-232/EIA-422 GeoPort
  1524.   which provides twisted-pairs (balanced) for transmit and receive.  It
  1525.   uses a small round "mini-DIN" connector.  It also provides
  1526.   conventional EIA-232 but only at 5 volts (which is still legal
  1527.   EIA-232).  However, due to the fact that Macs cost more than PC's,
  1528.   they are seldom used as a host computer for terminals.  Some newer
  1529.   terminals use EIA-423 but this is just like the unbalanced EIA-232 and
  1530.   can be connected to a EIA-232 port.  This EIA-423 is only 5 volts, but
  1531.   the specs call for higher speeds than the EIA-232 (which will be of no
  1532.   help on a long run where it's the unbalance that causes interference).
  1533.  
  1534.   EIA-530-A (balanced but can also be used unbalanced) at 2Mbits/s
  1535.   (balanced) was intended to be a replacement for EIA-232 but few have
  1536.   been installed.  It uses the same 25-pin connector as EIA-232.  The
  1537.   High Speed Serial Interface ( HSSI = EIA-612/613) uses a 50-pin
  1538.   connector and goes up to about 50 Mbits/s but the distance is limited
  1539.   to only several meters.  The Universal Serial Bus (USB) is being built
  1540.   into PCI chips.  It is 12 Mbits/s over a twisted pair with a 4-pin
  1541.   connector (2 wires are power supply) but it also is limited to short
  1542.   distances.
  1543.  
  1544.  
  1545.   9.5.3.  Line Drivers
  1546.  
  1547.   For a text terminal, the EIA-232 speeds are fast enough but the
  1548.   useable cable length is often too short.  Balanced technology could
  1549.   fix this.  The common method of obtaining balanced communication with
  1550.   a text terminal is to install 2@ line drivers in the serial line to
  1551.   convert unbalanced to balanced (and conversely).  They are a specialty
  1552.   item and are expensive if purchased new.
  1553.  
  1554.  
  1555.   9.6.  Synchronization & Synchronous
  1556.  
  1557.   9.6.1.  How "Asynchronous" is Synchronized
  1558.  
  1559.   Per EIA-232 there are only two states of the transmit (or receive)
  1560.   wire: mark (-12 V) or space (+12 V).  There is no state of 0 V.  Thus
  1561.   a sequence of 1-bits is transmitted by just a steady -12 V with no
  1562.   markers of any kind between bits.  For the receiver to detect
  1563.   individual bits it must always have a clock signal which is in
  1564.   synchronization with the transmitter clock.  Such clocks generate a
  1565.   "tick" in synchronization with each transmitted (or received) bit.
  1566.  
  1567.   For asynchronous transmission, synchronization is achieved by framing
  1568.   each byte with a start bit and a stop bit (done by hardware).  The
  1569.   receiver listens on the line for a start bit and when it detects one
  1570.   it starts its clock ticking.  It uses this clock tick to time the
  1571.   reading of the next 7, 8 or 9 bits.  (It actually is a little more
  1572.   complex than this since several samples of a bit are often taken and
  1573.   this requires additional timing ticks.)  Then the stop bit is read,
  1574.   the clock stops and the receiver waits for the next start bit.  Thus
  1575.   async is actually synchronized during the reception of a single byte
  1576.   but there is no synchronization between one byte and the next byte.
  1577.  
  1578.  
  1579.   9.6.2.  Defining Asynchronous vs Synchronous
  1580.  
  1581.   Asynchronous (async) means "not synchronous".  In practice, an async
  1582.   signal is what the async serial port sends and receives which is a
  1583.   stream of bytes each delimited by a start and stop bit.  Synchronous
  1584.   (sync) is most everything else.  But this doesn't explain the basic
  1585.   concepts.
  1586.  
  1587.   In theory, synchronous means that bytes are sent out at a constant
  1588.   rate one after another (in step with a clock signal tick ).
  1589.   Asynchronous bytes may be sent out erratically with various time
  1590.   intervals between bytes (like someone typing characters at a
  1591.   keyboard).
  1592.  
  1593.   There are borderline situations that need to be classified as either
  1594.   sync or async.  The async serial port often sends out bytes in a
  1595.   steady stream which would make this a synchronous case but since they
  1596.   still have the start/stop bits (which makes it possible to send them
  1597.   out erratically) its called async.  Another case is where data bytes
  1598.   (without any start-stop bits) are put into packets with possible
  1599.   erratic spacing between one packet and the next.  This is called sync
  1600.   since the bytes within each packet must be transmitted synchronously.
  1601.  
  1602.  
  1603.   9.6.3.  Synchronous Communication
  1604.  
  1605.   Did you ever wonder what all the unused pins are for on a 25-pin
  1606.   connector for the serial port?  Most of them are for use in
  1607.   synchronous communication which is seldom implemented on PC's.  There
  1608.   are pins for sync timing signals as well as for a sync reverse
  1609.   channel.  The EIA-232 spec provides for both sync and async but PC's
  1610.   use a UART (Universal Asynchronous Receiver/Transmitter) chip such as
  1611.   a 16450, 16550A, or 16650 and can't deal with sync.  For sync one
  1612.   needs a USART chip or the equivalent where the "S" stands for
  1613.   Synchronous.  Since sync is a niche market, a sync serial port is
  1614.   likely to be quite expensive.
  1615.  
  1616.   Besides the sync part of the EIA-232, there are various other EIA
  1617.   synchronous standards.  For EIA-232, 3 pins of the connector are
  1618.   reserved for clock (or timing) signals.  Sometimes it's a modem's task
  1619.   to generate some timing signals making it impossible to use
  1620.   synchronous communications without a synchronous modem (or without a
  1621.   device called a "synchronous modem eliminator" which provides the
  1622.   timing signals).
  1623.  
  1624.   Although few serial ports are sync, synchronous communication does
  1625.   often take place over telephone lines using modems which use V.42
  1626.   error correction.  This strips off the start/stop bits and puts the
  1627.   date bytes in packets resulting in synchronous operation over the
  1628.   phone line.
  1629.  
  1630.  
  1631.   9.7.  Block Mode
  1632.  
  1633.   9.7.1.  Introduction
  1634.  
  1635.   Block mode is seldom used with Linux.  In block mode when one types at
  1636.   a terminal, the results are saved in the terminal memory and are not
  1637.   sent just yet to the host computer.  Such terminals often have built-
  1638.   in editing capabilities.  When the user presses certain keys (such as
  1639.   the send key) what has been saved in the terminal memory is sent to
  1640.   the host computer.  Now the Linux editors vi and emacs, react
  1641.   instantly to pressing certain keys but in the above situation such
  1642.   keys will be pressed and nothing will happen since nothing is sent
  1643.   when a key is pressed.  Thus using a block mode terminal will not
  1644.   allow the use of such interactive programs.  The old IBM mainframe
  1645.   interface uses block mode so many IBM terminals are block-mode only
  1646.   and also synchronous (see Section ``Synchronization & Synchronous'').
  1647.  
  1648.  
  1649.  
  1650.  
  1651.   9.7.2.  Types of Block Modes, Forms
  1652.  
  1653.   Block mode may itself have various sub-modes such as "page" (a page at
  1654.   a time) and "line" (a line at a time).  Some terminals have both block
  1655.   transmission modes and conventional character modes and may be
  1656.   switched from one mode to another.  Async terminals which have block
  1657.   modes include HP2622A, VT130, VT131, VT330, VT340, and Visual500.
  1658.   Block modes may include a forms capability where the host computer
  1659.   sends a form to the terminal.  Then the user fills it out and hits the
  1660.   send key which sends only the data in the form back to the host
  1661.   computer.  The form itself (not the data) is displayed on the screen
  1662.   in protected fields which don't get transmitted to the host.
  1663.  
  1664.  
  1665.   9.7.3.  Efficiency
  1666.  
  1667.   Block mode takes a great deal of load off the host computer,
  1668.   especially if the host computer's hardware is designed for block modes
  1669.   (as IBM's is/was).  In character mode every character typed is sent
  1670.   immediately to the serial port and usually causes an interrupt at the
  1671.   host computer.  The host that receives the byte must stop whatever it
  1672.   is doing and fetch that character from the port hardware.  Even with
  1673.   UART's that have larger hardware buffers the timeout may be such that
  1674.   it issues an interrupt for every character typed.
  1675.  
  1676.   In true block mode a long block of characters is received using only
  1677.   one interrupt.  If block mode is used with conventional async serial
  1678.   ports newer models can now get by with issuing an interrupt every 14
  1679.   bytes since they have 16-byte hardware buffers.  Thus much of the load
  1680.   and overhead of interrupt handling is eliminated and the computer has
  1681.   more time to do other tasks when block mode is used.
  1682.  
  1683.   A significant savings for block mode occurs if the terminal is
  1684.   connected to its host via a network.  Without block mode, every
  1685.   character (byte) typed is sent in its own packet including all the
  1686.   overhead bytes (40 in a TCP/IP packet as used on the Internet).  With
  1687.   block mode, a large number of characters are sent in a single packet.
  1688.  
  1689.  
  1690.   9.8.  EIA-232 (RS-232) Books
  1691.  
  1692.   (Note: The first book covers much more than just EIA-232.)
  1693.  
  1694.   ╖  Black, Uyless D.: Physical Layer Interfaces & Protocalls, IEEE
  1695.      Computer Society Press, Los Alamitos, CA, 1996.
  1696.  
  1697.   ╖  Campbell, Joe: The RS-232 Solution, 2nd ed., Sybex, 1982.
  1698.  
  1699.   ╖  Putnam, Byron W.: RS-232 Simplified, Prentice Hall, 1987.
  1700.  
  1701.   ╖  Seyer, Martin D.: RS-232 Made Easy, 2nd ed., Prentice Hall, 1991.
  1702.  
  1703.  
  1704.   10.  Flow Control (Handshaking)
  1705.  
  1706.   Some terminal manuals call "flow control" handshaking.  Flow control
  1707.   is to prevent too fast of a flow of bytes from overrunning a terminal,
  1708.   computer, modem or other device.  Overrunning is when a device can't
  1709.   process what it is receiving quickly enough and thus loses bytes
  1710.   and/or makes other serious errors.  What flow control does is to halt
  1711.   the flow of bytes until the terminal (for example) is ready for some
  1712.   more bytes.  Flow control sends its signal to halt the flow in a
  1713.   direction opposite to the flow of bytes it wants to stop.  Flow
  1714.   control must both be set at the terminal and at the computer.
  1715.  
  1716.  
  1717.   There are 2 types of flow control: hardware and software (Xon/Xoff).
  1718.   Hardware flow control uses a dedicated signal wire while software flow
  1719.   control signals by sending Xon or Xoff control bytes in the normal
  1720.   data wire.  For hardware flow control, the cable must be correctly
  1721.   wired.
  1722.  
  1723.   The flow of data bytes in the cable between 2 serial ports is bi-
  1724.   directional so there are 2 different flows to consider:
  1725.  
  1726.   1. Byte flow from the computer to the terminal
  1727.  
  1728.   2. Byte flow from the terminal keyboard to the computer.
  1729.  
  1730.  
  1731.   10.1.  Why Is Flow Control Needed ?
  1732.  
  1733.   You might ask: "Why not send at a speed slow enough so that the device
  1734.   will not be overrun and then flow control is not needed?"  This is
  1735.   possible but it's usually significantly slower than sending faster and
  1736.   using flow control.  One reason for this is that one can't just select
  1737.   any serial port baud rate such as 14,500.  There are only a discrete
  1738.   number of choices.  For speed, one should select a rate that is a
  1739.   little higher than the device can keep up with but then use flow
  1740.   control to make things work right.  Another reason is that the maximum
  1741.   rate that a device can cope with (without flow control) often depends
  1742.   on what is being sent.  Sending escape sequences to a terminal to get
  1743.   it to do complex things usually requires a slower baud rate at that
  1744.   time.  For a modem, the increase in effective flow by compressing the
  1745.   data sent to it depends on how much the data can be compressed.  This
  1746.   depends on the randomness of the data, so flow control is needed for
  1747.   modems too.
  1748.  
  1749.  
  1750.   10.2.  Overrunning a Serial Port
  1751.  
  1752.   One might wonder how overrunning is possible at a serial port since
  1753.   both the sending and receiving serial ports involved in a transmission
  1754.   of data bytes are set for the same speed (in bits/sec) such as 19,200.
  1755.   The reason is that although the receiving serial port electronics can
  1756.   handle the incoming flow rate, the hardware/software that fetches and
  1757.   processes the bytes from the serial port sometimes can't cope with the
  1758.   high flow rate.
  1759.  
  1760.   One cause of this is that the serial port's hardware buffer is quite
  1761.   small.  Older serial ports had a hardware buffer size of only one byte
  1762.   (inside the UART chip).  If that one received byte of data in the
  1763.   buffer is not removed (fetched) by CPU instructions before the next
  1764.   byte arrives, that byte is lost (the buffer is overrun).  Newer
  1765.   UART's, namely the 16550A, have 16-byte buffers (but may be set to
  1766.   emulate a one-byte buffer) and are less likely to overrun.  It may be
  1767.   set to issue an interrupt when the number of bytes in its buffer
  1768.   reaches 1, 4, 8, or 14 bytes.  It's the job of another computer chip
  1769.   (usually the main CPU chip for a computer) to take these incoming
  1770.   bytes out of this small hardware buffer and process them (as well as
  1771.   perform other tasks).
  1772.  
  1773.   When contents of this small hardware buffer reaches the specified
  1774.   limit (one byte for old UART'S) an interrupt is issued.  Then the
  1775.   computer interrupts what it was doing and software checks to find out
  1776.   what happened.  It finally determines that it needs to fetch a byte
  1777.   (or more) from the serial port's buffer.  It takes these byte(s) and
  1778.   puts them into a larger buffer (also a serial port buffer) that the
  1779.   kernel maintains in main memory.
  1780.  
  1781.   Terminals also have serial ports and buffers similar to the computer.
  1782.   Since the flow rate of bytes to the terminal is usually much greater
  1783.   than the flow in the reverse direction from the keyboard to the host
  1784.   computer, it's the terminal that is most likely to suffer overrunning.
  1785.   Of course, if you're using a computer as a terminal (by emulation),
  1786.   then it is likewise subject to overrunning.
  1787.  
  1788.   Risky situations where overrunning is more likely are:  1. When
  1789.   another process has disabled interrupts (for a computer).  2. When the
  1790.   serial port buffer in main (or terminal) memory is about to overflow.
  1791.  
  1792.  
  1793.   10.3.  Stop Sending
  1794.  
  1795.   When its appears that the receiver is about to be overwhelmed by
  1796.   incoming bytes, it sends a signal to the sender to stop sending.  That
  1797.   is flow control and the flow control signals are always sent in a
  1798.   direction opposite to the flow of data which they control (although
  1799.   not in the same channel or wire).  This signal may either be a control
  1800.   character (^S = DC3 = Xoff) sent as an ordinary data byte on the data
  1801.   wire (in-band signalling), or a voltage transition from positive to
  1802.   negative in the rts-cts (or other) signal wire (out-of-band
  1803.   signalling).  Using Xoff is called "software flow control" and using
  1804.   the voltage transition in a special signal wire (inside the cable) is
  1805.   called "hardware flow control".
  1806.  
  1807.   When a terminal is told to stop sending, the terminal "locks" its
  1808.   keyboard.  This seldom happens but when it does, a message or light
  1809.   should inform you that the keyboard is locked.  Anything you type at a
  1810.   locked keyboard is ignored.  The term "locked" is also used when the
  1811.   computer is told to stop sending to a terminal.  The keyboard is not
  1812.   locked so that whatever you type goes to the computer.  Since the
  1813.   computer can't send anything back to you, characters you type don't
  1814.   display on the screen and it may seem like the keyboard is locked but
  1815.   it's not.
  1816.  
  1817.  
  1818.   10.4.  Resume Sending
  1819.  
  1820.   When the receiver has caught up with its processing and is ready to
  1821.   receive more data bytes it signals the sender.  For software flow
  1822.   control this signal is the control character ^Q = DC1 = Xon which is
  1823.   sent on the regular data line.  For hardware flow control the voltage
  1824.   in a signal line goes from negative (negated) to positive (asserted).
  1825.   If a terminal is told to resume sending the keyboard is then unlocked
  1826.   and ready to use.
  1827.  
  1828.  
  1829.   10.5.  Hardware Flow Control (RTS/CTS etc.)
  1830.  
  1831.   Some older terminals have no hardware flow control while others use a
  1832.   wide assortment of different pins on the serial port for this.  The
  1833.   most popular seems to be the DTR pin.
  1834.  
  1835.  
  1836.   10.5.1.  RTS/CTS and DTR Flow Control
  1837.  
  1838.   Linux PC's use RTS/CTS, but DTR flow control (used by many terminals)
  1839.   behaves similarly (except it is only in one direction).  RTS/CTS uses
  1840.   the pins RTS and CTS on the serial (EIA-232) connector.  RTS means
  1841.   "Request To Send".  When this pin stays asserted (positive voltage) at
  1842.   the receiver it means: keep sending data to me.  If RTS is negated
  1843.   (voltage goes negative) it negates "Request To Send" which means:
  1844.   request not to send to me (stop sending).  When the receiver is ready
  1845.   for more input, it asserts RTS requesting the other side to resume
  1846.   sending.  For computers and terminals (both DTE type equipment) the
  1847.   RTS pin sends the flow control signal and the CTS pin (Clear To Send)
  1848.   receives the signal.  That is, the RTS pin on one end of the cable is
  1849.   connected to the CTS pin at the other end.
  1850.  
  1851.   For a modem (DCE equipment) it's a different setup since the modem's
  1852.   RTS pin receives the signal and its CTS pin sends.  While this may
  1853.   seem confusing, there are valid historical reasons for this which are
  1854.   too involved to discuss here.  For DTR flow control at a terminal the
  1855.   DTR signal is like the signal sent from the RTS pin.
  1856.  
  1857.  
  1858.   10.5.2.  Interfacing DTR with RTS/CTS flow control
  1859.  
  1860.   Many terminals use DTR flow control.  This is only one-way flow
  1861.   control to keep the terminal from being overrun.  It doesn't protect
  1862.   the computer from someone typing too fast for the computer to handle
  1863.   it.  How can one use this with Linux which uses RTS/CTS flow control?
  1864.   Since the DTR pin behaves like a RTS pin just treat the DTR pin at the
  1865.   terminal like it was the RTS pin and connect it to the CTS pin at the
  1866.   computer.  You will likely need to make up a special cable for this
  1867.   (or rewire a connector).  Thus one may use the DTR flow control at the
  1868.   terminal end of the cable with the RTS/CTS flow control at the
  1869.   computer end of the cable.  When using this you should "stty local"
  1870.   since the terminal DTR pin can't perform its usual function of telling
  1871.   the host computer that the terminal is turned on.
  1872.  
  1873.  
  1874.   10.5.3.  Old RTS/CTS Handshaking Is Different
  1875.  
  1876.   What is confusing is that there is the original use of RTS where it
  1877.   means about the opposite of the previous explanation above.  This
  1878.   original meaning is: I Request To Send to you.  This request was
  1879.   intended to be sent from a terminal (or computer) to a modem which, if
  1880.   it decided to grant the request, would send back an asserted CTS from
  1881.   its CTS pin to the CTS pin of the computer: You are Cleared To Send to
  1882.   me.  Note that in contrast to the modern RTS/CTS bi-directional flow
  1883.   control, this only protects the flow in one direction: from the
  1884.   computer (or terminal) to the modem.
  1885.  
  1886.   For older terminals, RTS may have this meaning and goes high when the
  1887.   terminal has data to send out.  The above use is a form of flow
  1888.   control since if the modem wants the computer to stop sending it drops
  1889.   CTS (connected to CTS at the computer) and the computer stops sending.
  1890.  
  1891.  
  1892.   10.5.4.  Reverse Channel
  1893.  
  1894.   Old hard-copy terminals may have a reverse channel pin (such as pin
  1895.   19) which behaves like the RTS pin in RTS/CTS flow control.  This pin
  1896.   but will also be negated if paper or ribbon runs out.  It's often
  1897.   feasible to connect this pin to the CTS pin of the host computer.
  1898.   There may be a dip switch to set the polarity of the signal.
  1899.  
  1900.  
  1901.   10.6.  Is Hardware Flow Control Done by Hardware ?
  1902.  
  1903.   Some think that hardware flow control is done by hardware but (unless
  1904.   you are using an intelligent serial card with several serial ports)
  1905.   it's actually done by your operating system software.  UART chips and
  1906.   associated hardware usually know nothing at all about hardware flow
  1907.   control.  When a hardware flow control signal is received, the signal
  1908.   wire flips polarity and the hardware gives an electrical interrupt
  1909.   signal to the CPU.  However, the hardware has no idea what this
  1910.   interrupt means.  The CPU stops what it was doing and jumps to a table
  1911.   in main memory that tells the CPU where to go to find a program which
  1912.   will find out what happened and what to do about it.
  1913.  
  1914.  
  1915.   It's this program (part of the serial device driver) that stops (or
  1916.   resumes) the sending.  This program checks the contents of registers
  1917.   in the UART chip to find out that a certain wire has changed polarity.
  1918.   Then the software realizes that a flow control signal has been
  1919.   received and goes about stopping (or starting) the flow.  However, if
  1920.   it's a stop signal that has been received, the flow stops almost
  1921.   instantly when the signal arrives because the interrupt has stopped
  1922.   whatever the CPU was doing (including the program that was sending the
  1923.   data and putting it in the serial ports hardware buffers for
  1924.   transmission).  However any bytes (up to 16) which were already in the
  1925.   serial port's hardware transmit buffer will still get transmitted ??
  1926.   Thus the hardware almost instantly stops the flow only because it's
  1927.   reaction to a hardware signal is to interrupt and stop everything the
  1928.   CPU was doing.
  1929.  
  1930.  
  1931.   10.7.  Obsolete ETX/ACK Flow Control
  1932.  
  1933.   This is also software flow control and requires a device driver that
  1934.   knows about it.  Bytes are sent in packets (via the async serial port)
  1935.   with each packet terminated by an ETX (End of Text) control character.
  1936.   When the terminal gets an ETX it waits till it is ready to receive the
  1937.   next packet and then returns an ACK (Acknowledge).  When the computer
  1938.   gets the ACK, it then send the next packet.  And so on.  This is not
  1939.   supported by Linux ??
  1940.  
  1941.  
  1942.   11.  Physical Connection
  1943.  
  1944.   A terminal may be connected to its host computer either by a direct
  1945.   cable connection, via a modem, or via a terminal server.
  1946.  
  1947.  
  1948.   11.1.  Direct Cable Connection.
  1949.  
  1950.   The simplest and cheapest way to connect a terminal to a host computer
  1951.   is via a direct connection to a serial port on the computer.  Most
  1952.   PC's come with a couple of serial ports, but one is usually used by a
  1953.   mouse.  For the EIA-232 port, you need a null modem cable that crosses
  1954.   over the transmit and receive wires.  Pin 2 at one end is wired to pin
  1955.   3 at the other end.  If you want hardware flow control, you must find
  1956.   out which pins of the terminal (if any) are used for it as different
  1957.   models of terminals use different pins.  The diagrams in Serial-HOWTO
  1958.   7.1 will not work for hardware flow control unless the RTS pin of the
  1959.   terminal is used for flow control.  It rarely is ??
  1960.  
  1961.  
  1962.   11.1.1.  Multiport I/O Cards (Adapters)
  1963.  
  1964.   Additional serial cards may be purchased which have several serial
  1965.   ports on them called "multiport boards" (see Serial-HOWTO 2.3 & 2.4).
  1966.   One company which has below average prices is ByteRunner
  1967.   <http://www.byterunner.com/cgi-bin/goto.cgi?FILE=iocards.html>.  For
  1968.   some other brands see Computer ESP
  1969.   <http://www.computer.esp.com/INPUT_DEVICES/PARALLEL___SERIAL_ADAPTERS/>
  1970.  
  1971.  
  1972.   11.1.2.  Length Limitations
  1973.  
  1974.   A cable longer than a 50 feet or so may not work properly at high
  1975.   speed.  Much longer lengths sometimes work OK, especially if the speed
  1976.   is low and/or the cable is a special low-capacitance type and/or the
  1977.   electronics of the receiving end are extra sensitive.  It is claimed
  1978.   that under ideal conditions at 9600 baud, 1000 feet works OK.  One way
  1979.   to cover long distances is to install 2@ line drivers near each serial
  1980.   port so as to convert unbalanced to balanced (and conversely) and then
  1981.   use twisted pair cabling.
  1982.  
  1983.  
  1984.   11.1.3.  Type of Cable
  1985.  
  1986.   If you expect to use hardware flow control (handshaking) you will
  1987.   likely need to make up your own cable (or order one made).   You will
  1988.   need to determine what pins the terminal uses for this and make up a
  1989.   compatible cable.  See ``Hardware Flow Control''.   Older terminals
  1990.   may have no provision for hardware flow control.
  1991.  
  1992.   If you don't use hardware flow control a ready-made cable may work OK
  1993.   (if you can find one long enough).  A null modem cable is often
  1994.   labeled as a printer cable with "null modem" in fine print.  In this
  1995.   cable certain pairs of wires are crossed-over (= flipped or cross-
  1996.   wired).  For example, pin 2 on one end goes to pin 3 on the other end,
  1997.   but not all pins are crossed-over.  Many ready-made null modem cables
  1998.   will cross over RTS and CTS (Pins 4 & 5) but these are probably not
  1999.   the pins the terminal uses for hardware flow control.
  2000.  
  2001.   The normal "straight thru" cable will not work unless you are using it
  2002.   as an extension cable in conjunction with either a null modem cable or
  2003.   a null modem adapter (a two-sided connector) to obtain the cross-over
  2004.   effect.  Make sure that the connectors on the cable ends will mate
  2005.   with the connectors on the hardware.  Most printer cables use a
  2006.   centronics connector on the printer end which will not connect to
  2007.   terminals.  One may use twisted-pair telephone cable.  Shielded,
  2008.   special low-capacitance cable is best.
  2009.  
  2010.  
  2011.   11.1.4.  A Kludge using Twisted-Pair Cable
  2012.  
  2013.   Although none of the EIA-232 signals are balanced for twisted pair one
  2014.   may attempt to use twisted-pair cable with it.  Use one pair for
  2015.   transmit and another for receive.  To do this connect signal ground to
  2016.   one wire in each of these 2 pair.  Only part of the signal ground
  2017.   current flows in the desired wire but it may help.  Due to the lower
  2018.   inductance of the twisted pair circuit, more return (ground) current
  2019.   will confine itself to the desired path than one would expect from
  2020.   only resistance calculations.  This is especially true at higher
  2021.   frequencies since inductive impedance increases with frequency.  The
  2022.   rectangular wave of the serial port contains high frequency harmonics.
  2023.  
  2024.  
  2025.   11.1.5.  Cable Grounding
  2026.  
  2027.   Pin 1 should be chassis ground (also earth ground) but on cheap serial
  2028.   ports it may not even be connected to anything.  The signal ground is
  2029.   pin 7 and is usually grounded to chassis ground.  This means that part
  2030.   of the signal current will flow thru the ground wires of the building
  2031.   wiring (undesirable).  Cable shields are supposed to be only grounded
  2032.   at one end of the cable, but it may be better to ground both ends
  2033.   since it's better to have current in the shield than in the building
  2034.   wiring ??
  2035.  
  2036.  
  2037.   11.2.  Modem Connection
  2038.  
  2039.   Using a terminal-modem combination (without a computer) one may
  2040.   connect to BBS's.  Some BBS's (such a free-nets) permit Internet
  2041.   access via the text browser lynx which will work on text terminals.
  2042.   Thus with an old terminal and external modem, one may connect to the
  2043.   Internet.  If one connects to a host computer on which one has an
  2044.   account, then one may sometimes store ones work (or downloads) on the
  2045.   host computer.  Of course one may also do this easier with a computer
  2046.   emulating a terminal using a communication program such as Minicom.
  2047.   11.2.1.  Dialing Out From a Terminal
  2048.  
  2049.   Instead of connecting a terminal (or computer emulating a terminal)
  2050.   directly to a host computer using a cable it may be connected to the
  2051.   host via a telephone line (or dedicated private line) with a modem at
  2052.   each end of the line.  The terminal (or computer) will usually dial
  2053.   out on a phone line to a host computer.
  2054.  
  2055.   This dialing out is commonly done using a PC computer with a modem to
  2056.   call a BBS or ISP where the PC emulates a terminal once it's
  2057.   connected.  If you use a real terminal for this it's more difficult
  2058.   since the real terminal isn't very intelligent and doesn't give as
  2059.   much feedback to the user.  For dialing out, many terminals can store
  2060.   one or more telephone numbers as messages which may be "set-up" into
  2061.   them and are sent out to the modem by pressing certain function keys.
  2062.   Many modems can also store phone numbers.  The modem initiation
  2063.   sequence must precede the telephone number.  The host computer may use
  2064.   "mgetty" (a getty for use with modems) to log in someone who has
  2065.   dialed in to the host.
  2066.  
  2067.  
  2068.   11.2.2.  Terminal Gets Dialed Into
  2069.  
  2070.   A less common situation is for the host computer to dial-out to a
  2071.   terminal.  One possible reason for doing this is to save on phone
  2072.   bills where rates are not symmetric.  To do this, your modem at your
  2073.   terminal should be set for automatic answer (Register S0 set to 2 will
  2074.   answer on the 2nd ring).  You turn on the terminal and modem before
  2075.   you expect a call and when the call comes in you get a login prompt
  2076.   and log in.
  2077.  
  2078.   The host computer that dials out to your terminal may do so by running
  2079.   the Linux program "callback" (not widely distributed yet) sometimes
  2080.   named "cb".  Callback is for having computer A call computer B, and
  2081.   then B hangs up and calls A back.  This is what you want if you are
  2082.   using computer A to emulate a terminal.  For the case of a real
  2083.   terminal this may be too complex a task so the host may utilize only
  2084.   the "back" part of the callback program.  The setup file for callback
  2085.   must be properly configured at the host.  Callback makes the call to
  2086.   the terminal and then has mgetty run a login on that port.  Mgetty by
  2087.   itself (as of early 1998) is only for dial-in calls but there is work
  2088.   being done to incorporate callback features into it and thus make it
  2089.   able to dial-out.  By the time you read this, mgetty may be all you
  2090.   need.
  2091.  
  2092.  
  2093.   11.2.3.  Modem Commands
  2094.  
  2095.   As of June 1997 there were no detailed listings of modem commands on
  2096.   the Internet for most modems.  However Hayes
  2097.   <http://www.hayes.com/support/techref/> has a list of its commands and
  2098.   many proposed initialization strings were listed.  These init strings
  2099.   may not be the best for the terminal situation where sending from the
  2100.   terminal is at very slow typing speeds but where you want the
  2101.   receiving speed as fast as feasible ??
  2102.  
  2103.  
  2104.   11.3.  Terminal Server Connection
  2105.  
  2106.   A terminal server is something like an intelligent switch that can
  2107.   connect a many terminals (or modems) to one or more computers.  It's
  2108.   not a mechanical switch so it may change the speeds and protocalls of
  2109.   the streams of data that go thru it.
  2110.  
  2111.   One use for it is to connect many terminals (or modems) to a high
  2112.   speed network which connects to host computers.  Of course the
  2113.   terminal server must have the computing power and software to run
  2114.   network protocalls so it is in some ways like a computer.  The
  2115.   terminal server may interact with the user and ask what computer to
  2116.   connect to, etc.  One may sometimes send jobs to a printer thru a
  2117.   terminal server.
  2118.  
  2119.   A PC today has enough computing power to act like a terminal server
  2120.   for text terminals except that each serial port should have its own
  2121.   hardware interrupt.  PC's only have a few spare interrupts for this
  2122.   purpose and since they are hard-wired you can't create more by
  2123.   software.  A solution is to use an advanced multiport serial card
  2124.   which has its own system of interrupts.
  2125.  
  2126.   Today real terminal servers serve more than just terminals.  They also
  2127.   serve PC's which emulate terminals, and are sometimes connected to a
  2128.   bank of modems connected to phone lines.  If a terminal is connected
  2129.   directly to a modem, the modem at the other end of the line could be
  2130.   connected to a terminal server.  In some cases the terminal server by
  2131.   default expects the callers to use PPP packets, something that text
  2132.   terminals don't generate.
  2133.  
  2134.  
  2135.   11.4.  Making or Modifying a Cable
  2136.  
  2137.   11.4.1.  Buy or Make ?
  2138.  
  2139.   If you need long cables to connect up terminals, how do you get them?
  2140.   Ready-made long cables may be difficult to find, especially if you
  2141.   want to use a minimum (say 4) of conductors.  One option is to get
  2142.   them custom made, which is likely to be fairly expensive although you
  2143.   might find someone to make them at prices not too much higher than
  2144.   ready-made cable (I did).  Another alternative is to make your own.
  2145.   This may require special tools.  If you can find it, used cable can be
  2146.   a real bargain but you will probably need to rewire the connectors.
  2147.   One advantage of making your own cable is that the skills you learn
  2148.   will come in handy if a cable breaks (or goes bad) or if you need to
  2149.   make up another cable in a hurry.
  2150.  
  2151.  
  2152.   11.4.2.  Connectors & Pins
  2153.  
  2154.   Unfortunately, most cables one purchases today have molded connectors
  2155.   on each end and can't be modified.  Others have connectors which
  2156.   unscrew and can be rewired.  If you are making up cable or modifying
  2157.   an existing one then you need to know about pins.  There are two
  2158.   types: soldered and crimped.
  2159.  
  2160.   The crimped pins require a special crimping tool and also need an
  2161.   "insertion/extraction" tool.  But once you have these tools, making up
  2162.   and modifying cable is a lot faster than soldering.  To insert pins
  2163.   just push them in with the tool.  Removing a pin with the tool
  2164.   requires some tricks.  You must insert the tool tip around the back of
  2165.   the pin.  One tool tip requires spreading a little to get it over the
  2166.   wire but for this tip the pin should be easier to remove.  Then pull
  2167.   on both the tool and the wire with a gentle jerk.  If it doesn't come
  2168.   out, the tool was likely not inserted correctly or you should use
  2169.   another tip that goes more around the pin.  Using this tool one may
  2170.   readily convert a straight-thru cable to a null-modem cable, etc.
  2171.  
  2172.   Don't try soldering unless you know what you're doing or have read
  2173.   about how to do it.
  2174.  
  2175.  
  2176.  
  2177.  
  2178.  
  2179.   12.  Set-Up (Configure) for both Computer & Terminal
  2180.  
  2181.   12.1.  Introduction
  2182.  
  2183.   Part of the set-up is setting up the physical terminal by saving (in
  2184.   its non-volatile memory) the characteristics it will have when it is
  2185.   powered on.  In addition (or as an alternative), the terminal may be
  2186.   configured by sending escape sequences to it from the computer, but
  2187.   this configuration will usually be lost when the terminal is powered
  2188.   down.  So if you know how to set up and save the configuration inside
  2189.   the terminal it's likely the best way.
  2190.  
  2191.   Another part of the setup is letting the computer know what kind of
  2192.   terminal you have connected it to and how the terminal has been set
  2193.   up.  The environment variable TERM stores the name of the terminal and
  2194.   makes it easy for programs to look up the terminal capabilities under
  2195.   this name in the terminfo directory.  See ``Terminfo & Termcap
  2196.   (brief)''.
  2197.  
  2198.   Programs called "stty" and "setserial" configure the serial port at
  2199.   the computer (including it's device driver software).  These programs
  2200.   (if needed) must be run each time the computer starts up since the
  2201.   configuration is lost each time the computer powers down.
  2202.  
  2203.   There are a great many options for you to choose from.  Some options
  2204.   concern only the terminal and do not need to be set at the computer.
  2205.   For example: Do you want black letters on a light background?  (This
  2206.   is easier on the eyes than a black background.)  Should a key repeat
  2207.   when held down?  Should the screen wrap when a line runs off the right
  2208.   end of the screen?
  2209.  
  2210.   The "communication interface" options must be set exactly the same at
  2211.   the computer and inside the terminal: speed, parity, bits/character,
  2212.   and flow control.  Until these are compatibly set up there can be no
  2213.   satisfactory serial communication (and possibly no communication at
  2214.   all) between the terminal and the computer.  One must set these by
  2215.   doing it manually at each terminal (or using some sort of special
  2216.   cartridge at each terminal).  The host computer is configured by
  2217.   adding commands to certain files on its hard disk which will be
  2218.   executed each time the computer starts (or when people log in).
  2219.  
  2220.   While all this may seem overly complex, to get a terminal working is
  2221.   often fairly simple.  The ``Quick Install'' section describes a simple
  2222.   way to try to do this.  But to make the display look better and
  2223.   perform better more work may be needed.
  2224.  
  2225.  
  2226.   12.2.  Terminal Set-Up
  2227.  
  2228.   Once the communication interface is established, the rest of the
  2229.   configuration of the terminals may sometimes be done by sending
  2230.   commands to the terminals from the computer.  If you have a large
  2231.   number of terminals, it may be worthwhile to write (or locate) a shell
  2232.   script to automatically do this.  There may (or may not) be a command
  2233.   you can send to a terminal to tell it to save its current set-up in
  2234.   its non-volatile memory so that it will be present the next time the
  2235.   terminal is powered on.
  2236.  
  2237.   If you have a manual for your terminal, you should also consult it.
  2238.   You may send commands to configure the terminal using the programs
  2239.   "tput" and "setterm".  See ``Changing the Terminal Settings''.  You
  2240.   could just send the terminal an init string from the terminfo entry if
  2241.   the init string sets up the terminal the way want it.  Unless you plan
  2242.   to send these sequences from the computer to the terminal each time
  2243.   the terminal is powered on, you must somehow save the settings in the
  2244.   non-volatile memory of the terminal.
  2245.   To set up a terminal you usually need to enter set-up mode by
  2246.   depressing the "set-up" key (or the like).  This will display a menu
  2247.   from which you may go to other menus.  How to go to other menus may
  2248.   (or may not) be inferred from the display.  Look at the keyboard for
  2249.   labels just above the top row of numeric keys.  If they exist, these
  2250.   labels may be what these keys do in set-up mode.  Older terminals may
  2251.   only have only one "set-up" menu.  Still older ones have physical
  2252.   switches.  In some cases not all the switches are well labeled.  They
  2253.   may even be DIP switches hidden in obscure locations with no labels.
  2254.  
  2255.   Unless you set up the terminal by throwing switches, your set-up must
  2256.   be saved in the non-volatile memory of the terminal so that it will be
  2257.   effective the next time you turn on the terminal.  If you fail to save
  2258.   it, then the new settings will be lost when you turn off the terminal.
  2259.   Before you go to the trouble of setting up a terminal, make sure that
  2260.   you know how to save the settings.  In some older terminals, only the
  2261.   manual tells how to save them.
  2262.  
  2263.  
  2264.   12.3.  At the Computer
  2265.  
  2266.   (Of course you might do this from any working terminal connected to
  2267.   the computer.)
  2268.  
  2269.  
  2270.   12.3.1.  Inittab
  2271.  
  2272.   There are various files to edit to set up the computer for terminals.
  2273.   With luck, only one file on the computer needs to be changed:
  2274.   /etc/inittab.  Add a new getty command(s) to this file next to the
  2275.   existing getty command(s).  Getty will start a login process on the
  2276.   serial port(s) of your choice and tell the computer what kind of
  2277.   terminal you have via the TERM environment variable (see Serial-HOWTO
  2278.   4.1 & 7.2 and/or type "man getty").
  2279.  
  2280.   If you are not using modem control lines (for example if you only use
  2281.   the minimum number of 3 conductors: transmit, receive, and common
  2282.   signal ground) you must let getty know this by using a "local" flag.
  2283.   The format of this depends on which getty you use.
  2284.  
  2285.  
  2286.   12.3.2.  Stty & Setserial
  2287.  
  2288.   There is both a "stty" command and a "setserial" command for setting
  2289.   up the serial ports.   Some (or all) of the needed stty settings can
  2290.   be done via getty and there may be no need to use setserial so you may
  2291.   not need to use either command.  These two commands (stty and
  2292.   setserial) set up different aspects of the serial port.  Stty does the
  2293.   most while setserial configures the low-level stuff such as interrupts
  2294.   and port addresses.  To "save" the settings, these commands must be
  2295.   written in certain files (shell scripts) which run each time the
  2296.   computer starts up.  You may also use the stty and setserial commands
  2297.   on the command line, but such settings will be lost as soon at you
  2298.   turn off the computer.
  2299.  
  2300.  
  2301.   12.3.3.  Setserial
  2302.  
  2303.   Setserial can change both the interrupt (IRQ) number and the port
  2304.   address.  It can tell you what type of UART chips you have.  It can
  2305.   set the time that the port will keep operating after it's closed (in
  2306.   order to output any characters still in its buffer in main RAM).  This
  2307.   is needed at slow baud rates of 1200 or lower.  For setserial to work,
  2308.   the serial module (for the Linux kernel) must be loaded.  If you use
  2309.   more than 2 serial ports you need to use setserial to assign unique
  2310.   IRQ numbers.
  2311.   12.3.4.  Where to Run Setserial ?
  2312.  
  2313.   To modify (or add) a setserial command, edit the shell script that
  2314.   runs setserial.  Where it resides depends on your distribution.  It
  2315.   might be in /etc/rc.d in a "rc.local" or "rc.serial" file.  In the
  2316.   Debian distribution it was the 0setserial file in /etc/rc.boot but
  2317.   this eventually should change to a file in /etc/init.d.
  2318.  
  2319.  
  2320.   12.3.5.  Stty
  2321.  
  2322.   Stty does most of the configuration of the serial port.  To see how
  2323.   it's now set for the terminal (or console) you're now at type at the
  2324.   shell prompt: stty -a.  For other terminals (such as ttyS1) type: stty
  2325.   -a < /dev/ttyS1.  Here are some of the items stty configures: speed
  2326.   (bits/sec), parity, bits/byte, # of stop bits, strip 8th bit?, modem
  2327.   control signals, flow control, break signal, end-of-line markers,
  2328.   change case, padding, beep if buffer overrun?, echo, allow background
  2329.   tasks to write to terminal?, define special (control) characters (such
  2330.   as what keys to press for interrupt).  See the manual (type: man stty)
  2331.   for more details.  For use of some special characters see ``Special
  2332.   (Control) Characters''
  2333.  
  2334.   With some implementations of getty, the commands that one would
  2335.   normally give to stty are typed into a getty configuration file:
  2336.   /etc/gettydefs.  Even without this configuration file, the getty
  2337.   command line may be sufficient to set things up so that you don't need
  2338.   stty.
  2339.  
  2340.   One may write C programs which change the stty configuration, etc.
  2341.   Looking at the documentation for this may help one better understand
  2342.   the use of the stty command (and its many possible arguments).
  2343.   Serial-Programming-HOWTO is useful.  The manual page: termios contains
  2344.   a description of the C-language structure (of type termios) which
  2345.   stores the stty configuration in computer memory.  Many of the flag
  2346.   names in this C-structure are almost the same (and do the same thing)
  2347.   as the arguments to the stty command.
  2348.  
  2349.  
  2350.   12.3.6.  Where to Put the Stty Command ?
  2351.  
  2352.   To have stty set up the terminal each time the computer starts up you
  2353.   need to put the stty command in a file that will be executed each time
  2354.   the computer is started up (Linux booted).  This file should be run
  2355.   before getty starts.  There are many possible places to put it.  If it
  2356.   gets put in more than one place and you only know about (or remember)
  2357.   one of those places, then a conflict is likely.  So make sure to
  2358.   document (perhaps in your terminal manual) where it's put.
  2359.  
  2360.   One good place to put it would be in the same file that runs setserial
  2361.   when the system is booted.  See ``Where to Run Setserial?''.  It would
  2362.   seem best to put it after the setserial command so that the low level
  2363.   stuff is done first.  In the Debian distribution there is an
  2364.   /etc/init.d/bootmisc.sh script but it currently runs before 0setserial
  2365.   does.  Example line: stty crtscts < /dev/ttyS1.
  2366.  
  2367.  
  2368.   12.3.7.  Terminfo & Termcap (brief)
  2369.  
  2370.   See ``Terminfo and Termcap (detailed)'' for a more detailed discussion
  2371.   of termcap.  Many application programs that you run use the terminfo
  2372.   (formerly termcap) data base.  This has an entry for each model or
  2373.   type (such as vt100) of terminal and tells what the terminal can do,
  2374.   what codes to send for various actions, and what codes to send to the
  2375.   terminal to initialize it.
  2376.  
  2377.   Since many terminals (and PC's also) can emulate other terminals and
  2378.   have various "modes" of operation, there may be several terminfo
  2379.   entries from which to choose for a given physical terminal.  They
  2380.   usually will have similar names.  The last parameter of getty should
  2381.   be the terminfo name of the terminal (or terminal emulation) that you
  2382.   are using (such as vt100).
  2383.  
  2384.   The terminfo does more than just specify what the terminal is capable
  2385.   of doing and disclose what codes to send to the terminal to get it to
  2386.   do those things.  It also specifies what "bold" will look like, what
  2387.   the cursor will look like, if the letters will be black, white, or
  2388.   some other color, etc.  In PC terminology these are called
  2389.   "preferences".  It also specifies initialization codes to send to the
  2390.   terminal (analogous to the init strings sent to modems).  If you don't
  2391.   like the way the display on the screen looks and behaves you may need
  2392.   to edit (and then install) the terminfo (or termcap) file.
  2393.  
  2394.  
  2395.   12.4.  Communication Interface Settings
  2396.  
  2397.   These settings are:
  2398.  
  2399.   ╖  ``Speed (bits/second) ''
  2400.  
  2401.   ╖  ``Parity ''
  2402.  
  2403.   ╖  ``Bits per Character ''
  2404.  
  2405.   ╖  ``Flow Control ''
  2406.  
  2407.   The above settings must be set the same at both the terminal and
  2408.   computer.  At the computer these may often set by using parameters to
  2409.   the getty command in the /etc/inittab file.  All of them may be set at
  2410.   the computer with the "stty" command which you might put in a shell
  2411.   script.  The script must be run each time the computer starts up.  You
  2412.   could put the stty command in an existing script file which is run at
  2413.   boot-time.  See ``Where to Put the Stty Command ?''
  2414.  
  2415.  
  2416.   12.4.1.  Speed
  2417.  
  2418.   These must be set the same on both the terminal and the computer.  The
  2419.   speed is the bits/sec (bps or baud rate).  9,600 is often fast enough,
  2420.   but if a faster speed improves performance without errors, use it.
  2421.   There may be two speeds to set at the terminal: Transmit and Receive,
  2422.   sometimes abbreviated T and R.  Usually they are both set the same.
  2423.   Common speeds are 300, 600, 1200, 2400, 4800, 9600, 19200, ...  An old
  2424.   terminal may even have a speed of 2 to be compatible with teletypes of
  2425.   the 1920's that formed serial bytes by mechanical means without
  2426.   electronics.
  2427.  
  2428.  
  2429.   12.4.2.  Parity
  2430.  
  2431.   For a definition see ``Parity Explained''.  Parity disabled is often
  2432.   the default.  To enable parity, you must both enable it and then
  2433.   select either even or odd parity.  It probably makes no difference
  2434.   which one you choose.  For terminals there are sometimes settings for
  2435.   both transmit and receive parity.  You should set both of these the
  2436.   same since stty at the computer doesn't permit setting them
  2437.   differently.
  2438.  
  2439.   Should you use parity  at all?  Parity, while not really necessary, is
  2440.   nice to have.  If you don't have parity, then you may get an incorrect
  2441.   letter here and there and wind up correcting spelling errors that
  2442.   don't really exist.  However parity comes at a cost.  First, it's a
  2443.   little more complicated to set up since the default is usually no
  2444.   parity.  Secondly, parity will slow down the speed with which bytes
  2445.   travel over the serial cable since there will be one more bit per
  2446.   byte.  This may or may not slow down the effective speed.
  2447.  
  2448.   For example, a hard-copy terminal is usually limited by the mechanics
  2449.   of the printing process.  Increasing the bytes/sec when the computer
  2450.   (its UART chip) is transmitting only results in more flow-control
  2451.   "halt" signals to allow the mechanical printing to catch up.  Due to
  2452.   more flow-control waits the effective speed is no better without
  2453.   parity than with it.  The situation is similar for some terminals.
  2454.  
  2455.   One option is to install terminals with no parity.  Then if parity
  2456.   errors are noticed, it can be implemented later.  To spot possible
  2457.   errors with no parity, look for any spelling errors you don't think
  2458.   you made.  If you spot such an error, refresh the screen (retransmit
  2459.   from the computer).  If the error goes away, then it's likely a parity
  2460.   error.  If too many such errors happen (such as more than one ever
  2461.   hundred screens) then corrective action is needed such as:  Enable
  2462.   parity and/or reduce speed, and/or use a shorter/better cable.
  2463.   Enabling parity will not reduce the number of errors but it will tell
  2464.   you when an error has happened.
  2465.  
  2466.   Just the opposite policy is to initially enable parity.  Then if no
  2467.   parity errors (error symbols on the CRT) are ever seen (over a
  2468.   reasonable period of time, say a month or two) it may be safely
  2469.   disabled.
  2470.  
  2471.  
  2472.   12.4.3.  Bits/Character
  2473.  
  2474.   This is the character size (the number of data bits per character).
  2475.   For ASCII it's 7,  but it's 8 for ISO character sets.  If you are only
  2476.   going to use ASCII characters, then select 7-bits since it's faster to
  2477.   transmit 7 bits than 8.  Some older terminals will only display 7-bit
  2478.   characters.
  2479.  
  2480.  
  2481.   12.4.4.  Which Flow Control ?
  2482.  
  2483.   The choice is between "hardware" (for example rts/cts + dtr/dsr) or
  2484.   "software" (Xon/Xoff) flow control.  While hardware may be faster (if
  2485.   the two extra wires for it are available in the cable and if the
  2486.   terminal supports it) in most cases Xon/Xoff should work OK.  Some
  2487.   people report that they solved disturbing problems by converting to
  2488.   hardware flow control but software flow control has worked fine at
  2489.   other installations (and for me personally).
  2490.  
  2491.   If you use software (Xon/Xoff) flow control and have users who don't
  2492.   know about it, then they may accidentally send an Xoff to the host and
  2493.   lock up their terminal.  While it's locked, they may type frantically
  2494.   in a vain attempt to unlock it.  Then when Xon is finally sent to
  2495.   restore communication, all that was typed in haste gets executed,
  2496.   perhaps with unexpected results.  They can't do this with hardware
  2497.   flow control.  See ``Flow Control'' for an explanation of flow
  2498.   control.
  2499.  
  2500.  
  2501.   12.5.  Rarely Needed /etc/ttytype File
  2502.  
  2503.   The configuration file /etc/ttytype is used to map /dev/ttySn's to
  2504.   terminal names per terminfo.  tset uses it, but if the TERM
  2505.   environment variable is already set correctly, then this file is not
  2506.   needed.  Since the Linux getty sets TERM for each tty, you don't need
  2507.   this file.  In other Unix-like systems such as FreeBSD, the file
  2508.   /etc/ttys maps ttys to much more, such as the appropriate getty
  2509.   command, and the category of connection (such as "dialup").  An
  2510.   example line of Linux ttytype: vt220 ttyS1
  2511.  
  2512.  
  2513.   12.6.  Login Restrictions
  2514.  
  2515.   By default, the root user may not login from a terminal.  To permit
  2516.   this you must create (or edit) the file /etc/securetty per the manual
  2517.   page "securetty".  To restrict logins of certain users and/or certain
  2518.   terminals, etc. edit /etc/login.access (this replaces the old
  2519.   /etc/usertty file ??).  /etc/login.def determines if /etc/securetty is
  2520.   to be used and could be edited so as to make /etc/securetty not needed
  2521.   (or not used).  /etc/porttime restricts the times at which certain
  2522.   ttys and users may use the computer.  If there are too many failed
  2523.   login attempt by a user, that user may be prohibited from ever logging
  2524.   in again.  See the man page "faillog" for how to control this.
  2525.  
  2526.  
  2527.   12.7.  Run Command Only If TERM=my_term_type
  2528.  
  2529.   Sometimes there are commands that one wants to execute at start-up
  2530.   only for a certain type of terminal.  To do this for the stty command
  2531.   is no problem since one uses the redirection operator < to specify
  2532.   which terminal the command is for.  But what about shell aliases or
  2533.   functions?  You may want to make a function for the ls command so it
  2534.   will color-code the listing of directories only on color terminals or
  2535.   consoles.  For monochrome terminals you want the same function name
  2536.   (but a different function body) which will use symbols as a substitute
  2537.   for color-coding.  Where to put such function definitions that are to
  2538.   be different for different terminal?
  2539.  
  2540.   You may put them inside an "if" statement in /etc/profile which runs
  2541.   at startup each time one logs on.  The conditional "if" statement
  2542.   defines certain functions, etc. only if the terminal is of a specified
  2543.   type.  While much of what this if statement does could be done in the
  2544.   configuration file for dircolors, here's an example:
  2545.  
  2546.  
  2547.   ______________________________________________________________________
  2548.   if [ $TERM = linux ]; then
  2549.       eval `dircolors`;
  2550.   elif [ $TERM = vt220 ]; then
  2551.       ls () { command ls -F $* }
  2552.       declare -xf ls
  2553.   else echo "From /etc/profile: Unknown terminal type $TERM"
  2554.   fi
  2555.   ______________________________________________________________________
  2556.  
  2557.  
  2558.  
  2559.  
  2560.   13.  Terminfo and Termcap (detailed)
  2561.  
  2562.   13.1.  Introduction
  2563.  
  2564.   Terminfo (formerly Termcap) is a database of terminal capabilities and
  2565.   more.  For every (well almost) model of terminal it tells application
  2566.   programs what the terminal is capable of doing.  It tells what escape
  2567.   sequences (or control characters) to send to the terminal in order to
  2568.   do things such as move the cursor to a new location, erase part of the
  2569.   screen, scroll the screen, change modes, change appearance (colors,
  2570.   brightness, blinking, underlining, reverse video etc.).  After about
  2571.   1980, many terminals supported over a hundred such commands.
  2572.  
  2573.  
  2574.  
  2575.   13.2.  Terminfo Database
  2576.  
  2577.   The terminfo database is compiled and thus has a source part and a
  2578.   compiled part.  The old termcap database has only a source part but
  2579.   this source can be both converted to terminfo source and then compiled
  2580.   by a single command.  To see if your terminal (say vt100) is in the
  2581.   terminfo data base type "locate vt100".  It may show
  2582.   /usr/lib/terminfo/v/vt100 or /usr/share/terminfo/v/vt100 which are
  2583.   possible locations of the compiled terminfo files.  Some older
  2584.   programs may expect it to be in the /etc/terminfo directory.
  2585.  
  2586.   The source code you use may reside in /etc/termcap and/or in
  2587.   terminfo.src.  See the man pages: terminfo(5) or termcap(5) for the
  2588.   format required to create (or modify) these files.  The file
  2589.   terminfo.src may be in various locations or it may not be included
  2590.   with your linux distribution.  Use the locate command to try to find
  2591.   it.  It is available for downloading (under the name termtypes.ti)
  2592.   from  <locke.ccil.org/~esr/terminfo>
  2593.  
  2594.  
  2595.   13.2.1.  Terminfo Compiler (tic)
  2596.  
  2597.   The data in the source files is compiled with the "tic" program which
  2598.   is capable of converting between termcap format and terminfo format.
  2599.   Thus you can create a compiled terminfo data base from termcap source.
  2600.   The installation program which was used to install Linux probably
  2601.   installed the compiled files on your hard disk so you don't need to
  2602.   compile anything unless you modify /etc/termcap (or terminfo.src ).
  2603.   "tic" will automatically install the resulting compiled files into a
  2604.   terminfo directory ready to be used by application programs.
  2605.  
  2606.  
  2607.   13.2.2.  Look at Your Terminfo
  2608.  
  2609.   It's a good idea to take a look at your termcap/terminfo entry (source
  2610.   code of course) and read the comments.  A quick way to inspect it
  2611.   without comments is to just type "infocmp".  But the comments may tell
  2612.   you something special about the terminal such as how you need to set
  2613.   it up so that it will work correctly with the terminfo database.
  2614.  
  2615.  
  2616.   13.2.3.  Deleting Data Not Needed
  2617.  
  2618.   In order to save disk space, one may delete all of the database except
  2619.   for the terminals types that you have.  Don't delete any of the Linux
  2620.   termcaps or the xterm ones if you use X-Windows.  The terminal type
  2621.   "dumb" is used when an application program can't figure out what type
  2622.   of terminal you are using.  It would save disk space if install
  2623.   programs only installed the terminfo for the terminals that you have
  2624.   and if you could get a termcap for a newly installed terminal over the
  2625.   Internet in a fraction of a second.
  2626.  
  2627.  
  2628.   13.3.  Initialization
  2629.  
  2630.   Included in the terminfo are often a couple of initialization strings
  2631.   which may be sent to the terminal to initialize it.  This may change
  2632.   the appearance of the screen, change what mode the terminal is in,
  2633.   and/or make the terminal emulate another terminal.  The initialization
  2634.   strings are not automatically sent to the terminal to initialize it.
  2635.   You must use a command given on the command line (or in a shell
  2636.   script) to do it such as: "tset", "tput init", or "setterm
  2637.   -initialize".  Sometimes there is no need to send the init string
  2638.   since the terminal may set itself up correctly when it is powered on
  2639.   (using options/preferences one has set up and saved in non-volatile
  2640.   memory of the terminal).
  2641.   13.4.  TERM Variable
  2642.  
  2643.   The Environment variable TERM should be set to the type of terminal
  2644.   which you are using.  It is normally set by the terminal_type
  2645.   parameter passed to the getty program (look at it in the /etc/inittab
  2646.   file).  This name must be in the Terminfo data base.  Just type "set"
  2647.   at the command line to see what TERM is set to (or type: tset -q).  At
  2648.   a console (monitor) TERM is set to "linux" which is the PC monitor
  2649.   emulating a fictitious terminal model named "linux".  Since "linux" is
  2650.   close to a vt100 terminal and many text terminals are also, the
  2651.   "linux" designation will sometimes work as a temporary expedient with
  2652.   a text terminal.
  2653.  
  2654.   If more than one type of terminal may be connected to the same port
  2655.   (/dev/tty...) (for example, if there is a switch to permit different
  2656.   terminal types to use the same serial port, or if the port is
  2657.   connected to a modem to which people call in from different types of
  2658.   terminals) then TERM needs to be set each time someone connects to the
  2659.   serial port.  There is often a query escape sequence so that the
  2660.   computer may ask the terminal what type it is.  Another way is to ask
  2661.   the user to type in (or select) the type of terminal s/he is using.
  2662.   You may need to use tset of write a short shell script to handle this.
  2663.  
  2664.  
  2665.   One way to do this is to use "tset" (see the manual page).  tset tries
  2666.   to determine the terminal name of the terminal you are using.  Then it
  2667.   looks up the data in terminfo and sends your terminal an init string.
  2668.   It can also set the value of TERM.  For example, a user dials in and
  2669.   logs in.  The .profile login script is executed which contains within
  2670.   it the following statement: eval `tset -s ?vt100`.  This results in:
  2671.   The user is asked if s/he is using a vt100.  The user either responds
  2672.   yes or types in the actual terminal type s/he is using.  Then tset
  2673.   sends the init string and sets TERM to this terminal name (type).
  2674.  
  2675.  
  2676.   13.5.  Termcap Documents
  2677.  
  2678.  
  2679.  
  2680.   ╖  The Termcap Manual
  2681.      <http://www.delorie.com/gnu/docs/termcap/termcap_toc.html> by
  2682.      Richard M. Stallman is a GNU manual.
  2683.  
  2684.   ╖  manual pages for terminfo(5) and/or termcap(5).
  2685.  
  2686.   ╖  /etc/termcap (a file) or terminfo.src has info about various
  2687.      versions of termcap files, naming conventions for terminals, and
  2688.      special capabilities code named u6-u9
  2689.  
  2690.   ╖  "Termcap and Terminfo" is a book published by O'Reilly in 1988.
  2691.  
  2692.  
  2693.   14.  Using the Terminal
  2694.  
  2695.   14.1.  Introduction
  2696.  
  2697.   This section is about the controlling the terminal-computer interface
  2698.   and/or changing the terminal set-up while using the terminal.  It
  2699.   explains (or points to explanations of) how the user of a terminal can
  2700.   control and inspect the interface and how to use various commands
  2701.   provided by the device driver.  It does not explain how to use the
  2702.   many application programs, shells or most Linux utilities.  Two
  2703.   commands commonly used at the terminal are:
  2704.  
  2705.   ╖  clear (to clear the screen)
  2706.  
  2707.   ╖  reset (to reset the terminal)
  2708.  
  2709.  
  2710.   14.2.  Starting Up the Terminal
  2711.  
  2712.   You should be able to turn on the power to the terminal, hit the
  2713.   "return" (or "enter") key and then get a login prompt.  Then type your
  2714.   account name and your password when prompted for it.  If nothing
  2715.   happens, make sure the host computer is OK.  If the host computer is
  2716.   shut down (no power) what you type at the terminal keyboard may appear
  2717.   on the screen since the transmit and receive pins at the computer may
  2718.   be connected together resulting in echoing of characters by an "off"
  2719.   computer.  If you can't log in when the host computer is running, see
  2720.   ``Trouble-Shooting''.
  2721.  
  2722.  
  2723.   14.3.  Terminal Device Driver
  2724.  
  2725.   When typing at the command line, the shell (such as the Bash shell) is
  2726.   reading what you type and reacting to it.  What you type first passes
  2727.   thru the terminal driver part of your operating system.  This driver
  2728.   may translate certain characters (such as changing the "return"
  2729.   character generated by the "return" key into a "new-line" character
  2730.   for Linux files).  It also recognizes certain control codes which you
  2731.   may type at the keyboard such as ^C to interrupt the execution of a
  2732.   program.  It also normally echos what you type back to the display.
  2733.   ``Stty'' may be used to configure how this terminal driver behaves,
  2734.   including disabling some (or all) of its functionality.
  2735.  
  2736.  
  2737.   14.4.  Corrupted Terminal Interface
  2738.  
  2739.   14.4.1.  Symptoms
  2740.  
  2741.   When the display doesn't look right or what you type doesn't display
  2742.   correctly, you may have a corrupted terminal interface.  It could also
  2743.   be a bug in the program you're using, a hardware failure, or possibly
  2744.   an incorrect configuration.  If everything was working normally but it
  2745.   suddenly goes bad, it may be that the interface got corrupted by
  2746.   something you did.  Two ways to corrupt the interface are to send a
  2747.   binary file to the terminal or to abnormally exit an application
  2748.   program.
  2749.  
  2750.  
  2751.   14.4.2.  Sent Terminal Binary Characters
  2752.  
  2753.   Your terminal will change its characteristics if sent certain escape
  2754.   sequences or control characters.  It you inadvertently try to display
  2755.   a binary file, it might contain such sequences which may put your
  2756.   terminal into some strange mode of operation or even make it unusable.
  2757.   Always view or edit a binary file with programs designed for that
  2758.   purpose so that this doesn't happen.  Most editors and pagers will
  2759.   handle binary OK so as not to corrupt the interface.  Some may display
  2760.   a message telling you that they can't edit binary.  But using "cat
  2761.   ...." or "cp .... /dev/tty.." where .... is a binary file, will send
  2762.   the binary to the terminal and likely corrupt things.
  2763.  
  2764.   Corruption it can also happen when using a communications program
  2765.   where a remote computer may send binary to your screen.  There are
  2766.   numerous other ways it can happen so be prepared for it.  Even a
  2767.   supposed ASCII file may contain unwanted control codes.
  2768.  
  2769.   To fix this problem reset the terminal.  There may be a key which does
  2770.   this directly at the terminal (perhaps in setup mode) or you may try
  2771.   typing either "reset" or "setterm -reset" (although you may not be
  2772.   able to see what you're typing).  This will send the reset string from
  2773.   the terminfo entry to the terminal.
  2774.  
  2775.  
  2776.   14.4.3.  Abnormally Exit a Program
  2777.  
  2778.   Large application programs (such as editors) often use the stty
  2779.   command (or the like) in their code to temporarily change the stty
  2780.   configuration when you are running the program.  This may put the
  2781.   device driver into "raw" mode so that every character you type goes
  2782.   directly thru to the application program.  Echoing by the driver is
  2783.   disabled so that everything you see on the screen comes directly from
  2784.   the application program.  Thus many control commands (such as ^C) may
  2785.   not work within such applications.
  2786.  
  2787.   When you tell such an application to quit, the application program
  2788.   first restores the stty settings to what they were before the
  2789.   application program started.  If you abnormally exit the program (you
  2790.   may guess this has happened when what you type no longer displays on
  2791.   the screen) then you may still be in "raw mode" on the command line.
  2792.  
  2793.   To get out of raw mode and restore the normal stty settings type "stty
  2794.   sane".  However, you must type this just after a "return" and end it
  2795.   with a "return".   But hitting the "return" key doesn't do the job
  2796.   since the "return" code no longer gets translated to the new-lines
  2797.   that the shell is waiting for.  So just type new-line (^J) instead of
  2798.   "return".  The "sane" terminal interface may not be exactly the same
  2799.   as the normal one but it usually works.  "stty sane" may also useful
  2800.   to get out of a corrupted interface due to other causes.
  2801.  
  2802.  
  2803.   14.5.  Special (Control) Characters
  2804.  
  2805.   A number of control characters which you may type at the keyboard are
  2806.   "caught" by the terminal driver and perform various tasks.  To see
  2807.   these control commands type: stty -a and look at lines 2-4.  They are
  2808.   tersely explained in the stty manual pages.  They may be changed to
  2809.   different control characters or disabled using the stty command.  Thus
  2810.   your control characters might be different than those described below.
  2811.   They are used for command-line editing, interrupting, scrolling, and
  2812.   to pass the next character thru transparently.
  2813.  
  2814.  
  2815.   14.5.1.  Command-Line Editing
  2816.  
  2817.   While the terminal driver has a few commands for command-line editing,
  2818.   some shells have a built-in real editor (such as "readline" in the
  2819.   Bash shell).  Such an editor is normally on by default so you don't
  2820.   need to do anything to enable it.  If it's available you don't need to
  2821.   learn many of the following commands although they often still work
  2822.   along with the command-line editor.  The most important to learn are
  2823.   ^C (interrupt), ^D, and scrolling.
  2824.  
  2825.  
  2826.   ╖  Delete-key (shown by stty as ^?) erases the last character
  2827.  
  2828.   ╖  ^U kills (deletes) the line
  2829.  
  2830.   ╖  ^W deletes a word backwards
  2831.  
  2832.   ╖  ^R reprints the line.  Useful mainly on hard copy terminals ??
  2833.  
  2834.  
  2835.   14.5.2.  Interrupting (& Quit, Suspend, EOF, Flush)
  2836.  
  2837.  
  2838.  
  2839.   ╖  ^C interrupts.  Exits the program and returns you to the command-
  2840.      line prompt.
  2841.  
  2842.   ╖  ^/ quits.  Same as interrupt ^C but weaker.  Also dumps a "core"
  2843.      file (which you likely have no use for) into your working
  2844.      directory.
  2845.  
  2846.   ╖  ^Z suspends.  Stops the program and puts it in the background.
  2847.      Type fg to restart it.
  2848.  
  2849.   ╖  ^D end of file.  If typed at the command-line prompt, exits the
  2850.      shell and goes to where you were before the shell started.
  2851.  
  2852.   ╖  ^O flush.  Not implemented in Linux.  Sends output to /dev/null.
  2853.  
  2854.  
  2855.   14.5.3.  Scrolling
  2856.  
  2857.   If what you want to see scrolls off the bottom of the screen, you may
  2858.   prevent this by sending a "stop" signal (^S or Xoff) to the host
  2859.   (provided Xon-Xoff ``Flow Control'' is enabled).  Send a "start signal
  2860.   to resume (^Q or Xon).  Some terminals have a "No Scroll" key which
  2861.   will alternately send Xoff and Xon.  If you have hardware flow control
  2862.  
  2863.  
  2864.   ╖  ^S stops scrolling (Xoff)
  2865.  
  2866.   ╖  ^Q resume scrolling (Xon)
  2867.  
  2868.   If you want to both stop scrolling and quit, use ^C.  If you want to
  2869.   stop scrolling to do something else but want to keep the program in
  2870.   memory so you can resume scrolling later, use ^Z suspend.
  2871.  
  2872.   An alternative scrolling method is to pipe the output thru a pager
  2873.   such as more, less, or most.  However, the output might not be
  2874.   standard output but could be error output which the pager doesn't
  2875.   recognize.  To fix this you may need to use redirection "2>&1" to get
  2876.   the pager to work OK.  It is often simpler to just use ^S and ^Q
  2877.   unless you need to scroll backwards.
  2878.  
  2879.   At a PC console (emulating a terminal) you may scroll backwards by
  2880.   using Shift-PageUp.  This is frequently needed since the scrolling is
  2881.   too fast to stop it where you want using ^S.  Once you've scrolled
  2882.   backwards Shift-PageDown will scroll forward again.
  2883.  
  2884.  
  2885.   14.5.4.  Take Next Character Literally
  2886.  
  2887.   ^V sends the next character typed (usually a control character)
  2888.   directly  thru the device driver with no action or interpretation.
  2889.   Echoed back are two ASCII characters such as ^C.
  2890.  
  2891.  
  2892.   14.6.  Inspecting the Interface
  2893.  
  2894.   These utility programs will provide information about the terminal
  2895.   interface:
  2896.  
  2897.   ╖  gitkeys: shows what byte(s) each key sends to the host.
  2898.  
  2899.   ╖  tty: shows what tty port you are connected to.
  2900.  
  2901.   ╖  set: shows the value of TERM (the terminfo entry name)
  2902.  
  2903.   ╖  stty -a: shows all stty settings.
  2904.  
  2905.   ╖  setserial -g /dev/tty?? (you fill in ??) shows UART type, port
  2906.      address and IRQ number.
  2907.  
  2908.   ╖  infocmp: shows the current terminfo entry (less comments)
  2909.  
  2910.  
  2911.   14.7.  Changing the Terminal Settings
  2912.  
  2913.   The terminal settings are normally set once when the terminal is
  2914.   installed using the setup procedures in the terminal manual.  However,
  2915.   some settings may be changed when the terminal is in use.  You
  2916.   normally would not give any "stty" of "setserial" commands when the
  2917.   terminal is in use as they are likely to corrupt the terminal
  2918.   interface.  However, there are changes you may make to the appearance
  2919.   of the terminal screen or to its behavior without destroying the
  2920.   integrity of the interface.  Sometimes these changes are made
  2921.   automatically by application programs so you may not need to deal with
  2922.   them.
  2923.  
  2924.   One direct method of making such changes is to use the setup key at
  2925.   the terminal and then use menus or the like to make the changes.  To
  2926.   do this you may need to be familiar with the terminal.
  2927.  
  2928.  
  2929.   The other 3 methods send an escape sequence from the computer to the
  2930.   terminal to make the changes.  These 3 examples show different methods
  2931.   of doing this to set reverse video:
  2932.  
  2933.  
  2934.   1. setterm -reverse
  2935.  
  2936.   2. tput -rev
  2937.  
  2938.   3. echo ^[[7m
  2939.  
  2940.  
  2941.   14.7.1.  setterm
  2942.  
  2943.   This is the easiest command to use.  It uses long options (but doesn't
  2944.   use the -- before them) and consults the terminfo database to
  2945.   determine what code to send.  You may change the color, brightness,
  2946.   linewrap, keyboard repeat, cursor appearance, etc.
  2947.  
  2948.  
  2949.   14.7.2.  tput
  2950.  
  2951.   The "tput" command is similar to "setterm" but instead of using
  2952.   ordinary words as arguments, you must use the abbreviations used by
  2953.   terminfo.  Many of the abbreviations are quite terse and hard to
  2954.   remember.
  2955.  
  2956.  
  2957.   14.7.3.  echo
  2958.  
  2959.   In the example "echo ^[[7m" to set reverse video, the ^[ is the escape
  2960.   character.  To type it type ^V^[ (or ^V followed by the escape key).
  2961.   To use this "echo" method you must find out what code to use from your
  2962.   terminal manual or from terminfo or termcap.  It's simpler to use
  2963.   setterm or tput although echo will execute a little faster.  So you
  2964.   might use echo ... in shell scripts which deal with only one type of
  2965.   terminal.
  2966.  
  2967.  
  2968.  
  2969.  
  2970.  
  2971.   14.7.4.  Saving Changes
  2972.  
  2973.   When you turn off the terminal the changes you made will be lost
  2974.   (unless you saved them in non-volatile terminal memory by pressing
  2975.   certain keys at the terminal).  If you want to use them again without
  2976.   having to retype them, put the commands in a shell script or make it a
  2977.   shell function.  Then run it when you want to make the changes.  One
  2978.   way to make the changes semi-permanent is to put the commands in a
  2979.   file that runs each time you login or start up the computer.
  2980.  
  2981.  
  2982.   15.  Trouble-Shooting (software)
  2983.  
  2984.   If you suspect that the problem is a hardware problem, see the Repair
  2985.   and Diagnose section ``Repair & Diagnose''.
  2986.  
  2987.   Here is a list of possible problems:
  2988.  
  2989.   ╖  ``Is the Terminal OK ?''  Suspect the terminal is defective.
  2990.  
  2991.   ╖  ``Missing Text'' Either skips over some text or displays some text
  2992.      OK and hangs.
  2993.  
  2994.   ╖  ``Getty Respawning Too Rapidly'' (console error message)
  2995.  
  2996.   ╖  ``Fails Just After Login''
  2997.  
  2998.   ╖  ``Can't Login'' but login prompt is OK.
  2999.  
  3000.   ╖  ``Garbled Login Prompt''
  3001.  
  3002.   ╖  ``No Sign of any Login Prompt''
  3003.  
  3004.   There are two cases where the terminal goes bad.  One is when it's
  3005.   been recently working OK and suddenly goes bad.  This is discussed in
  3006.   the next section.  The other case is where things don't work right
  3007.   when you install a terminal.  For this case you may skip over the next
  3008.   section.
  3009.  
  3010.  
  3011.   15.1.  Terminal Was Working OK
  3012.  
  3013.   When a formerly working terminal suddenly goes bad it is often easy to
  3014.   find the problem.  The problem may be obvious such as an error message
  3015.   when the terminal is first turned on.  If it makes a noise it likely
  3016.   needs repair.  See ``Repair & Diagnose''.  First, think about what has
  3017.   been done or changed recently as it's likely the cause of the problem.
  3018.   Did the problem happen just after new system software was installed or
  3019.   after a change in the configuration?
  3020.  
  3021.  
  3022.   15.2.  Terminal Newly Installed
  3023.  
  3024.   If you've just connected up a terminal to a computer per instructions
  3025.   and it doesn't work this section is for you.  If a terminal that
  3026.   formerly worked OK doesn't work now then see ``Terminal Was Working
  3027.   OK'' If you suspect that the serial port on your computer may be
  3028.   defective you might try running a diagnostic test program on it,
  3029.   possibly from MS DOS.
  3030.  
  3031.   One approach is to first see if the the terminal will work by trying
  3032.   to copy a file to the terminal (cp my_file /dev/ttyS?) under the most
  3033.   simple situation.  This means with the modem control lines disabled
  3034.   and at a show speed that doesn't need flow control (make sure that any
  3035.   hardware flow control is disabled).  If this copy works, then make the
  3036.   situation a little more complicated and see if it still works, etc.,
  3037.   etc.  When the trouble appears just after you made a change, then that
  3038.   change is likely the source of the trouble.  Actually, its more
  3039.   efficient (but more complex) to jump from the simple situation to
  3040.   about half way to the final configuration so that the test eliminates
  3041.   about half of the remaining possible causes of the problem.  Then
  3042.   repeat this methodology for the next test.  This way it would only
  3043.   take about 10 tests to find the cause out of a thousand possible
  3044.   causes.  You should deviate a little from this method based on hunches
  3045.   and clues.
  3046.  
  3047.  
  3048.  
  3049.   15.3.  Is the Terminal OK ?
  3050.  
  3051.   A good terminal will usually start up with some words on the screen.
  3052.   If these words convey no error message, its probably OK.  If there is
  3053.   no sign of power (no lights on, etc.) re-plug in the computer power
  3054.   cord at both ends.  Make sure there is power at the wall jack (or at
  3055.   the extension cord end).  Try another power cord if you have one.
  3056.   Make sure the terminal is turned on and that it's fuse is not blown.
  3057.   A blank (or dim) screen may sometimes be fixed by just turning up the
  3058.   brightness and contrast using knobs or a key in set-up mode.  Put the
  3059.   terminal into local mode if possible and try typing.  If it still
  3060.   won't work See ``Repair & Diagnose'' for tips on repairing it.
  3061.  
  3062.  
  3063.   15.4.  Missing Text
  3064.  
  3065.   If some text displays on the terminal OK and then it stops without
  3066.   finishing (in the middle of a word, etc.) or if chunks of text are
  3067.   missing, you likely have a problem with flow control.  If you can't
  3068.   figure out right away what's causing it, decrease the speed.  If that
  3069.   fixes it, it's likely a flow control problem.  It may be that flow
  3070.   control is not working at all due to failure to configure it
  3071.   correctly, or due to incorrect cable wiring (for hardware flow
  3072.   control).  See ``Flow Control''
  3073.  
  3074.   If single characters are missing, perhaps the serial port is being
  3075.   overrun by too fast a speed.  Try a slower baud rate.
  3076.  
  3077.   If you are using a baud rate under 1200 (very slow, mostly used for
  3078.   old hard-copy terminals and printers) and the text gets truncated,
  3079.   then the problem is likely in the serial device driver.  See Printing-
  3080.   HOWTO under "Serial devices" on how to fix this.
  3081.  
  3082.  
  3083.   15.5.  Getty Respawning Too Rapidly
  3084.  
  3085.   15.5.1.  No Modem Control Voltage
  3086.  
  3087.   If getty can't open and/or use a port because of the lack of a
  3088.   positive modem control voltage on one of the pins, then getty might be
  3089.   killed.  Then, per the instructions in inittab, getty respawns and
  3090.   tries again, only to be killed again, etc., etc.  Try using the
  3091.   "local" option with getty and/or check the modem control settings and
  3092.   voltages.
  3093.  
  3094.  
  3095.   15.5.2.  Key Shorted
  3096.  
  3097.   Another possible cause of getty respawning is if a keyboard key is
  3098.   shorted, giving the same result as if the key was continuously held
  3099.   down.  With auto-repeat enabled, this "types" thousands characters to
  3100.   the login prompt.  Look for a screen filled with all the same
  3101.   character (in some cases with 2 or more different characters).
  3102.  
  3103.   15.6.  Fails Just After Login
  3104.  
  3105.   If you can login OK but then you can't use the terminal it may be
  3106.   because the starting of the login shell has reconfigured the terminal
  3107.   (to an incorrect setting) by a command which someone put into one of
  3108.   the files that are run when you login and a shell starts.  These files
  3109.   include /etc/profile and  /.bashrc.  Look for a command starting with
  3110.   "stty" or "setserial" and make sure that it's correct.  Even if it's
  3111.   done OK in one initialization file, it may be reset incorrectly in
  3112.   another initialization file that you are not aware of.  You may need
  3113.   to boot from a rescue diskette to be able to get into the system for
  3114.   fixing things.
  3115.  
  3116.  
  3117.   15.7.  Can't Login
  3118.  
  3119.   If you get a login prompt but get no response (or perhaps a garbled
  3120.   response) to your login attempts a possible cause is that the
  3121.   communication is bad one-way from the terminal to the computer.  If
  3122.   you're not already using the "local" option with getty, do so to
  3123.   disable the modem control lines.  You might also disable hardware flow
  3124.   control (stty -crtscts) if it was enabled.  If things now works then
  3125.   your modem control lines are likely either not wired or set up
  3126.   correctly.  Some terminals allow setting different values (such as
  3127.   baud rate) for send and receive so the receive could be OK but the
  3128.   send bad.
  3129.  
  3130.   If you get a message saying something like "login failed" then if
  3131.   there is no error in typing or the password there may be some
  3132.   restrictions on logins in effect.  See ``Login Restrictions''
  3133.  
  3134.  
  3135.   15.8.  Garbled Login Prompt
  3136.  
  3137.   This may be due to using the wrong character set, transmission errors
  3138.   due to too high of a baud rate, incompatible baud rates or
  3139.   incompatible parity.  If it's a variety of strange characters you have
  3140.   the wrong character set or a high order bit is being set by mistake.
  3141.   If words are misspelled, try a lower baud rate.  For baud or parity
  3142.   incompatibilities you see a lot of the same "error character" which
  3143.   represents a real character that can't be displayed correctly due to
  3144.   an error in parity or baud rate.
  3145.  
  3146.   If you are using agetty (often just named getty), the agetty program
  3147.   will detect and set parity if you type something.   Try it with a
  3148.   return to see if it fixes possible parity errors.
  3149.  
  3150.  
  3151.   15.9.  No Sign of any Login Prompt
  3152.  
  3153.   If nothing at all happens at the terminal, then the worst has
  3154.   occurred.  One of the first things to do is to make sure that all
  3155.   cable connections are tight and connected correctly.  Other problems
  3156.   could be: A baud rate mismatch, broken hardware, or Getty not running.
  3157.   At this point two different avenues of approach are (you may pursue
  3158.   more than one at a time).
  3159.  
  3160.  
  3161.   ╖  ``Diagnose Problem from the Console''
  3162.  
  3163.   ╖  Measure Voltages I ``Measure  Voltages''
  3164.  
  3165.  
  3166.  
  3167.  
  3168.  
  3169.   15.9.1.  Diagnose Problem from the Console
  3170.  
  3171.   At the console (or another working terminal), use "top" or "ps -al" to
  3172.   see if getty is running on the port.  Don't confuse it with getty
  3173.   programs running on other ports or on the virtual consoles.  You will
  3174.   not get a login prompt unless getty runs.  If it's running then you
  3175.   may disable it so that you can try to copy a file to the terminal as a
  3176.   test.
  3177.  
  3178.   To disable getty, edit /etc/inittab and comment out the getty command
  3179.   with an initial # so that it will not respawn after you kill it.  Then
  3180.   kill the old getty using the k key while in "top".
  3181.  
  3182.   To copy a short file to the terminal (It might be a good idea to try
  3183.   this near the start of the installation process before setting up
  3184.   getty) use the Linux copy command such as: cp file_name  /dev/ttyS1.
  3185.   If it doesn't work, use stty to make the interface as simple as
  3186.   possible with everything disabled (such as hardware flow control:
  3187.   -crtscts; parity, and modem control signals: clocal).  Be sure the
  3188.   baud rates and the bits/byte are the same.  If nothing happens verify
  3189.   that the port is alive with a voltmeter per the next section.
  3190.  
  3191.  
  3192.   15.9.2.  Measure Voltages
  3193.  
  3194.   If you have a voltmeter handy check for -12 V (-5 to -15) at pin 3
  3195.   (receive data) at the terminal side of the null modem cable.  The
  3196.   positive lead of the meter should be connected to a good ground (the
  3197.   metal connectors on the ends of cables are often not grounded).  If
  3198.   there is no such negative voltage then check for it at pin 2 on the
  3199.   computer.  If it's present there but not at pin 3 to at the terminal,
  3200.   then the cable is bad (loose connection, broken wire, or not a null
  3201.   modem with pin 2 feeding thru to pin 3).  If voltage is absent, then
  3202.   the serial port on the computer is dead.  Test it with software
  3203.   diagnostics or replace it.
  3204.  
  3205.   If the serial port is alive, you may want to send a file to it (with
  3206.   modem controls disabled) and see if anything gets to it.  To check for
  3207.   a transmitted signal, look at the voltmeter needle at -12 V when the
  3208.   line is idle.  Then start sending a file (or start getty).  You should
  3209.   see the needle dropping to 0 and fluttering about 0 as it measures
  3210.   short-run averages of the bit stream.  You can see this also on the AC
  3211.   scale provided that your meter has a capacitor to block out DC
  3212.   voltages when on the AC scale.  If it doesn't, then the idle DC of -12
  3213.   V will cause a high false AC reading.  Without a meter, you could
  3214.   connect a good device (such as another terminal or an external  modem)
  3215.   to the serial port and see if it works OK.
  3216.  
  3217.  
  3218.   15.10.  Serial Test Equipment
  3219.  
  3220.   15.10.1.  Breakout Gadgets, etc.
  3221.  
  3222.   While a multimeter (used as a voltmeter) may be all that you need for
  3223.   just a few terminals, special test equipment has been made for testing
  3224.   serial port lines.  Some are called "breakout ... " where breakout
  3225.   means to break out conductors from a cable.  These gadgets have a
  3226.   couple of connectors on them and insert into the serial cable.  Some
  3227.   have test points for connecting a voltmeter.  Others have LED lamps
  3228.   which light when certain modem control lines are asserted (turned on).
  3229.   Still others have jumpers so that you can connect any wire to any
  3230.   wire.  Some have switches.  Radio Shack sells a "RS-232
  3231.   troubleshooter" and a "RS-232 serial jumper box".
  3232.  
  3233.  
  3234.  
  3235.   15.10.2.  Measuring Voltages
  3236.  
  3237.   Any voltmeter or multimeter, even the cheapest that sells for about
  3238.   $10, should work fine.  Trying to use other methods for checking
  3239.   voltage is tricky.  Don't use a LED unless it has a series resistor to
  3240.   reduce the voltage across the LED.  A 470 ohm resistor is used for a
  3241.   20 ma LED (but not all LED's are 20 ma).  The LED will only light for
  3242.   a certain polarity so you may test for + or - voltages.  Does anyone
  3243.   make such a gadget for automotive circuit testing??  Logic probes may
  3244.   be damaged if you try to use them since the TTL voltages for which
  3245.   they are designed are only 5 volts.  Trying to use a 12 V incandescent
  3246.   light bulb is not a good idea.  It won't show polarity and due to
  3247.   limited output current of the UART it probably will not even light up.
  3248.  
  3249.   To measure voltage on a female connector you may plug in a bent paper
  3250.   clip.  Its diameter should be no larger than the pins so that it
  3251.   doesn't damage the contact.
  3252.  
  3253.  
  3254.   15.10.3.  Taste Voltage
  3255.  
  3256.   As a last resort, if you have no test equipment and are willing to
  3257.   risk getting shocked (or even electrocuted) you can always taste the
  3258.   voltage.  Before touching one of the test leads with your tongue, test
  3259.   them to make sure that there is no high voltage on them.  Touch both
  3260.   leads (at the same time) to one hand to see if they shock you.  Then
  3261.   if no shock, wet the skin contact points by licking and repeat.  If
  3262.   this test gives you a shock, you certainly don't want to use your
  3263.   tongue.
  3264.  
  3265.   For the test for 12 V, Lick a finger and hold one test lead in it.
  3266.   Put the other test lead on your tongue.  If the lead on your tongue is
  3267.   positive, there will be a noticeable taste.  You might try this with
  3268.   flashlight batteries first so you will know what taste to expect.
  3269.  
  3270.  
  3271.   16.  Repair & Diagnose
  3272.  
  3273.   Repairing a terminal has much in common with repairing a monitor
  3274.   and/or keyboard.  Sometimes the built-in diagnostics of the terminal
  3275.   will tell you what is wrong on the screen.  If not, then by the
  3276.   symptoms, one may often isolate the trouble to one of the following:
  3277.   bad keyboard, CRT dead, terminal digital electronics failure.  It's
  3278.   best to have a service manual, but even if you don't have one, many
  3279.   terminals may still be repaired.
  3280.  
  3281.  
  3282.   16.1.  Repair Books & Websites
  3283.  
  3284.   16.1.1.  Books
  3285.  
  3286.   Bigelow, Stephen J.: Troubleshooting & Repairing Computer Monitors,
  3287.   2nd edition, McGraw-Hill, 1997.  Doesn't cover the character
  3288.   generation electronics nor the keyboard.
  3289.  
  3290.  
  3291.   16.1.2.  Websites
  3292.  
  3293.   The FAQ  <http://www.repairfaq.org> for the newsgroup:
  3294.   sci.electronics.repair is long and comprehensive, although it doesn't
  3295.   cover terminals per se.  See the section "Computer and Video
  3296.   Monitors".  Much of this information is applicable to terminals as are
  3297.   the sections: "Testing Capacitors", "Testing Flyback Transformers",
  3298.   etc.  Perhaps in the future, the "info" on repair in this HOWTO will
  3299.   consist mainly of links to the above FAQ (or the like).
  3300.  
  3301.   16.2.  Safety
  3302.  
  3303.   CRT's use high voltage of up to 30,000 volts for color (less for
  3304.   monochrome).  Be careful not to touch this voltage if the set is on
  3305.   and the cover off.  It probably won't kill you even if you do since
  3306.   the amount of current it can supply is limited.  But it is likely to
  3307.   badly burn and shock you, etc.  High voltage can jump across air gaps
  3308.   and go thru cracked insulation so keep your hands a safe distance from
  3309.   it.  You should notice the well-insulated high voltage cable connected
  3310.   to one side of the picture tube.  Even when the set is off, there is
  3311.   still enough residual voltage on the picture tube cable connection to
  3312.   give you quite a shock.  To discharge this voltage when the set is
  3313.   unplugged use a screwdriver (insulated handle) with the metal blade
  3314.   grounded to the chassis with a jumper wire.
  3315.  
  3316.   The lower voltages (of hundreds of volts) can be even more dangerous,
  3317.   especially if your hands are wet or if you are wearing a metal
  3318.   watchband, ring or the like.  In rare cases people have been killed by
  3319.   it so be careful.  The lowest voltages of only several volts on
  3320.   digital circuitry are fairly safe but don't touch anything (except
  3321.   with a well insulated tool) unless you know for sure.
  3322.  
  3323.  
  3324.   16.3.  Appearance of Display
  3325.  
  3326.   If the display is too dim, turn up the brightness and/or contrast.
  3327.   using knobs on the exterior of the unit (if they exist).  If the
  3328.   width, height or centering is incorrect, there are often control knobs
  3329.   for these.  For some older terminals one must press an arrow key (or
  3330.   the like) in set-up mode.
  3331.  
  3332.   You may need to remove the cover to make adjustments, especially on
  3333.   older models.  You could arrange things so that a large mirror is in
  3334.   front of the terminal so as to view the display in the mirror while
  3335.   making adjustments.  The adjustments to turn may be on a printed
  3336.   circuit board.  While a screwdriver (possibly Phillips-head) may be
  3337.   all that's needed, inductors may require special TV alignment tools
  3338.   (plastic hex wrenches, etc.).  The abbreviated name of the adjustment
  3339.   should be printed on the circuit board.  For example, here are some
  3340.   such names:
  3341.  
  3342.  
  3343.   ╖  V-Size adjusts the Vertical height (Size)
  3344.  
  3345.   ╖  H-Size adjusts the Horizontal width (Size).  It may be an inductor.
  3346.  
  3347.   ╖  V-Pos adjusts the Vertical Position
  3348.  
  3349.   ╖  H-Pos adjusts the Horizontal Position
  3350.  
  3351.   ╖  V-Lin adjusts Vertical Linearity (Use if width of scan lines
  3352.      differs at the top and bottom of the screen)
  3353.  
  3354.   ╖  V-Hold adjusts Vertical Hold (Use if screen is uncontrollable
  3355.      scrolling)
  3356.  
  3357.   ╖  Bright adjusts brightness (an external knob may also exist)
  3358.  
  3359.   ╖  Sub-Bright adjusts brightness of subdued intensity mode (often the
  3360.      normal mode: dimmer than bold or bright mode).
  3361.  
  3362.   Changing linearity may change the size so that it will need to be
  3363.   readjusted.  A terminal that has been stored for some time may have a
  3364.   small display rectangle on the screen surrounded by a large black
  3365.   border.  If it's difficult to adjust, wait a while before adjusting it
  3366.   since it will likely recover some with use (the black borders will
  3367.   shrink).  Just being turned on for a while improves it.
  3368.  
  3369.  
  3370.   16.4.  Diagnose
  3371.  
  3372.   16.4.1.  Terminal Made a Noise
  3373.  
  3374.   If the terminal made some noise just before it failed (or when you
  3375.   turn it on after it failed) that noise is a clue to what is wrong.  If
  3376.   you hear a sparking noise or see/smell smoke, immediately turn the
  3377.   terminal off to prevent further damage.  The problem is likely in the
  3378.   high voltage power supply of several thousand volts.  Remove the cover
  3379.   and if the bad spot is not evident, turn it on again for a short time
  3380.   in a dimly lit room to look for arcing.  The high voltage cable (runs
  3381.   between the flyback transformer and the side of the picture tube) may
  3382.   have broken insulation that arcs to ground.  Fix it with high-voltage
  3383.   insulating dope, or special electrical tape designed say for 10,000
  3384.   volts.
  3385.  
  3386.   The flyback transformer (high voltage) may make only a faint clicking
  3387.   or sparking noise if it fails.  You may not hear it until you turn the
  3388.   terminal off for a while to rest and then turn it back on again.  To
  3389.   track down the noise you may use a piece of small rubber tubing (such
  3390.   as used in automobiles) as a stethoscope  to listen to it.  But while
  3391.   you are listening for the noise, the terminal is suffering more damage
  3392.   so try find it fast (but not so fast as to risk getting shocked).
  3393.  
  3394.   The noise might be due to a short in the power supply.  This may cause
  3395.   a fuse to blow with a pop.  Replacing a blown fuse may not solve the
  3396.   problem as the same short may blow the fuse again.  Inspect for any
  3397.   darkened spots due to high heat and test those components.  Shorted
  3398.   power transistors may cause the fuse to blow.  They may be tested with
  3399.   a transistor checker or even with an ohm-meter.  Use the low ohm scale
  3400.   on an ohm-meter so that the voltage applied by the meter is low.  This
  3401.   will reduce the possible damage to good components caused by this test
  3402.   voltage.
  3403.  
  3404.   If the terminal has been exposed to dampness such as being stored in a
  3405.   damp place or near a kitchen with steam from cooking, a fix may be to
  3406.   dry out the unit.  Heating a "failed" flyback transformer with a blow
  3407.   dryer for several minutes may restore it.
  3408.  
  3409.  
  3410.   16.4.2.  Terminal Made No Noise
  3411.  
  3412.   A blank screen may be due to someone turning the brightness control to
  3413.   the lowest level or to aging.  The next thing to do is to check the
  3414.   cables for loose or broken connections.  If there is no sign of power,
  3415.   substitute a new power cord after making sure that the power outlet on
  3416.   the wall is "hot".
  3417.  
  3418.   If the keyboard is suspected, try it on another terminal of the same
  3419.   type or substitute a good keyboard.  Wiggle the keyboard cable ends
  3420.   and the plug.  Wires inside cables may break, especially near their
  3421.   ends.  If the break is verified by wiggling it (having the problem go
  3422.   on and off in synchronization with the wiggles), then one may either
  3423.   get a new cable or cut into the cable and re-solder the breaks, etc.
  3424.  
  3425.   One of the first things to do if the keyboard works is to put the
  3426.   terminal into local mode (where it works like a typewriter and is
  3427.   disconnected from the computer).  If it works OK in local, then the
  3428.   problem is likely in the connection to the host computer (or incorrect
  3429.   interface) or in the UART chips of the terminal.
  3430.  
  3431.   By carefully inspecting the circuitry, one may often find the cause of
  3432.   the problem.  Look for discoloration, cracks, etc.  An intermittent
  3433.   problem may sometimes be found by tapping on components with a ball-
  3434.   point pen (not the metal tip of course).  A break in the conductor of
  3435.   a printed circuit board may sometimes be revealed by flexing the
  3436.   board.  Solder that looks like it formed a drop or a solder joint with
  3437.   little solder may need re-soldering.  Soldering may heat up
  3438.   transistors (and other components) and damage them so use a heat sink
  3439.   if feasible.
  3440.  
  3441.   If you have a common brand of terminal, you may be able to search
  3442.   newsgroup postings on the Internet to find out what the most frequent
  3443.   types of problems are for your terminal and perhaps information on how
  3444.   to fix them.
  3445.  
  3446.   To see if the digital electronics work, try (using a good keyboard)
  3447.   typing at the bad terminal.   Try to read this typing at a good
  3448.   terminal (or the console) using the copy command or with a terminal
  3449.   communication program such as Minicom.  You may need to hit the return
  3450.   key at the terminal in order to send a line.  One may ask the bad
  3451.   terminal for its identity etc. from another terminal.  This will show
  3452.   if two-way communication works.
  3453.  
  3454.  
  3455.   16.5.  Capacitors
  3456.  
  3457.   Electrolytic capacitors have a metal shell and are may become weak or
  3458.   fail if they set for years without being used.  Sometimes just leaving
  3459.   the terminal on for a while will help partially restore them.  If you
  3460.   can, exercise any terminals you have in storage by turning them on for
  3461.   a while every year or two.
  3462.  
  3463.  
  3464.   16.6.  Keyboards
  3465.  
  3466.   16.6.1.  Interchangeability
  3467.  
  3468.   The keyboards for terminals are not the same as keyboards for PC's.
  3469.   The difference is not only in the key layout but in the codes
  3470.   generated when a key is pressed.  Also, keyboards for various brands
  3471.   and models of terminals are not always interchangeable with each
  3472.   other.  Sometimes one get an "incompatible" keyboard to partially work
  3473.   on a terminal.  All the ASCII keys will work OK, but special keys such
  3474.   as set-up and break will not work correctly.
  3475.  
  3476.  
  3477.   16.6.2.  How They Work
  3478.  
  3479.   Most keyboards just make a simple contact between two conductors when
  3480.   you press a key.  Electronics inside a chip in the keyboard converts
  3481.   this contact closure into a code sent over the keyboard's external
  3482.   cable.  Instead of having a separate wire (or conductor) going from
  3483.   each key to the chip, the following type scheme is used.  Number the
  3484.   conductors say from 1-10 and A-J.  For example: conductor 3 goes to
  3485.   several keys and conductor B goes to several keys, but only one key
  3486.   has both conductors 3 and B going to it.  When that key is pressed, a
  3487.   short circuit is established between 3 and B.  The chip senses this
  3488.   short and knows what key has been pressed.  Such a scheme reduces the
  3489.   number of conductors needed (and  reduces the number of pins needed on
  3490.   the chip).  It's similar to what is called a crossbar switch.
  3491.  
  3492.  
  3493.   16.6.3.  One Press Types 2 Different Characters
  3494.  
  3495.   If, due to a defect, conductors 3 and 4 become shorted together then
  3496.   pressing the 3-B key will also short 4 and B and the chip will think
  3497.   that both keys 3-B and 4-B have been pressed.  This is likely to type
  3498.   2 different characters when all you wanted was one character.
  3499.   16.6.4.  Modern vs Old Keyboards
  3500.  
  3501.   While the modern keyboard and the old fashioned type look about the
  3502.   same, the mechanics of operation are different.  The old ones have
  3503.   individual key switches under the key-caps with each switch enclosed
  3504.   in a hard plastic case.  The modern ones use large flexible plastic
  3505.   sheets (membrane) the size of the keyboard.  A plastic sheet with
  3506.   holes in it is sandwiched between two other plastic sheets containing
  3507.   printed circuits (including contact points).  When you press a key,
  3508.   the two "printed" sheets are pressed together at a certain point,
  3509.   closing the contacts printed on the sheets at that point.
  3510.  
  3511.  
  3512.   16.6.5.  Keyboard Doesn't Work At All
  3513.  
  3514.   If none of the keys work try another keyboard (if you have one) to
  3515.   verify that the keyboard is the problem.  The most likely cause is a
  3516.   broken wire inside the cord (cable) that connects it to the terminal.
  3517.   The most likely location of the break is at either end of the cord.
  3518.   Try wigging the ends of the cord while tapping on a key to see if it
  3519.   works intermittently.  You may carefully cut into the cord with a
  3520.   knife at the bad spot and splice the broken conductor.  Sometimes just
  3521.   a drop of solder will splice it.  Seal up the cord with electrical
  3522.   tape, glue, or caulk.
  3523.  
  3524.  
  3525.   16.6.6.  Typing b Displays bb, etc. (doubled)
  3526.  
  3527.   If all characters appear double there is likely nothing wrong with the
  3528.   keyboard.  Instead, your terminal has likely been incorrectly set up
  3529.   for half-duplex (local echo on) and every character you type is echoed
  3530.   back both from the electronics inside your terminal and from your host
  3531.   computer.  If the two characters are not the same, there may be a
  3532.   short circuit inside your keyboard.  See ``One Press Types 2 Different
  3533.   Characters''
  3534.  
  3535.  
  3536.   16.6.7.  The Keyboard Types By Itself
  3537.  
  3538.   If a key is shorted out it is likely to type out a large number of the
  3539.   same character if auto-repeat is enabled.  If more than one key is
  3540.   shorted out then repeating sequences of a few characters will be
  3541.   typed.  This may cause getty to respawn too fast if it happens at the
  3542.   login prompt.  See ``Key Shorted''.  The fix is to clean the contacts
  3543.   per ``Cleaning Keyboard Contacts''.
  3544.  
  3545.  
  3546.   16.6.8.  Liquid Spilled on the Keyboard
  3547.  
  3548.   If water or watery liquid has been spilled on the keyboard (or if it
  3549.   was exposed to rain, heavy dew, or dampness) some keys may not work
  3550.   right.  The dampness may cause a key to short out (like it was pressed
  3551.   down all the time) and you may see the screen fill up with that letter
  3552.   if auto-repeat is enabled.  If it's gotten wet and then partially (or
  3553.   fully) dried out, certain keys may not work due to deposits on the
  3554.   contact surfaces.  For the modern type of keyboard, one may readily
  3555.   take apart the plastic sheets inside and dry/clean them.  For the old
  3556.   type one may let it dry out in the sun or oven (low temp.).  When it's
  3557.   dry it may still need contact cleaner on some keys as explained below.
  3558.  
  3559.  
  3560.   16.6.9.  Cleaning Keyboard Contacts
  3561.  
  3562.  
  3563.  
  3564.  
  3565.   16.6.9.1.  Keyboards with Membranes
  3566.  
  3567.   On some newer keyboards, the plastic sheets (membranes) are easy to
  3568.   remove for inspection and cleaning if needed.  You only need to remove
  3569.   several screws to take apart the keyboard and get to the sheets.  On
  3570.   some old IBM keyboards the sheets can't be removed without breaking
  3571.   off many plastic tabs which will need to be repaired with glue to put
  3572.   back (probably not worthwhile to repair).  Such a keyboard may
  3573.   sometimes be made to work by flexing, twisting, and/or pounding the
  3574.   assembly containing the plastic sheets.
  3575.  
  3576.  
  3577.   16.6.9.2.  Keyboards with Individual Switches
  3578.  
  3579.   What follows is for older keyboards that have separate hard plastic
  3580.   switches for each key.  Before going to all the work of cleaning
  3581.   electrical contacts first try turning the keyboard upside-down and
  3582.   working the bad keys.  This may help dislodge dirt, especially if you
  3583.   press the key hard and fast to set up vibration.
  3584.  
  3585.   Often the key-caps may be removed by prying them upward using a small
  3586.   screwdriver as a lever while preventing excessive tilting with a
  3587.   finger.  (Warning: Key-caps on modern keyboards don't pry up.)  The
  3588.   key-cap may tilt a bit and wobble as it comes loose.  It may even fly
  3589.   up and onto the floor.  Then you have two choices on how to clean the
  3590.   contacts: Use contact cleaner spray directly on top of the key switch,
  3591.   or take the key switch apart and clean it.  Still another choice is to
  3592.   replace the key switch with a new or used one.
  3593.  
  3594.   Directly spraying contact cleaner or the like (obtained at an
  3595.   electronics store) into the top of the key switch is the fastest
  3596.   method but may not work and it also might damage the plastic.  With
  3597.   the keyboard live (or with the key contacts connected to an ohm-meter)
  3598.   use the tube which came with the spray to squirt cleaner inside the
  3599.   key switch.  Tilt the keyboard so that the cleaner flows into the
  3600.   contacts.  For the CIT101e terminal with an Alps keyboard, this means
  3601.   tilting the digit row up toward the ceiling.  Work the key switch up
  3602.   and down with a pen or small screwdriver handle to avoid getting the
  3603.   toxic cleaner liquid on your skin (or wear gloves).  Finally turn the
  3604.   keyboard upside-down while working the key to drain off remaining
  3605.   cleaner.  The more cleaner you squirt in the more likely it will fix
  3606.   it but it is also more likely to do more damage to the plastic, so use
  3607.   what you think is just enough to do the job.  Once the key works OK,
  3608.   work it up and down a little more and test it a half minute later,
  3609.   etc. to make sure it will still work OK.
  3610.  
  3611.   Sometimes a key works fine when the contacts inside are saturated with
  3612.   contact cleaner liquid, but when the liquid dries a few minutes later
  3613.   then the resulting scale on the contacts prevents good contact and the
  3614.   key works erratically (if at all).  Operating the key when the liquid
  3615.   is drying inside may help.  Some switches have the contacts nearly
  3616.   sealed inside so little if any contact cleaner reaches the contacts.
  3617.   The cleaner that does get to the contacts may carry contamination with
  3618.   it.
  3619.  
  3620.   If you need to disassemble the key switch, first inspect it to see how
  3621.   it is installed and comes apart.  Sometimes one may remove the cover
  3622.   of the switch without removing the switch from the keyboard.  To do
  3623.   this pry up (or pull up) the top of the key switch after prying apart
  3624.   thin plastic tabs that retain it.  Don't pry too hard or you may break
  3625.   the thin plastic.  If this can't be done, you may have to unsolder the
  3626.   switch and remove it in order to take it apart (or replace it).  Once
  3627.   the switch has been taken apart you still may not be able to see the
  3628.   contacts if the contact surfaces are sandwiched together (nearly
  3629.   touching).  You may get contact cleaner on the contacts by slightly
  3630.   prying apart the conducting surfaces and squirting cleaner between
  3631.   them.  There may be some kind of clip holding the contact surfaces
  3632.   together which needs to be removed before prying these surfaces apart.
  3633.   With cleaner on the contacts, work them.  Tilting the keyboard or
  3634.   inverting it may help.  Take care not to loose small parts as they may
  3635.   fly up into the air when taking apart a key switch.
  3636.  
  3637.  
  3638.   17.  Appendix
  3639.  
  3640.   17.1.  List of Linux Terminal Commands
  3641.  
  3642.   17.1.1.  Sending a Command to the Terminal
  3643.  
  3644.  
  3645.   ╖  ``setterm'': long options
  3646.  
  3647.   ╖  ``tput'': terse options
  3648.  
  3649.   ╖  tset: initializes only
  3650.  
  3651.   ╖  clear: clears screen
  3652.  
  3653.   ╖  reset: sends reset string
  3654.  
  3655.  
  3656.   17.1.2.  Configuring the Terminal Device Driver
  3657.  
  3658.  
  3659.   ╖  ``setserial'':
  3660.  
  3661.   ╖  ``stty''
  3662.  
  3663.  
  3664.   17.1.3.  Terminfo
  3665.  
  3666.  
  3667.   ╖  ``tic'' terminfo compiler & translator
  3668.  
  3669.   ╖  toe: shows list of terminals for which you have terminfo (termcaps)
  3670.  
  3671.   ╖  ``infocmp'' compares or displays terminfo entries
  3672.  
  3673.  
  3674.   17.1.4.  Other
  3675.  
  3676.  
  3677.   ╖  gitkeys: shows what bytes each key sends to the host.
  3678.  
  3679.   ╖  tty: shows what tty port you are connected to.
  3680.  
  3681.   ╖  set (or tset -q): shows the value of TERM, the terminfo entry name
  3682.  
  3683.   ╖  ``tset'': sets TERM interactively and initializes
  3684.  
  3685.  
  3686.   17.2.  The Internet and Books
  3687.  
  3688.   17.2.1.  Terminal Info on the Internet
  3689.  
  3690.  
  3691.  
  3692.   ╖  Shuford's Website
  3693.      <http://www.cs.utk.edu/~shuford/terminal_index.html> at the
  3694.      University of Tennessee has a great deal of useful information
  3695.      about text terminals.
  3696.  
  3697.   ╖  Boundless <http://www.boundless.com/textterm/> purchased the VT and
  3698.      Dorio terminal business from DEC.
  3699.  
  3700.   ╖  Wyse <http://www.wyse.com/terminal/> is a major manufacturer of
  3701.      terminals.
  3702.  
  3703.   ╖  comp.terminals is the newsgroup for terminals
  3704.  
  3705.  
  3706.   17.2.2.  Books Related to Terminals
  3707.  
  3708.  
  3709.  
  3710.   ╖  EIA-232 serial port see ``EIA-232 (RS-232) Books''.
  3711.  
  3712.   ╖  Repair see ``Repair Books &  Websites''.
  3713.  
  3714.   ╖  Terminfo database see ``Termcap Documents''
  3715.  
  3716.  
  3717.   17.2.3.  Entire Books on Terminals
  3718.  
  3719.   As far as I know, there is no satisfactory book on text terminals
  3720.   (unless you are interested in antique terminals of the 1970's).
  3721.  
  3722.   ╖  Handbook of Interactive Computer Terminals by Duane E. Sharp;
  3723.      Reston Publishing Co. 1977. (mostly obsolete)
  3724.  
  3725.   ╖  Communicating with Display Terminals by Roger K. deBry; McGraw-Hill
  3726.      1985.  (mostly on IBM synchronous terminals)
  3727.  
  3728.   The "HANDBOOK ... " presents brief specification of over 100 different
  3729.   models of antique terminals made in the early 1970's by over 60
  3730.   different companies.  It also explains how they work physically but
  3731.   incorrectly shows a diagram for a CRT which uses electrostatic
  3732.   deflection of the electron beam (p. 36).  Terminals actually used
  3733.   magnetic deflection (even in the 1970's).  This book explains a number
  3734.   of advanced technical concepts such as "random scan" and "color
  3735.   penetration principle".
  3736.  
  3737.   The "COMMUNICATING ... " book in contrast to the "Handbook ... "
  3738.   ignores the physical and electronic details of terminals.  It has an
  3739.   entire chapter explaining binary numbers (which is not needed in a
  3740.   book on terminals since this information is widely available
  3741.   elsewhere).  It seems to mostly cover old IBM terminals (mainly the
  3742.   3270) in block and synchronous modes of operation.  It's of little use
  3743.   for the commonly used ANSI terminals used today on Unix-like systems.
  3744.   Although it does discuss them a little it doesn't show the various
  3745.   wiring schemes used to connect them to serial ports.
  3746.  
  3747.  
  3748.   17.2.4.  Books with Chapters on Terminals
  3749.  
  3750.   These chapters cover almost nothing about the terminals themselves and
  3751.   their capabilities.  Rather, these chapters are mostly about how to
  3752.   set up the computer (and its terminal driver) to work with terminals.
  3753.   Due to the differences of different Unix-like systems, much of the
  3754.   information does not not apply to Linux.
  3755.  
  3756.  
  3757.   ╖  Unix Power Tools by Jerry Peck et. al.  O'Reilly 1998.  Ch. 5
  3758.      Setting Up Your Terminal, Ch. 41: Terminal and Serial Line
  3759.      Settings, Ch. 42: Problems With Terminals
  3760.  
  3761.   ╖  Advanced Programming in the Unix Environment by W. Richard Stevens
  3762.      Addison-Wesley, 1993.  Ch. 11: Terminal I/O, Ch. 19: Pseudo
  3763.      Terminals
  3764.  
  3765.   ╖  Essential System Administration by Aleen Frisch, 2nd ed.  O'Reilly,
  3766.      1998.  Ch. 11: Terminals and Modems.
  3767.  
  3768.   The "UNIX POWER TOOLS" book has 3 short chapters on text terminals.
  3769.   It covers less ground than this HOWTO but gives more examples to help
  3770.   you.
  3771.  
  3772.   The "ADVANCED PROGRAMMING ... " Chapter 11 covers only the device
  3773.   driver (or terminal driver) aspect of terminals (the software which is
  3774.   included in the operating system to deal with terminals).  It explains
  3775.   the parameters one gives to the stty command to configure the
  3776.   terminal.
  3777.  
  3778.   The "ESSENTIAL SYSTEM ..." book's chapter has more about terminals
  3779.   than modems.  It seems well written.
  3780.  
  3781.  
  3782.  
  3783.  
  3784.  
  3785.  
  3786.  
  3787.  
  3788.  
  3789.  
  3790.  
  3791.  
  3792.  
  3793.  
  3794.  
  3795.  
  3796.  
  3797.  
  3798.  
  3799.  
  3800.  
  3801.  
  3802.  
  3803.  
  3804.  
  3805.  
  3806.  
  3807.  
  3808.  
  3809.  
  3810.  
  3811.  
  3812.  
  3813.  
  3814.  
  3815.  
  3816.  
  3817.  
  3818.  
  3819.  
  3820.  
  3821.  
  3822.  
  3823.  
  3824.  
  3825.  
  3826.  
  3827.  
  3828.  
  3829.