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

Revision 4360, 6.8 KB (checked in by jwrdegoede, 7 years ago)

add sensors_feature_get_type method, by Bob Schlarmann and Luuk Kleiweg

  • 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
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
31#define SENSORS_CHIP_NAME_BUS_DUMMY -4
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
39/* A chip name is encoded is in this structure */
40typedef struct sensors_chip_name {
41  char *prefix;
42  int bus;
43  int addr;
44  char *busname;        /* if dummy */
45} sensors_chip_name;
46
47/* (Re)load the configuration file and the detected chips list. If this
48    returns a value unequal to zero, you are in trouble; you can not
49    assume anything will be initialized properly. */
50extern int sensors_init(FILE *input);
51
52/* Clean-up function: You can't access anything after
53   this, until the next sensors_init() call! */
54extern void sensors_cleanup(void);
55
56/* Parse a chip name to the internal representation. Return 0 on succes, <0
57   on error. */
58extern int sensors_parse_chip_name(const char *orig_name,
59                                   sensors_chip_name *res);
60
61/* Compare two chips name descriptions, to see whether they could match.
62   Return 0 if it does not match, return 1 if it does match. */
63extern int sensors_match_chip(sensors_chip_name chip1, 
64                              sensors_chip_name chip2);
65
66/* Check whether the chip name is an 'absolute' name, which can only match
67   one chip, or whether it has wildcards. Returns 0 if it is absolute, 1
68   if there are wildcards. */
69extern int sensors_chip_name_has_wildcards(sensors_chip_name chip);
70
71/* This function returns the adapter name of a bus number,
72   as used within the sensors_chip_name structure. If it could not be found,
73   it returns NULL */
74extern const char *sensors_get_adapter_name(int bus_nr);
75
76/* This function is deprecated and will be dropped soon. */
77extern const char *sensors_get_algorithm_name(int bus_nr);
78
79/* Look up the label which belongs to this chip. Note that chip should not
80   contain wildcard values! *result is newly allocated (free it yourself).
81   This function will return 0 on success, and <0 on failure.  This
82   function takes logical mappings into account. */
83extern int sensors_get_label(sensors_chip_name name, int feature, 
84                             char **result);
85
86/* Looks up whether a feature should be ignored. Returns <0 on failure,
87   0 if it should be ignored, 1 if it is valid. This function takes
88   logical mappings into account. */
89extern int sensors_get_ignored(sensors_chip_name name, int fature);
90
91/* Read the value of a feature of a certain chip. Note that chip should not
92   contain wildcard values! This function will return 0 on success, and <0
93   on failure.  */
94extern int sensors_get_feature(sensors_chip_name name, int feature,
95                               double *result);
96
97/* Set 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. */
100extern int sensors_set_feature(sensors_chip_name name, int feature,
101                               double value);
102
103/* Execute all set statements for this particular chip. The chip may contain
104   wildcards!  This function will return 0 on success, and <0 on failure. */
105extern int sensors_do_chip_sets(sensors_chip_name name);
106
107/* Execute all set statements for all detected chips. This is the same as
108   calling sensors_do_chip_sets with an all wildcards chip name */
109extern int sensors_do_all_sets(void);
110
111/* This function returns all detected chips, one by one. To start at the
112   beginning of the list, use 0 for nr; NULL is returned if we are
113   at the end of the list. Do not try to change these chip names, as
114   they point to internal structures! Do not use nr for anything else. */
115extern const sensors_chip_name *sensors_get_detected_chips(int *nr);
116
117
118/* These defines are used in the mode field of sensors_feature_data */
119#define SENSORS_MODE_NO_RW 0
120#define SENSORS_MODE_R 1
121#define SENSORS_MODE_W 2
122#define SENSORS_MODE_RW 3
123
124/* This define is used in the mapping field of sensors_feature_data if no
125   mapping is available */
126#define SENSORS_NO_MAPPING -1
127
128/* This structure is used when you want to get all features of a specific
129   chip. */
130typedef struct sensors_feature_data {
131  int number;
132  const char *name;
133  int mapping;
134  int compute_mapping;
135  int mode;
136} sensors_feature_data;
137
138/* This returns all features of a specific chip. They are returned in
139   bunches: everything with the same mapping is returned just after each
140   other, with the master feature in front (that feature does not map to
141   itself, but has SENSORS_NO_MAPPING as mapping field). nr1 and nr2 are
142   two internally used variables. Set both to zero to start again at the
143   begin of the list. If no more features are found NULL is returned.
144   Do not try to change the returned structure; you will corrupt internal
145   data structures. */
146extern const sensors_feature_data *sensors_get_all_features
147             (sensors_chip_name name, int *nr1,int *nr2);
148
149typedef enum sensors_feature_type {
150  SENSORS_FEATURE_TEMP = 0,
151  SENSORS_FEATURE_TEMP_ALARM,
152  SENSORS_FEATURE_TEMP_HYST,
153  SENSORS_FEATURE_TEMP_OVER,
154  SENSORS_FEATURE_TEMP_MAX,
155  SENSORS_FEATURE_TEMP_MIN,
156  SENSORS_FEATURE_TEMP_HIGH,
157  SENSORS_FEATURE_TEMP_LOW,
158  SENSORS_FEATURE_TEMP_LIM,
159  SENSORS_FEATURE_TEMP_CRIT,
160 
161  SENSORS_FEATURE_IN,
162  SENSORS_FEATURE_IN_ALARM,
163  SENSORS_FEATURE_IN_MIN,
164  SENSORS_FEATURE_IN_MAX,
165  SENSORS_FEATURE_IN_MIN_ALARM,
166  SENSORS_FEATURE_IN_MAX_ALARM,
167 
168  SENSORS_FEATURE_FAN,
169  SENSORS_FEATURE_FAN_ALARM,
170  SENSORS_FEATURE_FAN_MIN,
171  SENSORS_FEATURE_FAN_DIV,
172 
173  SENSORS_FEATURE_VID,
174  SENSORS_FEATURE_VRM,
175 
176  SENSORS_FEATURE_UNKNOWN
177} sensors_feature_type;
178
179sensors_feature_type sensors_feature_get_type(
180  const sensors_feature_data *feature);
181#ifdef __cplusplus
182}
183#endif /* __cplusplus */
184
185#endif /* def LIB_SENSORS_ERROR_H */
Note: See TracBrowser for help on using the browser.