aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSteve Bennett <steveb@workware.net.au>2024-02-17 08:16:54 +1000
committerSteve Bennett <steveb@workware.net.au>2024-02-17 08:16:54 +1000
commitef5402943619c843981fb5f36abfb828fd3fe981 (patch)
treed8ccbf9088f6a13391fcc5e1642b3d5c31d21c40
parentd1612743af1e84d5eafd4f3ee5ac5ebeaab12d4e (diff)
downloadjimtcl-ef5402943619c843981fb5f36abfb828fd3fe981.zip
jimtcl-ef5402943619c843981fb5f36abfb828fd3fe981.tar.gz
jimtcl-ef5402943619c843981fb5f36abfb828fd3fe981.tar.bz2
examples/tip.tcl: No need for output-on-writable
Now that the I/O subsystem does auto-flush on write we no longer need to manually set up a writable handler.
-rwxr-xr-xexamples/tip.tcl39
1 files changed, 6 insertions, 33 deletions
diff --git a/examples/tip.tcl b/examples/tip.tcl
index ff8b2fc..fc6990c 100755
--- a/examples/tip.tcl
+++ b/examples/tip.tcl
@@ -107,34 +107,6 @@ stdout buffering none
set status ""
set tilde 0
-set tosend {}
-
-# To avoid sending too much data and blocking,
-# this sends str in chunks of 1000 bytes via writable
-proc output-on-writable {fh str} {
- # Add it to the buffer to send
- append ::tosend($fh) $str
-
- if {[string length [$fh writable]] == 0} {
- # Start the writable event handler
- $fh writable [list output-is-writable $fh]
- }
-}
-
-# This is the writable callback
-proc output-is-writable {fh} {
- global tosend
- set buf $tosend($fh)
- if {[string bytelength $buf] >= 1000} {
- set tosend($fh) [string byterange $buf 1000 end]
- set buf [string byterange $buf 0 999]
- } else {
- set tosend($fh) {}
- # All sent, so cancel the writable event handler
- $fh writable {}
- }
- $fh puts -nonewline $buf
-}
proc bgerror {args} {
set status $args
@@ -145,18 +117,19 @@ proc bgerror {args} {
$f readable {
set c [$f read]
+ #stdout puts "<serial:$c([string bytelength $c]>"
+ #stdout flush
if {[$f eof]} {
set status "$device: disconnected"
incr done
- break
}
- output-on-writable stdout $c
+ stdout puts -nonewline $c
}
proc tilde_timeout {} {
global tilde f
if {$tilde} {
- output-on-writable $f ~
+ $f puts -nonewline ~
set tilde 0
}
}
@@ -177,9 +150,9 @@ stdin readable {
incr done
return
}
- output-on-writable $f ~
+ $f puts -nonewline ~
}
- output-on-writable $f $c
+ $f puts -nonewline $c
}
}