fix handling of sensors that are read correctly

This commit is contained in:
Duncan Laurie 2005-04-22 05:07:17 +00:00
parent 26557547b4
commit a292d94239

View File

@ -473,10 +473,10 @@ ipmi_sdr_print_sensor_full(struct ipmi_intf * intf,
/* sensor not found */ /* sensor not found */
validread = 0; validread = 0;
} else { } else {
lprintf(LOG_ERR, "Error reading sensor %s (#%02x): %s", lprintf(LOG_DEBUG, "Error reading sensor %s (#%02x): %s",
desc, sensor->keys.sensor_num, desc, sensor->keys.sensor_num,
val2str(rsp->ccode, completion_code_vals)); val2str(rsp->ccode, completion_code_vals));
return -1; validread = 0;
} }
} else { } else {
if (rsp->data[1] & READING_UNAVAILABLE) { if (rsp->data[1] & READING_UNAVAILABLE) {
@ -774,6 +774,7 @@ ipmi_sdr_print_sensor_compact(struct ipmi_intf * intf,
{ {
struct ipmi_rs * rsp; struct ipmi_rs * rsp;
char desc[17]; char desc[17];
int validread = 1;
if (sensor == NULL) if (sensor == NULL)
return -1; return -1;
@ -784,23 +785,23 @@ ipmi_sdr_print_sensor_compact(struct ipmi_intf * intf,
/* get sensor reading */ /* get sensor reading */
rsp = ipmi_sdr_get_sensor_reading(intf, sensor->keys.sensor_num); rsp = ipmi_sdr_get_sensor_reading(intf, sensor->keys.sensor_num);
if (rsp == NULL) { if (rsp == NULL) {
lprintf(LOG_ERR, "Error reading sensor %s (#%02x)", lprintf(LOG_DEBUG, "Error reading sensor %s (#%02x)",
desc, sensor->keys.sensor_num); desc, sensor->keys.sensor_num);
return -1; validread = 0;
} }
if (rsp->ccode > 0 && rsp->ccode != 0xcd) { if (rsp->ccode > 0 && rsp->ccode != 0xcd) {
/* completion code 0xcd is special case */ /* completion code 0xcd is special case */
lprintf(LOG_ERR, "Error reading sensor %s (#%02x): %s", lprintf(LOG_DEBUG, "Error reading sensor %s (#%02x): %s",
desc, sensor->keys.sensor_num, desc, sensor->keys.sensor_num,
val2str(rsp->ccode, completion_code_vals)); val2str(rsp->ccode, completion_code_vals));
return -1; validread = 0;
} }
/* check for sensor scanning disabled bit */ /* check for sensor scanning disabled bit */
if (!(rsp->data[1] & SCANNING_DISABLED)) { if (!(rsp->data[1] & SCANNING_DISABLED)) {
lprintf(LOG_DEBUG, "Sensor %s (#%02x) scanning disabled", lprintf(LOG_DEBUG, "Sensor %s (#%02x) scanning disabled",
desc, sensor->keys.sensor_num); desc, sensor->keys.sensor_num);
return 0; /* not an error */ validread = 0;
} }
if (verbose) { if (verbose) {
@ -816,10 +817,11 @@ ipmi_sdr_print_sensor_compact(struct ipmi_intf * intf,
lprintf(LOG_DEBUG, " Event Type Code : 0x%02x", lprintf(LOG_DEBUG, " Event Type Code : 0x%02x",
sensor->event_type); sensor->event_type);
if (verbose > 1) if (validread && verbose > 1)
printbuf(rsp->data, rsp->data_len, "COMPACT SENSOR"); printbuf(rsp->data, rsp->data_len, "COMPACT SENSOR");
ipmi_sdr_print_discrete_state(sensor->sensor.type, if (validread)
ipmi_sdr_print_discrete_state(sensor->sensor.type,
sensor->event_type, rsp->data[2]); sensor->event_type, rsp->data[2]);
printf("\n"); printf("\n");
} }
@ -827,8 +829,12 @@ ipmi_sdr_print_sensor_compact(struct ipmi_intf * intf,
char * state; char * state;
char temp[18]; char temp[18];
if (rsp->ccode == 0xcd || if (validread == 0) {
(rsp->data[1] & READING_UNAVAILABLE)) { state = csv_output ?
"Not Readable" :
"Not Readable ";
} else if (rsp->data_len > 1 &&
(rsp->data[1] & READING_UNAVAILABLE)) {
state = csv_output ? state = csv_output ?
"Not Readable" : "Not Readable" :
"Not Readable "; "Not Readable ";
@ -880,7 +886,12 @@ ipmi_sdr_print_sensor_compact(struct ipmi_intf * intf,
else else
printf("%-16s | ", sensor->id_code ? desc : ""); printf("%-16s | ", sensor->id_code ? desc : "");
if (rsp->ccode == 0) { if (validread == 0) {
if (csv_output)
printf("%s,ns\n", state);
else
printf("%-17s | ns\n", state);
} else if (rsp->ccode == 0) {
if (csv_output) if (csv_output)
printf("%s,%s\n", state, printf("%s,%s\n", state,
(rsp->data[1] & READING_UNAVAILABLE) ? (rsp->data[1] & READING_UNAVAILABLE) ?