From 4bf945c9e873434f84fa55721cfaad76b11b2356 Mon Sep 17 00:00:00 2001 From: Steve Bennett Date: Thu, 20 Oct 2016 15:06:09 +1000 Subject: examples/tip.tcl: Gracefully handle serial port being removed e.g. a usb-serial port Signed-off-by: Steve Bennett --- examples/tip.tcl | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) (limited to 'examples/tip.tcl') 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 -- cgit v1.1