1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
|
/*
sensors.h - Part of libsensors, a Linux library for reading sensor data.
Copyright (c) 1998, 1999 Frodo Looijaard <frodol@dds.nl>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#ifndef LIB_SENSORS_SENSORS_H
#define LIB_SENSORS_SENSORS_H
#include <stdio.h>
#include <limits.h>
/* Publicly accessible library functions */
#define SENSORS_CHIP_NAME_PREFIX_ANY NULL
#define SENSORS_CHIP_NAME_BUS_ISA -1
#define SENSORS_CHIP_NAME_BUS_ANY -2
#define SENSORS_CHIP_NAME_BUS_ANY_I2C -3
#define SENSORS_CHIP_NAME_BUS_DUMMY -4
#define SENSORS_CHIP_NAME_BUS_PCI -5
#define SENSORS_CHIP_NAME_ADDR_ANY -1
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
/* A chip name is encoded is in this structure */
typedef struct sensors_chip_name {
char *prefix;
int bus;
int addr;
char *busname; /* if dummy */
} sensors_chip_name;
/* (Re)load the configuration file and the detected chips list. If this
returns a value unequal to zero, you are in trouble; you can not
assume anything will be initialized properly. */
extern int sensors_init(FILE *input);
/* Clean-up function: You can't access anything after
this, until the next sensors_init() call! */
extern void sensors_cleanup(void);
/* Parse a chip name to the internal representation. Return 0 on succes, <0
on error. */
extern int sensors_parse_chip_name(const char *orig_name,
sensors_chip_name *res);
/* Compare two chips name descriptions, to see whether they could match.
Return 0 if it does not match, return 1 if it does match. */
extern int sensors_match_chip(sensors_chip_name chip1,
sensors_chip_name chip2);
/* Check whether the chip name is an 'absolute' name, which can only match
one chip, or whether it has wildcards. Returns 0 if it is absolute, 1
if there are wildcards. */
extern int sensors_chip_name_has_wildcards(sensors_chip_name chip);
/* This function returns the adapter name of a bus number,
as used within the sensors_chip_name structure. If it could not be found,
it returns NULL */
extern const char *sensors_get_adapter_name(int bus_nr);
/* This function is deprecated and will be dropped soon. */
extern const char *sensors_get_algorithm_name(int bus_nr);
/* Look up the label which belongs to this chip. Note that chip should not
contain wildcard values! *result is newly allocated (free it yourself).
This function will return 0 on success, and <0 on failure. This
function takes logical mappings into account. */
extern int sensors_get_label(sensors_chip_name name, int feature,
char **result);
/* Looks up whether a feature should be ignored. Returns <0 on failure,
0 if it should be ignored, 1 if it is valid. This function takes
logical mappings into account. */
extern int sensors_get_ignored(sensors_chip_name name, int fature);
/* Read the value of a feature of a certain chip. Note that chip should not
contain wildcard values! This function will return 0 on success, and <0
on failure. */
extern int sensors_get_feature(sensors_chip_name name, int feature,
double *result);
/* Set the value of a feature of a certain chip. Note that chip should not
contain wildcard values! This function will return 0 on success, and <0
on failure. */
extern int sensors_set_feature(sensors_chip_name name, int feature,
double value);
/* Execute all set statements for this particular chip. The chip may contain
wildcards! This function will return 0 on success, and <0 on failure. */
extern int sensors_do_chip_sets(sensors_chip_name name);
/* Execute all set statements for all detected chips. This is the same as
calling sensors_do_chip_sets with an all wildcards chip name */
extern int sensors_do_all_sets(void);
/* This function returns all detected chips, one by one. To start at the
beginning of the list, use 0 for nr; NULL is returned if we are
at the end of the list. Do not try to change these chip names, as
they point to internal structures! Do not use nr for anything else. */
extern const sensors_chip_name *sensors_get_detected_chips(int *nr);
/* These defines are used in the mode field of sensors_feature_data */
#define SENSORS_MODE_NO_RW 0
#define SENSORS_MODE_R 1
#define SENSORS_MODE_W 2
#define SENSORS_MODE_RW 3
/* This define is used in the mapping field of sensors_feature_data if no
mapping is available */
#define SENSORS_NO_MAPPING -1
/* This structure is used when you want to get all features of a specific
chip. */
typedef struct sensors_feature_data {
int number;
const char *name;
int mapping;
int compute_mapping;
int mode;
} sensors_feature_data;
/* This returns all features of a specific chip. They are returned in
bunches: everything with the same mapping is returned just after each
other, with the master feature in front (that feature does not map to
itself, but has SENSORS_NO_MAPPING as mapping field). nr1 and nr2 are
two internally used variables. Set both to zero to start again at the
begin of the list. If no more features are found NULL is returned.
Do not try to change the returned structure; you will corrupt internal
data structures. */
extern const sensors_feature_data *sensors_get_all_features
(sensors_chip_name name, int *nr1,int *nr2);
/* This enum contains some "magic" used by sensors_read_dynamic_chip() from
lib/sysfs.c . All the sensor-types (in, fan, temp, misc) are a multiple of
0x100 apart, and sensor features which should not have a compute_mapping to
the _input feature start at 0x?10. */
typedef enum sensors_feature_type {
SENSORS_FEATURE_IN = 0x000,
SENSORS_FEATURE_IN_MIN,
SENSORS_FEATURE_IN_MAX,
SENSORS_FEATURE_IN_ALARM = 0x010,
SENSORS_FEATURE_IN_MIN_ALARM,
SENSORS_FEATURE_IN_MAX_ALARM,
SENSORS_FEATURE_FAN = 0x100,
SENSORS_FEATURE_FAN_MIN,
SENSORS_FEATURE_FAN_ALARM = 0x110,
SENSORS_FEATURE_FAN_FAULT,
SENSORS_FEATURE_FAN_DIV,
SENSORS_FEATURE_TEMP = 0x200,
SENSORS_FEATURE_TEMP_MAX,
SENSORS_FEATURE_TEMP_MAX_HYST,
SENSORS_FEATURE_TEMP_MIN,
SENSORS_FEATURE_TEMP_CRIT,
SENSORS_FEATURE_TEMP_CRIT_HYST,
SENSORS_FEATURE_TEMP_ALARM = 0x210,
SENSORS_FEATURE_TEMP_MAX_ALARM,
SENSORS_FEATURE_TEMP_MIN_ALARM,
SENSORS_FEATURE_TEMP_CRIT_ALARM,
SENSORS_FEATURE_TEMP_FAULT,
SENSORS_FEATURE_TEMP_SENS,
SENSORS_FEATURE_VID = 0x300,
SENSORS_FEATURE_VRM,
SENSORS_FEATURE_UNKNOWN = INT_MAX,
/* special the largest number of subfeatures used, iow the
highest ## from all the 0x?## above + 1*/
SENSORS_FEATURE_MAX_SUB_FEATURES = 22
} sensors_feature_type;
sensors_feature_type sensors_feature_get_type
(const sensors_feature_data *feature);
#ifdef __cplusplus
}
#endif /* __cplusplus */
#endif /* def LIB_SENSORS_ERROR_H */
|