improve luft driver

This commit is contained in:
l_samenv
2022-10-17 17:10:39 +02:00
parent 6d99df5bf1
commit 60112ccdc5
2 changed files with 22 additions and 7 deletions

View File

@ -45,8 +45,8 @@ proc luft::writeCf {} {
} else { } else {
luft::set_error "epics error: $val $errtxt" luft::set_error "epics error: $val $errtxt"
} }
if {[scan [lindex [sct target] 0] %d period]} { catch {
sct timeout [expr [clock seconds] + $period + 10] sct timeout [expr [clock seconds] + $timeout + 10]
} }
return idle return idle
} }

View File

@ -16,6 +16,7 @@ proc readpipe {} {
puts stdout "> $line" puts stdout "> $line"
} }
if {[eof $sea(pipe)]} { if {[eof $sea(pipe)]} {
puts stdout EOF
exit exit
} }
lassign $line adr date time value lassign $line adr date time value
@ -65,7 +66,12 @@ set env(EPICS_CA_AUTO_ADDR_LIST) NO
set env(PATH) $env(PATH):/afs/psi.ch/project/sinq/rhel7/stow/base-3.15.5/bin/linux-x86_64-debug/ set env(PATH) $env(PATH):/afs/psi.ch/project/sinq/rhel7/stow/base-3.15.5/bin/linux-x86_64-debug/
set sea(debug) [lindex "$argv 0" 0] set sea(debug) [lindex "$argv 0" 0]
set sea(heartbeat) 300 if {$sea(debug) eq "1"} {
set sea(heartbeat) 20
} else {
set sea(heartbeat) 300
set sea(debug) 0
}
# connect to sea server prep0 # connect to sea server prep0
set sea(sock) [socket samenv.psi.ch 8640] set sea(sock) [socket samenv.psi.ch 8640]
@ -78,15 +84,14 @@ if {$sea(debug)} {
set cmd "/afs/psi.ch/project/sinq/rhel7/stow/base-3.15.5/bin/linux-x86_64-debug/camonitor [array names values]" set cmd "/afs/psi.ch/project/sinq/rhel7/stow/base-3.15.5/bin/linux-x86_64-debug/camonitor [array names values]"
set ret [catch {set proc [exec ps ax -o pid,args | grep $cmd]} msg] set ret [catch {set proc [exec ps ax -o pid,args | grep $cmd]} msg]
set killed [list]
if {$ret == 0} { if {$ret == 0} {
foreach line [split $proc "\n"] { foreach line [split $proc "\n"] {
set l [split [string trim $line]] set l [split [string trim $line]]
set c [lrange $l 1 end] set c [lrange $l 1 end]
if {"$c" eq "$cmd"} { if {"$c" eq "$cmd"} {
# process was still running # process was still running
if {$sea(debug)} { lappend killed [lindex $l 0]
puts stdout "kill $proc ($c)"
}
exec kill -9 [lindex $l 0] exec kill -9 [lindex $l 0]
} }
} }
@ -95,5 +100,15 @@ if {$ret == 0} {
set sea(pipe) [open "|$cmd" r] set sea(pipe) [open "|$cmd" r]
fileevent $sea(pipe) readable readpipe fileevent $sea(pipe) readable readpipe
puts stdout [pid $sea(pipe)] set mypid [pid $sea(pipe)]
set f [open $env(HOME)/monitfiles/luft_camonitor.pid w]
puts $f $mypid
close $f
puts stdout $mypid
if {[llength $killed] > 0 && $sea(debug)} {
puts stdout "killed $killed"
}
seacom "clientlog luft started"
vwait forever vwait forever