debug "failing now"
fconfigure $p -blocking yes
gui "P 0"
- tellpic 20
+ tellpic 10
exit 1
}
catch { after cancel $watchdog; unset watchdog }
puts "failing $m"
tellpic 9801 ;# 16ms
- after 2000 fail_now
+ after 10000 fail_now
fileevent $p readable {}
}
}
proc onreadp {} {
- global p m
+ global p m rand
while 1 {
set c [read $p 1]
if {![string length $c]} {
return
}
binary scan $c H* x
+ if {![info exists rand]} {
+ fp ...$x
+ return
+ }
lappend m $x
if {[regexp {^[0-7]} $x]} {
if {![regexp {^x} $m]} {
set chwa [after $interval changewhat]
}
+proc onreadcmd {} {
+ if {[gets stdin l] < 0} {
+ if {[eof stdin]} { fileevent stdin readable {} }
+ return
+ }
+ eval $l
+}
+
proc setup {} {
- global port p rand testonly
+ global port p testonly
if {!$testonly} {
set p [open $port {RDWR NONBLOCK} 0]
-blocking false -buffering none
fileevent $p readable onreadp
+ fconfigure stdin -blocking false
+ fileevent stdin readable onreadcmd
} else {
set p stdin
fconfigure stdin -blocking false
fileevent stdin readable onreadp_test
}
+ after 250 setup_complete
+}
+
+proc setup_complete {} {
+ global rand
set rand [open /dev/urandom {RDONLY} 0]
fconfigure $rand -encoding binary -translation binary
+ tellpic 0a
}
setup