Technical article 105512

stty(C) switches port back to the default settings when getty(M) is disabled.

OpenServer 5.0.0OpenServer 5.0.2

Written · Last revised

Problem

I am connecting a device to a serial port of my computer that
sends data to my application.  The device does not work if getty(M)
is enabled, and it will not work at the default terminal settings,
for example, speed = 9600.

The serial port speed settings may be altered using the stty(C) utility when the port is enabled, but when the port is disabled to switch off getty(M), the settings revert back to the defaults.

Solution

One solution is to hold open the serial port using a background
process.  This process may be started at boot time, as in the
example below.
As root, add the following lines to the end of the file
/etc/rc2.d/P88USRDEFINE.  In this example, the port /dev/tty1a is
being set to 1200 baud.
#hold port open so stty settings are set
#                  port  setting
/usr/bin/holdopen tty1a 1200 &

Create a file called /usr/bin/holdopen with the contents:

# hold port open to retain stty settings
(stty $2             #$2 is stty setting
while true
do
  sleep 60000
done ) < /dev/$1     #1 is port
Make /usr/bin/holdopen executable with the following:
chmod u+x /usr/bin/holdopen

Then reboot the system to make the change take effect.

From the Xinuos technical article database, record 105512. Reproduced with permission. The original is at www.sco.com/ta/105512, which is reachable but blocked from search engines. Xinuos marks this article against a retired product line. That refers to the product’s lifecycle, not to whether the advice still works — plenty of it still applies to running systems.

Next step

Need this fixed rather than explained?

Tell us the release, what the system runs and what it is doing. We will reply by email with what we would do next.

  • You deal with the people who do the work
  • No obligation, and no upgrade required before we will help
  • We tell you plainly if something is not worth doing

Send an enquiry

We reply by email. If a server is down, say so in the first line. You can also write to help@scoexpert.com.