Blame lib/libsensors.3

Packit 53d5b6
.\" Copyright (C) 1998, 1999  Adrian Baugh <adrian.baugh@keble.ox.ac.uk>
Packit 53d5b6
.\" Copyright (C) 2007, 2009, 2013  Jean Delvare <jdelvare@suse.de>
Packit 53d5b6
.\" based on sensors.h, part of libsensors by Frodo Looijaard
Packit 53d5b6
.\" libsensors is distributed under the LGPL
Packit 53d5b6
.\"
Packit 53d5b6
.\" Permission is granted to make and distribute verbatim copies of this
Packit 53d5b6
.\" manual provided the copyright notice and this permission notice are
Packit 53d5b6
.\" preserved on all copies.
Packit 53d5b6
.\"
Packit 53d5b6
.\" Permission is granted to copy and distribute modified versions of this
Packit 53d5b6
.\" manual under the conditions for verbatim copying, provided that the
Packit 53d5b6
.\" entire resulting derived work is distributed under the terms of a
Packit 53d5b6
.\" permission notice identical to this one
Packit 53d5b6
.\" 
Packit 53d5b6
.\" Since the Linux kernel and libraries are constantly changing, this
Packit 53d5b6
.\" manual page may be incorrect or out-of-date.  The author(s) assume no
Packit 53d5b6
.\" responsibility for errors or omissions, or for damages resulting from
Packit 53d5b6
.\" the use of the information contained herein.  The author(s) may not
Packit 53d5b6
.\" have taken the same level of care in the production of this manual,
Packit 53d5b6
.\" which is licensed free of charge, as they might when working
Packit 53d5b6
.\" professionally.
Packit 53d5b6
.\" 
Packit 53d5b6
.\" Formatted or processed versions of this manual, if unaccompanied by
Packit 53d5b6
.\" the source, must acknowledge the copyright and authors of this work.
Packit 53d5b6
.\"
Packit 53d5b6
.\" References consulted:
Packit 53d5b6
.\"     libsensors source code
Packit 53d5b6
.TH libsensors 3  "September 2013" "lm-sensors 3" "Linux Programmer's Manual"
Packit 53d5b6
Packit 53d5b6
.SH NAME
Packit 53d5b6
libsensors \- publicly accessible functions provided by the sensors library
Packit 53d5b6
Packit 53d5b6
.SH SYNOPSIS
Packit 53d5b6
.nf
Packit 53d5b6
.B #include <sensors/sensors.h>
Packit 53d5b6
Packit 53d5b6
/* Library initialization and clean-up */
Packit 53d5b6
.BI "int sensors_init(FILE *" input ");"
Packit 53d5b6
.B void sensors_cleanup(void);
Packit 53d5b6
.BI "const char *" libsensors_version ";"
Packit 53d5b6
Packit 53d5b6
/* Chip name handling */
Packit 53d5b6
.BI "int sensors_parse_chip_name(const char *" orig_name ","
Packit 53d5b6
.BI "                            sensors_chip_name *" res ");"
Packit 53d5b6
.BI "void sensors_free_chip_name(sensors_chip_name *" chip ");"
Packit 53d5b6
.BI "int sensors_snprintf_chip_name(char *" str ", size_t " size ","
Packit 53d5b6
.BI "                               const sensors_chip_name *" chip ");"
Packit 53d5b6
.BI "const char *sensors_get_adapter_name(const sensors_bus_id *" bus ");"
Packit 53d5b6
Packit 53d5b6
/* Chips and features enumeration */
Packit 53d5b6
.B const sensors_chip_name *
Packit 53d5b6
.BI "sensors_get_detected_chips(const sensors_chip_name *" match ","
Packit 53d5b6
.BI "                           int *" nr ");"
Packit 53d5b6
.B const sensors_feature *
Packit 53d5b6
.BI "sensors_get_features(const sensors_chip_name *" name ","
Packit 53d5b6
.BI "                     int *" nr ");"
Packit 53d5b6
.B const sensors_subfeature *
Packit 53d5b6
.BI "sensors_get_all_subfeatures(const sensors_chip_name *" name ","
Packit 53d5b6
.BI "                            const sensors_feature *" feature ","
Packit 53d5b6
.BI "                            int *" nr ");"
Packit 53d5b6
.B const sensors_subfeature *
Packit 53d5b6
.BI "sensors_get_subfeature(const sensors_chip_name *" name ","
Packit 53d5b6
.BI "                       const sensors_feature *" feature ","
Packit 53d5b6
.BI "                       sensors_subfeature_type " type ");"
Packit 53d5b6
Packit 53d5b6
/* Features access */
Packit 53d5b6
.BI "char *sensors_get_label(const sensors_chip_name *" name ","
Packit 53d5b6
.BI "                        const sensors_feature *" feature ");"
Packit 53d5b6
.BI "int sensors_get_value(const sensors_chip_name *" name ", int " subfeat_nr ","
Packit 53d5b6
.BI "                      double *" value ");"
Packit 53d5b6
.BI "int sensors_set_value(const sensors_chip_name *" name ", int " subfeat_nr ","
Packit 53d5b6
.BI "                      double " value ");"
Packit 53d5b6
.BI "int sensors_do_chip_sets(const sensors_chip_name *" name ");"
Packit 53d5b6
Packit 53d5b6
.B #include <sensors/error.h>
Packit 53d5b6
Packit 53d5b6
/* Error decoding */
Packit 53d5b6
.BI "const char *sensors_strerror(int " errnum ");"
Packit 53d5b6
Packit 53d5b6
/* Error handlers */
Packit 53d5b6
.BI "void (*sensors_parse_error) (const char *" err ", int " lineno ");"
Packit 53d5b6
.BI "void (*sensors_parse_error_wfn) (const char *" err ","
Packit 53d5b6
.BI "                                 const char *" filename ", int " lineno ");"
Packit 53d5b6
.BI "void (*sensors_fatal_error) (const char *" proc ", const char *" err ");"
Packit 53d5b6
.fi
Packit 53d5b6
Packit 53d5b6
.SH DESCRIPTION
Packit 53d5b6
.B sensors_init()
Packit 53d5b6
loads the configuration file and the detected chips list. If this returns a
Packit 53d5b6
value unequal to zero, you are in trouble; you can not assume anything will
Packit 53d5b6
be initialized properly. If you want to reload the configuration file, or
Packit 53d5b6
load a different configuration file, call sensors_cleanup() below before
Packit 53d5b6
calling sensors_init() again. This means you can't load multiple configuration
Packit 53d5b6
files at once by calling sensors_init() multiple times.
Packit 53d5b6
Packit 53d5b6
The configuration file format is described in sensors.conf(5).
Packit 53d5b6
Packit 53d5b6
If FILE is NULL, the default configuration files are used (see the FILES
Packit 53d5b6
section below). Most applications will want to do that.
Packit 53d5b6
Packit 53d5b6
.B sensors_cleanup()
Packit 53d5b6
cleans everything up: you can't access anything after this, until the next sensors_init() call!
Packit 53d5b6
Packit 53d5b6
.B libsensors_version
Packit 53d5b6
is a string representing the version of libsensors.
Packit 53d5b6
Packit 53d5b6
.B sensors_parse_chip_name()
Packit 53d5b6
parses a chip name to the internal representation. Return 0 on success,
Packit 53d5b6
<0 on error. Make sure to call sensors_free_chip_name() when you're done
Packit 53d5b6
with the data.
Packit 53d5b6
Packit 53d5b6
.B sensors_free_chip_name()
Packit 53d5b6
frees the memory that may have been allocated for the internal
Packit 53d5b6
representation of a chip name. You only have to call this for chip
Packit 53d5b6
names which do not originate from libsensors itself (that is, chip
Packit 53d5b6
names which were generated by sensors_parse_chip_name()).
Packit 53d5b6
Packit 53d5b6
.B sensors_snprintf_chip_name()
Packit 53d5b6
prints a chip name from its internal representation. Note that chip should
Packit 53d5b6
not contain wildcard values! Return the number of characters printed on
Packit 53d5b6
success (same as snprintf), <0 on error.
Packit 53d5b6
Packit 53d5b6
.B sensors_get_adapter_name()
Packit 53d5b6
returns the adapter name of a bus type, number pair, as used within the
Packit 53d5b6
sensors_chip_name structure. If it could not be found, it returns NULL.
Packit 53d5b6
Packit 53d5b6
Adapters describe how a monitoring chip is hooked up to the system.
Packit 53d5b6
This is particularly relevant for I2C/SMBus sensor chips (bus type "i2c"),
Packit 53d5b6
which must be accessed over an I2C/SMBus controller. Each such controller
Packit 53d5b6
has a different number, assigned by the system at initialization time,
Packit 53d5b6
so that they can be referenced individually.
Packit 53d5b6
Packit 53d5b6
Super\-I/O or CPU\-embedded sensors, on the other hand, can be accessed
Packit 53d5b6
directly and technically don't use any adapter. They have only a bus type
Packit 53d5b6
but no bus number, and sensors_get_adapter_name() will return a generic
Packit 53d5b6
adapter name for them.
Packit 53d5b6
Packit 53d5b6
.B sensors_get_detected_chips()
Packit 53d5b6
returns all detected chips that match a given chip name,
Packit 53d5b6
one by one. If no chip name is provided, all detected chips are returned.
Packit 53d5b6
To start at the beginning of the list, use 0 for nr; NULL is returned if
Packit 53d5b6
we are at the end of the list. Do not try to change these chip names, as
Packit 53d5b6
they point to internal structures!
Packit 53d5b6
Packit 53d5b6
.B sensors_get_features()
Packit 53d5b6
returns all main features of a specific chip. nr is an internally
Packit 53d5b6
used variable. Set it to zero to start at the begin of the list. If no
Packit 53d5b6
more features are found NULL is returned.
Packit 53d5b6
Do not try to change the returned structure; you will corrupt internal
Packit 53d5b6
data structures.
Packit 53d5b6
Packit 53d5b6
.B sensors_get_all_subfeatures()
Packit 53d5b6
returns all subfeatures of a given main feature. nr is an internally
Packit 53d5b6
used variable. Set it to zero to start at the begin of the list. If no
Packit 53d5b6
more subfeatures are found NULL is returned.
Packit 53d5b6
Do not try to change the returned structure; you will corrupt internal
Packit 53d5b6
data structures.
Packit 53d5b6
Packit 53d5b6
.B sensors_get_subfeature()
Packit 53d5b6
returns the subfeature of the given type for a given main feature,
Packit 53d5b6
if it exists, NULL otherwise.
Packit 53d5b6
Do not try to change the returned structure; you will corrupt internal
Packit 53d5b6
data structures.
Packit 53d5b6
Packit 53d5b6
.B sensors_get_label()
Packit 53d5b6
looks up the label which belongs to this chip. Note that chip should not
Packit 53d5b6
contain wildcard values! The returned string is newly allocated (free it
Packit 53d5b6
yourself). On failure, NULL is returned.
Packit 53d5b6
If no label exists for this feature, its name is returned itself.
Packit 53d5b6
Packit 53d5b6
.B sensors_get_value()
Packit 53d5b6
Reads the value of a subfeature of a certain chip. Note that chip should not
Packit 53d5b6
contain wildcard values! This function will return 0 on success, and <0 on
Packit 53d5b6
failure.
Packit 53d5b6
Packit 53d5b6
.B sensors_set_value()
Packit 53d5b6
sets the value of a subfeature of a certain chip. Note that chip should not
Packit 53d5b6
contain wildcard values! This function will return 0 on success, and <0 on
Packit 53d5b6
failure.
Packit 53d5b6
Packit 53d5b6
.B sensors_do_chip_sets()
Packit 53d5b6
executes all set statements for this particular chip. The chip may contain
Packit 53d5b6
wildcards!  This function will return 0 on success, and <0 on failure.
Packit 53d5b6
Packit 53d5b6
.B sensors_strerror()
Packit 53d5b6
returns a pointer to a string which describes the error.
Packit 53d5b6
errnum may be negative (the corresponding positive error is returned).
Packit 53d5b6
You may not modify the result!
Packit 53d5b6
Packit 53d5b6
.B sensors_parse_error()
Packit 53d5b6
and
Packit 53d5b6
.B sensors_parse_error_wfn()
Packit 53d5b6
are functions which are called when a parse error is detected. Give them
Packit 53d5b6
new values, and your own functions are called instead of the default (which
Packit 53d5b6
print to stderr). These functions may terminate the program, but they
Packit 53d5b6
usually output an error and return. The first function is the original
Packit 53d5b6
one, the second one was added later when support for multiple
Packit 53d5b6
configuration files was added.
Packit 53d5b6
The library code now only calls the second function. However, for
Packit 53d5b6
backwards compatibility, if an application provides a custom handling
Packit 53d5b6
function for the first function but not the second, then all parse
Packit 53d5b6
errors will be reported using the first function (that is, the filename
Packit 53d5b6
is never reported.)
Packit 53d5b6
Note that filename can be NULL (if filename isn't known) and lineno
Packit 53d5b6
can be 0 (if the error occurs before the actual parsing starts.)
Packit 53d5b6
Packit 53d5b6
.B sensors_fatal_error()
Packit 53d5b6
Is a function which is called when an immediately fatal error (like no
Packit 53d5b6
memory left) is detected. Give it a new value, and your own function
Packit 53d5b6
is called instead of the default (which prints to stderr and ends
Packit 53d5b6
the program). Never let it return!
Packit 53d5b6
Packit 53d5b6
.SH DATA STRUCTURES
Packit 53d5b6
Packit 53d5b6
Structure \fBsensors_chip_name\fR contains information related to a
Packit 53d5b6
specific chip.
Packit 53d5b6
Packit 53d5b6
\fBtypedef struct sensors_chip_name {
Packit 53d5b6
.br
Packit 53d5b6
	sensors_bus_id bus;
Packit 53d5b6
.br
Packit 53d5b6
} sensors_chip_name;\fP
Packit 53d5b6
Packit 53d5b6
There are other members not documented here, which are only meant for
Packit 53d5b6
libsensors internal use.
Packit 53d5b6
Packit 53d5b6
Structure \fBsensors_feature\fR contains information related to a given
Packit 53d5b6
feature of a specific chip:
Packit 53d5b6
Packit 53d5b6
\fBtypedef struct sensors_feature {
Packit 53d5b6
.br
Packit 53d5b6
	const char *name;
Packit 53d5b6
.br
Packit 53d5b6
	int number;
Packit 53d5b6
.br
Packit 53d5b6
	sensors_feature_type type;
Packit 53d5b6
.br
Packit 53d5b6
} sensors_feature;\fP
Packit 53d5b6
Packit 53d5b6
There are other members not documented here, which are only meant for
Packit 53d5b6
libsensors internal use.
Packit 53d5b6
Packit 53d5b6
Structure \fBsensors_subfeature\fR contains information related to a given
Packit 53d5b6
subfeature of a specific chip feature:
Packit 53d5b6
Packit 53d5b6
\fBtypedef struct sensors_subfeature {
Packit 53d5b6
.br
Packit 53d5b6
	const char *name;
Packit 53d5b6
.br
Packit 53d5b6
	int number;
Packit 53d5b6
.br
Packit 53d5b6
	sensors_subfeature_type type;
Packit 53d5b6
.br
Packit 53d5b6
	int mapping;
Packit 53d5b6
.br
Packit 53d5b6
	unsigned int flags;
Packit 53d5b6
.br
Packit 53d5b6
} sensors_subfeature;\fP
Packit 53d5b6
Packit 53d5b6
The flags field is a bitfield, its value is a combination of
Packit 53d5b6
\fBSENSORS_MODE_R\fR (readable), \fBSENSORS_MODE_W\fR (writable) and
Packit 53d5b6
\fBSENSORS_COMPUTE_MAPPING\fR (affected by the computation rules of the
Packit 53d5b6
main feature).
Packit 53d5b6
Packit 53d5b6
.SH FILES
Packit 53d5b6
.I /etc/sensors3.conf
Packit 53d5b6
.br
Packit 53d5b6
.I /etc/sensors.conf
Packit 53d5b6
.RS
Packit 53d5b6
The system-wide
Packit 53d5b6
.BR libsensors (3)
Packit 53d5b6
configuration file. /etc/sensors3.conf is tried first, and if it doesn't exist,
Packit 53d5b6
/etc/sensors.conf is used instead.
Packit 53d5b6
.RE
Packit 53d5b6
Packit 53d5b6
.I /etc/sensors.d
Packit 53d5b6
.RS
Packit 53d5b6
A directory where you can put additional libsensors configuration files.
Packit 53d5b6
Files found in this directory will be processed in alphabetical order after
Packit 53d5b6
the default configuration file. Files with names that start with a dot are
Packit 53d5b6
ignored.
Packit 53d5b6
.RE
Packit 53d5b6
Packit 53d5b6
.SH SEE ALSO
Packit 53d5b6
sensors.conf(5)
Packit 53d5b6
Packit 53d5b6
.SH AUTHOR
Packit 53d5b6
Frodo Looijaard, Jean Delvare and others
Packit 53d5b6
http://www.lm-sensors.org/
Packit 53d5b6