April 24, 2019

New HOWTO: Modem-HOWTO - page 10

Table of Contents

  • April 12, 2001
  9.  Serial Port Devices /dev/ttyS2, etc.

  For creating devices in the device directory see: the Serial-HOWTO:
  "Creating Devices In the /dev directory".

  9.1.  Devfs (The new Device File System)

  This is a new type of device interface to Linix.  It's optional
  starting with kernel 2.4.  It's more efficient than the conventional
  interface and makes it easy to deal with a huge number of devices.
  The device names have all changed as well.  But there's an option to
  continue using the old names.  For a detailed description of it see:

  The name changes (if used) are: 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.

  9.2.  Serial Port Device Names & Numbers

  Devices in Linux have major and minor numbers (unless you use the new
  devfs).  The serial port ttySx (x=0,1,2, etc.) has major number 4.
  You may see this (and the minor numbers too) by typing: "ls -l ttyS*"
  in the /dev directory.

  There formerly was an alternate name for each serial port.  For
  example, ttyS2 would have cua2 as an alternate name.  You may still
  have the cua devices in your /dev directory but they are now
  deprecated.  Their drivers behave slightly different than for the ttyS
  ones.  Device Obsolete">."')

  Dos/Windows use the COM name while the setserial program uses tty00,
  tty01, etc.  Don't confuse these with dev/tty0, dev/tty1, etc.  which
  are used for the console (your PC monitor) but are not serial ports.
  The table below is for the "standard" case (but yours could be

                                                        IO      devfs
        dos            major minor       major minor  address   name
       COM1  /dev/ttyS0  4,  64;  /dev/cua0  5,  64     3F8   /dev/tts/0
       COM2  /dev/ttyS1  4,  65;  /dev/cua1  5,  65     2F8   /dev/tts/1
       COM3  /dev/ttyS2  4,  66;  /dev/cua2  5,  66     3E8   /dev/tts/2
       COM4  /dev/ttyS3  4,  67;  /dev/cua3  5,  67     2E8   /dev/tts/3

  9.3.  Universal Serial Bus Ports

  Although the USB is not covered in this HOWTO, the serial ports on the
  USB are: /dev/ttyUSB0 /dev/ttyUSB1, etc.

  9.4.  Link ttySN to /dev/modem

  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 device in /dev which you specified
  during the installation Except if you have a bus mouse, then
  /dev/mouse will point to the bus mouse device).

  Formerly 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.

  9.5.  cua Device Obsolete

  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 assert 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.

Most Popular LinuxPlanet Stories