aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSteve Bennett <steveb@workware.net.au>2016-10-20 15:06:09 +1000
committerSteve Bennett <steveb@workware.net.au>2016-10-26 19:44:15 +1000
commit4bf945c9e873434f84fa55721cfaad76b11b2356 (patch)
treee4c172da62a9a268508cf72e6e0343b27fafc67d
parentb464e52b99e0a44d8a0fae616b193bd2250e209b (diff)
downloadjimtcl-4bf945c9e873434f84fa55721cfaad76b11b2356.zip
jimtcl-4bf945c9e873434f84fa55721cfaad76b11b2356.tar.gz
jimtcl-4bf945c9e873434f84fa55721cfaad76b11b2356.tar.bz2
examples/tip.tcl: Gracefully handle serial port being removed
e.g. a usb-serial port Signed-off-by: Steve Bennett <steveb@workware.net.au>
-rwxr-xr-xexamples/tip.tcl11
1 files changed, 9 insertions, 2 deletions
diff --git a/examples/tip.tcl b/examples/tip.tcl
index 3de25e3..61ae2cc 100755
--- a/examples/tip.tcl
+++ b/examples/tip.tcl
@@ -105,13 +105,20 @@ stdin ndelay 1
stdout tty output raw
stdout buffering none
+set status ""
+
# I/O loop
set tilde 0
$f readable {
set c [$f read]
- stdout puts -nonewline $c
+ if {[$f eof]} {
+ set status "$device: disconnected"
+ incr done
+ } else {
+ stdout puts -nonewline $c
+ }
}
proc tilde_timeout {} {
@@ -150,4 +157,4 @@ vwait done
stdin tty {*}$stdin_save
stdout tty {*}$stdout_save
-puts ""
+puts $status