+Note that you need to have libdevice-serialport-perl or perl-Device-SerialPort
+installed and that the /dev/ttyUSBn need to be accessible by normal users.
+Feel free to alter the config file to accommodate your needs!
+Please don't use the # character to comment out lines
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/web/htdocs/pwr/pwr.conf b/web/htdocs/pwr/pwr.conf
new file mode 100644
index 0000000..5e6e030
--- /dev/null
+++ b/web/htdocs/pwr/pwr.conf
@@ -0,0 +1,2 @@
+//PWRSPLY:/path/to/device:Device_ID
+PWRSPLY:/dev/ttyUSB0:PWR_DEFAULT
\ No newline at end of file
diff --git a/web/htdocs/pwr/pwr.conf_out b/web/htdocs/pwr/pwr.conf_out
new file mode 100644
index 0000000..8f4bdb9
--- /dev/null
+++ b/web/htdocs/pwr/pwr.conf_out
@@ -0,0 +1,3 @@
+PWRSPLY:/dev/ttyUSB0:Device_1
+PWRSPLY:/dev/ttyUSB1:Device_2
+PWRSPLY:/dev/ttyUSB2:Device_3
diff --git a/web/htdocs/pwr/pwr.htm b/web/htdocs/pwr/pwr.htm
new file mode 100644
index 0000000..bf4f3af
--- /dev/null
+++ b/web/htdocs/pwr/pwr.htm
@@ -0,0 +1,160 @@
+
+
+
+
+
+
+Power Supply Monitor and Access
+
+
+
+
+
Power Supply Access
+
+
+
+
+
+
Readings:
Settings:
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/web/htdocs/pwr/pwr.pl b/web/htdocs/pwr/pwr.pl
new file mode 100755
index 0000000..2e174ef
--- /dev/null
+++ b/web/htdocs/pwr/pwr.pl
@@ -0,0 +1,159 @@
+#!/usr/bin/perl -w
+#print "Content-type: text/html\n\n";
+
+
+use strict;
+use warnings;
+use Device::SerialPort;
+use feature 'state';
+use Time::HiRes qw( usleep);
+
+my $envstring = $ENV{'QUERY_STRING'};
+$envstring =~ s/%20/ /g;
+
+
+my @new_command = split('&',$envstring);
+my $ser_dev = shift(@new_command);
+$ser_dev = "/dev/ttyUSB0" unless defined $ser_dev;
+
+
+
+my $port = new Device::SerialPort($ser_dev);
+unless ($port)
+{
+ print "can't open serial interface $ser_dev\n";
+ exit;
+}
+
+$port->user_msg('ON');
+$port->baudrate(2400);
+$port->parity("none");
+$port->databits(8);
+$port->stopbits(1);
+$port->handshake("xoff");
+$port->write_settings;
+
+# debug output
+#print "attempting to communicate with power supply connected to interface:\n$ser_dev\n\n";
+
+
+transmit_command(); #if new command, send it!
+receive_answer(); # always called
+# transmit_command(); # send relais off in case current maximum is reached!
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+sub transmit_command {
+
+$port->lookclear;
+
+while ( my $command = shift(@new_command) ) {
+
+ $port->write("$command\r");
+ #print "i sent the command: $command";
+ #print "\n\nokay.\n";
+ usleep 1E5;
+ }
+}
+
+
+
+
+sub receive_answer {
+
+
+
+
+ my %state_lookup = (
+ 0 => 'off',
+ 1 => 'on' );
+
+ my $found = 0;
+
+
+
+ # clear buffers, then send the "list"-command to the power supply
+ $port->lookclear;
+ $port->write("L\r");
+ # sleep a second to give the supply time to react
+ usleep 1E5;
+
+ # read what has accumulated in the serial buffer
+ while(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)/) {
+ $found = 1;
+ my $c_volt = $1;
+ my $c_cur = $2;
+ my $c_pwr = $3;
+ my $l_volt = $4;
+ my $l_cur = $5;
+ my $l_pwr = $6;
+ my $state_string = $7;
+ my $relais_state = $state_lookup{substr $state_string, 0,1};
+ printf("
+