From the portability issues section.
Unix
Valid values for fileName to open a serial port are generally
of the form /dev/ttyX, where X is a or b, but the name of any
pseudo-file that maps to a serial port may be used.
The way it actually determines whether it is a serial port is use
the isatty (fd) function. I presume that this returns FALSE on those
devices for which there a device special file but no hardware and so Tcl
assumes that it is not a TTY and so does not do any special processing.
If Tcl gets an error from opening a file then it returns it, otherwise
it can't. So it appears as though the device driver for those
/dev/ttyS<x> special files allows the file to be opened even when there
is no hardware.
You should use the fact that it is not a TTY and therefore does not
have the serial port options as an indicator that it does not have
any hardware. Add a [catch] around an [fconfigure $channel -mode]
to detect whether it is a valid TTY or not.
this would be a possibilty.
I had a look into tclUnixChan.c and did some experimenting.
isatty() returns 0 on any error ( it does not look at errno ).
would it be apropriate to check for ENOTTY / EIO after the call to
isatty()
and close the file on EIO?
i've submitted a patch in this direction.
G!
UK
--
Uwe Klein [mailto:uwe-...@foni.net]
KLEIN MESSGERAETE Habertwedt 1
D-24376 Groedersby b. Kappeln, GERMANY
phone: +49 4642 920 123 FAX: +49 4642 920 125
I just had a look on AIX documentation and the only error codes that are
returned by isatty are ENOTTY and EBADF. Under what circumstances does
isatty return EIO ? What OS are you running on ?