]> jspc29.x-matter.uni-frankfurt.de Git - daqtools.git/commitdiff
fixed access to padiwa to be atomic. JM, MT
authorMichael Traxler <M.Traxler@gsi.de>
Tue, 21 Oct 2014 21:53:22 +0000 (23:53 +0200)
committerMichael Traxler <M.Traxler@gsi.de>
Tue, 21 Oct 2014 21:53:22 +0000 (23:53 +0200)
thresholds/run_thresh_on_system.pl
thresholds/thresholds_automatic.pl
thresholds/write_thresholds.pl
users/gsi_dirc/addresses_trb3.db
web/CtsConfig.pm

index 570b006bf732858a167369190ee8abaccea7d991..576f7aedd1d53498e743f5264c05e9d806b56454 100755 (executable)
@@ -103,8 +103,8 @@ sub get_ranges {
 
     my @array;
     foreach my $str (@$ra_data) {
-        $str=~s/-/\.\./;
-        $str=~s/\.\.\./\.\./;
+        $str=~s/-/\.\./g;
+        $str=~s/\.\.\./\.\./g;
         my @val = split(/\,/, $str);
         #print Dumper \@val;
         foreach my $c_val (@val) {
index 3761da38fd0ab511d9b3aed7d2c34854b2979108..e7d14e527904c79623cdf8a0b401598f007d8cfd 100755 (executable)
@@ -234,7 +234,7 @@ write_thresholds($mode, $chain, \@best_thresh);
 my $uid;
 foreach my $i (reverse (0..3)) {
   #print "send command: $endpoint , i: $i\n";
-  $rh_res = send_command($endpoint, 0x10000000 | $i * 0x10000);
+  $rh_res = send_command($endpoint, $chain, 0x10000000 | $i * 0x10000);
   $uid .= sprintf("%04x", $rh_res->{$endpoint} &0xffff);
   #print $uid;
 }
@@ -305,8 +305,7 @@ sub write_thresholds {
       die "could not lock shared element";
   }
 
-
-  my $rh_res = trb_register_write($endpoint,0xd410, 1 << $chain);
+  ### old and wrong way #my $rh_res = trb_register_write($endpoint,0xd410, 1 << $chain);
 
   foreach my $current_channel (0..15) {
 
@@ -324,7 +323,7 @@ sub write_thresholds {
     }
 
     $command = $fixed_bits | ($current_channel << 16) | ($ra_thresh->[$current_channel] << $shift_bits);
-    send_command($endpoint, $command);
+    send_command($endpoint, $chain, $command);
 
 
   }
@@ -335,8 +334,22 @@ sub write_thresholds {
 
 }
 
-
 sub send_command {
+    (my $endpoint, my $chain, my $command) = @_;
+
+    my $ra_atomic = [$command,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1<<$chain,0x10001];
+    my $rh_res = trb_register_write_mem($endpoint, 0xd400, 0, $ra_atomic, scalar @{$ra_atomic});
+    send_command_error($endpoint) if (!defined $rh_res);
+
+    $rh_res = trb_register_read($endpoint,0xd412);
+  #print Dumper $rh_res;
+    send_command_error($endpoint) if (!defined $rh_res);
+    return $rh_res;
+
+}
+
+
+sub send_command_old {
   (my $endpoint, my $command) = @_;
 
   my $rh_res = trb_register_write($endpoint,0xd400, $command);
index 661b7106f16e8dc7d68477a048e761a6d9742fa3..08d83231b7631a72c3c44109468f235afc56ae1c 100755 (executable)
@@ -79,9 +79,6 @@ exit;
 sub write_threshold {
   (my $mode, my $endpoint, my $chain, my $current_channel, my $thresh) = @_;
 
-  my $rh_res = trb_register_write($endpoint,0xd410, 1<<$chain);
-
-  my $command;
   my $fixed_bits;
   my $shift_bits;
   
@@ -94,22 +91,17 @@ sub write_threshold {
       $shift_bits = 4;
   }
 
-  $command= $fixed_bits | ($current_channel<<16) | ($thresh << $shift_bits);
-  send_command($endpoint, $command);
-
+  my $command= $fixed_bits | ($current_channel<<16) | ($thresh << $shift_bits);
 
+  send_command($endpoint, $chain, $command);
 }
 
 
-
-
 sub send_command {
-  (my $endpoint, my $command) = @_;
-
-  my $rh_res = trb_register_write($endpoint,0xd400, $command);
-  send_command_error($endpoint) if (!defined $rh_res);
+  (my $endpoint, my $chain, my $command) = @_;
 
-  $rh_res = trb_register_write($endpoint,0xd411, 0x1);
+  my $ra_atomic = [$command,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1<<$chain,0x10001];
+  my $rh_res = trb_register_write_mem($endpoint, 0xd400, 0, $ra_atomic, scalar @{$ra_atomic});
   send_command_error($endpoint) if (!defined $rh_res);
 
   $rh_res = trb_register_read($endpoint,0xd412);
index 965cacfcd9425cc28c0cf55587895becfa5849bc..8791b7c0ca70ab9b0f5d27184f8631f2ff84ba7b 100644 (file)
 0x8000      28            5
 
 
-0x0800             29     0
-0x0201             29     1
-0x0202             29     2
-0x0203             29     3
-0x8001      29            5
+0x1510             29     0
+0x1511             29     1
+0x1512             29     2
+0x1513             29     3
+0x8015      29            5
 
 0x2010             30     0
 0x2011             30     1
 0x8004      73            5
 
 #MCP TOF back
-0x1610      74      0
-0x1611      74      1
-0x1612      74      2
-0x1613      74      3
-0x8016      74      5
+0x0910      74      0
+0x0911      74      1
+0x0912      74      2
+0x0913      74      3
+0x8009      74      5
 
 0xc000             75     0
 0xc001             75     1
 0x8000     100      5
 
 #Beam counters
-0x1510     101      0
-0x1511     101      1
-0x1512     101      2
-0x1513     101      3
-0x8015     101      5
+0x1610     101      0
+0x1611     101      1
+0x1612     101      2
+0x1613     101      3
+0x8016     101      5
 
 #MCP 5
 0x0510     102      0
index 5863cc4983fa0c98590185511ec504d9f4bc4603..36a60823279f4af7fa1354939970d11e0a266b71 100644 (file)
@@ -2,7 +2,7 @@ package CtsConfig;
 
 #default cts endpoint. can be overriden by a command line parameter
 sub getDefaultEndpoint {
-   return 0x8000
+   return 0x7005
 }
 
 1;