From 4d758154c71835f6bbac395d43e56f5c35d37bde Mon Sep 17 00:00:00 2001 From: Jan Michel Date: Wed, 29 Oct 2014 17:46:12 +0100 Subject: [PATCH] dmon padiwa temperature monitor (not tested yet) --- dmon/scripts/dmon_padiwatemp.pl | 64 +++++++++++++++++++++++++++++++++ 1 file changed, 64 insertions(+) create mode 100755 dmon/scripts/dmon_padiwatemp.pl diff --git a/dmon/scripts/dmon_padiwatemp.pl b/dmon/scripts/dmon_padiwatemp.pl new file mode 100755 index 0000000..5c51aa9 --- /dev/null +++ b/dmon/scripts/dmon_padiwatemp.pl @@ -0,0 +1,64 @@ +#!/usr/bin/perl -w + +use warnings; +use lib "./code"; +use HADES::TrbNet; +use Dmon; +use Data::Dumper; + +my %config = do $ARGV[0]; + + + +sub sendcmd { + my ($cmd,$board,$chain) = @_; + my $c = [$cmd,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1<<$chain,0x10001]; + my $errcnt = 0; + while(1){ + trb_register_write_mem($board,0xd400,0,$c,scalar @{$c}); + if (trb_strerror() ne "No Error") { + sleep 1; + if($errcnt >= 12) { + die "SPI still blocked\n"; + } + elsif($errcnt++ >= 10) { + trb_register_read($board,0xd412); + } + } + else { + last; + } + } + return trb_register_read($board,0xd412); + } + + +while(1) { + my $r = sendcmd(0x10040000,0xfe48,0); + my $max = 1; + my $min = 100; + my ($maxboard, $minboard); + + foreach my $b (keys %$r) { + my $temp = (($r->{$b} & 0xFFF))/16; + next if ($temp < 10 || $temp > 90); + if ($max < $temp) { + $max = $temp; + $maxboard = $b; + } + elsif ($min > $temp) { + $min = $temp; + $minboard = $b; + } + } + + my $title = "Temperature"; + my $value = sprintf("%.1f",$max); + my $longtext = sprintf("Maximum: %.1f on board 0x%04x
Minimum: %.1f on board 0x%04x",$max,$maxboard,$min,$minboard); + my $status = Dmon::GetQAState('below',$max,(60,75,80)); + + + Dmon::WriteQALog($config{flog},"padiwatemp",30,$status,$title,$value,$longtext); + + sleep(15); +} -- 2.43.0