From: David Z. <zol...@lr...> - 2009-01-08 10:03:31
|
Le 8 janv. 09 à 03:17, Scott Redman a écrit : > I'm a little rusty on serial port usage... > > You're using nonblocking i/o on the port. You're also using the port > unbuffered. I doesn't change anything with -buffering line -blocking 1 > The "gets" command may be returning an empty string and not consuming > data because there isn't a full line of text, but $::tty is still > readable because there is still data on it and your "reader" proc > keeps getting called. Have you tried using "read" instead to read > partial lines (without newlines)? > > Also, you're not closing $::tty when you detect an eof inside of > reader, which may be leaving $::tty as readable. You may need to > either close it or disable the fileevent. I rewrote my reader proc: proc reader {} { if {![eof $::tty] && ![fblocked $::tty]} { if {[catch {gets $::tty} data]} { tk_messageBox -icon error -parent .\ -title "Error reading $::comport" \ -message "Error on $::comport when reading."\ -detail $data catch {close $::tty} exit } if {[string length [string trim $data]]} { .h.t insert end [string map {"\r" "\n"} "> $data\n"] .h.t yview end } } } But it changes nothing. Moreover, when I run the original script on VMWare on the same MacBook with the same PL2303 (connected ta an Accura Hayes modem) it works perfectly in Windows XP or Ubuntu linux. Then, I guess the problem comes from Mac OS X.5.6 or Darwin Tcl but not from the hardware nor my script (even if this one was not perfect). -- David Zolli R&D Manager zol...@lr... http://www.lr-i.com |