From: Keith on
If I attempt to open a serial port and the device exist:
com1: or /dev/ttyS1
but does not respond TCL/TK will lock up waiting for the device to respond
Is there a way to test a serial port connection so that tcl/tk will not
lock up if the device exists but does not respond?



--
Best Regards, Keith
http://home.comcast.net/~kilowattradio/
Tired of Google Groups?
http://home.comcast.net/~kilowattradio/usenet.html
From: James Littlefield on
Keith wrote:
> If I attempt to open a serial port and the device exist:
> com1: or /dev/ttyS1
> but does not respond TCL/TK will lock up waiting for the device to respond
> Is there a way to test a serial port connection so that tcl/tk will not
> lock up if the device exists but does not respond?
>
>
>
Not sure if you are saying that the open succeeds but attempting to read
from the device locks up? If so, you can do any of several things....

- "fconfigure" the file as non-blocking. This will allow you to do a
gets w/o getting stuck if there is nothing to be read
- You might also take a look at the event driven I/O manpages and the
"fileevent" command


--- news://freenews.netfront.net/ - complaints: news(a)netfront.net ---
From: Joerg H on
Keith wrote:

> If I attempt to open a serial port and the device exist:
> com1: or /dev/ttyS1
> but does not respond TCL/TK will lock up waiting for the device to respond
> Is there a way to test a serial port connection so that tcl/tk will not
> lock up if the device exists but does not respond?
>
>
>

I have done this many times in a separate procedure:

....
set fileid [open "/dev/ttyS0" w+]
fconfigure $fileid -buffering line -blocking no

....

puts "*IDN?"
flush $fileid

set end [expr [clock clicks -milliseconds] + 1000]
while {[clock clicks -milliseconds] < $end} {
gets $fileid returnval
if { [fblocked $fileid] == 0 } {
return $returnVal
}
}
return -1


This code waits one second if the devices answers and returns $returnVal. if
not it returns -1. I use it for control measurement devices such as dmm's or
scopes. So the program doesn't stop if I have'nt switched on the devices.

Joerg



From: Keith on
On Sat, 06 Mar 2010 20:11:55 +0100, Joerg H <joerg.honerla(a)t-online.de>
wrote:

>
> puts "*IDN?"
> flush $fileid

Is the puts going to stdout or someplace else?

--
Best Regards, Keith
http://home.comcast.net/~kilowattradio/
Tired of Google Groups?
http://home.comcast.net/~kilowattradio/usenet.html