Bug 1407 - Not setting serial port setting correctly
Not setting serial port setting correctly
Product: Red Hat Linux
Classification: Retired
Component: tcltk (Show other bugs)
i386 Linux
medium Severity medium
: ---
: ---
Assigned To: Jens Petersen
Depends On:
  Show dependency treegraph
Reported: 1999-03-03 02:04 EST by brad
Modified: 2008-05-01 11:37 EDT (History)
0 users

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Last Closed: 1999-07-02 17:29:13 EDT
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---

Attachments (Terms of Use)

  None (edit)
Description brad 1999-03-03 02:04:43 EST
I have a Point Of Sale application which uses Tcl/Tk/TclX.
Part of its operation is to open a serial port and send/
receive data from it (example is a serial port printer).
With the default Red Hat 5.2 tcl-8.0.3-20 package, the Tcl
code is failing to notice that /dev/ttyS1 is a tty device
and therefore it doesn't set the termios settings to a nice
default.  The end result is that icannon is left set which
means I don't get the return data from the printer (since
it is sending me control codes that are almost never a
newline).  Also echo is left set so that everything I
receive from the printer (status information) is echoed
back to the printer which results in garbage all over the

The really odd thing is that if I rebuild the tcltk packages
myself using "rpm -ba tcltk-8.0.spec" and then use it, all
is fine!  Why would my version generated from the same
sources as the one that ships with Red Hat 5.2 give a
different result?

I've tracked the code down and basically in the tcl
source code tcl8.0.3/unix/tclUnixChan.c there is code
that uses isatty to check if the file being opened is
a serial port.  If so it calls TtyInit which sets up the
stty setting nicely.  With the Tcl that Red Hat ships,
isatty is returning false for /dev/ttyS1 whereas when I
compile my own, it properly returns true.

I tracked the problem down a little using strace and found
that at the point the file is being opened, there is a
TCGETA systems call to get the current attributes.  I
assume this is isatty doing this.  Then in the good version
TCGETA is called again followed by a TCSETA which properly
sets the attributes (like -icanon -echo ... which are needed
for the serial printer).  In the tcl that ships with Red
Hat 5.2, there is only the one TCGETA and then the code
carries on.  The attributes are never set so my LinuxPOS
product fails.

Can anyone shed any more light on this problem?  I don't
want to have to tell all our customers running Red Hat 5.2
that they have to recompile the tcl package.  I can add
code to my LinuxPOS product to set the tty attributes
which is what I guess I'll have to do but I would really
like to understand the problem.  Also I hope the problem
will be fixed in the next Red Hat release.

I believe this problem may exist in all the 5.x Red Hat
releases since I've had this problem before and could never
figure it out.  I always just went back to Red Hat 4.2
which worked correctly.  Now that I've tracked it down
more, I hope it can get fixed!
Comment 1 David Lawrence 1999-03-03 16:49:59 EST
I have assigned this report to a developer for further review.
Comment 2 Michael K. Johnson 1999-04-09 17:38:59 EDT
isatty() should not be doing a TCSETA (really a tcsetattr()) call.
I suggest doing a "stty -g" on a working system, then give the
output of stty -g on the working system as an argument to stty
on the non-working system, and see if that fixes it.   Please
report here.  Thanks!
Comment 3 Cristian Gafton 1999-07-02 17:29:59 EDT
Closed because of lack of feedback. Please reopen if still valid.

Note You need to log in before you can comment on or make changes to this bug.