Once upon a time the names of the serial ports were simple. Except for some multiport serial cards they were named /dev/ttyS0, /dev/ttyS1, etc. Then around the year 2000 came the USB bus with names like /dev/ttyUSB0 and /dev/ttyACM1 (for the ACM modem on the USB bus).
A little later with kernel 2.4 came the "device file system" (devfs) with a whole new set of names for everything. The use of the device file system was optional and many still continued using the old system. Then in 2003-4, it was claimed that devfs had unsolvable problems and will be replaced with what's called "udev". Although udev doesn't provide all the functionality of devfs it does handle hot plugging. With all this confusion, most distributions use neither devfs nor udev.
If you use devfs or udev, ttyS1 becomes tts/1, ttyUSB1 becomes /usb/tts/1, and ttyACM1 is /usb/acm/1. Note that the the number 1 above is just an example. It could be replaced by 0, 2, 3, 4, etc. One may use devfs but have the conventional names linked (via symlinks) to the new names. So they use the new system with the old names but may also use some of the new names for some devices. It's even possible ?? to use the new names for the old (non-devfs) system.
Since DOS provided for 4 serial ports on the old ISA bus: COM1-COM4, ttyS0-ttyS3 (tts/0-tts/3) most serial ports on the newer PCI bus use higher numbers such as ttyS4 (tts/4) or ttyS14 (tts/14) for kernel 2.6. This permits one to have both ISA serial ports and PCI serial ports on the same PC with no name conflicts. 0-3 are reserved for the old ISA bus and 4-upward (or 14-upward) are used for PCI. It's not required to be this way but it often is. On-board serial ports on motherboards which have both PCI and ISA slots are likely to still be ISA ports. Even for all-PCI-slot motherboards, the serial ports are often not PCI. They are either ISA, on an internal ISA bus or on a LPC bus which is intended for slow legacy I/O devices: serial/parallel ports and floppy drives.
In kernel 2.4 the devfs was created only to be obsoleted in favor of udev in kernel 2.6. devfs creased a new system of device naming which was continued with udev. The naming system makes it easier to deal with a huge number of devices. But there's also a popular option to continue using the old names. However, a new device may not have an old-style name so then one must use the new name. For a detailed description of devfs see: http://www.atnf.csiro.au/~rgooch/linux/docs/devfs.html Also see the kernel documentation tree: filesystems/devfs.
Some more examples of devfs names: ttyS2 becomes tts/2 (Serial port), tty3 becomes vc/3 (Virtual Console), ptyp1 becomes pty/m1 (PTY master), ttyp2 becomes pty/s2 (PTY slave). "tts" looks like a directory which contains devices "files": 0, 1, 2, etc. All of these new names should still be in the /dev directory although optionally one may put them elsewhere.
For devfs, device names in the /dev directory are created automatically by the corresponding driver. Thus, if serial support comes from a module and that module isn't loaded yet, there will not be any serial devices in the /dev directory. This can be confusing: you physically have serial ports but don't see them in the /dev directory. However, if a device name is told to a communication program and the serial module isn't loaded, the kernel is supposed to try to find a driver for it and create a name for it in the /dev directory.
This is works OK if it finds a driver. But suppose there is no driver found for it. For example, if you try to use "setserial" to configure a port that the driver failed to detect, it claims there is no such port. How does one create a devfs port in this case?
Before the device file system, devices in Linux had major and minor numbers. The serial port ttySx (x=0,1,2, etc.) was major number 4. You could see this (and the minor numbers too) by typing: "ls -l ttyS*" in the /dev directory. To find the old device names for various devices, see the "devices" file in the kernel documentation.
There formerly was a "cua" name for each serial port and it behaved just a little differently. For example, ttyS2 would correspond to cua2. It was mainly used for modems. The cua major number was 5 and minor numbers started at 64. You may still have the cua devices in your /dev directory but they are now deprecated. For details see Modem-HOWTO, section: cua Device Obsolete.
For creating the old devices in the device directory see: the Serial-HOWTO: "Creating Devices In the /dev directory".
Dos/Windows use the COM name while the messages from the serial driver use ttyS00, ttyS01, etc. Older serial drivers (2001 ?) used just tty00, tty01, etc.
The tables below shows some examples of serial device names. The IO addresses are the default addresses for the old ISA bus (not for the newer PCI and USB buses). The major/minor numbers aren't needed for the devfs, but they often exist anyway just in case the devfs method of locating drivers can't be used.
dos devfs common IO name name name major minor address COM1 /dev/tts/0 /dev/ttyS0 4, 64; 3F8 COM2 /dev/tts/1 /dev/ttyS1 4, 65; 2F8 COM3 /dev/tts/2 /dev/ttyS2 4, 66; 3E8 COM4 /dev/tts/3 /dev/ttyS3 4, 67; 2E8 - /dev/tts/4 /dev/ttyS4 4, 68; various DEVICES-ON-THE-USB-BUS (acm is a certain type of modem) devfs common name devfs common name /dev/usb/tts/0 /dev/ttyUSB0 | /dev/usb/acm/0 /dev/ttyACM0 /dev/usb/tts/1 /dev/ttyUSB1 | /dev/usb/acm/1 /dev/ttyACM1 /dev/usb/tts/2 /dev/ttyUSB2 | /dev/usb/acm/2 /dev/ttyACM2 /dev/usb/tts/3 /dev/ttyUSB3 | /dev/usb/acm/3 /dev/ttyACM3
For more info see the usb subdirectory in the kernel documentation directory for files: usb-serial, acm, etc.
On some installations, two extra devices will be created,
/dev/modem for your modem and
/dev/mouse for a
mouse. Both of these are symbolic links to the appropriate serial
/dev which you specified during the installation
Except if you have a bus mouse, then
/dev/mouse will point to
the bus mouse device).
Historical note: Formerly (in the 1990s) the use of
/dev/modem was discouraged since lock files might not realize
that it was really say
/dev/ttyS2. The newer lock file
system doesn't fall into this trap so it's now OK to use such links.
Each ttyS device has a corresponding cua device. But the cua device is deprecated so it's best to use ttyS (unless cua is required). There is a difference between cua and ttyS but a savvy programmer can make a ttyS port behave just like a cua port so there is no real need for the cua anymore. Except that some older programs may need to use the cua.
What's the difference? 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. If a cua port has been set to check modem control signals, the port can be opened even if the CD modem control signal says not to. Astute programming (by adding additional lines to the program) can force a ttyS port to behave this way also. But a cua port can be more easily programmed to open for dialing out on a modem even when the modem fails to raise CD (since no one has called into it and there's no carrier). That's why cua was once used for dial-out and ttyS used for dial-in.
Starting with Linux kernel 2.2, a warning message is put in the kernel log when one uses cua. This is an omen that cua is defunct and should be avoided if possible.
Hosting by: Hurra Communications Ltd.
Generated: 2007-01-26 17:58:33