root/lm-sensors/trunk/doc/developers/applications

Revision 5056, 3.0 KB (checked in by khali, 7 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
Line 
1How to write applications which use the hwmon drivers
2=====================================================
3
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.
7
8From lowest-level to the highest-level, the access methods are:
9
10   1. sysfs access
11   2. libsensors library
12   3. sensors program
13
14
15Details:
16
171. sysfs access
18---------------
19   Hwmon drivers create subdirectories in the sysfs filesystem (usually /sys)
20   which can be accessed directly by applications.
21   Naming and content standards for the entries in these subdirectories
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.
24
25   Note that most drivers provide only raw sensor readings via /sys;
26   many readings must be scaled or adjusted, and these adjustments
27   must often be changed by the user. An application using /sys must
28   generally provide adjustment facilities and the requirements
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.)
32
33   Still, this method may work well for shell and perl scripts written to
34   access a specific device.
35
36   For an example of a program using /sys accesses, see gkrellm (though
37   recent versions use libsensors instead.) See also lib/sysfs.c.
38
392. libsensors library
40---------------------
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
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.
47
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.
51
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.
57
58   For examples of programs using libsensors accesses, see prog/sensors and
59   prog/sensord.
60
613. sensors program
62------------------
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'.
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.