Tcl Source Code

View Ticket
Login
Bounty program for improvements to Tcl and certain Tcl packages.
Tcl 2019 Conference, Houston/TX, US, Nov 4-8
Send your abstracts to [email protected]
or submit via the online form by Sep 9.
Ticket UUID: 438509
Title: TIP#35 Patches: Serial port enhancements
Type: Patch Version: None
Submitter: schroedter Created on: 2001-07-04 12:03:50
Subsystem: 27. Channel Types Assigned To: schroedter
Priority: 5 Medium Severity:
Status: Closed Last Modified: 2003-04-09 16:01:36
Resolution: None Closed By: schroedter
    Closed on: 2003-04-09 09:01:36
Description:
The attached tar.gz file contains patches for 
TIP#35: Enhanced Support for Serial communications.

Affected systems: Windows and Unix (termios.h).
The changes have been tested under 
    Windows 95/98/NT4.0/2000
    Linux (Suse7.1).

Unix system file patches:
    tclUnixChan.c

The following options are added to the fconfigure 
command for serial ports:
    -handshake none|rtscts|xonxoff
        Setup automatic handshake
    -xchar
        Query xon/xoff characters
    -xchar {xonChar xoffChar}
        Setup xon/xoff characters
    -timeout msec
        Setup read timeout, granularity = 100 msec
    -ttycontrol {RTS 1 DTR 0 BREAK 1}
        Control RS-232 handshake output lines
    -ttystatus
        Query RS-232 handshake input lines,
        returns e.g. {CTS 1 DSR 0 RING 1 DCD 0}
    -queue
        Query number of bytes in the system input
        and output queues, returns a list of 2 int's,
        e.g. {25 87}

For Windows the following options are
implemented:
    -handshake none|dtrdsr|rtscts|xonxoff
        Setup automatic handshake
    -sysbuffer {inBufSize outBufSize}
        Setup the system buffer sizes for serial I/O.
    -xchar
    -xchar {xonChar xoffChar}
    -timeout msec
    -ttycontrol {RTS 1 DTR 0 BREAK 1}
    -ttystatus
    -queue

For Windows the following files are affected:

tclWinPort.h
    Declare a new function TclWinSerialReopen()

tclWinChan.h
    Call TclWinSerialReopen() after detecting the
    serial port.

tclWinSerial.c
    Partial rewrite of Tcl's serial driver. 
    The current implementation only performs blocking
    output. Added [fconfigure] options.

The following doc files are patched:

fconfigure.n
    Serial [fconfigure] options are now documented 
    here.

open.n
    Serial port filenames are documented here.
    Added a link to [fconfigure] for additional serial 
    options.
   
The attached file tip35patch.tgz contains patches
(diff -c file.old file.new > file.patch)
against the Tcl8.4a2 sources.

The patch file for tclWinSerial.c is larger 
than the original file. 
Therefore both files are attached:
    tclWinSerial.c
    tclWinSerial.c.patch
User Comments: hobbs added on 2002-03-06 04:03:17:
Logged In: YES 
user_id=72656

The unix implementation introduced bug 525783 
(http://sourceforge.net/tracker/?
func=detail&atid=110894&aid=525783&group_id=10894).

The problem was the use of tcflush that throws away data on 
exit.  This should really only be done on true serial 
channels, if it is a problem.  I've reverted that behavior 
for now (8.4a4), but it must be revisited.

schroedter added on 2002-02-27 14:01:15:
Logged In: YES 
user_id=99573

Thanks, Jeff.

There is no Mac version for TIP#35 and no Non-Posix version (TERMIO,SGTTY).
IMO this is clearly stated in the docs (fconfigure.n, large section on serial communications).

Tests are a problem because for monitoring handshake signals you'll need either a 2nd PC
with a proper cable (many NULL-modem cables are only 3 lines), a breakout box and/or a loopback 
connector.

hobbs added on 2002-02-27 03:06:01:
File Deleted - 14693:

hobbs added on 2002-02-27 03:06:00:
Logged In: YES 
user_id=72656

added the necessary config stuff for HPs, tested on AIX-
4.3/rs6000, Solaris 2.6 and 2.8, Linux 2.2 and 2.4.

This still needs more docs and (perhaps conditional) tests, 
but the code is in the 8.4a4cvs.  I'm leaving it open for 
docs and tests, and perhaps a Mac version.  If we don't get 
any Mac version, that must be clearly stated in the docs.

schroedter added on 2002-02-26 20:49:06:
File Added - 18460: tclUnixChan.c.patch

schroedter added on 2002-02-26 20:49:02:
Logged In: YES 
user_id=99573

