synchronize command sending to gaw with gaw replies so at the end the tcp channel is closed gracefully (avoid port in use error messages). Timeout whatchdog is set to prevent forever waits/deadlocks.

This commit is contained in:
Stefan Schippers 2020-11-07 21:07:16 +01:00
parent 3f76397522
commit ec6ad39acc
3 changed files with 43 additions and 5 deletions

View File

@ -765,10 +765,26 @@ proc gaw_cmd {cmd} {
}
return
}
chan configure $gaw_fd -blocking 1 -buffering line -encoding binary -translation binary
chan configure $gaw_fd -blocking 0 -buffering line -encoding binary -translation binary
puts $gaw_fd "$cmd"
set n [regexp -all \n $cmd]
incr n
puts "gaw command lines: $n"
fileevent $gaw_fd readable gaw_echoline
vwait gaw_fd
while { $n} {
#timeout for abnormal deadlocks
after 10000 set gaw_fd stalled
vwait gaw_fd
if { $gaw_fd ne {stalled} } {
after cancel set gaw_fd stalled
} else {
puts "timeout waiting for gaw response.."
break
}
incr n -1
}
close $gaw_fd
unset gaw_fd
}
proc waves {} {

View File

@ -396,7 +396,15 @@ descr = power
}
C {launcher.sym} 800 -140 0 0 {name=h3
descr="Load file into gaw"
tclcommand="gaw_cmd \\"tabledel mos_power_ampli.raw
load $netlist_dir/mos_power_ampli.raw
table_set mos_power_ampli.raw\\""
comment="
This launcher gets raw filename from current schematic using 'xschem get schname'
and stripping off path and suffix. It then loads raw file into gaw.
This allow to use it in any schematic without changes.
"
tclcommand="
set rawfile [file tail [file rootname [xschem get schname]]].raw
gaw_cmd \\"tabledel $rawfile
load $netlist_dir/$rawfile
table_set $rawfile\\"
unset rawfile"
}

View File

@ -240,3 +240,17 @@ C {ngspice_get_expr.sym} 820 -510 2 0 {name=r29
node="[format %.4g [expr ([ngspice::get_voltage outm] - [ngspice::get_voltage outp]) * [ngspice::get_current \{r1[i]\}]]] W"
descr = power
}
C {launcher.sym} 780 -190 0 0 {name=h3
descr="Load file into gaw"
comment="
This launcher gets raw filename from current schematic using 'xschem get schname'
and stripping off path and suffix. It then loads raw file into gaw.
This allow to use it in any schematic without changes.
"
tclcommand="
set rawfile [file tail [file rootname [xschem get schname]]].raw
gaw_cmd \\"tabledel $rawfile
load $netlist_dir/$rawfile
table_set $rawfile\\"
unset rawfile"
}