my @board = split(//, $boarddesc);
foreach my $byte (@board) {
printf ("0x%02x ", ord($byte));
-}
-print "\n";
+ }
+ print "\n";
}
sub show_all_vars {
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";
}
}
print "FW upgrade progress:\t${boardfwprogress}\n";
}
print "\nSensors:\n";
- sensors();
+ show_sensors();
}
sub login {