# 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;
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;
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) . "<br><!-- end status //-->";
#print $status_str;
{"bgcolor"=>"#FFCC99", "text" => ""}, {"bgcolor"=>"#FF0000", "text" => ""}, {"bgcolor"=>"#99FF99", "text" => ""}]];
$status_str .= "<h4>Legend</h4>".colored_table(@legend_table) . "<br><!-- end status //-->";
$str = $status_str . $str;
- if(!($run_counter_changed == 0)) {
+ if((!($run_counter_changed == 0))||$errors_occured != 0) {
Hmon::WriteFile("jtagmonitor_usechainsini",$str);
}