views:

406

answers:

2

Hi all,

I've got a Tcl/Expect program that reads and writes data to the serial port. I did all of my development and testing on a Fedora 7 machine, but I'm now trying to run the same code in Ubuntu 8.10, and I'm getting the following error:

spawn: returns {0}
bad option "-mode": should be one of -blocking, -buffering, -buffersize, -encoding, -eofchar, or -translation
    while executing
"fconfigure $port -mode 19200,n,8,1"
    (file "./scan1.tcl" line 31)

I have no issues in Fedora, just Ubuntu. It would seem that it doesn't like the serial options being given to fconfigure, but I don't know of an alternate way of doing this. Both machines have Tcl 8.4.

Here's the relevant code snippet:

#Open serial port
set portname "/dev/ttyS0"
spawn -open [set port [open $portname "r+"]];#This is a beast!
fconfigure $port -mode 19200,n,8,1

Does anyone know what's wrong? Thanks for your help!

+1  A: 

Some research seems to indicate that the [fconfigure] command doesn't offer the -mode switch when it doesn't recognize the channel in question as being a true serial port (though I don't see this mentioned in the docs). Ultimately, that decision seems to rely on an "isatty()" system call, which is apparently failing to report the channel as a TTY. More info can be found here:

http://groups.google.com/group/comp.lang.tcl/browse%5Fthread/thread/ea0e772c59fa1e52/949c04fe4cebc2a3?q=fconfigure+mode+group%3Acomp.lang.tcl#949c04fe4cebc2a3

According to the above thread, this could be due to a misconfigured Tcl.

Update... I see the serial configuration options (including -mode) are documented with the [open] command. There, it mentions that [fconfigure] can be used to query or set the additional options specific to serial ports. The [fconfigure] docs should probably be updated to reflect that fact also.

Bottom line, Tcl doesn't think your port really is a serial port under Ubuntu, though I don't know why...

Jeff Godfrey
A: 

Could be a bug. It has been in the past.

http://sourceforge.net/tracker/?func=detail&atid=110894&aid=218617&group%5Fid=10894

Juan