]> hydra-www.ietfng.org Git - acmetensortoys-snakecontrol/commitdiff
Further robustification
authorNathaniel Wesley Filardo <nwfilardo@gmail.com>
Tue, 19 Dec 2017 00:03:21 +0000 (19:03 -0500)
committerNathaniel Wesley Filardo <nwfilardo@gmail.com>
Sun, 11 Feb 2018 00:07:12 +0000 (19:07 -0500)
lcdproc-monitor.expect leaks memory (?) in operation, so artificially
clamp down while looking for a better fix.  runit will restart it if
it dies.  Do the same for lcd-remind.

bin/lcdproc-monitor.expect
bin/lcdproc-remind.expect
runit/pi-sc-lcd-remind/run
runit/pi-sc-lcd/run

index b5d9b642dfde5f3abc76ba666ddf1260b2a5cb69..84618aa467035fe66895f31f0bc301642f8677a5 100755 (executable)
@@ -68,47 +68,42 @@ set sid [::lcdproclib::spawnlcd "localhost" "13666"]
 ::lcdproclib::cmd ${sid} "screen_set 1 -priority info"
 
 set loopctr 0
-# set tempctr 0
 
-proc drawtemp { scr wid x y } {
-  variable sid
-  variable expect_out
-  variable tempctr
-
-  set t [expr round(${expect_out(1,string)}*10.0)/10.0]
+proc drawtemp { sid scr wid x y v } {
+  set t [expr round(${v}*10.0)/10.0]
   ::lcdproclib::cmd ${sid} "widget_set ${scr} ${wid} ${x} ${y} ${t}"
-
-  # ::lcdproclib::cmd ${sid} "widget_set 1 v_tickt 19 2 ${tempctr}"
-  # set tempctr [expr (${tempctr} + 1) % 10]
 }
 
 # Render DMX as "A" (0-9) through "Z" (250-255)
-proc drawdmx { scr wid x y } {
-  variable sid
-  variable expect_out
-  set t [ format %c [ expr 65 + ${expect_out(1,string)} / 10 ] ]
+proc drawdmx { sid scr wid x y d } {
+  set t [ format %c [ expr 65 + ${d} / 10 ] ]
   ::lcdproclib::cmd ${sid} "widget_set ${scr} ${wid} ${x} ${y} {${t}}"
 }
 
 set datapfx "^\[^ \]* DATA: "
-set datare "(\[^ \r\n]*)"
+set datare "(\[^ \r\n\]*)"
 set dskip "\[^\n\]*"
 
 while { true } {
   expect {
-    -i ${logsid} -re "${datapfx}hide-near${dskip} temp=${datare}${dskip}\n"  { drawtemp 1 "v_lh" 3  2 }
-    -i ${logsid} -re "${datapfx}hide-far${dskip} temp=${datare}${dskip}\n"   { drawtemp 1 "v_rh" 3  4 }
-    -i ${logsid} -re "${datapfx}tank-near${dskip} temp=${datare}${dskip}\n"  { drawtemp 1 "v_lt" 9  2 }
-    -i ${logsid} -re "${datapfx}tank-far${dskip} temp=${datare}${dskip}\n"   { drawtemp 1 "v_rt" 9  4 }
-    -i ${logsid} -re "${datapfx}tank-mid${dskip} temp=${datare}${dskip}\n"   { drawtemp 1 "v_mt" 3  3 }
-    -i ${logsid} -re "${datapfx}tank-mid${dskip} humid=${datare}${dskip}\n"  { drawtemp 1 "v_mh" 9  3 }
-    -i ${logsid} -re "${datapfx}dmx-tanknear${dskip} dmx=${datare}${dskip}\n" { drawdmx 1 "v_ldmx" 15 3 }
-    -i ${logsid} -re "${datapfx}dmx-hidenear${dskip} dmx=${datare}${dskip}\n" { drawdmx 1 "v_hdmx" 16 3 }
+    -i ${logsid} -re "${datapfx}(${dskip})\n" {
+      # This uses the many-argument form of switch to get expansion inside the
+      # templates.  That's a little gross, but so it goes.
+      switch -regexp -matchvar m -- "${expect_out(1,string)}" \
+        "hide-near temp=${datare}"   { drawtemp ${sid} 1 "v_lh"    3 2 [lindex ${m} 1] } \
+        "hide-far temp=${datare}"    { drawtemp ${sid} 1 "v_rh"    3 4 [lindex ${m} 1] } \
+        "tank-near temp=${datare}"   { drawtemp ${sid} 1 "v_lt"    9 2 [lindex ${m} 1] } \
+        "tank-far temp=${datare}"    { drawtemp ${sid} 1 "v_rt"    9 4 [lindex ${m} 1] } \
+        "tank-mid temp=${datare}"    { drawtemp ${sid} 1 "v_mt"    3 3 [lindex ${m} 1] } \
+        "tank-mid humid=${datare}"   { drawtemp ${sid} 1 "v_mh"    9 3 [lindex ${m} 1] } \
+        "dmx-tanknear dmx=${datare}" { drawdmx  ${sid} 1 "v_ldmx" 15 3 [lindex ${m} 1] } \
+        "dmx-hidenear dmx=${datare}" { drawdmx  ${sid} 1 "v_hdmx" 16 3 [lindex ${m} 1] } \
+    }
     -i ${logsid} -re "\[^ :\]*:..:..\.\[^ \]* check temps fini${dskip}\n" {
       ::lcdproclib::cmd ${sid} "widget_set 1 v_tickl 20 2 ${loopctr}"
       set loopctr [expr (${loopctr} + 1) % 10]
     }
-    -i ${logsid} -re "\n" {}
+    -i ${logsid} -re "${dskip}\n" {}
 
     -i ${doorlogsid} -re "${datapfx}door${dskip} left=${datare} right=${datare}${dskip}\n" {
       switch -regexp "${expect_out(1,string)}${expect_out(2,string)}" {
@@ -130,9 +125,10 @@ while { true } {
         }
       }
     }
-    -i ${doorlogsid} -re "\n" {}
+    -i ${doorlogsid} -re "${dskip}\n" {}
 
-    -i ${sid} -re "^listen ${dskip}\n" {}
-    -i ${sid} -re "^ignore ${dskip}\n" {}
+    # -i ${sid} -re "^listen ${dskip}\n" {}
+    # -i ${sid} -re "^ignore ${dskip}\n" {}
+    -i ${sid} -re "${dskip}\n" {}
   }
 }
index 034da27d4d6cc572335a843b3d31c8ddad16250c..08cb4f4fb731c5b9b624ac02489d6869b189834a 100755 (executable)
@@ -85,7 +85,8 @@ while { true } {
       set waitsid [spawninotify ${filename}]
     }
     -i ${waitsid} "Watches established." { reload ${lcdsid} ${filename} }
-    -i ${lcdsid} -re "^listen .*\n" {}
-    -i ${lcdsid} -re "^ignore .*\n" {}
+    -i ${lcdsid} -re "^listen \[^\n\]*\n" {}
+    -i ${lcdsid} -re "^ignore \[^\n\]*\n" {}
+    -i ${lcdsid} -re "\[^\n\]*\n" {}
   }
 }
index 14a0bf582e410f96147ca473867502af7fb523a4..28a629b4e425a9b0ad2e404b207ac61fdfa2e7d9 100755 (executable)
@@ -1,3 +1,3 @@
 #!/bin/sh
 export TCLLIBPATH="$TCLLIBPATH /home/pi/sc/bin"
-exec chpst -u pi:pi expect /home/pi/sc/bin/lcdproc-remind.expect >/dev/null
+exec chpst -d 20000000 -u pi:pi expect /home/pi/sc/bin/lcdproc-remind.expect >/dev/null
index 249418947874b8c7c2385466af2ebcf61c0856aa..fe109fe89da37347d678952e8cb8627036285b8f 100755 (executable)
@@ -1,3 +1,3 @@
 #!/bin/sh
 export TCLLIBPATH="$TCLLIBPATH /home/pi/sc/bin"
-exec chpst -u pi:pi expect /home/pi/sc/bin/lcdproc-monitor.expect >/dev/null
+exec chpst -d 20000000 -u pi:pi expect /home/pi/sc/bin/lcdproc-monitor.expect >/dev/null