| [5647] | 1 | .\" Copyright (C) 1998, 1999 Adrian Baugh <adrian.baugh@keble.ox.ac.uk> |
|---|
| 2 | .\" Copyright (C) 2007, 2009 Jean Delvare <khali@linux-fr.org> |
|---|
| [205] | 3 | .\" based on sensors.h, part of libsensors by Frodo Looijaard |
|---|
| [5844] | 4 | .\" libsensors is distributed under the LGPL |
|---|
| [205] | 5 | .\" |
|---|
| 6 | .\" Permission is granted to make and distribute verbatim copies of this |
|---|
| 7 | .\" manual provided the copyright notice and this permission notice are |
|---|
| 8 | .\" preserved on all copies. |
|---|
| 9 | .\" |
|---|
| 10 | .\" Permission is granted to copy and distribute modified versions of this |
|---|
| 11 | .\" manual under the conditions for verbatim copying, provided that the |
|---|
| 12 | .\" entire resulting derived work is distributed under the terms of a |
|---|
| 13 | .\" permission notice identical to this one |
|---|
| 14 | .\" |
|---|
| 15 | .\" Since the Linux kernel and libraries are constantly changing, this |
|---|
| 16 | .\" manual page may be incorrect or out-of-date. The author(s) assume no |
|---|
| 17 | .\" responsibility for errors or omissions, or for damages resulting from |
|---|
| 18 | .\" the use of the information contained herein. The author(s) may not |
|---|
| 19 | .\" have taken the same level of care in the production of this manual, |
|---|
| 20 | .\" which is licensed free of charge, as they might when working |
|---|
| 21 | .\" professionally. |
|---|
| 22 | .\" |
|---|
| 23 | .\" Formatted or processed versions of this manual, if unaccompanied by |
|---|
| 24 | .\" the source, must acknowledge the copyright and authors of this work. |
|---|
| 25 | .\" |
|---|
| 26 | .\" References consulted: |
|---|
| 27 | .\" libsensors source code |
|---|
| [5647] | 28 | .TH libsensors 3 "February 2009" "lm-sensors 3" "Linux Programmer's Manual" |
|---|
| [5650] | 29 | |
|---|
| [205] | 30 | .SH NAME |
|---|
| [4208] | 31 | libsensors \- publicly accessible functions provided by the sensors library |
|---|
| [5650] | 32 | |
|---|
| [205] | 33 | .SH SYNOPSIS |
|---|
| 34 | .nf |
|---|
| [2378] | 35 | .B #include <sensors/sensors.h> |
|---|
| [205] | 36 | |
|---|
| [5650] | 37 | /* Library initialization and clean-up */ |
|---|
| 38 | .BI "int sensors_init(FILE *" input ");" |
|---|
| [205] | 39 | .B void sensors_cleanup(void); |
|---|
| [5650] | 40 | .BI "const char *" libsensors_version ";" |
|---|
| 41 | |
|---|
| 42 | /* Chip name handling */ |
|---|
| 43 | .BI "int sensors_parse_chip_name(const char *" orig_name "," |
|---|
| 44 | .BI " sensors_chip_name *" res ");" |
|---|
| [5740] | 45 | .BI "void sensors_free_chip_name(sensors_chip_name *" chip ");" |
|---|
| [5653] | 46 | .BI "int sensors_snprintf_chip_name(char *" str ", size_t " size "," |
|---|
| 47 | .BI " const sensors_chip_name *" chip ");" |
|---|
| [5650] | 48 | .BI "const char *sensors_get_adapter_name(const sensors_bus_id *" bus ");" |
|---|
| 49 | |
|---|
| 50 | /* Chips and features enumeration */ |
|---|
| 51 | .B const sensors_chip_name * |
|---|
| 52 | .BI "sensors_get_detected_chips(const sensors_chip_name *" match "," |
|---|
| 53 | .BI " int *" nr ");" |
|---|
| 54 | .B const sensors_feature * |
|---|
| 55 | .BI "sensors_get_features(const sensors_chip_name *" name "," |
|---|
| 56 | .BI " int *" nr ");" |
|---|
| 57 | .B const sensors_subfeature * |
|---|
| 58 | .BI "sensors_get_all_subfeatures(const sensors_chip_name *" name "," |
|---|
| 59 | .BI " const sensors_feature *" feature "," |
|---|
| 60 | .BI " int *" nr ");" |
|---|
| 61 | .B const sensors_subfeature * |
|---|
| 62 | .BI "sensors_get_subfeature(const sensors_chip_name *" name "," |
|---|
| 63 | .BI " const sensors_feature *" feature "," |
|---|
| 64 | .BI " sensors_subfeature_type " type ");" |
|---|
| 65 | |
|---|
| 66 | /* Features access */ |
|---|
| 67 | .BI "char *sensors_get_label(const sensors_chip_name *" name "," |
|---|
| 68 | .BI " const sensors_feature *" feature ");" |
|---|
| 69 | .BI "int sensors_get_value(const sensors_chip_name *" name ", int " subfeat_nr "," |
|---|
| 70 | .BI " double *" value ");" |
|---|
| 71 | .BI "int sensors_set_value(const sensors_chip_name *" name ", int " subfeat_nr "," |
|---|
| 72 | .BI " double " value ");" |
|---|
| 73 | .BI "int sensors_do_chip_sets(const sensors_chip_name *" name ");" |
|---|
| [5654] | 74 | |
|---|
| 75 | .B #include <sensors/error.h> |
|---|
| 76 | |
|---|
| 77 | /* Error decoding */ |
|---|
| 78 | .BI "const char *sensors_strerror(int " errnum ");" |
|---|
| 79 | |
|---|
| 80 | /* Error handlers */ |
|---|
| 81 | .BI "void (*sensors_parse_error) (const char *" err ", int " lineno ");" |
|---|
| 82 | .BI "void (*sensors_parse_error_wfn) (const char *" err "," |
|---|
| 83 | .BI " const char *" filename ", int " lineno ");" |
|---|
| 84 | .BI "void (*sensors_fatal_error) (const char *" proc ", const char *" err ");" |
|---|
| [205] | 85 | .fi |
|---|
| [5650] | 86 | |
|---|
| [205] | 87 | .SH DESCRIPTION |
|---|
| [5651] | 88 | .B sensors_init() |
|---|
| 89 | loads the configuration file and the detected chips list. If this returns a |
|---|
| [4693] | 90 | value unequal to zero, you are in trouble; you can not assume anything will |
|---|
| 91 | be initialized properly. If you want to reload the configuration file, call |
|---|
| 92 | sensors_cleanup() below before calling sensors_init() again. |
|---|
| [205] | 93 | |
|---|
| [5647] | 94 | If FILE is NULL, the default configuration files are used (see the FILES |
|---|
| [4985] | 95 | section below). Most applications will want to do that. |
|---|
| 96 | |
|---|
| [5651] | 97 | .B sensors_cleanup() |
|---|
| 98 | cleans everything up: you can't access anything after this, until the next sensors_init() call! |
|---|
| [205] | 99 | |
|---|
| [5652] | 100 | .B libsensors_version |
|---|
| 101 | is a string representing the version of libsensors. |
|---|
| 102 | |
|---|
| [5651] | 103 | .B sensors_parse_chip_name() |
|---|
| 104 | parses a chip name to the internal representation. Return 0 on success, |
|---|
| [5740] | 105 | <0 on error. Make sure to call sensors_free_chip_name() when you're done |
|---|
| 106 | with the data. |
|---|
| [205] | 107 | |
|---|
| [5740] | 108 | .B sensors_free_chip_name() |
|---|
| 109 | frees the memory that may have been allocated for the internal |
|---|
| 110 | representation of a chip name. You only have to call this for chip |
|---|
| 111 | names which do not originate from libsensors itself (that is, chip |
|---|
| 112 | names which were generated by sensors_parse_chip_name()). |
|---|
| 113 | |
|---|
| [5653] | 114 | .B sensors_snprintf_chip_name() |
|---|
| 115 | prints a chip name from its internal representation. Note that chip should |
|---|
| 116 | not contain wildcard values! Return the number of characters printed on |
|---|
| 117 | success (same as snprintf), <0 on error. |
|---|
| 118 | |
|---|
| [5651] | 119 | .B sensors_get_adapter_name() |
|---|
| 120 | returns the adapter name of a bus number, as used within the |
|---|
| [4208] | 121 | sensors_chip_name structure. If it could not be found, it returns NULL. |
|---|
| 122 | |
|---|
| [5652] | 123 | .B sensors_get_detected_chips() |
|---|
| 124 | returns all detected chips that match a given chip name, |
|---|
| 125 | one by one. If no chip name is provided, all detected chips are returned. |
|---|
| 126 | To start at the beginning of the list, use 0 for nr; NULL is returned if |
|---|
| 127 | we are at the end of the list. Do not try to change these chip names, as |
|---|
| 128 | they point to internal structures! |
|---|
| 129 | |
|---|
| 130 | .B sensors_get_features() |
|---|
| 131 | returns all main features of a specific chip. nr is an internally |
|---|
| 132 | used variable. Set it to zero to start at the begin of the list. If no |
|---|
| 133 | more features are found NULL is returned. |
|---|
| 134 | Do not try to change the returned structure; you will corrupt internal |
|---|
| 135 | data structures. |
|---|
| 136 | |
|---|
| 137 | .B sensors_get_all_subfeatures() |
|---|
| 138 | returns all subfeatures of a given main feature. nr is an internally |
|---|
| 139 | used variable. Set it to zero to start at the begin of the list. If no |
|---|
| 140 | more subfeatures are found NULL is returned. |
|---|
| 141 | Do not try to change the returned structure; you will corrupt internal |
|---|
| 142 | data structures. |
|---|
| 143 | |
|---|
| 144 | .B sensors_get_subfeature() |
|---|
| 145 | returns the subfeature of the given type for a given main feature, |
|---|
| 146 | if it exists, NULL otherwise. |
|---|
| 147 | Do not try to change the returned structure; you will corrupt internal |
|---|
| 148 | data structures. |
|---|
| 149 | |
|---|
| [5651] | 150 | .B sensors_get_label() |
|---|
| 151 | looks up the label which belongs to this chip. Note that chip should not |
|---|
| [4694] | 152 | contain wildcard values! The returned string is newly allocated (free it |
|---|
| 153 | yourself). On failure, NULL is returned. |
|---|
| 154 | If no label exists for this feature, its name is returned itself. |
|---|
| [205] | 155 | |
|---|
| [5651] | 156 | .B sensors_get_value() |
|---|
| 157 | Reads the value of a subfeature of a certain chip. Note that chip should not |
|---|
| [4836] | 158 | contain wildcard values! This function will return 0 on success, and <0 on |
|---|
| 159 | failure. |
|---|
| [205] | 160 | |
|---|
| [5651] | 161 | .B sensors_set_value() |
|---|
| 162 | sets the value of a subfeature of a certain chip. Note that chip should not |
|---|
| [4836] | 163 | contain wildcard values! This function will return 0 on success, and <0 on |
|---|
| 164 | failure. |
|---|
| [205] | 165 | |
|---|
| [5651] | 166 | .B sensors_do_chip_sets() |
|---|
| 167 | executes all set statements for this particular chip. The chip may contain |
|---|
| 168 | wildcards! This function will return 0 on success, and <0 on failure. |
|---|
| [205] | 169 | |
|---|
| [5654] | 170 | .B sensors_strerror() |
|---|
| 171 | returns a pointer to a string which describes the error. |
|---|
| 172 | errnum may be negative (the corresponding positive error is returned). |
|---|
| 173 | You may not modify the result! |
|---|
| 174 | |
|---|
| 175 | .B sensors_parse_error() |
|---|
| 176 | and |
|---|
| 177 | .B sensors_parse_error_wfn() |
|---|
| 178 | are functions which are called when a parse error is detected. Give them |
|---|
| 179 | new values, and your own functions are called instead of the default (which |
|---|
| 180 | print to stderr). These functions may terminate the program, but they |
|---|
| 181 | usually output an error and return. The first function is the original |
|---|
| 182 | one, the second one was added later when support for multiple |
|---|
| 183 | configuration files was added. |
|---|
| 184 | The library code now only calls the second function. However, for |
|---|
| 185 | backwards compatibility, if an application provides a custom handling |
|---|
| 186 | function for the first function but not the second, then all parse |
|---|
| 187 | errors will be reported using the first function (that is, the filename |
|---|
| 188 | is never reported.) |
|---|
| 189 | Note that filename can be NULL (if filename isn't known) and lineno |
|---|
| 190 | can be 0 (if the error occurs before the actual parsing starts.) |
|---|
| 191 | |
|---|
| 192 | .B sensors_fatal_error() |
|---|
| 193 | Is a function which is called when an immediately fatal error (like no |
|---|
| 194 | memory left) is detected. Give it a new value, and your own function |
|---|
| 195 | is called instead of the default (which prints to stderr and ends |
|---|
| 196 | the program). Never let it return! |
|---|
| 197 | |
|---|
| [5652] | 198 | .SH DATA STRUCTURES |
|---|
| [205] | 199 | |
|---|
| [5652] | 200 | Structure \fBsensors_feature\fR contains information related to a given |
|---|
| 201 | feature of a specific chip: |
|---|
| 202 | |
|---|
| [4860] | 203 | \fBtypedef struct sensors_feature { |
|---|
| [205] | 204 | .br |
|---|
| [5651] | 205 | const char *name; |
|---|
| [4733] | 206 | .br |
|---|
| [5651] | 207 | int number; |
|---|
| [205] | 208 | .br |
|---|
| [5651] | 209 | sensors_feature_type type; |
|---|
| [4629] | 210 | .br |
|---|
| [4860] | 211 | } sensors_feature;\fP |
|---|
| 212 | |
|---|
| [5652] | 213 | There are other members not documented here, which are only meant for |
|---|
| 214 | libsensors internal use. |
|---|
| 215 | |
|---|
| 216 | Structure \fBsensors_subfeature\fR contains information related to a given |
|---|
| 217 | subfeature of a specific chip feature: |
|---|
| 218 | |
|---|
| [4860] | 219 | \fBtypedef struct sensors_subfeature { |
|---|
| 220 | .br |
|---|
| [5651] | 221 | const char *name; |
|---|
| [4860] | 222 | .br |
|---|
| [5651] | 223 | int number; |
|---|
| [4860] | 224 | .br |
|---|
| [5651] | 225 | sensors_subfeature_type type; |
|---|
| [4860] | 226 | .br |
|---|
| [5651] | 227 | int mapping; |
|---|
| [205] | 228 | .br |
|---|
| [5651] | 229 | unsigned int flags; |
|---|
| [205] | 230 | .br |
|---|
| [4832] | 231 | } sensors_subfeature;\fP |
|---|
| [5652] | 232 | |
|---|
| [4757] | 233 | The flags field is a bitfield, its value is a combination of |
|---|
| [5652] | 234 | \fBSENSORS_MODE_R\fR (readable), \fBSENSORS_MODE_W\fR (writable) and |
|---|
| 235 | \fBSENSORS_COMPUTE_MAPPING\fR (affected by the computation rules of the |
|---|
| 236 | main feature). |
|---|
| [205] | 237 | |
|---|
| [4985] | 238 | .SH FILES |
|---|
| [4990] | 239 | .I /etc/sensors3.conf |
|---|
| 240 | .br |
|---|
| [4985] | 241 | .I /etc/sensors.conf |
|---|
| 242 | .RS |
|---|
| 243 | The system-wide |
|---|
| 244 | .BR libsensors (3) |
|---|
| [4990] | 245 | configuration file. /etc/sensors3.conf is tried first, and if it doesn't exist, |
|---|
| 246 | /etc/sensors.conf is used instead. |
|---|
| [5647] | 247 | .RE |
|---|
| [4985] | 248 | |
|---|
| [5647] | 249 | .I /etc/sensors.d |
|---|
| 250 | .RS |
|---|
| 251 | A directory where you can put additional libsensors configuration files. |
|---|
| 252 | Files found in this directory will be processed in alphabetical order after |
|---|
| 253 | the default configuration file. Files with names that start with a dot are |
|---|
| 254 | ignored. |
|---|
| 255 | .RE |
|---|
| 256 | |
|---|
| [205] | 257 | .SH SEE ALSO |
|---|
| 258 | sensors.conf(5) |
|---|
| 259 | |
|---|
| [2456] | 260 | .SH AUTHOR |
|---|
| 261 | Frodo Looijaard and the lm_sensors group |
|---|
| [4157] | 262 | http://www.lm-sensors.org/ |
|---|
| [205] | 263 | |
|---|