X hits on this document

PDF document

February 10, 2006 - page 149 / 238

942 views

0 shares

0 downloads

0 comments

149 / 238

8.6. USING SENSORS IN OPENIPMI

137

multiply, the modifier unit would be meters, the rate unit would be per second, and the percentage would be true. The following functions return these units for a sensor:

enum ipmi_unit_type_e ipmi_sensor_get_base_unit(ipmi_sensor_t *sensor); enum ipmi_unit_type_e ipmi_sensor_get_modifier_unit(ipmi_sensor_t *sensor); enum ipmi_rate_unit_e ipmi_sensor_get_rate_unit(ipmi_sensor_t *sensor); enum ipmi_modifier_unit_use_e ipmi_sensor_get_modifier_unit_use(

ipmi_sensor_t *sensor); int ipmi_sensor_get_percentage(ipmi_sensor_t *sensor);

The following return string representations for the units:

char *ipmi_sensor_get_rate_unit_string(ipmi_sensor_t *sensor); char *ipmi_sensor_get_base_unit_string(ipmi_sensor_t *sensor); char *ipmi_sensor_get_modifier_unit_string(ipmi_sensor_t *sensor);

Note that for OEM values, OEM code may set the strings even though the unit enumerations return an invalid value. So use the strings if you can. As a quick example, the following code will print out a value with all the various units attached:

char

*percent = "";

char

*base;

char

*mod_use = "";

char

*modifier = "";

char

*rate;

base

= i p m i _ s e n s o r _ g e t _ b a s e _ u n i t _ s t r i n g ( s e n s o r ) ;

if (ipmi_sensor_get_percentage(sensor)) percent = "%"; s w i t c h ( i p m i _ s e n s o r _ g e t _ m o d i f i e r _ u n i t _ u s e ( s e n s o r ) ) { c a s e I P M I _ M O D I F I E R _ U N I T _ N break; case IPMI_MODIFIER_UNIT_BASE_DIV_MOD: mod_use = "/"; O N E : m o d i f i e r = i p m i _ s e n s o r _ g e t _ m o d i f i e r _ u n i t _ s t r i n g ( s e break; case IPMI_MODIFIER_UNIT_BASE_MULT_MOD: mod_use = "*"; n s o r ) ; m o d i f i e r = i p m i _ s e n s o r _ g e t _ m o d i f i e r _ u n i t _ s t r i n break; } g ( s e n s o r ) ; r a t e = i p m i _ s e n s o r _ g e t _ r a t e _ u n i t _ s t r i n g ( s e n s o r ) ;

printf(

"

value: %lf%s %s%s%s%s\n", val, percent, base, mod_use, modifier, rate);

The modifier units uses in OpenIPMI are:

Document info
Document views942
Page views942
Page last viewedSun Dec 11 08:24:51 UTC 2016
Pages238
Paragraphs8090
Words85809

Comments