]> git.zerfleddert.de Git - rsbs2/commitdiff
show sensor values when boardstatus is requested
authorMichael Gernoth <michael@gernoth.net>
Sun, 8 Feb 2009 13:15:16 +0000 (14:15 +0100)
committerMichael Gernoth <michael@gernoth.net>
Sun, 8 Feb 2009 13:15:16 +0000 (14:15 +0100)
rsbs2.pl

index 4d09c1bde6e7b9f50eabf449300f96549f671b60..43f4986b2243ba8abd63e2d798d65088e28c239c 100755 (executable)
--- a/rsbs2.pl
+++ b/rsbs2.pl
@@ -282,8 +282,8 @@ sub show_boarddesc {
        my @board = split(//, $boarddesc);
        foreach my $byte (@board) {
                printf ("0x%02x ", ord($byte));
-}
-print "\n";
+       }
+       print "\n";
 }
 
 sub show_all_vars {
@@ -378,16 +378,51 @@ sub syslog_debug {
        print "Debug messages will be sent to ${destination_ip} (broadcast: ${bcast})\n";
 }
 
-sub sensors {
+sub get_sensors {
        my $slist= _cmd("sensorlist");
-       my %sens = ();
+       my @sensors;
 
        if ($slist->{RC} ne '0x0') {
                print "Error getting sensorlist: ".$slist->{RC}."\n";
                return;
        }
 
+       my $req = '<REQ CMD="sensorpropget"><HANDLE>0x1</HANDLE><SENSORLIST>';
        foreach my $s (@{$slist->{SENSORLIST}->{SENSOR}}) {
+               $req .= '<SENSOR KEY="'.$s->{KEY}.'"/>';
+       }
+       $req .= '</SENSORLIST></REQ>';
+
+       my $sprop = _req($req);
+       foreach my $s (@{$sprop->{RESP}->{SENSORLIST}->{SENSOR}}) {
+               my $sensor = {};
+               foreach my $sp (@{$s->{PROP}}) {
+                       $sensor->{$sp->{NAME}} = $sp->{VAL};
+               }
+
+               next if (!defined($sensor->{NAME}));
+               $sensor->{VAL} = '0' if ($sensor->{VAL} eq '');
+               push @sensors, $sensor;
+       }
+       @sensors;
+}
+
+sub show_sensors {
+       my @sensors = get_sensors();
+
+       foreach my $sensor (@sensors) {
+               print $sensor->{NAME}.": ".$sensor->{VAL}.$sensor->{UNITS}." ";
+
+               my @info = ();
+               foreach my $field qw(MIN MAX LOW_NON_CRITICAL UPPER_NON_CRITICAL LOW_CRITICAL UPPER_CRITICAL) {
+                       if ($sensor->{$field} ne '') {
+                               push @info, "${field}: ".$sensor->{$field}.$sensor->{UNITS};
+                       }
+               }
+
+               print " (".join(", ",@info).")" if (@info);
+
+               print "\n";
        }
 }
 
@@ -439,7 +474,7 @@ sub status {
                print "FW upgrade progress:\t${boardfwprogress}\n";
        }
        print "\nSensors:\n";
-       sensors();
+       show_sensors();
 }
 
 sub login {
Impressum, Datenschutz