604 606




Linux Unleashed, Third Edition:Devices





-->















Previous
Table of Contents
Next




Adding a Terminal
Terminals are added to Linux in much the same manner as printers—using the mknod command. To add a terminal, you must decide which port the terminal will be connected to. The serial ports on a PC are referred to by Linux as /dev/ttyS0 (for COM1 in DOS terms), /dev/ttyS1 (for COM2), and so on.
Most PC systems have one or two serial ports, although up to four can be accommodated (ttyS0 to ttyS3). Linux uses the serial ports based on their addresses in the BIOS. The usual addresses for the serial ports are as follows:


ttyS0 (COM1)
0x03f8

ttyS1 (COM2)
0x02f8

ttyS2 (COM3)
0x03e8

ttyS3 (COM4)
0x02e8


If you’re not sure which serial port is which, you may have to use either a DOS-based diagnostic utility (such as MS-DOS’s MSD.EXE) or start at the lowest address and work up, testing the terminal each time. If the PC has only one port, it is almost always configured as COM1.

To create a new terminal device, you must run the mknod (make node) command to create the new device driver file, and then change the permissions on the file to let it be run by root or daemon. Most Linux distributions include the terminal devices already. The mknod command was covered in detail earlier in this chapter. Check out the section “The mknod Command.”
A typical command for creating a new terminal device is


mknod -m 660 /dev/ttyS0 c 4 64


The -m 660 sets the permissions on the file. /dev/ttyS0 specifies the first serial port on the machine (COM1). The c indicates that the terminal is a character device (almost all terminals, except very high-speed high-end models, are character devices). The major device number is set to 4, while the minor device number is set to 64. For the other serial ports on the PC (COM2 through COM4), the commands would be as follows:


mknod -m 660 /dev/ttyS1 c 4 65
mknod -m 660 /dev/ttyS2 c 4 66
mknod -m 660 /dev/ttyS3 c 4 67


The changes in the minor device number with the preceding different commands are not required, but there must be a unique minor device number for each terminal.

After the mknod command has been executed, the device driver must be set to the proper ownership. Issue the command


chown root.tty /dev/ttyS0


replacing the /dev/ttyS0 with whatever device the command applies to. The ownership is set to root.tty.
You also want to change the entry in the /etc/ttys file to include the terminal type and device that you have added so that the startup of the terminal can be performed properly. Because the /etc/inittab file already contains entries for the standard serial ports, you can edit the entry for your new terminal’s port (if necessary) to set the baud rate and other parameters that may be required.
Using stty and tset
The stty command enables you to change and query a terminal option. The stty command is very complex, with dozens of options that modify the behavior of the terminal device driver. Luckily, only the most intense system administrators have to use the many options, so in this chapter we will ignore most of the details.
To see the current settings of a terminal, use the stty command without any arguments. It displays a set of parameters. You can use this to verify that the terminal has read the configuration information properly from the /etc/inittab and /etc/gettydefs files.
Like stty, the tset command has many options, most of which are seldom used (especially if you are not dealing with strange terminals and weird connectors). The tset command is used to initialize the terminal driver. If the tset command is given with a specific argument, it uses that. Otherwise, the value in the TERM environment variable is used.
You can use tset within the startup files of a user who always logs in from a remote terminal (through a modem). If you put the command


tset -m dialup:vt100


in the shell startup file (.profile, .cshrc, and so on), the terminal type will be set to vt100 every time a connection is made through the modem. Of course, this sets the terminal type even if someone isn’t using a VT100 terminal, so you can use the command


tset -m dialup:?vt100


to have the user connecting through the modem prompted for the terminal type. The prompt looks like this:



TERM=(vt100)?


If the user presses Enter, the TERM variable is set to vt100. If the user doesn’t want to use that value, she can enter the correct string at the prompt.
So far, tset seems to be quite simple, but, in fact, it has a very complex structure when dealing with hard-wired terminals. To properly configure a terminal connected through a serial port, you need a command such as this:


eval ‘tset -s -Q -m dialup:?vt100 -m switch:z29‘


The full details of this type of command are unimportant for most system administrators. If you want more information, check the man pages for tset and stty that came with your Linux system.
Resetting a Screwy Terminal
Every now and then a terminal connected through a serial port starts acting screwy, either not showing a prompt or generating garbage. There are two quick ways to try to reset the terminal. If they don’t work, the terminal should be shut down and restarted. (You might have to kill the processes that were running on the terminal.)

The first approach is to issue a set of Ctrl+J characters on the screwy terminal, and then type stty sane followed by another Ctrl+J. The command stty sane should reset the terminal characteristics to normal. You probably won’t see the letters you are typing, so enter them carefully.
If the terminal isn’t behaving at this point, try typing reset and pressing Enter or Ctrl+J. If this doesn’t work, the terminal is hung and should be reset manually.



Previous
Table of Contents
Next














Wyszukiwarka

Podobne podstrony:
604 606
604 606
fileQ83 3 br 604 info
599 604
W Ziemi Obiecanej (1615 606 p n e )
MaxCom KXT 604
606 (2)
Gruca Jaroslaw  14 gr=604
606 613
ONKYO KODY DO PILOTA 506,576,606,5100codes
603 606
601 604
606 (3)
604 (2)
606 Tablice
606 609

więcej podobnych podstron