Next Previous Contents

8. How Do I Set Up A Terminal Connected To My PC?

See Text-Terminal-HOWTO for a more detailed (but still incomplete) discussion of terminals. The instructions in this section will work for connecting terminals, as well as other computers to the serial port on your Linux box.

8.1 Hardware Requirements

Make sure you have the right kind of cable. A null modem cable bought at a computer store may do it, but it probably will not work for hardware flow control. But it must be a null modem cable! Many computer stores advertise this kind of cable as a serial printer cable. Make sure you are using your serial port, the male DB25 or the DB9, and not your parallel port (female DB25 or centronics).

For a DB25 connector, you need a minimum of:

 
PC male DB25                            Terminal DB25
        TxD   Transmit Data         2 --> 3     RxD   Receive Data
        RxD   Receive Data          3 <-- 2  TxD   Transmit Data
        SG    Signal Ground         7 --- 7     SG    Signal Ground

This null modem cable works OK between two computers that use RTS/CTS hardware handshaking signals, but many terminals use DTR handshaking which can't be set in linux with "stty". A workaround is to stty crtscts and connect terminal pin 20 (DTR) with the PC pin 5 (CTS).

PC male DB25                            Terminal DB25
TxD   Transmit Data         2 --> 3     RxD   Receive Data
RxD   Receive Data          3 <-- 2     TxD   Transmit Data
RTS   Request To Send       4 --> 5     CTS   Clear To Send
CTS   Clear To Send         5 <-- 4     RTS   Request To Send
DSR   Data Set Ready        6
                            |
DCD   Carrier Detect        8 <-- 20    DTR   Data Terminal Ready
SG    Signal Ground         7 --- 7     SG    Signal Ground
                                  6     DSR   Data Set Ready
                                  |
DTR   Data Terminal Ready  20 --> 8     DCD   Carrier Detect

If you have a DB9 connector on your serial port, try the following:

PC DB9                                  Terminal DB25 
        RxD   Receive Data          2 <-- 2  TxD   Transmit Data
        TxD   Transmit Data         3 --> 3     RxD   Receive Data
        SG    Signal Ground         5 --- 7     SG    Signal Ground

Alternatively, a full DB9-DB25 null modem cable (Not likely to work with terminal hardware handshaking; see above):

PC DB9                                  Terminal DB25
RxD   Receive Data          2 <-- 2     TxD   Transmit Data
TxD   Transmit Data         3 --> 3     RxD   Receive Data
                                  6     DSR   Data Set Ready
                                  |
DTR   Data Terminal Ready   4 --> 8     DCD   Carrier Detect
GND   Signal Ground         5 --- 7     GND   Signal Ground
DCD   Carrier Detect        1
                            |
DSR   Data Set Ready        6 <-- 20    DTR   Data Terminal Ready
RTS   Request To Send       7 --> 5     CTS   Clear To Send
CTS   Clear To Send         8 <-- 4     RTS   Request To Send
(RI   Ring Indicator        9 not needed)
(Yes, the pins 2 and 3 really do have the opposite meanings in DB9 connectors than in DB25 connectors!)

If you are not using a full null modem cable, you might have to do the following trick: on your computer side of the connector, connect RTS and CTS together, and also connect DSR, DCD and DTR together. This way, when the computer wants a certain handshaking signal, it will get it (from itself).

Now that you have the right kind of cable?, connect your terminal to your computer. If you can, tell the terminal to ignore modem control signals. Try using 9600 bps, 8 data bits, 1 stop bit, no parity bits for the terminal's setup (or enable parity if you want to be more sophisticated).

8.2 Setting up getty (part of getty_ps)

Consult your getty manual for other getty programs such as agetty. Add entries for getty to use for your terminal in /etc/gettydefs if there they aren't already there:

# 38400 bps Dumb Terminal entry
DT38400# B38400 CS8 CLOCAL # B38400 SANE -ISTRIP CLOCAL #@S @L login: #DT38400

# 19200 bps Dumb Terminal entry
DT19200# B19200 CS8 CLOCAL # B19200 SANE -ISTRIP CLOCAL #@S @L login: #DT19200

# 9600 bps Dumb Terminal entry
DT9600# B9600 CS8 CLOCAL # B9600 SANE -ISTRIP CLOCAL #@S @L login: #DT9600

If you want, you can make getty print interesting things in the login banner. In my examples, I have the system name and the serial line printed. You can add other things:

@B    The current (evaluated at the time the @B is seen) bps rate.
@D    The current date, in MM/DD/YY.
@L    The serial line to which getty is attached.
@S    The system name.
@T    The current time, in HH:MM:SS (24-hour).
@U    The number of currently signed-on users.  This is  a
      count of the number of entries in the /etc/utmp file
      that have a non-null ut_name field.
@V    The value of VERSION, as given in the defaults file.
To display a single '@' character, use either '\@' or '@@'.

When you are done editing /etc/gettydefs, you can verify that the syntax is correct by doing:

linux# getty -c /etc/gettydefs

Make sure there is no getty or uugetty config file for the serial port that your terminal is attached to (/etc/default/{uu}getty.ttySN or /etc/conf.{uu}getty.ttySN), as this will probably interfere with running getty on a terminal. Remove the file if it exits.

Edit your /etc/inittab file to run getty on the serial port (substituting in the correct information for your environment - port, speed, and default terminal type):

S1:456:respawn:/sbin/getty ttyS1 DT9600 vt100
Restart init:
linux# init q 

At this point, you should see a login prompt on your terminal. You may have to hit return to get the terminal's attention.

8.3 Notes On Setting Up A PC As A Terminal

Many people set up other PCs as terminals connected to Linux boxes. For example, old 8088 or 80286 PCs are perfect for this purpose. All you need is a DOS boot disk containing a version of DOS suitable for your terminal-PC, and a communications program for your terminal-PC to run. kermit works very well for this purpose. You can find pre-compiled versions of kermit for every OS in existence at http://www.columbia.edu/kermit/. Other popular DOS comm programs such as telix and procomm will work equally well. Be sure to input correct serial port information into your terminal-PC's communications setup.


Next Previous Contents