chiark / gitweb /
fixes from bessar fettling session
authorian <ian>
Thu, 5 Jan 2006 03:27:50 +0000 (03:27 +0000)
committerian <ian>
Thu, 5 Jan 2006 03:27:50 +0000 (03:27 +0000)
hostside/eventrun.events [new file with mode: 0644]
hostside/eventrun.procs [new file with mode: 0644]
hostside/gui-displayer
hostside/stopgap-controller

diff --git a/hostside/eventrun.events b/hostside/eventrun.events
new file mode 100644 (file)
index 0000000..1080b15
--- /dev/null
@@ -0,0 +1,9 @@
+# spong
+INIT   source /u/ian/things/Bessar/trains/eventrun.procs
+
+e3     trains_stop
+eb     trains_start
+
+b2     tw ask_slow
+e6     tw ask_randspeed
+ec     tw ask_fast
diff --git a/hostside/eventrun.procs b/hostside/eventrun.procs
new file mode 100644 (file)
index 0000000..168a856
--- /dev/null
@@ -0,0 +1,46 @@
+# -*- tcl -*-
+
+cd /u/ian/things/Bessar/trains
+exec xsetroot -solid #00000f
+
+set trainscmd {
+    set -x
+    savelog -c 7 bessar.log
+#    (set -ex
+    cd /u/ian/things/trains-bessar/hostside
+    ./stopgap-controller | ./gui-displayer -
+#    ) 2>&1 | tee bessar.log
+}
+
+proc trains_start {} {
+    global trainsf trainscmd
+    trains_stop
+    set cmdl [list sh -ec $trainscmd 2>@ stderr]
+    set trainsf [open |$cmdl w]
+    fconfigure $trainsf -buffering none -blocking no
+}
+
+proc tw {s} {
+    global trainsf
+    if {![info exists trainsf]} return
+    if {[catch {
+       puts $trainsf $s
+    } emsg]} {
+       puts stderr "tw: $emsg"
+       trains_stop
+    }
+}
+
+proc okagain {} {
+    global okagain
+    set okagain 1
+}
+
+proc trains_stop {} {
+    global trainsf okagain
+    if {![info exists trainsf]} return
+    catch { close $trainsf }
+    unset trainsf
+    after 3000 okagain
+    vwait okagain
+}
index d4425d60003a0f006cfcd05c6e37b52227530189..eadac7d9fa4a603520de7e336704bdc2c8362171 100755 (executable)
@@ -142,6 +142,8 @@ proc main {} {
     update_push
 }
 
+proc EOE {} { global exitoneof; set exitoneof 1}
+
 main
 
 while {[gets stdin l]>=0} {
@@ -152,3 +154,5 @@ while {[gets stdin l]>=0} {
        puts $l
     }
 }
+
+if {[info exists exitoneof]} { exit 0 }
index 8f89014266a1690a171dcb6f4cfaf3a217a3c982..0c4f3342c2e3846e6b58429e665cecfc22a77c45 100755 (executable)
@@ -41,8 +41,9 @@ proc gui {m} {
 proc gui_init {} {
     global watchdog polarity segdetect
     gui "M A2 0"
-#    gui "M A5 0 J"
-#    gui "M A6 0 J"
+    gui "M A5 0 J"
+    gui "M A6 0 J"
+    gui "EOE"
     if {[info exists watchdog]} { gui "P 1" }
     gui_polarity
     foreach seg [array names segdetect] {
@@ -90,7 +91,7 @@ proc fail {m} {
     catch { after cancel $watchdog; unset watchdog }
     puts "failing $m"
     tellpic 9801 ;# 16ms
-    after 10000 fail_now
+    after 1000 fail_now
     fileevent $p readable {}
 }
 
@@ -143,6 +144,12 @@ proc pt_ifthenmust {ifpoint ifposwant thenpoint thenpos} {
     pt_must $thenpoint $thenpos
 }
 
+proc badwatchdog {} {
+    global pq
+    puts "watchdog - oh well"
+    if {![info exists pq]} { set pq {} }
+}
+
 proc pm_charged {} {
     global pq
     if {[llength $pq]} {
@@ -315,6 +322,7 @@ proc frompic {m} {
        01 - 02 { tellnmra $m }
        09 { fp $m; pm_hello }
        07 { puts "short circuit"; exit 1 }
+       0d { fp $m; badwatchdog }
        28 { fp $m; pm_charged }
        9[0-7] { fp $m; pm_maydetect 0 $v }
        9? { fp $m; pm_maydetect 1 $v }
@@ -458,7 +466,7 @@ proc ask_fast {} {
     global speeddirn_fixed; set speeddirn_fixed {speed126 2 126 0}
 }
 proc ask_slow {} {
-    global speeddirn_fixed; set speeddirn_fixed {speed126 2 126 10}
+    global speeddirn_fixed; set speeddirn_fixed {speed126 2 10}
 }
 proc ask_randspeed {} {
     global speeddirn_fixed; catch { unset speeddirn_fixed }