/dev/ttySN
Devices in Linux have major and minor numbers. Each serial port may have 2 possible names, but the cua name is deprecated and may not be used in the future. See The cua Device.
major minor major minor I/O address
/dev/ttyS0 4, 64 /dev/cua0 5, 64 3F8
/dev/ttyS1 4, 65 /dev/cua1 5, 65 2F8
/dev/ttyS2 4, 66 /dev/cua2 5, 66 3E8
/dev/ttyS3 4, 67 /dev/cua3 5, 67 2E8
Note that all distributions should come with these devices already made
correctly (unless cua is abolished). You can verify this by typing:
linux% ls -l /dev/cua*
linux% ls -l /dev/ttyS*
If you don't have a device, you will have to create it with the
mknod
command. Example, suppose you needed to create devices
for ttyS0
:
linux# mknod -m 666 /dev/cua0 c 5 64
linux# mknod -m 666 /dev/ttyS0 c 4 64
You can use the MAKEDEV
script, which lives in /dev
.
This simplifies the making of devices. For example, if you needed
to make the devices for ttyS0
you would type:
linux# cd /dev
linux# ./MAKEDEV ttyS0
This handles the devices creation and should set the correct permissions.
On some installations, two extra devices will be created,
/dev/modem
for your modem and /dev/mouse
for your
mouse. Both of these are symbolic links to the appropriate
device in /dev
which you specified during the
installation (unless you have a bus mouse, then /dev/mouse
will point to the bus mouse device).
There has been some discussion on the merits of /dev/mouse
and /dev/modem
. I strongly discourage the use of these
links. In particular, if you are planning on using your modem for
dialin you may run into problems because the lock files may not work
correctly if you use /dev/modem
. Use them if you like, but
be sure they point to the right device. However, if you change
or remove this link, some applications might need reconfiguration.
Each ttyS device has a corresponding cua device. There has been some talk about abolishing cua so perhaps it's best to use ttyS. The main difference between cua and ttyS has to do with what happens in a C_program when an ordinary "open" command tries to open the port. The cua will open the port even if the modem control signals (such as DCD) say not to (stty must have been set to check modem control signals). A ttyS port would refuse to open in such a case, but it can be forced to open by giving a certain flag to the "open" command. Unfortunately, this forced open has a side effect which may need to be undone by other commands.
Thus a ttyS port can do everything a cua port can (with a little more work for the programmer). Eliminating cua would brings Linux more into compliance with the Posix standard and avoids certain problems with lock files. It looks like cua is on the way out.