Commit 62c97bf7 authored by Alessandro Rubini's avatar Alessandro Rubini

tools and doc: added fau-config-if

Signed-off-by: Alessandro Rubini's avatarAlessandro Rubini <rubini@gnudd.com>
parent 40bc21c4
......@@ -964,6 +964,32 @@ the trigger is initially automatically enabled. This may change in the
future, for better naming consistency with hardware documentation and
across tools.
@c ==========================================================================
@node Gain Configuration
@section Gain Configuration
The program @t{tools/fau-config-if} is a simple graphic tool that allow
to select offset and range for the four channels, activate termination
and see the current value of each channel, every 500ms.
The program open one window for each detected card, and configures it
by writing to @i{sysfs}. Such writes are also reported to @i{stdout}
(in the terminal where you invoked the program), so you can easily copy
the pathnames in your shell commands.
@ref{fig:fau-config-if} shows two instances of the tool, running on
the same card with device_id 0x200 (your window decorations will be
different, according to your choice of window manager or desktop
environment). The first one (at the left) is running under Tk-8.5;
the second one shows the graphic appearance of Tk-8.4 (and earlier
versions). If you prefer the older one, run ``@t{wish8.4
tools/fau-config-if}'' instead of ``@t{tools/fau-config-if}'' (or set
the previous version as default Tk interpreter).
@float Figure, fig:fau-config-if
@center @image{img/config-if, 10cm, ,Two snapshots of fau-config-if, pdf}
@end float
@c ==========================================================================
@node Acquisition Time
@section Acquisition Time
......
Two snapshots of fa-config-if
#!/usr/bin/wish
set base "/sys/bus/zio/devices/adc-100m14b-"
# We trace the "v" (values) array to write to sysfs
trace add variable v write doact
proc doact {var element op} {
global v; # lazy me
global argv0 base
foreach "index channel what" [split $element :] {}
#puts "trace: $index $channel $var = \"$v($element)\""
set fname ${base}$index/cset0/ch${channel}-$what
if ![file writable $fname] {
puts stderr "$argv0: file \"$fname\" not writable"
return
}
puts "$v($element) > $fname"
set F [open $fname w]
puts $F $v($element)
close $F
}
# Create one window for each card
proc onewin {dir index} {
global v base labels
set t [toplevel .$index]
foreach ch "1 2 3 4" {
set hwch [expr $ch - 1]
pack [set f [frame $t.f$ch]] -side left -expand true
pack [label $f.l -text "ch $ch"]
pack [scale $f.off -orient v -from 5000 -to -5000 -resolution 10 \
-variable v($index:$hwch:offset)]
set v($index:$hwch:vref) 17
pack [radiobutton $f.100m -text "100mV" \
-variable v($index:$hwch:vref) -value 35]
pack [radiobutton $f.1v -text "1V" \
-variable v($index:$hwch:vref) -value 17]
pack [radiobutton $f.10v -text "10V" \
-variable v($index:$hwch:vref) -value 69]
pack [checkbutton $f.r -text "term" \
-variable v($index:$hwch:50ohm-term)]
pack [label $f.cur -text ""]
lappend labels $f.cur ${base}$index/cset0/chan${hwch}/current-value
if {$ch != 4} {
pack [frame $t.sep$ch -width 4 -bg black] -side left -fill y
}
}
}
set dirs [glob -nocomplain "${base}*"]
if ![llength $dirs] {
puts stderr "$argv0: No matches for \"${base}*\""
exit 1
}
proc checkval {} {
global labels
foreach {l f} $labels {
# if we rmmodded, break out of this loop
if [catch {set F [open $f]}] break
set v [read -nonewline $F]
close $F
if {$v >= 32768} {
set v [expr $v - 65536]
}
$l config -text $v
}
after 500 checkval
}
foreach dir $dirs {
regsub $base $dir "" index
onewin $dir $index
after 500 checkval
}
wm withdraw .
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment