1. This forum section is a read-only archive which contains old newsgroup posts. If you wish to post a query, please do so in one of our main forum sections (here). This way you will get a faster, better response from the members on Motherboard Point.

Difference between /dev/ttyS0 and /dev/cua0

Discussion in 'Embedded' started by Thomas Baier, Nov 2, 2004.

  1. Thomas Baier

    Thomas Baier Guest

    Hi there,

    I've got a question about the difference between /dev/ttyS0 and /dev/cua0.
    Im using the serial port to transmit data to a microcontroller and I've got
    to PC both with SuSE Linux 9.0 prof. On the one I can use both ttyS0 and
    cua0 and on the other I can only use cua0? Why is that and where is the
    difference between them? I know that cua0 was thought for connections to
    modems and that it is deprecated. Can anybody tell me maybe what options I
    have to check to get my prog working with /dev/ttyS0 on both PC?

    Thanks for your help

    Thomas
     
    Thomas Baier, Nov 2, 2004
    #1
    1. Advertisements

  2. Thomas Baier

    Jim Stewart Guest

    You might want to try posting your question
    on comp.os.linux.embedded
     
    Jim Stewart, Nov 2, 2004
    #2
    1. Advertisements

  3. A /dev/cua0 port can be opened by multiple applications at the same time,
    while a /dev/ttyS0 port cannot.

    Meindert
     
    Meindert Sprang, Nov 2, 2004
    #3
  4. That is simply not true.

    Any number of applications that can open /dev/ttyS0. I just
    opened /dev/ttyS0 8 times. Four are "cat >/dev/ttyS0" and four
    are copies of kermit:

    $ ls -l /dev/ttyS0
    lr-xr-xr-x 1 root root 5 Oct 28 12:40 /dev/ttyS0 -> tts/0

    $ lsof | grep /dev/tts
    cat 15176 grante 1w CHR 4,64 604 /dev/tts/0
    cat 15177 grante 1w CHR 4,64 604 /dev/tts/0
    cat 15178 grante 1w CHR 4,64 604 /dev/tts/0
    cat 15179 grante 1w CHR 4,64 604 /dev/tts/0
    kermit 15244 grante 4u CHR 4,64 604 /dev/tts/0
    kermit 15292 grante 4u CHR 4,64 604 /dev/tts/0
    kermit 15340 grante 4u CHR 4,64 604 /dev/tts/0
    kermit 15388 grante 4u CHR 4,64 604 /dev/tts/0

    I quite regularly have /dev/ttyS0 open simultaneously by more
    than one application. It's usually by accident, and things
    don't work right -- but that's another issue.
     
    Grant Edwards, Nov 2, 2004
    #4
  5. Historically, /dev/cua* was used to "dial out" and when you
    opened it, it did not wait for carrier detect. /dev/ttys* was
    used for dial-in, and it _did_ block waiting for carrier detect
    when you tried to open/read it. An open of one would block if
    the port was already opened via the _other_ device. That was
    many years ago, and I'm pretty sure it doesn't work that way
    any more.

    I'm surprised you've even found a distro that still has
    /dev/cua0.
     
    Grant Edwards, Nov 2, 2004
    #5
  6. Thomas Baier

    Ben Jackson Guest

    ....so that you could have a dialin service configured on /dev/ttyS0
    without having to build in any knowledge of other applications that
    want to share the port for dialout. Then you configure those dialout
    applications to use /dev/cuaa0 without having to teach them anything
    about the daemons.

    If you plan to "own" the serial port you should use cuaa0 to avoid the
    carrier-detect issues with ttyS0.
     
    Ben Jackson, Nov 3, 2004
    #6
  7. Exactly. That's the way it worked years ago in kernel 2.0 and
    older.
    Wrong.

    Use of /dev/cuaN devices has been depreciated for years (since
    kernel 2.1), and a decently modern distro won't even have the
    cua devices. The /dev/cuaN devices (major number 5) are absent
    in 2.4 and later.
    The carrier detect issues you're talking about are in the old
    tty devices. That stuff was all re-written a half-decade ago.
    See this thread from 1988 for an excellent explination by Ted
    Ts'o, the main man behind the serial stuff for years:

    http://groups.google.com/groups?selm=
     
    Grant Edwards, Nov 3, 2004
    #7
  8. Uh, that's obviously a typo -- it was 1998.
     
    Grant Edwards, Nov 3, 2004
    #8
  9. Thomas Baier

    Ben Jackson Guest

    Oh, I didn't catch the original post that mentioned Linux. Other
    unices have retained the cua/tty distinction.
     
    Ben Jackson, Nov 3, 2004
    #9
  10. Ok, my turn: Wrong. Slackware 10 (kernel 2.4 I believe) still has 'em.....

    Meindert
     
    Meindert Sprang, Nov 3, 2004
    #10
  11. Interesting. Are they a different major number (5, IIRC) than
    the /dev/ttySN devices (4), or are they just alternative names
    for the same devices?
     
    Grant Edwards, Nov 3, 2004
    #11
  12. The /dev/cuaN devices are major 5 and the /dev/ttySN are 4.

    Meindert
     
    Meindert Sprang, Nov 3, 2004
    #12
  13. Weird. Do they work?

    I checked a few of my systems: Deban stable (2.4.18) and
    unstabled (2.4.25) and Mandrake 10.0 (2.6.3). None of them had
    /dev/cuaN devices. When I created them (e.g. with major 5,
    minor 64), and open of the cua device failed with an error of
    "no such device".
     
    Grant Edwards, Nov 3, 2004
    #13
  14. It appears so. I could 'cat' a file to both /dev/ttyS0 and /dev/cua0

    Meindert
     
    Meindert Sprang, Nov 4, 2004
    #14
    1. Advertisements

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.