From 9c2c1f70ab97981ff337f359a390383fc5934fc1 Mon Sep 17 00:00:00 2001 From: Jan Michel Date: Thu, 22 Oct 2015 19:10:34 +0200 Subject: [PATCH] modified power supply reader to run on modified httpi and normal httpi servers --- web/htdocs/tools/pwr/build_index.pl | 7 ++++++- web/htdocs/tools/pwr/pwr.pl | 10 +++++----- web/htdocs/tools/pwr/read_conf.pl | 8 ++++++-- web/htdocs/tools/pwr/save_conf.pl | 7 ++++++- 4 files changed, 23 insertions(+), 9 deletions(-) diff --git a/web/htdocs/tools/pwr/build_index.pl b/web/htdocs/tools/pwr/build_index.pl index 3c29691..c5ea77a 100755 --- a/web/htdocs/tools/pwr/build_index.pl +++ b/web/htdocs/tools/pwr/build_index.pl @@ -1,7 +1,13 @@ #!/usr/bin/perl -w use Cwd; + +if ($ENV{'SERVER_SOFTWARE'} =~ /HTTP-?i/i) { + &htsponse(200, "OK"); + } print "Content-type: text/html\n\n"; + + my $pwd = &Cwd::cwd(); my $file = "pwr.conf"; @@ -10,7 +16,6 @@ if ($ENV{'SERVER_SOFTWARE'} =~ /HTTPi/i) { } - open(LESEN,$file) or die "Fehler beim oeffnen von : $!\n"; diff --git a/web/htdocs/tools/pwr/pwr.pl b/web/htdocs/tools/pwr/pwr.pl index 8a57692..2e3807e 100755 --- a/web/htdocs/tools/pwr/pwr.pl +++ b/web/htdocs/tools/pwr/pwr.pl @@ -1,5 +1,5 @@ #!/usr/bin/perl -w -if ($ENV{'SERVER_SOFTWARE'} =~ /HTTPi/i) { +if ($ENV{'SERVER_SOFTWARE'} =~ /HTTP-?i/i) { &htsponse(200, "OK"); } print "Content-type: text/html\n\n"; @@ -106,7 +106,7 @@ sub receive_answer { # do polling for 5 seconds, break polling as soon as answer was received my $i; - for ($i = 0; ($i<500) ;$i++) { + for ($i = 0; ($i<100) ;$i++) { my $a = $port->lookfor; #print $a."\n"; # debug output if ($a =~ m/V(\d\d\.\d\d)A(\d\.\d\d\d)W(\d\d\d\.\d)U(\d\d)I(\d\.\d\d)P(\d\d\d)F(\d\d\d\d\d\d)/) { @@ -150,7 +150,7 @@ sub receive_answer { last; } else { - usleep 1E4; # 10 ms delay + usleep 5E4; # 50 ms delay } } } @@ -169,13 +169,13 @@ sub receive_answer_HMP { usleep(20000) if $ser_type eq "PST"; if($command =~ m/\?/) { # print "waiting...\n"; - READBACK: for (my $i = 0; ($i<500) ;$i++) { + READBACK: for (my $i = 0; ($i<100) ;$i++) { $a = $port->lookfor(3); if (defined $a and $a ne "" and $a =~ m/\d/) { print $a."&"; last READBACK; } - usleep(1000); + usleep(5000); usleep(20000) if $ser_type eq "PST"; } } diff --git a/web/htdocs/tools/pwr/read_conf.pl b/web/htdocs/tools/pwr/read_conf.pl index 3b9f5a0..acf4909 100755 --- a/web/htdocs/tools/pwr/read_conf.pl +++ b/web/htdocs/tools/pwr/read_conf.pl @@ -1,8 +1,12 @@ #!/usr/bin/perl -w -print "Content-type: text/html\r\n\r\n"; - use Cwd; +if ($ENV{'SERVER_SOFTWARE'} =~ /HTTP-?i/i) { + &htsponse(200, "OK"); + } +print "Content-type: text/html\n\n"; + + my $pwd = &Cwd::cwd(); my $file = "pwr.conf"; diff --git a/web/htdocs/tools/pwr/save_conf.pl b/web/htdocs/tools/pwr/save_conf.pl index 3834987..8fb553c 100755 --- a/web/htdocs/tools/pwr/save_conf.pl +++ b/web/htdocs/tools/pwr/save_conf.pl @@ -1,5 +1,10 @@ #!/usr/bin/perl -w -print "Content-type: text/html\r\n\r\n"; + +if ($ENV{'SERVER_SOFTWARE'} =~ /HTTP-?i/i) { + &htsponse(200, "OK"); + } +print "Content-type: text/html\n\n"; + my $envstring = $ENV{'QUERY_STRING'}; $envstring =~ s/%20/ /g; -- 2.43.0