root/lm-sensors/branches/lm-sensors-3.0.0/lib/sensors.h @ 4673

Revision 4673, 6.5 KB (checked in by khali, 7 years ago)

Rename sensors_chip_name.busname to path, as this is what we are using
it for by now.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
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#include <limits.h>
25
26/* Publicly accessible library functions */
27
28#define SENSORS_CHIP_NAME_PREFIX_ANY NULL
29#define SENSORS_CHIP_NAME_BUS_ISA -1
30#define SENSORS_CHIP_NAME_BUS_ANY -2
31#define SENSORS_CHIP_NAME_BUS_ANY_I2C -3
32#define SENSORS_CHIP_NAME_BUS_PCI -5
33#define SENSORS_CHIP_NAME_ADDR_ANY -1
34
35#ifdef __cplusplus
36extern "C" {
37#endif /* __cplusplus */
38
39extern const char *libsensors_version;
40
41/* A chip name is encoded is in this structure */
42typedef struct sensors_chip_name {
43  char *prefix;
44  int bus;
45  int addr;
46  char *path;
47} sensors_chip_name;
48
49/* (Re)load the configuration file and the detected chips list. If this
50    returns a value unequal to zero, you are in trouble; you can not
51    assume anything will be initialized properly. */
52extern int sensors_init(FILE *input);
53
54/* Clean-up function: You can't access anything after
55   this, until the next sensors_init() call! */
56extern void sensors_cleanup(void);
57
58/* Parse a chip name to the internal representation. Return 0 on succes, <0
59   on error. */
60extern int sensors_parse_chip_name(const char *orig_name,
61                                   sensors_chip_name *res);
62
63/* Compare two chips name descriptions, to see whether they could match.
64   Return 0 if it does not match, return 1 if it does match. */
65extern int sensors_match_chip(const sensors_chip_name *chip1,
66                              const sensors_chip_name *chip2);
67
68/* This function returns the adapter name of a bus number,
69   as used within the sensors_chip_name structure. If it could not be found,
70   it returns NULL */
71extern const char *sensors_get_adapter_name(int bus_nr);
72
73/* Look up the label which belongs to this chip. Note that chip should not
74   contain wildcard values! *result is newly allocated (free it yourself).
75   This function will return 0 on success, and <0 on failure.  This
76   function takes logical mappings into account. */
77extern int sensors_get_label(const sensors_chip_name *name, int feature,
78                             char **result);
79
80/* Read the value of a feature of a certain chip. Note that chip should not
81   contain wildcard values! This function will return 0 on success, and <0
82   on failure.  */
83extern int sensors_get_feature(const sensors_chip_name *name, int feature,
84                               double *result);
85
86/* Set the value of a feature of a certain chip. Note that chip should not
87   contain wildcard values! This function will return 0 on success, and <0
88   on failure. */
89extern int sensors_set_feature(const sensors_chip_name *name, int feature,
90                               double value);
91
92/* Execute all set statements for this particular chip. The chip may contain
93   wildcards!  This function will return 0 on success, and <0 on failure. */
94extern int sensors_do_chip_sets(const sensors_chip_name *name);
95
96/* This function returns all detected chips, one by one. To start at the
97   beginning of the list, use 0 for nr; NULL is returned if we are
98   at the end of the list. Do not try to change these chip names, as
99   they point to internal structures! Do not use nr for anything else. */
100extern const sensors_chip_name *sensors_get_detected_chips(int *nr);
101
102
103/* These defines are used in the mode field of sensors_feature_data */
104#define SENSORS_MODE_NO_RW 0
105#define SENSORS_MODE_R 1
106#define SENSORS_MODE_W 2
107#define SENSORS_MODE_RW 3
108
109/* This define is used in the mapping field of sensors_feature_data if no
110   mapping is available */
111#define SENSORS_NO_MAPPING -1
112
113/* This enum contains some "magic" used by sensors_read_dynamic_chip() from
114   lib/sysfs.c. All the sensor types (in, fan, temp, vid) are a multiple of
115   0x100 apart, and sensor features which should not have a compute_mapping to
116   the _input feature start at 0x?10. */
117typedef enum sensors_feature_type {
118  SENSORS_FEATURE_IN = 0x000,
119  SENSORS_FEATURE_IN_MIN,
120  SENSORS_FEATURE_IN_MAX,
121  SENSORS_FEATURE_IN_ALARM = 0x010,
122  SENSORS_FEATURE_IN_MIN_ALARM,
123  SENSORS_FEATURE_IN_MAX_ALARM,
124 
125  SENSORS_FEATURE_FAN = 0x100,
126  SENSORS_FEATURE_FAN_MIN,
127  SENSORS_FEATURE_FAN_ALARM = 0x110,
128  SENSORS_FEATURE_FAN_FAULT,
129  SENSORS_FEATURE_FAN_DIV,
130 
131  SENSORS_FEATURE_TEMP = 0x200,
132  SENSORS_FEATURE_TEMP_MAX,
133  SENSORS_FEATURE_TEMP_MAX_HYST,
134  SENSORS_FEATURE_TEMP_MIN,
135  SENSORS_FEATURE_TEMP_CRIT,
136  SENSORS_FEATURE_TEMP_CRIT_HYST,
137  SENSORS_FEATURE_TEMP_ALARM = 0x210,
138  SENSORS_FEATURE_TEMP_MAX_ALARM,
139  SENSORS_FEATURE_TEMP_MIN_ALARM,
140  SENSORS_FEATURE_TEMP_CRIT_ALARM,
141  SENSORS_FEATURE_TEMP_FAULT,
142  SENSORS_FEATURE_TEMP_SENS,
143 
144  SENSORS_FEATURE_VID = 0x300,
145 
146  SENSORS_FEATURE_UNKNOWN = INT_MAX,
147 
148  /* special the largest number of subfeatures used, iow the
149     highest ## from all the 0x?## above + 1*/
150  SENSORS_FEATURE_MAX_SUB_FEATURES = 22
151} sensors_feature_type;
152
153/* This structure is used when you want to get all features of a specific
154   chip. */
155typedef struct sensors_feature_data {
156  int number;
157  char *name;
158  sensors_feature_type type;
159  int mapping;
160  int compute_mapping;
161  int mode;
162} sensors_feature_data;
163
164/* This returns all features of a specific chip. They are returned in
165   bunches: everything with the same mapping is returned just after each
166   other, with the master feature in front (that feature does not map to
167   itself, but has SENSORS_NO_MAPPING as mapping field). nr is
168   an internally used variable. Set it to zero to start again at the
169   begin of the list. If no more features are found NULL is returned.
170   Do not try to change the returned structure; you will corrupt internal
171   data structures. */
172extern const sensors_feature_data *sensors_get_all_features
173             (const sensors_chip_name *name, int *nr);
174
175#ifdef __cplusplus
176}
177#endif /* __cplusplus */
178
179#endif /* def LIB_SENSORS_ERROR_H */
Note: See TracBrowser for help on using the browser.