From 87af9f0433544b090f548d52708496d6978d670a Mon Sep 17 00:00:00 2001 From: Michael Traxler Date: Tue, 21 Oct 2014 23:53:22 +0200 Subject: [PATCH] fixed access to padiwa to be atomic. JM, MT --- thresholds/run_thresh_on_system.pl | 4 ++-- thresholds/thresholds_automatic.pl | 23 ++++++++++++++++++----- thresholds/write_thresholds.pl | 18 +++++------------- users/gsi_dirc/addresses_trb3.db | 30 +++++++++++++++--------------- web/CtsConfig.pm | 2 +- 5 files changed, 41 insertions(+), 36 deletions(-) diff --git a/thresholds/run_thresh_on_system.pl b/thresholds/run_thresh_on_system.pl index 570b006..576f7ae 100755 --- a/thresholds/run_thresh_on_system.pl +++ b/thresholds/run_thresh_on_system.pl @@ -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) { diff --git a/thresholds/thresholds_automatic.pl b/thresholds/thresholds_automatic.pl index 3761da3..e7d14e5 100755 --- a/thresholds/thresholds_automatic.pl +++ b/thresholds/thresholds_automatic.pl @@ -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); diff --git a/thresholds/write_thresholds.pl b/thresholds/write_thresholds.pl index 661b710..08d8323 100755 --- a/thresholds/write_thresholds.pl +++ b/thresholds/write_thresholds.pl @@ -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); diff --git a/users/gsi_dirc/addresses_trb3.db b/users/gsi_dirc/addresses_trb3.db index 965cacf..8791b7c 100644 --- a/users/gsi_dirc/addresses_trb3.db +++ b/users/gsi_dirc/addresses_trb3.db @@ -103,11 +103,11 @@ 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 @@ -383,11 +383,11 @@ 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 @@ -554,11 +554,11 @@ 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 diff --git a/web/CtsConfig.pm b/web/CtsConfig.pm index 5863cc4..36a6082 100644 --- a/web/CtsConfig.pm +++ b/web/CtsConfig.pm @@ -2,7 +2,7 @@ package CtsConfig; #default cts endpoint. can be overriden by a command line parameter sub getDefaultEndpoint { - return 0x8000; + return 0x7005; } 1; -- 2.43.0