]> jspc29.x-matter.uni-frankfurt.de Git - daqtools.git/commitdiff
*** empty log message ***
authorhadeshyp <hadeshyp>
Wed, 5 Sep 2012 16:17:43 +0000 (16:17 +0000)
committerhadeshyp <hadeshyp>
Wed, 5 Sep 2012 16:17:43 +0000 (16:17 +0000)
padiwa.pl [new file with mode: 0755]

diff --git a/padiwa.pl b/padiwa.pl
new file mode 100755 (executable)
index 0000000..e98a5c5
--- /dev/null
+++ b/padiwa.pl
@@ -0,0 +1,77 @@
+#!/usr/bin/perl -w
+use warnings;
+use FileHandle;
+use Time::HiRes qw( usleep );
+use Data::Dumper;
+use HADES::TrbNet;
+
+if (!defined &trb_init_ports()) {
+  die("can not connect to trbnet-daemon on the $ENV{'DAQOPSERVER'}");
+}
+my $fh;
+
+if(!$ARGV[0]) {
+  print "usage: padiwa.pl \$FPGA \$chain \$command \$options\n\n";
+  print "\t uid \t\t reads unique ID, no options\n";
+  print "\t temp \t\t reads temperature, no options\n";
+  print "\t pwm \t\t set PWM value. options: \$channel, \$value\n";
+  print "\t pwm \t\t read PWM value. options: \$channel\n";
+  exit;
+  }
+my $board, my $value;
+  
+($board) = $ARGV[0] =~ /^0?x?(\w+)/;
+$board = hex($board);
+
+if (defined $ARGV[4]) {  
+  ($value) = $ARGV[4] =~ /^0?x?(\w+)/;
+  $value = hex($value);
+  }
+    
+  
+# my $board = hex($ARGV[0]);  
+my $chain = hex($ARGV[1]);  
+  
+  
+sub sendcmd {
+  my ($cmd) = @_;
+  trb_register_write($board,0xd400,$cmd);
+  trb_register_write($board,0xd411,1);
+  return trb_register_read($board,0xd412);
+  }
+  
+  
+
+
+trb_register_write($board,0xd410,1<<$chain) or die "trb_register_write: ", trb_strerror(); 
+  
+if($ARGV[2] eq "temp") {
+  my $b = sendcmd(0x10040000);
+  foreach my $e (sort keys $b) {
+    printf("0x%04x\t%d\t%2.1f\n",$e,$chain,($b->{$e}&0xfff)/16);
+    }
+  }
+
+if($ARGV[2] eq "uid") {
+  my $ids;
+  for(my $i = 0; $i <= 3; $i++) {
+    my $b = sendcmd(0x10000000 + $i*0x10000);
+    foreach my $e (sort keys $b) {
+      $ids->{$e}->{$i} = $b->{$e}&0xffff;
+      }
+    }
+  foreach my $e (sort keys $ids) {
+    printf("0x%04x\t%d\t0x%04x%04x%04x%04x\n",$e,$chain,$ids->{$e}->{3},$ids->{$e}->{2},$ids->{$e}->{1},$ids->{$e}->{0});
+    }
+  }
+  
+if($ARGV[2] eq "pwm" && defined $ARGV[4]) {
+  my $b = sendcmd(0x00800000+$ARGV[3]*0x10000+(hex($ARGV[4])&0xffff));
+  }    
+  
+if($ARGV[2] eq "pwm") {
+  my $b = sendcmd(0x00000000+$ARGV[3]*0x10000);
+  foreach my $e (sort keys $b) {
+    printf("0x%04x\t%d\t%d\t0x%04x\t%4.2f\n",$e,$chain,$ARGV[3],$b->{$e}&0xffff,($b->{$e}&0xffff)*3300/65536);
+    }
+  }  
\ No newline at end of file