From 88a76e140f87b500d22eac95616e0d9733b715c9 Mon Sep 17 00:00:00 2001 From: Jan Michel Date: Fri, 3 Feb 2023 12:07:22 +0100 Subject: [PATCH] add switch option for power --- scripts/mdc_voltage.pl | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/scripts/mdc_voltage.pl b/scripts/mdc_voltage.pl index c2a4c25..03d45ac 100755 --- a/scripts/mdc_voltage.pl +++ b/scripts/mdc_voltage.pl @@ -15,6 +15,8 @@ my $setting; my $write; my $load; my $relative; +my $on; +my $off; Getopt::Long::Configure(qw(gnu_getopt)); GetOptions( @@ -48,6 +50,9 @@ mdc_voltage.pl (-board|-b) 0x8nnn (-channel|c) (0|1) (-value|-v) (0-7) (-write|- mdc_voltage.pl (-board|-b) 0x8nnn (-channel|c) (0|1) (-relative|-r) (-7..7) [(-write|-w)] change setting relative to the setting in file +mdc_voltage.pl (-board|-b) 0xnnnn (--on|--off) + switches board on/off + Reads the current voltage setting from configuration file. Sets the current voltage (optionally changes configuration file if -w is set). Board needs to be a valid OEP address, or FFFF to show/load all channels. @@ -74,9 +79,16 @@ if(defined $setting && ($setting < 0 || $setting > 7)) { if(defined $relative && ($relative < -7 || $relative > 7)) { die "Wrong relative number (-7-7)\n"; } + +#Switch boards on/off +if((defined $on || defined $off) && defined $board) { + if(defined $on && defined $off) {$on = 2;} + my $ret = MDCPower::power_switch($board,$on//0); + die "Board not found.\n" if $ret == -1; + } #Load all settings -if(defined $load && !defined $board) { +elsif(defined $load && !defined $board) { my $ret = MDCPower::set_all_voltages(); } -- 2.43.0