Skip to contentSkip to conversation

stty < /dev/modem blocks???

DISCUSSION Lou Langholtz 4 participants 5 messages Sep 14, 1999 – Sep 17, 1999

lore
Share & tools
lore
#0 lore raw

On my 2.2.12 kernel with some hacks I've added I can't use stty to get the configuration info for /dev/ttyS0. stty < /dev/ttyS0 (aka /dev/modem) just hangs. strace stty < /dev/ttyS0 does the same thing. strace doesn't even show me any output. Ctrl-C kills the stty or strace but shouldn't stty work on the modem serial device to get the config info? Is it just the hacks I've added in my kernel perhaps? stty < /dev/pts/0 works just fine. Ideas?

Thanks!!

** Sent via the linuxppc-dev mail list. See http://lists.linuxppc.org/

#1 lore raw

Lou,

As you know, the less-than (<) operator in all Unix shells opens the file name given as an argument before it executes the command. In order for an open() call on a TTY device to complete, the RS232 hardware signals that indicate the presence of an active device connected to the port. In practice, this means that the DTR (data terminal ready) signal must be asserted before the open call will return. Because the TTY drivers are "slow" devices, the kernel wait call that synchronizes the application program's open() call with the serial hardware state is interruptable. That is why you can get out of the "hang" with a SIGINT (control-C).

The reason you're able to make the analogous thing work with /dev/pts/0 is that in place of waiting for a hardware signal, the PTY driver slave side (/dev/pts/nn) waits for an open on the corresponding controlling side (/dev/ptc/nn). If you're running X and you have a terminal window open, then there's a terminal emulator with the controlling side of /dev/pts/0 open and that allows your "stty </dev/pts/0" command to complete.

Randy Schulz
Mountain View, CA USA

Quoted 9 lines · Lou Langholtz

On my 2.2.12 kernel with some hacks I've added I can't use stty to get the configuration info for /dev/ttyS0. stty < /dev/ttyS0 (aka /dev/modem) just hangs. strace stty < /dev/ttyS0 does the same thing. strace doesn't even show me any output. Ctrl-C kills the stty or strace but shouldn't stty work on the modem serial device to get the config info? Is it just the hacks I've added in my kernel perhaps? stty < /dev/pts/0 works just fine. Ideas?

Thanks!!

** Sent via the linuxppc-dev mail list. See http://lists.linuxppc.org/

#2 lore raw

On 15 Sep, this message from Randall R Schulz echoed through cyberspace:

Quoted 7 lines

As you know, the less-than (<) operator in all Unix shells opens the file name given as an argument before it executes the command. In order for an open() call on a TTY device to complete, the RS232 hardware signals that indicate the presence of an active device connected to the port. In practice, this means that the DTR (data terminal ready) signal must be asserted before the open call will return.

OK, this sounds right, but how do you explain that I can get at the tty settings with

stty -a < /dev/ttySx

for both of my serial ports, with absolutely nothing connected to them?

;-)

Michel

-------------------------------------------------------------------------

Michel Lanners                 |  " Read Philosophy.  Study Art.
23, Rue Paul Henkes            |    Ask Questions.  Make Mistakes.
L-1710 Luxembourg              |
email   [email protected]            |
http://www.cpu.lu/~mlan        |                     Learn Always. "

** Sent via the linuxppc-dev mail list. See http://lists.linuxppc.org/

#3 lore raw

Michel,

It depends on the serial hardware and possibly on the defaults for the driver associated with those ports. Not all serial hardware behaves identically. I may be wrong about this, but it might be possible that a floating input (one connected neither to ground or +12) might get interpreted differently on different serial controller chips.

Without poring over the pertinent kernel driver code and knowing the details of the serial hardware and it's incorporation into your computer, I cannot give a more definitive answer.

Randy Schulz
Mountain View, CA USA

Quoted 18 lines · Michel Lanners

On 15 Sep, this message from Randall R Schulz echoed through cyberspace:

Quoted 7 lines

As you know, the less-than (<) operator in all Unix shells opens the file name given as an argument before it executes the command. In order for an open() call on a TTY device to complete, the RS232 hardware signals must indicate the presence of an active device connected to the port. In practice, this means that the DTR (data terminal ready) signal must be asserted before the open call will return.

OK, this sounds right, but how do you explain that I can get at the tty settings with

stty -a < /dev/ttySx

for both of my serial ports, with absolutely nothing connected to them?

;-)

Quoted 8 lines

Michel

-------------------------------------------------------------------------

Michel Lanners                 |  " Read Philosophy.  Study Art.
23, Rue Paul Henkes            |    Ask Questions.  Make Mistakes.
L-1710 Luxembourg              |
email   [email protected]            |
http://www.cpu.lu/~mlan        |                     Learn Always. "

** Sent via the linuxppc-dev mail list. See http://lists.linuxppc.org/

#4 lore raw
In reply to Michel Lanners
Quoted 6 lines · Michel Lanners

OK, this sounds right, but how do you explain that I can get at the tty settings with

stty -a < /dev/ttySx

for both of my serial ports, with absolutely nothing connected to them?

It depends on the state of the CLOCAL flag. If it's set, which is the default on boot, you can open it without waiting. If it's clear, an open will normally block until the CD (carrier detect) input is asserted. (To open it without waiting when CLOCAL is clear, you put O_NONBLOCK in the flags on the open system call.)

When you run pppd, it will normally clear the CLOCAL flag (unless you give it the `local' option), so that it can tell when the modem hangs up. It tries to restore the settings on exit, but this can fail if the modem has already hung up, since after a hangup, the linux tty driver won't let you do anything at all with the fd you had open to the tty except close it.

Paul.

** Sent via the linuxppc-dev mail list. See http://lists.linuxppc.org/