mirror of
https://github.com/lm-sensors/lm-sensors
synced 2025-09-03 15:55:15 +00:00
New sensors option: --bus-list. This option lists i2c buses that are
used by sensor chips on the running system, in a format suitable for sensors.conf. This is a replacement for the old, broken grab_busses.sh script. Benefits of having this directly in sensors: * It lists only the i2c buses that are relevant to sensors. * sensors is installed by default, while most people didn't have access to grab_busses.sh. git-svn-id: http://lm-sensors.org/svn/lm-sensors/branches/lm-sensors-3.0.0@4781 7894878c-1315-0410-8ee3-d5d059ff63e0
This commit is contained in:
1
CHANGES
1
CHANGES
@@ -55,6 +55,7 @@ SVN HEAD
|
|||||||
Fix alignment of alarm for one-limit temperatures
|
Fix alignment of alarm for one-limit temperatures
|
||||||
Drop option -U
|
Drop option -U
|
||||||
Fix a memory leak on error (with -u)
|
Fix a memory leak on error (with -u)
|
||||||
|
New option --bus-list
|
||||||
Program sensors-detect: Stop Super-I/O probe after first family success
|
Program sensors-detect: Stop Super-I/O probe after first family success
|
||||||
Fix SMSC DME1737 detection
|
Fix SMSC DME1737 detection
|
||||||
Add /usr/sbin to the PATH (#2199)
|
Add /usr/sbin to the PATH (#2199)
|
||||||
|
@@ -237,9 +237,7 @@
|
|||||||
#
|
#
|
||||||
# chip "lm75-i2c-0-*"
|
# chip "lm75-i2c-0-*"
|
||||||
#
|
#
|
||||||
# You should really use the output of /proc/bus/chips to generate bus lines,
|
# You can use "sensors --bus-list" to generate bus lines for your system.
|
||||||
# because one mistyped characted will inhibit the match. Wildcards are not
|
|
||||||
# yet supported; spaces at the end are ignored, though.
|
|
||||||
#
|
#
|
||||||
#
|
#
|
||||||
# BEEPS
|
# BEEPS
|
||||||
|
@@ -59,6 +59,7 @@ static void print_long_help(void)
|
|||||||
" -s, --set Execute `set' statements (root only)\n"
|
" -s, --set Execute `set' statements (root only)\n"
|
||||||
" -f, --fahrenheit Show temperatures in degrees fahrenheit\n"
|
" -f, --fahrenheit Show temperatures in degrees fahrenheit\n"
|
||||||
" -A, --no-adapter Do not show adapter for each chip\n"
|
" -A, --no-adapter Do not show adapter for each chip\n"
|
||||||
|
" --bus-list Generate bus statements for sensors.conf\n"
|
||||||
" -u Raw output (debugging only)\n"
|
" -u Raw output (debugging only)\n"
|
||||||
" -v, --version Display the program version\n"
|
" -v, --version Display the program version\n"
|
||||||
"\n"
|
"\n"
|
||||||
@@ -207,9 +208,35 @@ static int do_the_real_work(const sensors_chip_name *match, int *error)
|
|||||||
return cnt;
|
return cnt;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* List the buses in a format suitable for sensors.conf. We only list
|
||||||
|
bus types for which bus statements are actually useful and supported.
|
||||||
|
Known bug: i2c buses with number >= 32 or 64 could be listed several
|
||||||
|
times. Very unlikely to ever happen, though. */
|
||||||
|
static void print_bus_list(void)
|
||||||
|
{
|
||||||
|
const sensors_chip_name *chip;
|
||||||
|
int chip_nr;
|
||||||
|
unsigned long seen_i2c = 0;
|
||||||
|
|
||||||
|
chip_nr = 0;
|
||||||
|
while ((chip = sensors_get_detected_chips(NULL, &chip_nr))) {
|
||||||
|
switch (chip->bus.type) {
|
||||||
|
case SENSORS_BUS_TYPE_I2C:
|
||||||
|
if (chip->bus.nr < (int)sizeof(unsigned long) * 8) {
|
||||||
|
if (seen_i2c & (1 << chip->bus.nr))
|
||||||
|
break;
|
||||||
|
seen_i2c |= 1 << chip->bus.nr;
|
||||||
|
}
|
||||||
|
printf("bus \"i2c-%d\" \"%s\"\n", chip->bus.nr,
|
||||||
|
sensors_get_adapter_name(&chip->bus));
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
int main(int argc, char *argv[])
|
int main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
int c, res, i, error;
|
int c, res, i, error, do_bus_list;
|
||||||
const char *config_file_name = DEFAULT_CONFIG_FILE;
|
const char *config_file_name = DEFAULT_CONFIG_FILE;
|
||||||
|
|
||||||
struct option long_opts[] = {
|
struct option long_opts[] = {
|
||||||
@@ -219,6 +246,7 @@ int main(int argc, char *argv[])
|
|||||||
{ "fahrenheit", no_argument, NULL, 'f' },
|
{ "fahrenheit", no_argument, NULL, 'f' },
|
||||||
{ "no-adapter", no_argument, NULL, 'A' },
|
{ "no-adapter", no_argument, NULL, 'A' },
|
||||||
{ "config-file", required_argument, NULL, 'c' },
|
{ "config-file", required_argument, NULL, 'c' },
|
||||||
|
{ "bus-list", no_argument, NULL, 'B' },
|
||||||
{ 0, 0, 0, 0 }
|
{ 0, 0, 0, 0 }
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -226,6 +254,7 @@ int main(int argc, char *argv[])
|
|||||||
|
|
||||||
do_raw = 0;
|
do_raw = 0;
|
||||||
do_sets = 0;
|
do_sets = 0;
|
||||||
|
do_bus_list = 0;
|
||||||
hide_adapter = 0;
|
hide_adapter = 0;
|
||||||
while (1) {
|
while (1) {
|
||||||
c = getopt_long(argc, argv, "hsvfAc:u", long_opts, NULL);
|
c = getopt_long(argc, argv, "hsvfAc:u", long_opts, NULL);
|
||||||
@@ -257,6 +286,9 @@ int main(int argc, char *argv[])
|
|||||||
case 'u':
|
case 'u':
|
||||||
do_raw = 1;
|
do_raw = 1;
|
||||||
break;
|
break;
|
||||||
|
case 'B':
|
||||||
|
do_bus_list = 1;
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
fprintf(stderr,
|
fprintf(stderr,
|
||||||
"Internal error while parsing options!\n");
|
"Internal error while parsing options!\n");
|
||||||
@@ -271,7 +303,9 @@ int main(int argc, char *argv[])
|
|||||||
/* build the degrees string */
|
/* build the degrees string */
|
||||||
set_degstr();
|
set_degstr();
|
||||||
|
|
||||||
if (optind == argc) { /* No chip name on command line */
|
if (do_bus_list) {
|
||||||
|
print_bus_list();
|
||||||
|
} else if (optind == argc) { /* No chip name on command line */
|
||||||
if (!do_the_real_work(NULL, &error)) {
|
if (!do_the_real_work(NULL, &error)) {
|
||||||
fprintf(stderr,
|
fprintf(stderr,
|
||||||
"No sensors found!\n"
|
"No sensors found!\n"
|
||||||
|
@@ -22,7 +22,7 @@
|
|||||||
.\" Formatted or processed versions of this manual, if unaccompanied by
|
.\" Formatted or processed versions of this manual, if unaccompanied by
|
||||||
.\" the source, must acknowledge the copyright and authors of this work.
|
.\" the source, must acknowledge the copyright and authors of this work.
|
||||||
.\"
|
.\"
|
||||||
.TH sensors 1 "August 2007" "lm-sensors 3" "Linux User's Manual"
|
.TH sensors 1 "September 2007" "lm-sensors 3" "Linux User's Manual"
|
||||||
.SH NAME
|
.SH NAME
|
||||||
sensors \- print sensors information
|
sensors \- print sensors information
|
||||||
.SH SYNOPSIS
|
.SH SYNOPSIS
|
||||||
@@ -33,10 +33,10 @@ sensors \- print sensors information
|
|||||||
.B ]
|
.B ]
|
||||||
.br
|
.br
|
||||||
.B sensors -s [
|
.B sensors -s [
|
||||||
.I options
|
|
||||||
.B ] [
|
|
||||||
.I chips
|
.I chips
|
||||||
.B ]
|
.B ]
|
||||||
|
.br
|
||||||
|
.B sensors --bus-list
|
||||||
|
|
||||||
.SH DESCRIPTION
|
.SH DESCRIPTION
|
||||||
.B sensors
|
.B sensors
|
||||||
@@ -44,6 +44,9 @@ is used to show the current readings of all sensor chips.
|
|||||||
.br
|
.br
|
||||||
.B sensors -s
|
.B sensors -s
|
||||||
is used to set all limits as specified in the configuration file.
|
is used to set all limits as specified in the configuration file.
|
||||||
|
.br
|
||||||
|
.B sensors --bus-list
|
||||||
|
is used to generate bus statements suitable for the configuration file.
|
||||||
|
|
||||||
.SH OPTIONS
|
.SH OPTIONS
|
||||||
.IP "-c config-file"
|
.IP "-c config-file"
|
||||||
@@ -64,6 +67,12 @@ Raw output. This mode is only meant for debugging.
|
|||||||
Print the program version and exit.
|
Print the program version and exit.
|
||||||
.IP -f
|
.IP -f
|
||||||
Print the temperatures in degrees Fahrenheit instead of Celsius.
|
Print the temperatures in degrees Fahrenheit instead of Celsius.
|
||||||
|
.IP --bus-list
|
||||||
|
Generate bus statements suitable for using in sensors.conf. Such bus statements
|
||||||
|
are only needed if you have several chips sharing the same address on different
|
||||||
|
buses of the same type. As bus numbers are usually not guaranteed to be stable
|
||||||
|
over reboots, these statements let you refer to each bus by its name rather
|
||||||
|
than numbers.
|
||||||
.SH FILES
|
.SH FILES
|
||||||
.I /etc/sensors.conf
|
.I /etc/sensors.conf
|
||||||
.RS
|
.RS
|
||||||
|
Reference in New Issue
Block a user