Difference between /dev/ttyS0 and /dev/cua0

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

Reply to
Thomas Baier
Loading thread data ...

You might want to try posting your question on comp.os.linux.embedded

Reply to
Jim Stewart

got

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

Meindert

Reply to
Meindert Sprang

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                   grante             Yow!  If I had a Q-TIP, I
                                  at               could prevent th' collapse
                               visi.com            of NEGOTIATIONS!!
Reply to
Grant Edwards

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                   grante             Yow!  I feel real
                                  at               SOPHISTICATED being in
                               visi.com            FRANCE!
Reply to
Grant Edwards

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

http://www.ben.com/
Reply to
Ben Jackson

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:

formatting link

--
Grant Edwards                   grante             Yow!  ... or were you
                                  at               driving the PONTIAC that
                               visi.com            HONKED at me in MIAMI last
                                                   Tuesday?
Reply to
Grant Edwards

Uh, that's obviously a typo -- it was 1998.

--
Grant Edwards                   grante             Yow!  VICARIOUSLY
                                  at               experience some reason
                               visi.com            to LIVE!!
Reply to
Grant Edwards

Oh, I didn't catch the original post that mentioned Linux. Other unices have retained the cua/tty distinction.

--
Ben Jackson

http://www.ben.com/
Reply to
Ben Jackson

Ok, my turn: Wrong. Slackware 10 (kernel 2.4 I believe) still has 'em.....

Meindert

Reply to
Meindert Sprang

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                   grante             Yow!  JAPAN is a WONDERFUL
                                  at               planet -- I wonder if we'll
                               visi.com            ever reach their level of
                                                   COMPARATIVE SHOPPING...
Reply to
Grant Edwards

The /dev/cuaN devices are major 5 and the /dev/ttySN are 4.

Meindert

Reply to
Meindert Sprang

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                   grante             Yow!  TONY RANDALL! Is YOUR
                                  at               life a PATIO of FUN??
                               visi.com
Reply to
Grant Edwards

It appears so. I could 'cat' a file to both /dev/ttyS0 and /dev/cua0

Meindert

Reply to
Meindert Sprang

ElectronDepot website is not affiliated with any of the manufacturers or service providers discussed here. All logos and trade names are the property of their respective owners.