mirror of
https://github.com/ipmitool/ipmitool.git
synced 2025-05-11 02:57:22 +00:00
add function to handle printing asserted states
This commit is contained in:
parent
d17909e3ec
commit
929d330424
@ -48,6 +48,7 @@
|
|||||||
#include <ipmitool/ipmi_sel.h>
|
#include <ipmitool/ipmi_sel.h>
|
||||||
#include <ipmitool/ipmi_entity.h>
|
#include <ipmitool/ipmi_entity.h>
|
||||||
#include <ipmitool/ipmi_constants.h>
|
#include <ipmitool/ipmi_constants.h>
|
||||||
|
#include <ipmitool/ipmi_strings.h>
|
||||||
|
|
||||||
#if HAVE_CONFIG_H
|
#if HAVE_CONFIG_H
|
||||||
# include <config.h>
|
# include <config.h>
|
||||||
@ -91,7 +92,7 @@ sdr_convert_sensor_reading(struct sdr_record_full_sensor * sensor, unsigned char
|
|||||||
case 2:
|
case 2:
|
||||||
return (float)(((m * (signed char)val) + (b * pow(10, k1))) * pow(10, k2));
|
return (float)(((m * (signed char)val) + (b * pow(10, k1))) * pow(10, k2));
|
||||||
default:
|
default:
|
||||||
/* Ops! This isn't an analog sensor. */
|
/* Oops! This isn't an analog sensor. */
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -237,15 +238,6 @@ ipmi_sdr_get_next_header(struct ipmi_intf * intf, struct ipmi_sdr_iterator * itr
|
|||||||
return header;
|
return header;
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline int get_offset(unsigned char x)
|
|
||||||
{
|
|
||||||
int i;
|
|
||||||
for (i=0; i<8; i++)
|
|
||||||
if (x>>i == 1)
|
|
||||||
return i;
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
void ipmi_sdr_print_sensor_full(struct ipmi_intf * intf,
|
void ipmi_sdr_print_sensor_full(struct ipmi_intf * intf,
|
||||||
struct sdr_record_full_sensor * sensor)
|
struct sdr_record_full_sensor * sensor)
|
||||||
{
|
{
|
||||||
@ -498,31 +490,87 @@ void ipmi_sdr_print_sensor_full(struct ipmi_intf * intf,
|
|||||||
printf(" Maximum sensor range : Unspecified\n");
|
printf(" Maximum sensor range : Unspecified\n");
|
||||||
else
|
else
|
||||||
printf(" Maximum sensor range : %.3f\n", (float)max_reading);
|
printf(" Maximum sensor range : %.3f\n", (float)max_reading);
|
||||||
|
|
||||||
|
printf(" Event Message Control : ");
|
||||||
|
switch (sensor->sensor.capabilities.event_msg) {
|
||||||
|
case 0:
|
||||||
|
printf("Per-threshold or discrete-state event\n");
|
||||||
|
break;
|
||||||
|
case 1:
|
||||||
|
printf("Entire Sensor Only\n");
|
||||||
|
break;
|
||||||
|
case 2:
|
||||||
|
printf("Global Disable Only\n");
|
||||||
|
break;
|
||||||
|
case 3:
|
||||||
|
printf("No Events From Sensor\n");
|
||||||
|
break;
|
||||||
|
}
|
||||||
} else { /* discrete */
|
} else { /* discrete */
|
||||||
printf(" Sensor Type (Discrete): %s\n",
|
printf(" Sensor Type (Discrete): %s\n",
|
||||||
ipmi_sdr_get_sensor_type_desc(sensor->sensor.type));
|
ipmi_sdr_get_sensor_type_desc(sensor->sensor.type));
|
||||||
|
|
||||||
printf(" Sensor Reading : ");
|
printf(" Sensor Reading : ");
|
||||||
if (validread)
|
if (validread)
|
||||||
printf("%xh\n", (unsigned int)val);
|
printf("%xh\n", (unsigned int)val);
|
||||||
else
|
else
|
||||||
printf("not present\n");
|
printf("not present\n");
|
||||||
|
ipmi_sdr_print_discrete_state(sensor->sensor.type, sensor->event_type, rsp->data[2]);
|
||||||
printf(" Status : %s\n",
|
|
||||||
ipmi_sdr_get_status(rsp->data[2]));
|
|
||||||
}
|
}
|
||||||
printf("\n");
|
printf("\n");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static inline int get_offset(unsigned char x)
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
for (i=0; i<8; i++)
|
||||||
|
if (x>>i == 1)
|
||||||
|
return i;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* print out list of asserted states for a discrete sensor
|
||||||
|
* @sensor_type : sensor type code
|
||||||
|
* @event_type : event type code
|
||||||
|
* @state : mask of asserted states
|
||||||
|
*/
|
||||||
|
void ipmi_sdr_print_discrete_state(unsigned char sensor_type,
|
||||||
|
unsigned char event_type,
|
||||||
|
unsigned char state)
|
||||||
|
{
|
||||||
|
unsigned char typ;
|
||||||
|
struct ipmi_event_sensor_types *evt;
|
||||||
|
int pre = 0;
|
||||||
|
|
||||||
|
if (state == 0)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (event_type == 0x6f) {
|
||||||
|
evt = sensor_specific_types;
|
||||||
|
typ = sensor_type;
|
||||||
|
} else {
|
||||||
|
evt = generic_event_types;
|
||||||
|
typ = event_type;
|
||||||
|
}
|
||||||
|
|
||||||
|
printf(" States Asserted : ");
|
||||||
|
|
||||||
|
for (evt; evt->type != NULL; evt++) {
|
||||||
|
if (evt->code == typ && ((1<<evt->offset) & state)) {
|
||||||
|
if (pre)
|
||||||
|
printf(" ");
|
||||||
|
printf("%s\n", evt->desc);
|
||||||
|
pre = 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void ipmi_sdr_print_sensor_compact(struct ipmi_intf * intf,
|
void ipmi_sdr_print_sensor_compact(struct ipmi_intf * intf,
|
||||||
struct sdr_record_compact_sensor * sensor)
|
struct sdr_record_compact_sensor * sensor)
|
||||||
{
|
{
|
||||||
struct ipmi_rs * rsp;
|
struct ipmi_rs * rsp;
|
||||||
char desc[17];
|
char desc[17];
|
||||||
unsigned char typ, off;
|
|
||||||
struct ipmi_event_sensor_types *evt;
|
|
||||||
|
|
||||||
if (!sensor)
|
if (!sensor)
|
||||||
return;
|
return;
|
||||||
@ -560,28 +608,12 @@ void ipmi_sdr_print_sensor_compact(struct ipmi_intf * intf,
|
|||||||
printf(" Entity ID : %d.%d (%s)\n",
|
printf(" Entity ID : %d.%d (%s)\n",
|
||||||
sensor->entity.id, sensor->entity.instance,
|
sensor->entity.id, sensor->entity.instance,
|
||||||
val2str(sensor->entity.id, entity_id_vals));
|
val2str(sensor->entity.id, entity_id_vals));
|
||||||
printf(" Sensor Type : %s\n", ipmi_sdr_get_sensor_type_desc(sensor->sensor.type));
|
printf(" Sensor Type (Discrete): %s\n", ipmi_sdr_get_sensor_type_desc(sensor->sensor.type));
|
||||||
if (verbose > 1) {
|
if (verbose > 1) {
|
||||||
printf(" Event Type Code : 0x%02x\n", sensor->event_type);
|
printf(" Event Type Code : 0x%02x\n", sensor->event_type);
|
||||||
printbuf(rsp->data, rsp->data_len, "COMPACT SENSOR READING");
|
printbuf(rsp->data, rsp->data_len, "COMPACT SENSOR READING");
|
||||||
}
|
}
|
||||||
|
ipmi_sdr_print_discrete_state(sensor->sensor.type, sensor->event_type, rsp->data[2]);
|
||||||
|
|
||||||
off = get_offset(rsp->data[2]);
|
|
||||||
if (off) {
|
|
||||||
if (sensor->event_type == 0x6f) {
|
|
||||||
evt = sensor_specific_types;
|
|
||||||
typ = sensor->sensor.type;
|
|
||||||
} else {
|
|
||||||
evt = generic_event_types;
|
|
||||||
typ = sensor->event_type;
|
|
||||||
}
|
|
||||||
while (evt->type) {
|
|
||||||
if (evt->code == typ && evt->offset == off)
|
|
||||||
printf(" State : %s\n", evt->desc);
|
|
||||||
evt++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
printf("\n");
|
printf("\n");
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user