From 3f74f1ad65d1bd4cd281c64f3a9e2e393f902c54 Mon Sep 17 00:00:00 2001 From: Michael Traxler Date: Tue, 6 Aug 2013 16:47:00 +0200 Subject: [PATCH] scripts for the gsi dirc group --- users/gsi_dirc/configure_trb3.sh | 110 +++++++++++++++++++++++++ users/gsi_dirc/merge_serial_address.pl | 71 ++++++++++++++++ users/gsi_dirc/start_readout.pl | 60 ++++++++++++++ users/gsi_dirc/startup.sh | 50 +++++++++++ 4 files changed, 291 insertions(+) create mode 100755 users/gsi_dirc/configure_trb3.sh create mode 100755 users/gsi_dirc/merge_serial_address.pl create mode 100755 users/gsi_dirc/start_readout.pl create mode 100755 users/gsi_dirc/startup.sh diff --git a/users/gsi_dirc/configure_trb3.sh b/users/gsi_dirc/configure_trb3.sh new file mode 100755 index 0000000..7fd6474 --- /dev/null +++ b/users/gsi_dirc/configure_trb3.sh @@ -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 index 0000000..8684ecd --- /dev/null +++ b/users/gsi_dirc/merge_serial_address.pl @@ -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 + +exit; +} diff --git a/users/gsi_dirc/start_readout.pl b/users/gsi_dirc/start_readout.pl new file mode 100755 index 0000000..72d86db --- /dev/null +++ b/users/gsi_dirc/start_readout.pl @@ -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