root/lm-sensors/trunk/lib/sensors.h
| Revision 4979, 6.3 kB (checked in by jwrdegoede, 1 year ago) | |
|---|---|
| |
| Line | |
|---|---|
| 1 | /* |
| 2 | sensors.h - Part of libsensors, a Linux library for reading sensor data. |
| 3 | Copyright (c) 1998, 1999 Frodo Looijaard <frodol@dds.nl> |
| 4 | |
| 5 | This program is free software; you can redistribute it and/or modify |
| 6 | it under the terms of the GNU General Public License as published by |
| 7 | the Free Software Foundation; either version 2 of the License, or |
| 8 | (at your option) any later version. |
| 9 | |
| 10 | This program is distributed in the hope that it will be useful, |
| 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 13 | GNU General Public License for more details. |
| 14 | |
| 15 | You should have received a copy of the GNU General Public License |
| 16 | along with this program; if not, write to the Free Software |
| 17 | Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
| 18 | */ |
| 19 | |
| 20 | #ifndef LIB_SENSORS_SENSORS_H |
| 21 | #define LIB_SENSORS_SENSORS_H |
| 22 | |
| 23 | #include <stdio.h> |
| 24 | |
| 25 | /* Publicly accessible library functions */ |
| 26 | |
| 27 | /* libsensors API version define, first digit is the major version (changed |
| 28 | when the API + ABI breaks), the third digit is incremented to track small |
| 29 | API additions like new flags / enum values. The second digit is for tracking |
| 30 | larger additions like new methods. */ |
| 31 | #define SENSORS_API_VERSION 0x300 |
| 32 | |
| 33 | #define SENSORS_CHIP_NAME_PREFIX_ANY NULL |
| 34 | #define SENSORS_CHIP_NAME_BUS_ISA -1 |
| 35 | #define SENSORS_CHIP_NAME_BUS_ANY -2 |
| 36 | #define SENSORS_CHIP_NAME_BUS_ANY_I2C -3 |
| 37 | #define SENSORS_CHIP_NAME_BUS_DUMMY -4 |
| 38 | #define SENSORS_CHIP_NAME_BUS_PCI -5 |
| 39 | #define SENSORS_CHIP_NAME_ADDR_ANY -1 |
| 40 | |
| 41 | #ifdef __cplusplus |
| 42 | extern "C" { |
| 43 | #endif /* __cplusplus */ |
| 44 | |
| 45 | /* A chip name is encoded in this structure */ |
| 46 | typedef struct sensors_chip_name { |
| 47 | char *prefix; |
| 48 | int bus; |
| 49 | int addr; |
| 50 | char *busname; /* if dummy */ |
| 51 | } sensors_chip_name; |
| 52 | |
| 53 | /* (Re)load the configuration file and the detected chips list. If this |
| 54 | returns a value unequal to zero, you are in trouble; you can not |
| 55 | assume anything will be initialized properly. */ |
| 56 | extern int sensors_init(FILE *input); |
| 57 | |
| 58 | /* Clean-up function: You can't access anything after |
| 59 | this, until the next sensors_init() call! */ |
| 60 | extern void sensors_cleanup(void); |
| 61 | |
| 62 | /* Parse a chip name to the internal representation. Return 0 on success, <0 |
| 63 | on error. */ |
| 64 | extern int sensors_parse_chip_name(const char *orig_name, |
| 65 | sensors_chip_name *res); |
| 66 | |
| 67 | /* Compare two chips name descriptions, to see whether they could match. |
| 68 | Return 0 if it does not match, return 1 if it does match. */ |
| 69 | extern int sensors_match_chip(sensors_chip_name chip1, |
| 70 | sensors_chip_name chip2); |
| 71 | |
| 72 | /* Check whether the chip name is an 'absolute' name, which can only match |
| 73 | one chip, or whether it has wildcards. Returns 0 if it is absolute, 1 |
| 74 | if there are wildcards. */ |
| 75 | extern int sensors_chip_name_has_wildcards(sensors_chip_name chip); |
| 76 | |
| 77 | /* This function returns the adapter name of a bus number, |
| 78 | as used within the sensors_chip_name structure. If it could not be found, |
| 79 | it returns NULL */ |
| 80 | extern const char *sensors_get_adapter_name(int bus_nr); |
| 81 | |
| 82 | /* This function is deprecated and will be dropped soon. */ |
| 83 | extern const char *sensors_get_algorithm_name(int bus_nr); |
| 84 | |
| 85 | /* Look up the label which belongs to this chip. Note that chip should not |
| 86 | contain wildcard values! *result is newly allocated (free it yourself). |
| 87 | This function will return 0 on success, and <0 on failure. |
| 88 | If no label exists for this feature, its name is returned itself. */ |
| 89 | extern int sensors_get_label(sensors_chip_name name, int feature, |
| 90 | char **result); |
| 91 | |
| 92 | /* Looks up whether a feature should be ignored. Returns <0 on failure, |
| 93 | 0 if it should be ignored, 1 if it is valid. This function takes |
| 94 | logical mappings into account. */ |
| 95 | extern int sensors_get_ignored(sensors_chip_name name, int feature); |
| 96 | |
| 97 | /* Read the value of a feature of a certain chip. Note that chip should not |
| 98 | contain wildcard values! This function will return 0 on success, and <0 |
| 99 | on failure. */ |
| 100 | extern int sensors_get_feature(sensors_chip_name name, int feature, |
| 101 | double *result); |
| 102 | |
| 103 | /* Set the value of a feature of a certain chip. Note that chip should not |
| 104 | contain wildcard values! This function will return 0 on success, and <0 |
| 105 | on failure. */ |
| 106 | extern int sensors_set_feature(sensors_chip_name name, int feature, |
| 107 | double value); |
| 108 | |
| 109 | /* Execute all set statements for this particular chip. The chip may contain |
| 110 | wildcards! This function will return 0 on success, and <0 on failure. */ |
| 111 | extern int sensors_do_chip_sets(sensors_chip_name name); |
| 112 | |
| 113 | /* Execute all set statements for all detected chips. This is the same as |
| 114 | calling sensors_do_chip_sets with an all wildcards chip name */ |
| 115 | extern int sensors_do_all_sets(void); |
| 116 | |
| 117 | /* This function returns all detected chips, one by one. To start at the |
| 118 | beginning of the list, use 0 for nr; NULL is returned if we are |
| 119 | at the end of the list. Do not try to change these chip names, as |
| 120 | they point to internal structures! Do not use nr for anything else. */ |
| 121 | extern const sensors_chip_name *sensors_get_detected_chips(int *nr); |
| 122 | |
| 123 | |
| 124 | /* These defines are used in the mode field of sensors_feature_data */ |
| 125 | #define SENSORS_MODE_NO_RW 0 |
| 126 | #define SENSORS_MODE_R 1 |
| 127 | #define SENSORS_MODE_W 2 |
| 128 | #define SENSORS_MODE_RW 3 |
| 129 | |
| 130 | /* This define is used in the mapping field of sensors_feature_data if no |
| 131 | mapping is available */ |
| 132 | #define SENSORS_NO_MAPPING -1 |
| 133 | |
| 134 | /* This structure is used when you want to get all features of a specific |
| 135 | chip. */ |
| 136 | typedef struct sensors_feature_data { |
| 137 | int number; |
| 138 | const char *name; |
| 139 | int mapping; |
| 140 | int compute_mapping; |
| 141 | int mode; |
| 142 | } sensors_feature_data; |
| 143 | |
| 144 | /* This returns all features of a specific chip. They are returned in |
| 145 | bunches: everything with the same mapping is returned just after each |
| 146 | other, with the master feature in front (that feature does not map to |
| 147 | itself, but has SENSORS_NO_MAPPING as mapping field). nr1 and nr2 are |
| 148 | two internally used variables. Set both to zero to start again at the |
| 149 | begin of the list. If no more features are found NULL is returned. |
| 150 | Do not try to change the returned structure; you will corrupt internal |
| 151 | data structures. */ |
| 152 | extern const sensors_feature_data *sensors_get_all_features |
| 153 | (sensors_chip_name name, int *nr1,int *nr2); |
| 154 | |
| 155 | #ifdef __cplusplus |
| 156 | } |
| 157 | #endif /* __cplusplus */ |
| 158 | |
| 159 | #endif /* def LIB_SENSORS_ERROR_H */ |
Note: See TracBrowser for help on using the browser.
