From f86117d2bac9badd330c2b415600427a6a595811 Mon Sep 17 00:00:00 2001 From: Jan Michel Date: Fri, 3 Feb 2023 13:58:38 +0100 Subject: [PATCH] add output of proper commands, execute and write option --- scripts/check_voltages.pl | 45 +++++++++++++++++++++++++++++++++------ 1 file changed, 39 insertions(+), 6 deletions(-) diff --git a/scripts/check_voltages.pl b/scripts/check_voltages.pl index 927fccf..c0bef12 100755 --- a/scripts/check_voltages.pl +++ b/scripts/check_voltages.pl @@ -10,36 +10,69 @@ use HADES::TrbNet; trb_init_ports() or die trb_strerror(); +my $write; +my $execute; +my $help; +Getopt::Long::Configure(qw(gnu_getopt)); +GetOptions( + 'help|h' => \$help, + 'write|w' => \$write, + 'exec|e' => \$execute, +); +if($help) { +print <{$b}[0] / 16; my $diff = $value - $nominal[0] - $headroom; if($diff > $stepsize) { my $sugg = $diff/$stepsize ; - printf("%04x\t%i\t%i\t%i\n",$b,$value,1,-$sugg); + makechange($b,$value,1,-$sugg); + } if($diff < 0) { my $sugg = (-$diff)/$stepsize + 1; - printf("%04x\t%i\t%i\t%i\n",$b,$value,1,$sugg); + makechange($b,$value,1,$sugg); } $value = $values->{$b}[2] / 16; $diff = $value - $nominal[1] - $headroom; if($diff > $stepsize) { my $sugg = $diff/$stepsize ; - printf("%04x\t%i\t%i\t%i\n",$b,$value,0,-$sugg); + makechange($b,$value,0,-$sugg); } if($diff < 0) { my $sugg = (-$diff)/$stepsize + 1; - printf("%04x\t%i\t%i\t%i\n",$b,$value,0,$sugg); + makechange($b,$value,0,$sugg); } } + + +sub makechange { + my ($b,$v,$c,$r) = @_; + my $cmd = sprintf("./mdc_voltage.pl %s -b 0x%04x\t-c %i\t-r %i\t#%i mV\n",$write,$b,$c,$r,$v); + print $cmd; + qx($cmd) if defined $execute; + } -- 2.43.0