@@ -107,34 +107,6 @@ stdout buffering none
107
107
108
108
set status " "
109
109
set tilde 0
110
- set tosend {}
111
-
112
- # To avoid sending too much data and blocking,
113
- # this sends str in chunks of 1000 bytes via writable
114
- proc output-on-writable {fh str} {
115
- # Add it to the buffer to send
116
- append ::tosend($fh ) $str
117
-
118
- if {[string length [$fh writable]] == 0} {
119
- # Start the writable event handler
120
- $fh writable [list output-is-writable $fh ]
121
- }
122
- }
123
-
124
- # This is the writable callback
125
- proc output-is-writable {fh} {
126
- global tosend
127
- set buf $tosend($fh)
128
- if {[string bytelength $buf ] >= 1000} {
129
- set tosend($fh ) [string byterange $buf 1000 end]
130
- set buf [string byterange $buf 0 999]
131
- } else {
132
- set tosend($fh ) {}
133
- # All sent, so cancel the writable event handler
134
- $fh writable {}
135
- }
136
- $fh puts -nonewline $buf
137
- }
138
110
139
111
proc bgerror {args} {
140
112
set status $args
@@ -145,18 +117,19 @@ proc bgerror {args} {
145
117
146
118
$f readable {
147
119
set c [$f read]
120
+ # stdout puts "<serial:$c([string bytelength $c]>"
121
+ # stdout flush
148
122
if {[$f eof]} {
149
123
set status " $device : disconnected"
150
124
incr done
151
- break
152
125
}
153
- output-on-writable stdout $c
126
+ stdout puts -nonewline $c
154
127
}
155
128
156
129
proc tilde_timeout {} {
157
130
global tilde f
158
131
if {$tilde } {
159
- output-on-writable $f ~
132
+ $f puts -nonewline ~
160
133
set tilde 0
161
134
}
162
135
}
@@ -177,9 +150,9 @@ stdin readable {
177
150
incr done
178
151
return
179
152
}
180
- output-on-writable $f ~
153
+ $f puts -nonewline ~
181
154
}
182
- output-on-writable $f $c
155
+ $f puts -nonewline $c
183
156
}
184
157
}
185
158
0 commit comments