2
0
mirror of https://github.com/lm-sensors/lm-sensors synced 2025-08-31 14:25:39 +00:00

Merge sensors-detect-stat.pl functionality into sensors-detect. This

will be more reliable that way, and easier to maintain.


git-svn-id: http://lm-sensors.org/svn/lm-sensors/branches/lm-sensors-3.0.0@5512 7894878c-1315-0410-8ee3-d5d059ff63e0
This commit is contained in:
Jean Delvare
2008-12-03 13:44:26 +00:00
parent 17dea03489
commit 495275e1e3
3 changed files with 41 additions and 104 deletions

View File

@@ -4838,6 +4838,39 @@ sub c7temp_detect
return;
}
#################
# SPECIAL MODES #
#################
sub show_i2c_stats
{
my ($chip, $addr, %histo, $chips);
# Gather the data
foreach $chip (@chip_ids) {
next unless defined $chip->{i2c_addrs};
$chips++;
foreach my $addr (@{$chip->{i2c_addrs}}) {
$histo{$addr}++;
}
}
# Display the data
printf "\%d I2C chips known, \%d I2C addresses probed\n\n",
$chips, scalar keys %histo;
print " 0 1 2 3 4 5 6 7 8 9 a b c d e f\n".
"00: ";
for (my $addr = 0x03; $addr <= 0x77; $addr ++) {
printf("\n\%02x:", $addr) if ($addr % 16) == 0;
if (defined $histo{$addr}) {
printf ' %02d', $histo{$addr};
} else {
print ' --';
}
}
print "\n";
}
################
# MAIN PROGRAM #
################
@@ -4982,6 +5015,12 @@ sub main
{
my ($input, $superio_features);
# Handle special command line cases first
if (defined $ARGV[0] && $ARGV[0] eq "--stat") {
show_i2c_stats();
exit 0;
}
# We won't go very far if not root
unless ($> == 0) {
print "You need to be root to run this script.\n";