root/lm-sensors/branches/lm-sensors-3.0.0/doc/developers/applications @ 5056

Revision 5056, 3.0 KB (checked in by khali, 8 years ago)

Update the application writing guidelines:
* The drivers are no longer in this package.
* Drop all references to i2c, these aren't related to sensors per se and
belong elsewhere.
* Random updates, fix broken references, clarify some parts.
* Add references to the relevant manual pages.
* Drop references to freshmeat, they don't really help.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
[5056]1How to write applications which use the hwmon drivers
[5056]4You have several choices in accessing sensor devices using the hwmon drivers.
5This document will briefly describe these methods, their advantages and
6disadvantages, and provide examples.
8From lowest-level to the highest-level, the access methods are:
[5056]10   1. sysfs access
11   2. libsensors library
12   3. sensors program
[5056]171. sysfs access
[5056]19   Hwmon drivers create subdirectories in the sysfs filesystem (usually /sys)
20   which can be accessed directly by applications.
[2142]21   Naming and content standards for the entries in these subdirectories
[5056]22   are documented in the file Documentation/hwmon/sysfs-interface in the 2.6
23   kernel source tree. sysfs is the lowest-level access to sensor values.
25   Note that most drivers provide only raw sensor readings via /sys;
26   many readings must be scaled or adjusted, and these adjustments
[4484]27   must often be changed by the user. An application using /sys must
[2142]28   generally provide adjustment facilities and the requirements
[5056]29   of the adjustments can be quite complex. For this reason, this
30   approach isn't recommended. Instead, consider the libsensors library,
31   which offers a higher-level interface on top of sysfs (see below.)
[5056]33   Still, this method may work well for shell and perl scripts written to
34   access a specific device.
[5056]36   For an example of a program using /sys accesses, see gkrellm (though
37   recent versions use libsensors instead.) See also lib/sysfs.c.
[5056]392. libsensors library
41   The libsensors library provides standardized access to all chip drivers.
42   It also provides a translation layer with settings in /etc/sensors.conf
43   so that your application sees adjusted (scaled) values using settings
[5056]44   provided by the user. Other facilities are sensor labelling, limit setting,
45   and ignoring individual sensors. This is the recommended way to access
46   the sensor chips.
[5056]48   The library API is documented in the libsensors(3) manual page. The
49   configuration file format is documented in the sensors.conf(5) manual
50   page.
52   Note that libsensors falls under the GPL, not the LGPL.
53   In more human language, that means it is FORBIDDEN to link any application
54   to the library, even to the shared version, if the application itself
55   does not fall under the GPL. This may or may not be changed in the future.
56   Contact us if you wish to discuss your application.
[5056]58   For examples of programs using libsensors accesses, see prog/sensors and
59   prog/sensord.
[5056]613. sensors program
63   The 'sensors' program is a text-based application that uses libsensors.
64   The output is fairly standardized; therefore this output could be
65   used by other applications.
66   One simple method is 'sensors|grep ALARM'.
[5056]67   Note though that there is no guarantee that the output format won't change
68   in the future, so be careful. We might improve the command-line interface
69   of 'sensors' someday to make it more convenient for external programs to
70   use it as a back-end.
Note: See TracBrowser for help on using the browser.