From 72ed7040d628263ca2b40b2465e1c00339797e28 Mon Sep 17 00:00:00 2001 From: Hadaq in Frankfurt Date: Wed, 27 Mar 2013 18:09:43 +0100 Subject: [PATCH] added extra checks for CRC errors and STARTED bit of JTAG-Chain-Controller. bn --- .../jtag_atomic/jtagmonitor_usechainsini4.pl | 53 +++++++++++++++++-- 1 file changed, 48 insertions(+), 5 deletions(-) diff --git a/soft/toolbox/jtag_atomic/jtagmonitor_usechainsini4.pl b/soft/toolbox/jtag_atomic/jtagmonitor_usechainsini4.pl index 25acf8c..5b598eb 100755 --- a/soft/toolbox/jtag_atomic/jtagmonitor_usechainsini4.pl +++ b/soft/toolbox/jtag_atomic/jtagmonitor_usechainsini4.pl @@ -76,19 +76,29 @@ while (1){ # file to write counter values to open(my $lastcounters_fh, ">", $lastcountersfile); my $run_counter_changed = 0; + my $errors_occured = 0; foreach my $chain (sort(keys %allchains)) { my %settings=%{$allchains{$chain}}; my $fpga_addr = hex(substr($settings{'FPGAtrbnetAddr'},2)); my $cmd_reg_addr = hex(substr($settings{'CMDreg_trbnetAddr'},2)); my $status2_ram3b_baseaddr_reg_addr = hex(substr($settings{'STATUS2RAM3BBASEADDRREGtrbnetAddr'},2)); my $status2_ram3b_addr = hex(substr($settings{'STATUS2RAM3BtrbnetAddr'},2)); + my $status_crcok_addr = hex(substr($settings{'STATUSCRCCHECKtrbnetAddr'},2)); my $stat_nibbles_addr = hex(substr($settings{'STAT_NIBBLEStrbnetAddr'},2)); + my $status2_started_addr = hex(substr($settings{'STATUS2STARTEDtrbnetAddr'},2)); # get status of last run: my $nibbles = trb_register_read(($fpga_addr), ($stat_nibbles_addr)); + print 'FPGA:'.sprintf("%X",$fpga_addr)."REG:".sprintf("%X", ($stat_nibbles_addr)); my $k=0, $v=0; - ($k, $v) = each %$nibbles; - my $last_run_successful = '(Last Run OK: '. substr(sprintf("%X", $v), 6, 1) . ')'; - + #($k, $v) = each %$nibbles; + $v = ${$nibbles}{$fpga_addr}; + print "Value:". $v . "\n"; #${$nibbles}{$fpga_addr}; + my $vstr = sprintf("%.8X", $v); + print "Value (hex):". $vstr . "\n"; #${$nibbles}{$fpga_addr}; + my $last_run_successful = '(Last Run OK: '. substr($vstr, 6, 1) ; + if(not (substr($vstr, 6, 1) == 1)) { + $errors_occured = 1; + } my @sensors; my @vert_list1; @@ -102,7 +112,37 @@ while (1){ my $botherrors = 0; my $minlastruncounter = 0; my $maxruncounter = 0; - foreach my $setting_name (reverse sort keys %settings) { + + # get number of sensors: + my $numsensors = 0; + foreach my $setting_name (sort keys %settings) { + if ($setting_name =~ /sensor[0-9]+/) { + $numsensors++; + } + } + # Get CRC Check Results + my $crc_ok = trb_register_read(($fpga_addr), ($status_crcok_addr)); + + ($k, $v) = each %$crc_ok; + if(2**$numsensors-1 == $v) { + $last_run_successful .= ', CRC OK: '. $numsensors . ' sensors,'; + } + else { + $last_run_successful .= ', CRC Error: '. sprintf('%.8X', $v) . ','; + $errors_occured = 1; + } + # Check if M26CS is STARTED (waiting for triggers) + my $is_started = trb_register_read(($fpga_addr), ($status2_started_addr)); + ($k, $v) = each %$is_started; + $vstr = sprintf("%.8X", $v); + print "Value (hex):". $vstr . "\n"; #${$nibbles}{$fpga_addr}; + $last_run_successful .= ' started: '. substr($vstr, 7, 1) . ')'; + if(not (substr($vstr, 7, 1) == 1)) { + $errors_occured = 1; + } + + + foreach my $setting_name (sort keys %settings) { if ($setting_name =~ /sensor[0-9]+/) { push(@sensors, $setting_name); my $i = (scalar @sensors)-1; @@ -218,6 +258,9 @@ while (1){ syslog("WARNING", "Only WRITE_ERROR and READ_ERROR $chain between runs $minlastruncounter and $maxruncounter. Power off?"); } $status_str .= Hmon::MakeTitle(8,5,$chain . $last_run_successful,1); + # Sensor 0 (first in status_table_row*) belongs at the end of the chain. + @status_table_row1 = reverse @status_table_row1; + @status_table_row2 = reverse @status_table_row2; my @table = [\@status_table_row1,\@status_table_row2]; $status_str .= colored_table(@table) . "
"; #print $status_str; @@ -234,7 +277,7 @@ while (1){ {"bgcolor"=>"#FFCC99", "text" => ""}, {"bgcolor"=>"#FF0000", "text" => ""}, {"bgcolor"=>"#99FF99", "text" => ""}]]; $status_str .= "

Legend

".colored_table(@legend_table) . "
"; $str = $status_str . $str; - if(!($run_counter_changed == 0)) { + if((!($run_counter_changed == 0))||$errors_occured != 0) { Hmon::WriteFile("jtagmonitor_usechainsini",$str); } -- 2.43.0