How do I set up a terminal connected to my PC?

# 9 How do I set up a terminal connected to my PC? Can I use more than 2 serial devices?

Contents of this section

You don't need to read this section, unless you want to use 3 or more serial devices... (assuming you don't have a multiport board).

Providing you have another spare serial port, yes, you can.

The number of serial ports you can use is limited by the number of interrupts (IRQ) and port I/O addresses we have to use. Each serial devices must be assigned it's own interrupt and address. A serial device can be a serial port, an internal modem, or a multiport serial board.

Multiport serial boards are specially designed to have multiple serial ports that share the same IRQ for all serial ports on the board. Linux gets data from them by using a different I/O address for each port on the card.

## 9.1 Choosing serial device interrupts

Your PC will normally come with `ttyS0` and `ttyS2` at IRQ 4, and `ttyS1` and `ttyS3` at IRQ 3. To use more than 2 serial devices, you will have to give up an interrupt to use. A good choice is to reassign an interrupt from your parallel port. Your PC normally comes with IRQ 5 and IRQ 7 set up as interrupts for your parallel ports, but few people use 2 parallel ports. You can reassign one of the interrupts to a serial device, and still happily use a parallel port. You will need the `setserial` program to do this. In addition, you have to play with the jumpers on your boards, check the docs for your board. Set the jumpers to the IRQ you want for each port.

You will need to set things up so that there is one, and only one interrupt for each serial device. Here is how I set mine up in `/etc/rc.local` - you should do it upon startup somewhere:

> `

>             /etc/setserial /dev/cua0 irq 3          # my mouse
>             /etc/setserial /dev/cua1 irq 4          # my dumb terminal
>             /etc/setserial /dev/cua2 irq 5          # my 2400 bps modem
>             /etc/setserial /dev/cua3 irq 9          # my telebit modem

> `

Standard IRQ assignments:

> `

>                   IRQ  0    Timer channel 0
>                   IRQ  1    Keyboard
>                   IRQ  2    Cascade for controller 2
>                   IRQ  3    Serial port 2
>                   IRQ  4    Serial port 1
>                   IRQ  5    Parallel port 2
>                   IRQ  6    Floppy diskette
>                   IRQ  7    Parallel port 1
>                   IRQ  8    Real-time clock
>                   IRQ  9    Redirected to IRQ2
>                   IRQ 10    not assigned
>                   IRQ 11    not assigned
>                   IRQ 12    not assigned
>                   IRQ 13    Math coprocessor
>                   IRQ 14    Hard disk controller
>                   IRQ 15    not assigned

> `

There is really no Right Thing to do when choosing interrupts. Just make sure it isn't being used. 2, 3, 4, 5, or 7 is a good choice. ``not assigned'' means that currently nothing standard uses these IRQs. Also note that IRQ 2 is the same as IRQ 9. You can call it either 2 or 9, the serial driver is very understanding.

If you have a serial card with a 16-bit bus connector, you can also use IRQ 10, 11, 12 or 15.

Just make sure you don't use IRQ 0, 1, 6, 8, 13 or 14! These are used by your mother board. You will make her very unhappy by taking her IRQs.

## 9.2 Setting serial device addresses

Next, you must set the port address. Check the manual on your board for the jumper settings. Like interrupts, there can only be one serial device at each address. Yours port will usually come configured as follows:

> `

>             /dev/cua0, /dev/ttyS0 address 0x3f8 ttyS0
>             /dev/cua1, /dev/ttyS1 address 0x2f8 ttyS1
>             /dev/cua2, /dev/ttyS2 address 0x3e8 ttyS2
>             /dev/cua3, /dev/ttyS3 address 0x3e8 ttyS3

> `

Choose which address you want each serial device to have and set the jumpers accordingly. I have my modem on `ttyS3`, and my mouse on `ttyS0`.

When you reboot, Linux should see your serial ports at the address you set them. The IRQ Linux sees may not correspond to the IRQ you set with the jumpers. Don't worry about this. Linux does not do any IRQ detection when it boots, because IRQ detection is dicy and can be fooled. Use `setserial` to tell Linux what IRQ the port is using.

Next Chapter, Previous Chapter

Table of contents of this chapter, General table of contents

Top of the document, Beginning of this Chapter