| [95] | 1 | /* |
|---|
| 2 | sensors.h - Part of libsensors, a Linux library for reading sensor data. |
|---|
| [207] | 3 | Copyright (c) 1998, 1999 Frodo Looijaard <frodol@dds.nl> |
|---|
| [95] | 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 | |
|---|
| [98] | 23 | #include <stdio.h> |
|---|
| 24 | |
|---|
| [95] | 25 | /* Publicly accessible library functions */ |
|---|
| 26 | |
|---|
| 27 | #define SENSORS_CHIP_NAME_PREFIX_ANY NULL |
|---|
| 28 | #define SENSORS_CHIP_NAME_BUS_ISA -1 |
|---|
| 29 | #define SENSORS_CHIP_NAME_BUS_ANY -2 |
|---|
| 30 | #define SENSORS_CHIP_NAME_BUS_ANY_I2C -3 |
|---|
| [1606] | 31 | #define SENSORS_CHIP_NAME_BUS_DUMMY -4 |
|---|
| [95] | 32 | #define SENSORS_CHIP_NAME_ADDR_ANY -1 |
|---|
| 33 | |
|---|
| [722] | 34 | #ifdef __cplusplus |
|---|
| 35 | extern "C" { |
|---|
| 36 | #endif /* __cplusplus */ |
|---|
| 37 | |
|---|
| [110] | 38 | /* A chip name is encoded is in this structure */ |
|---|
| [95] | 39 | typedef struct sensors_chip_name { |
|---|
| 40 | char *prefix; |
|---|
| 41 | int bus; |
|---|
| 42 | int addr; |
|---|
| [1606] | 43 | char *busname; /* if dummy */ |
|---|
| [95] | 44 | } sensors_chip_name; |
|---|
| 45 | |
|---|
| [101] | 46 | /* (Re)load the configuration file and the detected chips list. If this |
|---|
| 47 | returns a value unequal to zero, you are in trouble; you can not |
|---|
| 48 | assume anything will be initialized properly. */ |
|---|
| [98] | 49 | extern int sensors_init(FILE *input); |
|---|
| [97] | 50 | |
|---|
| [2090] | 51 | /* Clean-up function: You can't access anything after |
|---|
| [97] | 52 | this, until the next sensors_init() call! */ |
|---|
| 53 | extern void sensors_cleanup(void); |
|---|
| 54 | |
|---|
| [95] | 55 | /* Parse a chip name to the internal representation. Return 0 on succes, <0 |
|---|
| 56 | on error. */ |
|---|
| 57 | extern int sensors_parse_chip_name(const char *orig_name, |
|---|
| 58 | sensors_chip_name *res); |
|---|
| 59 | |
|---|
| 60 | /* Compare two chips name descriptions, to see whether they could match. |
|---|
| 61 | Return 0 if it does not match, return 1 if it does match. */ |
|---|
| 62 | extern int sensors_match_chip(sensors_chip_name chip1, |
|---|
| 63 | sensors_chip_name chip2); |
|---|
| 64 | |
|---|
| 65 | /* Check whether the chip name is an 'absolute' name, which can only match |
|---|
| 66 | one chip, or whether it has wildcards. Returns 0 if it is absolute, 1 |
|---|
| 67 | if there are wildcards. */ |
|---|
| 68 | extern int sensors_chip_name_has_wildcards(sensors_chip_name chip); |
|---|
| 69 | |
|---|
| [103] | 70 | /* These functions return the adapter and algorithm names of a bus number, |
|---|
| 71 | as used within the sensors_chip_name structure. If it could not be found, |
|---|
| 72 | it returns NULL */ |
|---|
| 73 | extern const char *sensors_get_adapter_name(int bus_nr); |
|---|
| 74 | extern const char *sensors_get_algorithm_name(int bus_nr); |
|---|
| 75 | |
|---|
| [95] | 76 | /* Look up the label which belongs to this chip. Note that chip should not |
|---|
| 77 | contain wildcard values! *result is newly allocated (free it yourself). |
|---|
| [676] | 78 | This function will return 0 on success, and <0 on failure. This |
|---|
| 79 | function takes logical mappings into account. */ |
|---|
| [95] | 80 | extern int sensors_get_label(sensors_chip_name name, int feature, |
|---|
| 81 | char **result); |
|---|
| 82 | |
|---|
| [676] | 83 | /* Looks up whether a feature should be ignored. Returns <0 on failure, |
|---|
| 84 | 0 if it should be ignored, 1 if it is valid. This function takes |
|---|
| 85 | logical mappings into account. */ |
|---|
| 86 | extern int sensors_get_ignored(sensors_chip_name name, int fature); |
|---|
| 87 | |
|---|
| [95] | 88 | /* Read the value of a feature of a certain chip. Note that chip should not |
|---|
| 89 | contain wildcard values! This function will return 0 on success, and <0 |
|---|
| 90 | on failure. */ |
|---|
| 91 | extern int sensors_get_feature(sensors_chip_name name, int feature, |
|---|
| 92 | double *result); |
|---|
| 93 | |
|---|
| 94 | /* Set the value of a feature of a certain chip. Note that chip should not |
|---|
| 95 | contain wildcard values! This function will return 0 on success, and <0 |
|---|
| [138] | 96 | on failure. */ |
|---|
| [103] | 97 | extern int sensors_set_feature(sensors_chip_name name, int feature, |
|---|
| 98 | double value); |
|---|
| [95] | 99 | |
|---|
| [138] | 100 | /* Execute all set statements for this particular chip. The chip may contain |
|---|
| 101 | wildcards! This function will return 0 on success, and <0 on failure. */ |
|---|
| 102 | extern int sensors_do_chip_sets(sensors_chip_name name); |
|---|
| 103 | |
|---|
| 104 | /* Execute all set statements for all detected chips. This is the same as |
|---|
| 105 | calling sensors_do_chip_sets with an all wildcards chip name */ |
|---|
| 106 | extern int sensors_do_all_sets(void); |
|---|
| 107 | |
|---|
| [102] | 108 | /* This function returns all detected chips, one by one. To start at the |
|---|
| 109 | beginning of the list, use 0 for nr; NULL is returned if we are |
|---|
| 110 | at the end of the list. Do not try to change these chip names, as |
|---|
| 111 | they point to internal structures! Do not use nr for anything else. */ |
|---|
| 112 | extern const sensors_chip_name *sensors_get_detected_chips(int *nr); |
|---|
| 113 | |
|---|
| 114 | |
|---|
| [110] | 115 | /* These defines are used in the mode field of sensors_feature_data */ |
|---|
| 116 | #define SENSORS_MODE_NO_RW 0 |
|---|
| 117 | #define SENSORS_MODE_R 1 |
|---|
| 118 | #define SENSORS_MODE_W 2 |
|---|
| 119 | #define SENSORS_MODE_RW 3 |
|---|
| 120 | |
|---|
| 121 | /* This define is used in the mapping field of sensors_feature_data if no |
|---|
| 122 | mapping is available */ |
|---|
| 123 | #define SENSORS_NO_MAPPING -1 |
|---|
| 124 | |
|---|
| 125 | /* This structure is used when you want to get all features of a specific |
|---|
| 126 | chip. */ |
|---|
| 127 | typedef struct sensors_feature_data { |
|---|
| 128 | int number; |
|---|
| 129 | const char *name; |
|---|
| 130 | int mapping; |
|---|
| 131 | int unused; |
|---|
| 132 | int mode; |
|---|
| 133 | } sensors_feature_data; |
|---|
| 134 | |
|---|
| 135 | /* This returns all features of a specific chip. They are returned in |
|---|
| 136 | bunches: everything with the same mapping is returned just after each |
|---|
| 137 | other, with the master feature in front (that feature does not map to |
|---|
| 138 | itself, but has SENSORS_NO_MAPPING as mapping field). nr1 and nr2 are |
|---|
| 139 | two internally used variables. Set both to zero to start again at the |
|---|
| 140 | begin of the list. If no more features are found NULL is returned. |
|---|
| 141 | Do not try to change the returned structure; you will corrupt internal |
|---|
| 142 | data structures. */ |
|---|
| 143 | extern const sensors_feature_data *sensors_get_all_features |
|---|
| 144 | (sensors_chip_name name, int *nr1,int *nr2); |
|---|
| 145 | |
|---|
| [722] | 146 | #ifdef __cplusplus |
|---|
| 147 | } |
|---|
| 148 | #endif /* __cplusplus */ |
|---|
| 149 | |
|---|
| [95] | 150 | #endif /* def LIB_SENSORS_ERROR_H */ |
|---|