]> jspc29.x-matter.uni-frankfurt.de Git - daqtools.git/commitdiff
scripts for the gsi dirc group
authorMichael Traxler <hadaq@kp1pc105.gsi.de>
Tue, 6 Aug 2013 14:47:00 +0000 (16:47 +0200)
committerMichael Traxler <hadaq@kp1pc105.gsi.de>
Tue, 6 Aug 2013 14:47:00 +0000 (16:47 +0200)
users/gsi_dirc/configure_trb3.sh [new file with mode: 0755]
users/gsi_dirc/merge_serial_address.pl [new file with mode: 0755]
users/gsi_dirc/start_readout.pl [new file with mode: 0755]
users/gsi_dirc/startup.sh [new file with mode: 0755]

diff --git a/users/gsi_dirc/configure_trb3.sh b/users/gsi_dirc/configure_trb3.sh
new file mode 100755 (executable)
index 0000000..7fd6474
--- /dev/null
@@ -0,0 +1,110 @@
+# CTS Board 0x8000 trb060
+trbcmd w 0x8000 0x8300 0x8000       # SubeventId
+trbcmd w 0x8000 0x8301 0x00020001   # SubEventDecoding
+trbcmd w 0x8000 0x8302 0x00030062   # Queue decoding
+trbcmd w 0x8000 0x8303 0xea60       # max packet size
+trbcmd w 0x8000 0x8304 0x0578       # max frame size
+trbcmd w 0x8000 0x8305 0x1          # use GbE
+trbcmd w 0x8000 0x8306 0x0          # use TRBnet to send data
+trbcmd w 0x8000 0x8307 0x0          # Multi event queue size
+trbcmd w 0x8000 0x8308 0xffffff     # Trigger counter
+trbcmd w 0x8000 0x830b 0x7          # ??
+trbcmd w 0x8000 0x830d 0x1          # enable readout bit
+
+#mac address of the EB
+#kp1pc105 00:1b:21:43:97:ea
+trbcmd w 0x8000 0x8100 0x214397ea   # lower 4 bytes 
+trbcmd w 0x8000 0x8101 0x001b       # upper two bytes
+
+trbcmd w 0x8000 0x8102 0xc0a80002   # destination IP-address: 192.168.0.2
+trbcmd w 0x8000 0x8103 0xc350       # destination port 50000
+trbcmd w 0x8000 0x8104 0xdead0110   # source MAC-address
+trbcmd w 0x8000 0x8105 0x001b       # source MAC: upper bytes
+trbcmd w 0x8000 0x8106 0xc0a80138   # source IP trb056
+trbcmd w 0x8000 0x8107 0xc353       # source Port
+trbcmd w 0x8000 0x8108 0x578        # MTU
+
+
+
+## Slave 1 0x8001 trb061
+#trbcmd w 0x8001 0x8300 0x8001       # SubeventId
+#trbcmd w 0x8001 0x8301 0x00020001   # SubEventDecoding
+#trbcmd w 0x8001 0x8302 0x00030062   # Queue decoding
+#trbcmd w 0x8001 0x8303 0xea60       # max packet size
+#trbcmd w 0x8001 0x8304 0x0578       # max frame size
+#trbcmd w 0x8001 0x8305 0x1          # use GbE
+#trbcmd w 0x8001 0x8306 0x0          # use TRBnet to send data
+#trbcmd w 0x8001 0x8307 0x0          # Multi event queue size
+#trbcmd w 0x8001 0x8308 0xffffff     # Trigger counter
+#trbcmd w 0x8001 0x830b 0x7          # ??
+#trbcmd w 0x8001 0x830d 0x1          # enable readout bit
+
+##mac address of the EB
+##kp1pc105 00:1b:21:43:97:ea
+#trbcmd w 0x8001 0x8100 0x214397ea   # lower 4 bytes 
+#trbcmd w 0x8001 0x8101 0x001b       # upper two bytes
+#
+#trbcmd w 0x8001 0x8102 0xc0a80001   # destination IP-address: 192.168.0.1
+#trbcmd w 0x8001 0x8103 0xc352       # destination port 50002
+#                                    # port 50001 is for debug messages from GbE
+#trbcmd w 0x8001 0x8104 0xdead0110   # source MAC-address
+#trbcmd w 0x8001 0x8105 0x001b       # source MAC: upper bytes
+#trbcmd w 0x8001 0x8106 0xc0a8013d   # source IP trb061
+#trbcmd w 0x8001 0x8107 0xc353       # source Port
+#trbcmd w 0x8001 0x8108 0x578        # MTU
+#
+
+## Slave 2 0x8002 trb062
+#trbcmd w 0x8002 0x8300 0x8002       # SubeventId
+#trbcmd w 0x8002 0x8301 0x00020001   # SubEventDecoding
+#trbcmd w 0x8002 0x8302 0x00030062   # Queue decoding
+#trbcmd w 0x8002 0x8303 0xea60       # max packet size
+#trbcmd w 0x8002 0x8304 0x0578       # max frame size
+#trbcmd w 0x8002 0x8305 0x1          # use GbE
+#trbcmd w 0x8002 0x8306 0x0          # use TRBnet to send data
+#trbcmd w 0x8002 0x8307 0x0          # Multi event queue size
+#trbcmd w 0x8002 0x8308 0xffffff     # Trigger counter
+#trbcmd w 0x8002 0x830b 0x7          # ??
+#trbcmd w 0x8002 0x830d 0x1          # enable readout bit
+
+##mac address of the EB
+##kp1pc105 00:1b:21:43:97:ea
+#trbcmd w 0x8002 0x8100 0x214397ea   # lower 4 bytes 
+#trbcmd w 0x8002 0x8101 0x001b       # upper two bytes
+#
+#trbcmd w 0x8002 0x8102 0xc0a80001   # destination IP-address: 192.168.0.1
+#trbcmd w 0x8002 0x8103 0xc353       # destination port 50003
+#                                    # port 50001 is for debug messages from GbE
+#trbcmd w 0x8002 0x8104 0xdead0110   # source MAC-address
+#trbcmd w 0x8002 0x8105 0x001b       # source MAC: upper bytes
+#trbcmd w 0x8002 0x8106 0xc0a8013e   # source IP trb062
+#trbcmd w 0x8002 0x8107 0xc353       # source Port
+#trbcmd w 0x8002 0x8108 0x578        # MTU
+#
+
+## Slave 3 0x8003 trb063
+#trbcmd w 0x8003 0x8300 0x8003       # SubeventId
+#trbcmd w 0x8003 0x8301 0x00020001   # SubEventDecoding
+#trbcmd w 0x8003 0x8302 0x00030062   # Queue decoding
+#trbcmd w 0x8003 0x8303 0xea60       # max packet size
+#trbcmd w 0x8003 0x8304 0x0578       # max frame size
+#trbcmd w 0x8003 0x8305 0x1          # use GbE
+#trbcmd w 0x8003 0x8306 0x0          # use TRBnet to send data
+#trbcmd w 0x8003 0x8307 0x0          # Multi event queue size
+#trbcmd w 0x8003 0x8308 0xffffff     # Trigger counter
+#trbcmd w 0x8003 0x830b 0x7          # ??
+#trbcmd w 0x8003 0x830d 0x1          # enable readout bit
+
+##mac address of the EB
+##kp1pc105 00:1b:21:43:97:ea
+#trbcmd w 0x8003 0x8100 0x214397ea   # lower 4 bytes 
+#trbcmd w 0x8003 0x8101 0x001b       # upper two bytes
+#
+#trbcmd w 0x8003 0x8102 0xc0a80001   # destination IP-address: 192.168.0.1
+#trbcmd w 0x8003 0x8103 0xc354       # destination port 50004
+#                                    # port 50001 is for debug messages from GbE
+#trbcmd w 0x8003 0x8104 0xdead0110   # source MAC-address
+#trbcmd w 0x8003 0x8105 0x001b       # source MAC: upper bytes
+#trbcmd w 0x8003 0x8106 0xc0a8013f   # source IP trb063
+#trbcmd w 0x8003 0x8107 0xc353       # source Port
+#trbcmd w 0x8003 0x8108 0x578        # MTU
diff --git a/users/gsi_dirc/merge_serial_address.pl b/users/gsi_dirc/merge_serial_address.pl
new file mode 100755 (executable)
index 0000000..8684ecd
--- /dev/null
@@ -0,0 +1,71 @@
+#!/usr/bin/perl
+
+use warnings;
+use strict;
+
+use Data::Dumper;
+use HADES::TrbNet;
+
+my $fn1 = $ARGV[0];
+my $fn2 = $ARGV[1];
+
+&usage if (!$fn1 || !$fn2);
+
+# check input
+
+open my $fh1, "<", $fn1 or die "could not open $fn1: $!";
+open my $fh2, "<", $fn2 or die "could not open $fn2, $!";
+
+
+trb_init_ports() or die trb_strerror();
+
+my %trb;
+foreach my $cur_ln (<$fh1>) {
+    next if($cur_ln =~ /^\s*#/ or $cur_ln =~ /^\s*$/);
+    (my $serial_nr, my $uid) = $cur_ln =~ /(\d+)\s+(\w+)/;
+    next if (!defined $serial_nr);
+    $serial_nr = int($serial_nr);
+    $trb{$serial_nr}->{'uid'} = $uid;
+}
+
+#print Dumper \%trb;
+
+foreach my $cur_ln (<$fh2>) {
+    next if($cur_ln =~ /^\s*#/ or $cur_ln =~ /^\s*$/);
+    (my $address, my $sernr1, my $sernr2) = $cur_ln =~ /(\w+)\s+(\d+)\s+(\d+)/;
+    my $serial_nr = $sernr1*10 + $sernr2;
+    next if (!defined $serial_nr);
+    $trb{$serial_nr}->{'address'} = hex($address);
+    $trb{$serial_nr}->{'endpoint_nr'} = $sernr2;
+}
+
+
+#print Dumper \%trb;
+
+
+foreach my $serial_nr (keys %trb) {
+    next if(!$trb{$serial_nr}->{'address'} || !defined $trb{$serial_nr}->{'uid'});
+    printf "0x%4.4x  ", $trb{$serial_nr}->{'address'};
+    print $trb{$serial_nr}->{'uid'} . "  ";
+    printf "0x%2.2x\n", $trb{$serial_nr}->{'endpoint_nr'};
+
+    no warnings 'portable';
+    my $uid = hex($trb{$serial_nr}->{'uid'});
+    use warnings 'portable';
+
+    my $ref = trb_set_address($uid, $trb{$serial_nr}->{'endpoint_nr'} , $trb{$serial_nr}->{'address'});
+
+}
+
+
+exit;
+
+sub usage {
+    print <<EOF;
+usage:
+merge_serial_address.pl <serials.db> <address.db>
+
+EOF
+
+exit;
+}
diff --git a/users/gsi_dirc/start_readout.pl b/users/gsi_dirc/start_readout.pl
new file mode 100755 (executable)
index 0000000..72d86db
--- /dev/null
@@ -0,0 +1,60 @@
+#!/usr/bin/perl
+use warnings;
+use strict;
+use Getopt::Long;
+
+my $help = "";
+my $dataPath = "~/trbsoft/data";
+my $source1 = "50000"; # don't use 50001
+my $source2 = "50002"; # it is assigned for GbE debug
+my $source3 = "50003";
+my $source4 = "50004";
+my $source5 = "50005";
+my $label = "test";
+my $time = -1;
+my $c;
+
+my $result = GetOptions (
+    "h|help"    => \$help,
+    "t|time=i"  => \$time,
+    "l|label=s" => \$label,
+    "p|path=s"  => \$dataPath
+    );
+
+if($help) {
+    print "Usage: start_readout.pl <time>\n\n";
+    print "-h --help\tPrints the usage manual\n";
+    print "-t --time\tDefine length of time in seconds for data taking (Default = -1)\n";
+    print "\t\tFor unlimited data taking define <time> as -1.\n";
+    print "-l --label\tDefine label for the daq_evtbuild and daq_netmem processes (Default = test)\n";
+    print "-p --path\tDefine path for saving data (Default = ~/trbsoft/data\)\n";
+    print "\n";
+    exit;
+}
+
+
+$c=qq|pkill -f "daq_evtbuild -S $label"|; qx($c); # if any, kill existing daq_evtbuild
+$c=qq|pkill -f "daq_netmem -S $label"|;   qx($c); # if any, kill existing daq_netmem
+
+
+$c=qq|xterm -geometry 122x14-0+0 -e bash -c 'daq_evtbuild -S $label -m 1 -d file -o $dataPath'|;
+print $c;
+exit;
+
+system("$c &");
+
+sleep 1;
+$c=qq"xterm -geometry 82x17-0+210 -e bash -c 'daq_netmem -S $label -m 1 -i UDP:127.0.0.1:50000'";
+system("$c &");
+
+print "Saving data to $dataPath\n";
+
+if($time == -1) {
+    print "Data taking will run until manual quit with Ctrl+C\n\n";
+}
+else {
+    print "Data taking will run for $time seconds.\n\n";
+    sleep $time;
+    $c=qq|pkill -f "daq_evtbuild -S $label"|; qx($c);
+    $c=qq|pkill -f "daq_netmem -S $label"|;   qx($c);
+}
diff --git a/users/gsi_dirc/startup.sh b/users/gsi_dirc/startup.sh
new file mode 100755 (executable)
index 0000000..bb07d5c
--- /dev/null
@@ -0,0 +1,50 @@
+#!/bin/sh
+# PATH should already be marked as exported...
+#PATH=${HOME}/trbsoft/bin:${PATH}
+#PATH=${HOME}/trbsoft/daqdata/bin:${PATH}
+#PATH=${HOME}/trbsoft/trbnettools/bin:${PATH}
+export TRB3_SERVER=trb056
+export DAQOPSERVER=localhost:56
+
+
+##################################################
+## Set addresses
+##################################################
+./merge_serial_address.pl ~/trbsoft/daqtools/base/serials_trb3.db ~/trbsoft/daqtools/base/addresses_trb3.db  > /dev/null
+
+##################################################
+## System Reset
+##################################################
+trbcmd reset
+
+##################################################
+## Configure GbE for DAQ
+##################################################
+./configure_trb3.sh # central hub configuration to send data via GbE
+
+##################################################
+## Configure TDCs
+##################################################
+trbcmd setbit   0xfe48 0xc800 0x00001000 ## Triggerless mode
+#trbcmd clearbit 0xfe48 0xc800 0x00001000 ## Triggered   mode
+
+trbcmd w 0xfe48 0xc801 0x000f0005 ## trigger window enable & trigger window width
+trbcmd w 0xfe48 0xc802 0x00000000 ## channel 01-32 enable
+trbcmd w 0xfe48 0xc803 0x00000000 ## channel 33-64 enable
+trbcmd w 0xfe48 0xc804 0x00000080 ## data transfer limit
+
+##################################################
+## Other Settings
+##################################################
+# Reset trigger logic - only a workaround for a bug
+trbcmd w 0xffff 0x20 0x33
+
+# timeouts
+trbcmd w 0xfffe 0xc5 0x800050ff
+
+# pulser #1 to 1k Hz
+trbcmd w 0x8000 0xa137 0x0001869f
+
+# pulser enable
+#trbcmd setbit 0x8000 0xa101 0x2
+trbcmd clearbit 0x8000 0xa101 0x2