The patch from january doesn't apply, because its "too old". There were lot of changes (TIP#27) since then 
(TIP#27). I remade the changes. The patch file is attached.

Non-POSIX systems: Should compile and run without the TIP#35 enhancements.
To make it clear: The TIP#35 enhancements are Windows and TERMIOS (POSIX) only.

IMO I put everything into #ifdef's, so it should compile also for USE_TERMIO and USE_SGTTY systems.
I did it to the *best of my knowledge* without having such a system.
So if there are problems, please give me a precise error message.

hobbs added on 2002-02-26 03:50:31:
Logged In: YES 
user_id=72656

This patch doesn't apply against the current sources.  Can 
we get an updated version of this?  It seems to be based on 
quite old sources actually.

Also, this still doesn't address cleanly excising the code 
if support isn't available (in the USE_SGTTY or USE_TERMIO 
cases).  The compile will just barf on the non-existent 
#defines then.  Thus the patch really isn't complete.

schroedter added on 2002-01-10 13:34:25:
File Added - 15784: tclUnixChan.c.patch

Logged In: YES 
user_id=99573

Following a comment from Andreas Kupries, this patch
should use strncasecmp() instead of defining a new strCaseEqu().

schroedter added on 2002-01-07 18:12:50:
File Added - 15614: tclUnixChan.c.patch

Logged In: YES 
user_id=99573

The TIP#35 implementation for Unix contains the same bug
as described for bug#500348:
TtySetOptionProc() shouldn't modify it's 'value' argument.

The new patch file is attached.

schroedter added on 2001-12-14 14:57:20:
File Added - 14693: tclUnixChan.c.patch

Logged In: YES 
user_id=99573

I can contribute a better patch for tclUnixChan which should 
meet the 2nd point, when USE_TERMIOS isn't true.
But I don't have access to Unix systems other than Linux, 
Sparc.
Nor I'm familiar with autoconf.

Who can help ?
Rolf.

hobbs added on 2001-12-13 08:11:32:
Logged In: YES 
user_id=72656

OK, Rolf noted that sys/modem.h is needed on HP, and 
perhaps other platforms.  We need an up-to-date patch 
against the current sources that also makes use of 
HAVE_SYS_MODEM_H (add AC_CHECK_HEADER(sys/modem.h) to 
SC_SERIAL_PORT in tcl.m4).  We also need to make sure that 
all the cases are covered when USE_TERMIOS isn't true.

hobbs added on 2001-10-17 04:21:39:
Logged In: YES 
user_id=72656

I have applied the Windows portions of this to 8.4a4cvs 
(this is targeted for 8.4, not 8.3.x).  We need to work on 
tclUnixChan.c so that it compiles cleanly across systems 
(although it may only have the serial enhancements on good 
posix systems).

hobbs added on 2001-10-13 02:30:56:
Logged In: YES 
user_id=72656

These do not compile on an HP with uname:

HP-UX llbertha B.11.00 U 9000/800 2002402864

where the original sources are OK.  It complains about the 
lack of certain definitions.  Windows went OK, as did 
Linux.  However, looking through the patch, it can't 
compile if USE_TERMIOS isn't 1 (which is possible).  The 
TTYFLUSH was created only for USE_TERMIOS, and there may be 
a few other tidbits lying in wait like that.

schroedter added on 2001-10-08 12:53:49:
Logged In: YES 
user_id=99573

For real tests you'll need hardware (a loopback connector,
a second PC sending data, producing overruns & handshake).
I've tested it here for Linux, Win2k/NT/98/95.

The handshake itself is performed by the OS driver.
Tcl provides only the [fconfigure] interface to the 
corresponding OS calls ioctl() or SetCommState().
The only new *code* is the writer thread for windows,
supporting non-blocking writes.

hobbs added on 2001-10-06 07:31:40:
Logged In: YES 
user_id=72656

Are there any tests that we can safely make to ensure that 
this features works (on unix and/or windows)?

schroedter added on 2001-10-05 14:44:36:
Logged In: YES 
user_id=99573

The patches are now complete following TIP#35.
Latest file: tip35_patch1.0.tgz
(Somehow I'm unable to delete the older files ...)

IMO it should be not a problem to backport them
to the upcoming Tcl 8.3.4 release.

Rolf.

schroedter added on 2001-09-24 13:59:17:
File Added - 11131: tip35_patch1.0.tgz

hobbs added on 2001-08-02 08:47:55:
Logged In: YES 
user_id=72656

Are these now complete following the vote on TIP #35?

schroedter added on 2001-07-04 19:32:40:
File Added - 8067: tip32patch.tgz

Logged In: YES 
user_id=99573

Sorry, I touched tclUnixChan.c with a DOS editor,
therefore the diff file became too large.
I hope for tclUnicChan.c the following diff is better:

diff -c --ignore-all-space f.old f.new > f.patch

schroedter added on 2001-07-04 19:03:51:
File Added - 8066: tip35patch.tgz

Attachments: