mirror of
https://github.com/ipmitool/ipmitool.git
synced 2025-05-10 18:47:22 +00:00
Correct Threshold/Discrete Sensor Display - Patch Tracker ID - 3508759
This commit is contained in:
parent
8de0428bdc
commit
5f11bb25b0
@ -322,7 +322,7 @@ struct sdr_record_mask {
|
||||
#ifdef HAVE_PRAGMA_PACK
|
||||
#pragma pack(1)
|
||||
#endif
|
||||
struct sdr_record_compact_sensor {
|
||||
struct sdr_record_common_sensor {
|
||||
struct {
|
||||
uint8_t owner_id;
|
||||
#if WORDS_BIGENDIAN
|
||||
@ -376,7 +376,7 @@ struct sdr_record_compact_sensor {
|
||||
uint8_t ignore:1;
|
||||
#endif
|
||||
} ATTRIBUTE_PACKING capabilities;
|
||||
uint8_t type; /* sensor type */
|
||||
uint8_t type;
|
||||
} ATTRIBUTE_PACKING sensor;
|
||||
|
||||
uint8_t event_type; /* event/reading type code */
|
||||
@ -400,7 +400,21 @@ struct sdr_record_compact_sensor {
|
||||
uint8_t modifier;
|
||||
} ATTRIBUTE_PACKING type;
|
||||
} ATTRIBUTE_PACKING unit;
|
||||
} ATTRIBUTE_PACKING;
|
||||
|
||||
/* SDR Record Common Sensor header macros */
|
||||
#define IS_THRESHOLD_SENSOR(s) ((s)->event_type == 1)
|
||||
#define UNITS_ARE_DISCRETE(s) ((s)->unit.analog == 3)
|
||||
|
||||
#ifdef HAVE_PRAGMA_PACK
|
||||
#pragma pack(0)
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_PRAGMA_PACK
|
||||
#pragma pack(1)
|
||||
#endif
|
||||
struct sdr_record_compact_sensor {
|
||||
struct sdr_record_common_sensor cmn;
|
||||
struct {
|
||||
#if WORDS_BIGENDIAN
|
||||
uint8_t __reserved:2;
|
||||
@ -492,83 +506,7 @@ struct sdr_record_eventonly_sensor {
|
||||
#pragma pack(1)
|
||||
#endif
|
||||
struct sdr_record_full_sensor {
|
||||
struct {
|
||||
uint8_t owner_id;
|
||||
#if WORDS_BIGENDIAN
|
||||
uint8_t channel:4; /* channel number */
|
||||
uint8_t __reserved:2;
|
||||
uint8_t lun:2; /* sensor owner lun */
|
||||
#else
|
||||
uint8_t lun:2; /* sensor owner lun */
|
||||
uint8_t __reserved:2;
|
||||
uint8_t channel:4; /* channel number */
|
||||
#endif
|
||||
uint8_t sensor_num; /* unique sensor number */
|
||||
} ATTRIBUTE_PACKING keys;
|
||||
|
||||
struct entity_id entity;
|
||||
|
||||
struct {
|
||||
struct {
|
||||
#if WORDS_BIGENDIAN
|
||||
uint8_t __reserved:1;
|
||||
uint8_t scanning:1;
|
||||
uint8_t events:1;
|
||||
uint8_t thresholds:1;
|
||||
uint8_t hysteresis:1;
|
||||
uint8_t type:1;
|
||||
uint8_t event_gen:1;
|
||||
uint8_t sensor_scan:1;
|
||||
#else
|
||||
uint8_t sensor_scan:1;
|
||||
uint8_t event_gen:1;
|
||||
uint8_t type:1;
|
||||
uint8_t hysteresis:1;
|
||||
uint8_t thresholds:1;
|
||||
uint8_t events:1;
|
||||
uint8_t scanning:1;
|
||||
uint8_t __reserved:1;
|
||||
#endif
|
||||
} ATTRIBUTE_PACKING init;
|
||||
struct {
|
||||
#if WORDS_BIGENDIAN
|
||||
uint8_t ignore:1;
|
||||
uint8_t rearm:1;
|
||||
uint8_t hysteresis:2;
|
||||
uint8_t threshold:2;
|
||||
uint8_t event_msg:2;
|
||||
#else
|
||||
uint8_t event_msg:2;
|
||||
uint8_t threshold:2;
|
||||
uint8_t hysteresis:2;
|
||||
uint8_t rearm:1;
|
||||
uint8_t ignore:1;
|
||||
#endif
|
||||
} ATTRIBUTE_PACKING capabilities;
|
||||
uint8_t type;
|
||||
} ATTRIBUTE_PACKING sensor;
|
||||
|
||||
uint8_t event_type; /* event/reading type code */
|
||||
|
||||
struct sdr_record_mask mask;
|
||||
|
||||
struct {
|
||||
#if WORDS_BIGENDIAN
|
||||
uint8_t analog:2;
|
||||
uint8_t rate:3;
|
||||
uint8_t modifier:2;
|
||||
uint8_t pct:1;
|
||||
#else
|
||||
uint8_t pct:1;
|
||||
uint8_t modifier:2;
|
||||
uint8_t rate:3;
|
||||
uint8_t analog:2;
|
||||
#endif
|
||||
struct {
|
||||
uint8_t base;
|
||||
uint8_t modifier;
|
||||
} ATTRIBUTE_PACKING type;
|
||||
} ATTRIBUTE_PACKING unit;
|
||||
struct sdr_record_common_sensor cmn;
|
||||
|
||||
#define SDR_SENSOR_L_LINEAR 0x00
|
||||
#define SDR_SENSOR_L_LN 0x01
|
||||
@ -822,6 +760,7 @@ struct sdr_record_list {
|
||||
uint8_t *raw;
|
||||
struct sdr_record_list *next;
|
||||
union {
|
||||
struct sdr_record_common_sensor *common;
|
||||
struct sdr_record_full_sensor *full;
|
||||
struct sdr_record_compact_sensor *compact;
|
||||
struct sdr_record_eventonly_sensor *eventonly;
|
||||
@ -896,14 +835,22 @@ int ipmi_sdr_print_rawentry(struct ipmi_intf *intf, uint8_t type, uint8_t * raw,
|
||||
int len);
|
||||
int ipmi_sdr_print_listentry(struct ipmi_intf *intf,
|
||||
struct sdr_record_list *entry);
|
||||
const char *ipmi_sdr_get_unit_string(uint8_t pct, uint8_t type,
|
||||
void ipmi_sdr_print_sensor_hysteresis(struct sdr_record_common_sensor *sensor,
|
||||
struct sdr_record_full_sensor *full,
|
||||
uint8_t hysteresis_value,
|
||||
const char *hdrstr);
|
||||
const char *ipmi_sdr_get_unit_string(uint8_t pct, uint8_t type,
|
||||
uint8_t base, uint8_t modifier);
|
||||
const char *ipmi_sdr_get_status(struct sdr_record_full_sensor *sensor,
|
||||
uint8_t stat);
|
||||
const char *ipmi_sdr_get_thresh_status(struct ipmi_rs *rsp,
|
||||
int validread, const char *invalidstr);
|
||||
const char *ipmi_sdr_get_status(int, const char *, uint8_t stat);
|
||||
double sdr_convert_sensor_tolerance(struct sdr_record_full_sensor *sensor,
|
||||
uint8_t val);
|
||||
double sdr_convert_sensor_reading(struct sdr_record_full_sensor *sensor,
|
||||
uint8_t val);
|
||||
double sdr_convert_analog_reading(struct ipmi_intf *intf,
|
||||
struct sdr_record_full_sensor *sensor, uint8_t read,
|
||||
int *convert_success);
|
||||
double sdr_convert_sensor_hysterisis(struct sdr_record_full_sensor *sensor,
|
||||
uint8_t val);
|
||||
uint8_t sdr_convert_sensor_value_to_raw(struct sdr_record_full_sensor *sensor,
|
||||
@ -925,10 +872,6 @@ const char *ipmi_sdr_get_sensor_type_desc(const uint8_t type);
|
||||
int ipmi_sdr_get_reservation(struct ipmi_intf *intf, int use_builtin,
|
||||
uint16_t * reserve_id);
|
||||
|
||||
int ipmi_sdr_print_sensor_full(struct ipmi_intf *intf,
|
||||
struct sdr_record_full_sensor *sensor);
|
||||
int ipmi_sdr_print_sensor_compact(struct ipmi_intf *intf,
|
||||
struct sdr_record_compact_sensor *sensor);
|
||||
int ipmi_sdr_print_sensor_eventonly(struct ipmi_intf *intf,
|
||||
struct sdr_record_eventonly_sensor *sensor);
|
||||
int ipmi_sdr_print_sensor_generic_locator(struct ipmi_intf *intf,
|
||||
|
@ -84,7 +84,6 @@ struct sensor_set_thresh_rq {
|
||||
|
||||
|
||||
int ipmi_sensor_main(struct ipmi_intf *, int, char **);
|
||||
int ipmi_sensor_print_full(struct ipmi_intf *, struct sdr_record_full_sensor *);
|
||||
int ipmi_sensor_print_compact(struct ipmi_intf *, struct sdr_record_compact_sensor *);
|
||||
int ipmi_sensor_print_fc(struct ipmi_intf *, struct sdr_record_common_sensor *, uint8_t);
|
||||
int ipmi_sensor_get_sensor_reading_factors( struct ipmi_intf * intf, struct sdr_record_full_sensor * sensor, uint8_t reading);
|
||||
#endif /* IPMI_SENSOR_H */
|
||||
|
@ -1997,14 +1997,13 @@ static int ipmi_print_sensor_info(struct ipmi_intf *intf, uint16_t rec_id)
|
||||
rc = -1;
|
||||
}
|
||||
|
||||
if(header->type == SDR_RECORD_TYPE_FULL_SENSOR) {
|
||||
r = ipmi_sensor_print_full(intf, (struct sdr_record_full_sensor *)rec);
|
||||
}
|
||||
else if(header->type == SDR_RECORD_TYPE_COMPACT_SENSOR) {
|
||||
r = ipmi_sensor_print_compact(intf, (struct sdr_record_compact_sensor *)rec);
|
||||
if((header->type == SDR_RECORD_TYPE_FULL_SENSOR) ||
|
||||
(header->type == SDR_RECORD_TYPE_COMPACT_SENSOR)) {
|
||||
r = ipmi_sensor_print_fc(intf,
|
||||
(struct sdr_record_common_sensor *)rec, header->type);
|
||||
}
|
||||
else
|
||||
rc = -1;
|
||||
rc = -1;
|
||||
}
|
||||
else {
|
||||
rc = -1; /* record id not found */
|
||||
|
@ -3579,20 +3579,20 @@ static int ipmi_get_power_consumption_data(struct ipmi_intf* intf,uint8_t unit)
|
||||
if (NULL ==sdr)
|
||||
{
|
||||
printf ("Error : Can not access the System Level sensor data \n\n");
|
||||
return -1;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
sensor_number = sdr->record.full->keys.sensor_num;
|
||||
ipmi_get_sensor_reading (intf,sensor_number,&sensorReadingData);
|
||||
sensor_number = sdr->record.common->keys.sensor_num;
|
||||
ipmi_get_sensor_reading (intf,sensor_number,&sensorReadingData);
|
||||
|
||||
rsp = ipmi_sdr_get_sensor_thresholds(intf,
|
||||
sdr->record.full->keys.sensor_num,
|
||||
sdr->record.full->keys.owner_id,
|
||||
sdr->record.full->keys.lun,
|
||||
sdr->record.full->keys.channel);
|
||||
sdr->record.common->keys.sensor_num,
|
||||
sdr->record.common->keys.owner_id,
|
||||
sdr->record.common->keys.lun,
|
||||
sdr->record.common->keys.channel);
|
||||
|
||||
if (rsp != NULL && rsp->ccode == 0)
|
||||
{
|
||||
{
|
||||
readingbtuphr=sdr_convert_sensor_reading
|
||||
(sdr->record.full, sensorReadingData.sensorReading);
|
||||
warning_threshbtuphr=sdr_convert_sensor_reading
|
||||
|
@ -273,25 +273,15 @@ ipmi_event_fromsensor(struct ipmi_intf * intf, char * id, char * state, char * e
|
||||
switch (sdr->type)
|
||||
{
|
||||
case SDR_RECORD_TYPE_FULL_SENSOR:
|
||||
|
||||
emsg.sensor_type = sdr->record.full->sensor.type;
|
||||
emsg.sensor_num = sdr->record.full->keys.sensor_num;
|
||||
emsg.event_type = sdr->record.full->event_type;
|
||||
target = sdr->record.full->keys.owner_id;
|
||||
lun = sdr->record.full->keys.lun;
|
||||
channel = sdr->record.full->keys.channel;
|
||||
break;
|
||||
|
||||
case SDR_RECORD_TYPE_COMPACT_SENSOR:
|
||||
|
||||
emsg.sensor_type = sdr->record.compact->sensor.type;
|
||||
emsg.sensor_num = sdr->record.compact->keys.sensor_num;
|
||||
emsg.event_type = sdr->record.compact->event_type;
|
||||
target = sdr->record.compact->keys.owner_id;
|
||||
lun = sdr->record.compact->keys.lun;
|
||||
channel = sdr->record.compact->keys.channel;
|
||||
emsg.sensor_type = sdr->record.common->sensor.type;
|
||||
emsg.sensor_num = sdr->record.common->keys.sensor_num;
|
||||
emsg.event_type = sdr->record.common->event_type;
|
||||
target = sdr->record.common->keys.owner_id;
|
||||
lun = sdr->record.common->keys.lun;
|
||||
channel = sdr->record.common->keys.channel;
|
||||
break;
|
||||
|
||||
default:
|
||||
lprintf(LOG_ERR, "Unknown sensor type for id '%s'", id);
|
||||
return -1;
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -1124,10 +1124,10 @@ ipmi_sel_print_std_entry(struct ipmi_intf * intf, struct sel_event_record * evt)
|
||||
((evt->sel_type.standard_type.event_data[0] & 0xf) % 2) ? ">" : "<",
|
||||
(threshold_reading==(int)threshold_reading) ? 0 : 2,
|
||||
threshold_reading,
|
||||
ipmi_sdr_get_unit_string(sdr->record.full->unit.pct,
|
||||
sdr->record.full->unit.modifier,
|
||||
sdr->record.full->unit.type.base,
|
||||
sdr->record.full->unit.type.modifier));
|
||||
ipmi_sdr_get_unit_string(sdr->record.common->unit.pct,
|
||||
sdr->record.common->unit.modifier,
|
||||
sdr->record.common->unit.type.base,
|
||||
sdr->record.common->unit.type.modifier));
|
||||
}
|
||||
else if (evt->sel_type.standard_type.event_type == 0x6f) {
|
||||
/*
|
||||
@ -1312,10 +1312,10 @@ ipmi_sel_print_extended_entry_verbose(struct ipmi_intf * intf, struct sel_event_
|
||||
sdr_convert_sensor_reading(sdr->record.full,
|
||||
evt->sel_type.standard_type.event_data[1]));
|
||||
/* determine units with possible modifiers */
|
||||
printf ("%s\n", ipmi_sdr_get_unit_string(sdr->record.full->unit.pct,
|
||||
sdr->record.full->unit.modifier,
|
||||
sdr->record.full->unit.type.base,
|
||||
sdr->record.full->unit.type.modifier));
|
||||
printf ("%s\n", ipmi_sdr_get_unit_string(sdr->record.common->unit.pct,
|
||||
sdr->record.common->unit.modifier,
|
||||
sdr->record.common->unit.type.base,
|
||||
sdr->record.common->unit.type.modifier));
|
||||
break;
|
||||
case 2:
|
||||
/* oem code in byte 2 */
|
||||
@ -1338,10 +1338,10 @@ ipmi_sel_print_extended_entry_verbose(struct ipmi_intf * intf, struct sel_event_
|
||||
sdr_convert_sensor_reading(sdr->record.full,
|
||||
evt->sel_type.standard_type.event_data[2]));
|
||||
/* determine units with possible modifiers */
|
||||
printf ("%s\n", ipmi_sdr_get_unit_string(sdr->record.full->unit.pct,
|
||||
sdr->record.full->unit.modifier,
|
||||
sdr->record.full->unit.type.base,
|
||||
sdr->record.full->unit.type.modifier));
|
||||
printf ("%s\n", ipmi_sdr_get_unit_string(sdr->record.common->unit.pct,
|
||||
sdr->record.common->unit.modifier,
|
||||
sdr->record.common->unit.type.base,
|
||||
sdr->record.common->unit.type.modifier));
|
||||
break;
|
||||
case 2:
|
||||
/* OEM code in byte 3 */
|
||||
@ -2052,14 +2052,11 @@ ipmi_sel_show_entry(struct ipmi_intf * intf, int argc, char ** argv)
|
||||
verbose = verbose ? : 1;
|
||||
switch (sdr->type) {
|
||||
case SDR_RECORD_TYPE_FULL_SENSOR:
|
||||
ipmi_sensor_print_full(intf, sdr->record.full);
|
||||
entity.id = sdr->record.full->entity.id;
|
||||
entity.instance = sdr->record.full->entity.instance;
|
||||
break;
|
||||
case SDR_RECORD_TYPE_COMPACT_SENSOR:
|
||||
ipmi_sensor_print_compact(intf, sdr->record.compact);
|
||||
entity.id = sdr->record.compact->entity.id;
|
||||
entity.instance = sdr->record.compact->entity.instance;
|
||||
ipmi_sensor_print_fc(intf, sdr->record.common,
|
||||
sdr->type);
|
||||
entity.id = sdr->record.common->entity.id;
|
||||
entity.instance = sdr->record.common->entity.instance;
|
||||
break;
|
||||
case SDR_RECORD_TYPE_EVENTONLY_SENSOR:
|
||||
ipmi_sdr_print_sensor_eventonly(intf, sdr->record.eventonly);
|
||||
|
@ -43,9 +43,6 @@
|
||||
|
||||
extern int verbose;
|
||||
|
||||
#define SCANNING_DISABLED 0x40
|
||||
#define READING_UNAVAILABLE 0x20
|
||||
|
||||
// static
|
||||
int
|
||||
ipmi_sensor_get_sensor_reading_factors(
|
||||
@ -65,7 +62,7 @@ ipmi_sensor_get_sensor_reading_factors(
|
||||
memset(id, 0, sizeof(id));
|
||||
memcpy(id, sensor->id_string, 16);
|
||||
|
||||
req_data[0] = sensor->keys.sensor_num;
|
||||
req_data[0] = sensor->cmn.keys.sensor_num;
|
||||
req_data[1] = reading;
|
||||
|
||||
memset(&req, 0, sizeof(req));
|
||||
@ -78,7 +75,7 @@ ipmi_sensor_get_sensor_reading_factors(
|
||||
|
||||
if (rsp == NULL) {
|
||||
lprintf(LOG_ERR, "Error updating reading factor for sensor %s (#%02x)",
|
||||
id, sensor->keys.sensor_num);
|
||||
id, sensor->cmn.keys.sensor_num);
|
||||
return -1;
|
||||
} else if (rsp->ccode) {
|
||||
return -1;
|
||||
@ -142,20 +139,34 @@ ipmi_sensor_set_sensor_thresholds(struct ipmi_intf *intf,
|
||||
}
|
||||
|
||||
static int
|
||||
ipmi_sensor_print_full_discrete(struct ipmi_intf *intf,
|
||||
struct sdr_record_full_sensor *sensor)
|
||||
ipmi_sensor_print_fc_discrete(struct ipmi_intf *intf,
|
||||
struct sdr_record_common_sensor *sensor,
|
||||
uint8_t sdr_record_type)
|
||||
{
|
||||
char id[17];
|
||||
char *unitstr = "discrete";
|
||||
int validread = 1;
|
||||
uint8_t val = 0;
|
||||
struct ipmi_rs *rsp;
|
||||
struct sdr_record_full_sensor *full = NULL;
|
||||
struct sdr_record_compact_sensor *compact = NULL;
|
||||
|
||||
if (sensor == NULL)
|
||||
return -1;
|
||||
|
||||
switch (sdr_record_type) {
|
||||
case (SDR_RECORD_TYPE_FULL_SENSOR):
|
||||
full = (struct sdr_record_full_sensor *)sensor;
|
||||
break;
|
||||
case SDR_RECORD_TYPE_COMPACT_SENSOR:
|
||||
compact = (struct sdr_record_compact_sensor *)sensor;
|
||||
break;
|
||||
default:
|
||||
return -1;
|
||||
}
|
||||
|
||||
memset(id, 0, sizeof (id));
|
||||
memcpy(id, sensor->id_string, 16);
|
||||
memcpy(id, full ? full->id_string : compact->id_string, 16);
|
||||
|
||||
/*
|
||||
* Get current reading
|
||||
@ -166,12 +177,17 @@ ipmi_sensor_print_full_discrete(struct ipmi_intf *intf,
|
||||
sensor->keys.lun,
|
||||
sensor->keys.channel);
|
||||
if (rsp == NULL) {
|
||||
/*
|
||||
* Why can't we just set validread equal to zero and fall
|
||||
* though in the same way ipmi_sdr_print_sensor_fc does?
|
||||
* All the cases below correctly handle validread.
|
||||
*/
|
||||
lprintf(LOG_ERR, "Error reading sensor %s (#%02x)",
|
||||
id, sensor->keys.sensor_num);
|
||||
return -1;
|
||||
} else if (rsp->ccode > 0 || (rsp->data[1] & READING_UNAVAILABLE)) {
|
||||
} else if (rsp->ccode || IS_READING_UNAVAILABLE(rsp->data[1])) {
|
||||
validread = 0;
|
||||
} else if (!(rsp->data[1] & SCANNING_DISABLED)) {
|
||||
} else if (IS_SCANNING_DISABLED(rsp->data[1])) {
|
||||
validread = 0;
|
||||
} else {
|
||||
/* convert RAW reading into units */
|
||||
@ -206,41 +222,82 @@ ipmi_sensor_print_full_discrete(struct ipmi_intf *intf,
|
||||
printf(" Sensor Type (Discrete): %s\n",
|
||||
ipmi_sdr_get_sensor_type_desc(sensor->sensor.
|
||||
type));
|
||||
if( validread )
|
||||
{
|
||||
ipmi_sdr_print_discrete_state("States Asserted",
|
||||
sensor->sensor.type,
|
||||
sensor->event_type,
|
||||
rsp->data[2],
|
||||
rsp->data[3]);
|
||||
if( validread )
|
||||
{
|
||||
ipmi_sdr_print_discrete_state("States Asserted",
|
||||
sensor->sensor.type,
|
||||
sensor->event_type,
|
||||
rsp->data[2],
|
||||
rsp->data[3]);
|
||||
if (compact) {
|
||||
printf(" Raw Data: %X", rsp->data[1]);
|
||||
if(rsp->data_len > 2)
|
||||
printf(" %X", rsp->data[2]);
|
||||
if(rsp->data_len > 3)
|
||||
printf(" %X", rsp->data[3]);
|
||||
printf("\n");
|
||||
}
|
||||
printf("\n");
|
||||
} else {
|
||||
printf(" Unable to read sensor: Device Not Present\n\n");
|
||||
}
|
||||
|
||||
} else {
|
||||
printf(" Unable to read sensor: Device Not Present\n\n");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return (validread ? 0 : -1 );
|
||||
}
|
||||
|
||||
static void
|
||||
print_thresh_setting(struct sdr_record_full_sensor *full,
|
||||
uint8_t thresh_is_avail, uint8_t setting,
|
||||
const char *field_sep,
|
||||
const char *analog_fmt,
|
||||
const char *discrete_fmt,
|
||||
const char *na_fmt)
|
||||
{
|
||||
printf("%s", field_sep);
|
||||
if (!thresh_is_avail) {
|
||||
printf(na_fmt, "na");
|
||||
return;
|
||||
}
|
||||
if (full && !UNITS_ARE_DISCRETE(&full->cmn)) {
|
||||
printf(analog_fmt, sdr_convert_sensor_reading (full, setting));
|
||||
} else {
|
||||
printf(discrete_fmt, setting);
|
||||
}
|
||||
}
|
||||
|
||||
static int
|
||||
ipmi_sensor_print_full_analog(struct ipmi_intf *intf,
|
||||
struct sdr_record_full_sensor *sensor)
|
||||
ipmi_sensor_print_fc_threshold(struct ipmi_intf *intf,
|
||||
struct sdr_record_common_sensor *sensor,
|
||||
uint8_t sdr_record_type)
|
||||
{
|
||||
const char *unitstr = NULL;
|
||||
char id[17];
|
||||
int validread = 1, thresh_available = 1;
|
||||
double val = 0.0;
|
||||
double val = 0.0; /* converted analog value if a valid read */
|
||||
uint8_t get_sens_read = 0;/* discrete value if a valid read*/
|
||||
struct ipmi_rs *rsp;
|
||||
char *status = NULL;
|
||||
const char *thresh_status = "";
|
||||
struct sdr_record_full_sensor *full = NULL;
|
||||
struct sdr_record_compact_sensor *compact = NULL;
|
||||
|
||||
if (sensor == NULL)
|
||||
return -1;
|
||||
|
||||
memset(id, 0, sizeof (id));
|
||||
memcpy(id, sensor->id_string, 16);
|
||||
switch (sdr_record_type) {
|
||||
case (SDR_RECORD_TYPE_FULL_SENSOR):
|
||||
full = (struct sdr_record_full_sensor *)sensor;
|
||||
break;
|
||||
case SDR_RECORD_TYPE_COMPACT_SENSOR:
|
||||
compact = (struct sdr_record_compact_sensor *)sensor;
|
||||
break;
|
||||
default:
|
||||
return -1;
|
||||
}
|
||||
|
||||
memset(id, 0, sizeof (id));
|
||||
memcpy(id, full ? full->id_string : compact->id_string, 16);
|
||||
|
||||
/*
|
||||
* Get current reading
|
||||
@ -251,28 +308,25 @@ ipmi_sensor_print_full_analog(struct ipmi_intf *intf,
|
||||
sensor->keys.lun,
|
||||
sensor->keys.channel);
|
||||
if (rsp == NULL) {
|
||||
/*
|
||||
* Why can't we just set validread equal to zero and fall
|
||||
* though in the same way ipmi_sdr_print_sensor_fc does?
|
||||
* All the cases below correctly handle validread.
|
||||
*/
|
||||
lprintf(LOG_ERR, "Error reading sensor %s (#%02x)",
|
||||
id, sensor->keys.sensor_num);
|
||||
return -1;
|
||||
} else if (rsp->ccode || (rsp->data[1] & READING_UNAVAILABLE)) {
|
||||
} else if (rsp->ccode || IS_READING_UNAVAILABLE(rsp->data[1])) {
|
||||
validread = 0;
|
||||
} else if (!(rsp->data[1] & SCANNING_DISABLED)) {
|
||||
} else if (IS_SCANNING_DISABLED(rsp->data[1])) {
|
||||
validread = 0;
|
||||
} else {
|
||||
|
||||
/* Non linear sensors might provide updated reading factors */
|
||||
if (sensor->linearization>=SDR_SENSOR_L_NONLINEAR && sensor->linearization<=0x7F) {
|
||||
if (ipmi_sensor_get_sensor_reading_factors(intf, sensor, rsp->data[0]) < 0){
|
||||
printf("sensor %s non-linear!\n", id);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
/* Store off for use later */
|
||||
get_sens_read = rsp->data[0];
|
||||
|
||||
/* convert RAW reading into units */
|
||||
/* a raw reading of 0 is perfectly valid, and might be converted to a positive or
|
||||
negative value, as any other raw values */
|
||||
val = sdr_convert_sensor_reading(sensor, rsp->data[0]);
|
||||
status = (char *) ipmi_sdr_get_status(sensor, rsp->data[2]);
|
||||
val = sdr_convert_analog_reading(intf, full, get_sens_read, &validread);
|
||||
thresh_status = ipmi_sdr_get_thresh_status(rsp, validread, "ns");
|
||||
}
|
||||
|
||||
/*
|
||||
@ -299,49 +353,28 @@ ipmi_sensor_print_full_analog(struct ipmi_intf *intf,
|
||||
*/
|
||||
printf("%-16s ", id);
|
||||
if (validread) {
|
||||
printf("| %-10.3f | %-10s | %-6s",
|
||||
val, unitstr, status ? : "");
|
||||
if (full && !UNITS_ARE_DISCRETE(sensor))
|
||||
printf("| %-10.3f | %-10s | %-6s",
|
||||
val, unitstr, thresh_status);
|
||||
else
|
||||
printf("| 0x%-8x | %-10s | %-6s",
|
||||
get_sens_read, unitstr, thresh_status);
|
||||
} else {
|
||||
printf("| %-10s | %-10s | %-6s",
|
||||
"na", unitstr, "na");
|
||||
}
|
||||
if (thresh_available) {
|
||||
if (rsp->data[0] & LOWER_NON_RECOV_SPECIFIED)
|
||||
printf("| %-10.3f",
|
||||
sdr_convert_sensor_reading
|
||||
(sensor, rsp->data[3]));
|
||||
else
|
||||
printf("| %-10s", "na");
|
||||
if (rsp->data[0] & LOWER_CRIT_SPECIFIED)
|
||||
printf("| %-10.3f",
|
||||
sdr_convert_sensor_reading
|
||||
(sensor, rsp->data[2]));
|
||||
else
|
||||
printf("| %-10s", "na");
|
||||
if (rsp->data[0] & LOWER_NON_CRIT_SPECIFIED)
|
||||
printf("| %-10.3f",
|
||||
sdr_convert_sensor_reading
|
||||
(sensor, rsp->data[1]));
|
||||
else
|
||||
printf("| %-10s", "na");
|
||||
if (rsp->data[0] & UPPER_NON_CRIT_SPECIFIED)
|
||||
printf("| %-10.3f",
|
||||
sdr_convert_sensor_reading
|
||||
(sensor, rsp->data[4]));
|
||||
else
|
||||
printf("| %-10s", "na");
|
||||
if (rsp->data[0] & UPPER_CRIT_SPECIFIED)
|
||||
printf("| %-10.3f",
|
||||
sdr_convert_sensor_reading
|
||||
(sensor, rsp->data[5]));
|
||||
else
|
||||
printf("| %-10s", "na");
|
||||
if (rsp->data[0] & UPPER_NON_RECOV_SPECIFIED)
|
||||
printf("| %-10.3f",
|
||||
sdr_convert_sensor_reading
|
||||
(sensor, rsp->data[6]));
|
||||
else
|
||||
printf("| %-10s", "na");
|
||||
if (thresh_available && full) {
|
||||
#define PTS(bit, dataidx) { \
|
||||
print_thresh_setting(full, rsp->data[0] & (bit), \
|
||||
rsp->data[(dataidx)], "| ", "%-10.3f", "0x-8x", "%-10s"); \
|
||||
}
|
||||
PTS(LOWER_NON_RECOV_SPECIFIED, 3);
|
||||
PTS(LOWER_CRIT_SPECIFIED, 2);
|
||||
PTS(LOWER_NON_CRIT_SPECIFIED, 1);
|
||||
PTS(UPPER_NON_CRIT_SPECIFIED, 4);
|
||||
PTS(UPPER_CRIT_SPECIFIED, 5);
|
||||
PTS(UPPER_NON_RECOV_SPECIFIED, 6);
|
||||
#undef PTS
|
||||
} else {
|
||||
printf
|
||||
("| %-10s| %-10s| %-10s| %-10s| %-10s| %-10s",
|
||||
@ -356,99 +389,64 @@ ipmi_sensor_print_full_analog(struct ipmi_intf *intf,
|
||||
printf(" Entity ID : %d.%d\n",
|
||||
sensor->entity.id, sensor->entity.instance);
|
||||
|
||||
printf(" Sensor Type (Analog) : %s\n",
|
||||
printf(" Sensor Type (Threshold) : %s\n",
|
||||
ipmi_sdr_get_sensor_type_desc(sensor->sensor.
|
||||
type));
|
||||
|
||||
printf(" Sensor Reading : ");
|
||||
if (validread) {
|
||||
uint16_t raw_tol = __TO_TOL(sensor->mtol);
|
||||
double tol =
|
||||
sdr_convert_sensor_tolerance(sensor,
|
||||
raw_tol);
|
||||
printf("%.*f (+/- %.*f) %s\n",
|
||||
(val == (int) val) ? 0 : 3, val,
|
||||
(tol == (int) tol) ? 0 : 3, tol,
|
||||
unitstr);
|
||||
printf(" Status : %s\n",
|
||||
status ? : "");
|
||||
if (full) {
|
||||
uint16_t raw_tol = __TO_TOL(full->mtol);
|
||||
if (!UNITS_ARE_DISCRETE(sensor)) {
|
||||
double tol =
|
||||
sdr_convert_sensor_tolerance(full,
|
||||
raw_tol);
|
||||
printf("%.*f (+/- %.*f) %s\n",
|
||||
(val == (int) val) ? 0 : 3, val,
|
||||
(tol == (int) tol) ? 0 : 3, tol,
|
||||
unitstr);
|
||||
} else {
|
||||
printf("0x%x (+/- 0x%x) %s\n",
|
||||
get_sens_read,
|
||||
raw_tol,
|
||||
unitstr);
|
||||
}
|
||||
} else {
|
||||
printf("0x%x %s\n", get_sens_read, unitstr);
|
||||
}
|
||||
printf(" Status : %s\n", thresh_status);
|
||||
|
||||
if (thresh_available) {
|
||||
if (rsp->data[0] & LOWER_NON_RECOV_SPECIFIED)
|
||||
printf
|
||||
(" Lower Non-Recoverable : %.3f\n",
|
||||
sdr_convert_sensor_reading
|
||||
(sensor, rsp->data[3]));
|
||||
else
|
||||
printf
|
||||
(" Lower Non-Recoverable : na\n");
|
||||
if (rsp->data[0] & LOWER_CRIT_SPECIFIED)
|
||||
printf
|
||||
(" Lower Critical : %.3f\n",
|
||||
sdr_convert_sensor_reading
|
||||
(sensor, rsp->data[2]));
|
||||
else
|
||||
printf
|
||||
(" Lower Critical : na\n");
|
||||
if (rsp->data[0] & LOWER_NON_CRIT_SPECIFIED)
|
||||
printf
|
||||
(" Lower Non-Critical : %.3f\n",
|
||||
sdr_convert_sensor_reading
|
||||
(sensor, rsp->data[1]));
|
||||
else
|
||||
printf
|
||||
(" Lower Non-Critical : na\n");
|
||||
if (rsp->data[0] & UPPER_NON_CRIT_SPECIFIED)
|
||||
printf
|
||||
(" Upper Non-Critical : %.3f\n",
|
||||
sdr_convert_sensor_reading
|
||||
(sensor, rsp->data[4]));
|
||||
else
|
||||
printf
|
||||
(" Upper Non-Critical : na\n");
|
||||
if (rsp->data[0] & UPPER_CRIT_SPECIFIED)
|
||||
printf
|
||||
(" Upper Critical : %.3f\n",
|
||||
sdr_convert_sensor_reading
|
||||
(sensor, rsp->data[5]));
|
||||
else
|
||||
printf
|
||||
(" Upper Critical : na\n");
|
||||
if (rsp->data[0] & UPPER_NON_RECOV_SPECIFIED)
|
||||
printf
|
||||
(" Upper Non-Recoverable : %.3f\n",
|
||||
sdr_convert_sensor_reading
|
||||
(sensor, rsp->data[6]));
|
||||
else
|
||||
printf
|
||||
(" Upper Non-Recoverable : na\n");
|
||||
if (full) {
|
||||
#define PTS(bit, dataidx, str) { \
|
||||
print_thresh_setting(full, rsp->data[0] & (bit), \
|
||||
rsp->data[(dataidx)], \
|
||||
(str), "%.3f\n", "0x%x\n", "%s\n"); \
|
||||
}
|
||||
|
||||
if (
|
||||
sensor->threshold.hysteresis.positive == 0x00
|
||||
||
|
||||
sensor->threshold.hysteresis.positive == 0xff
|
||||
)
|
||||
printf(" Positive Hysteresis : Unspecified\n");
|
||||
else
|
||||
printf(" Positive Hysteresis : %.3f\n",
|
||||
sdr_convert_sensor_hysterisis
|
||||
(sensor,sensor->threshold.hysteresis.positive));
|
||||
PTS(LOWER_NON_RECOV_SPECIFIED, 3, " Lower Non-Recoverable : ");
|
||||
PTS(LOWER_CRIT_SPECIFIED, 2, " Lower Critical : ");
|
||||
PTS(LOWER_NON_CRIT_SPECIFIED, 1, " Lower Non-Critical : ");
|
||||
PTS(UPPER_NON_CRIT_SPECIFIED, 4, " Upper Non-Critical : ");
|
||||
PTS(UPPER_CRIT_SPECIFIED, 5, " Upper Critical : ");
|
||||
PTS(UPPER_NON_RECOV_SPECIFIED, 6, " Upper Non-Recoverable : ");
|
||||
#undef PTS
|
||||
|
||||
if (
|
||||
sensor->threshold.hysteresis.negative == 0x00
|
||||
||
|
||||
sensor->threshold.hysteresis.negative == 0xff
|
||||
)
|
||||
printf(" Negative Hysteresis : Unspecified\n");
|
||||
else
|
||||
printf(" Negative Hysteresis : %.3f\n",
|
||||
sdr_convert_sensor_hysterisis
|
||||
(sensor,sensor->threshold.hysteresis.negative));
|
||||
}
|
||||
ipmi_sdr_print_sensor_hysteresis(sensor, full,
|
||||
full ? full->threshold.hysteresis.positive :
|
||||
compact->threshold.hysteresis.positive,
|
||||
"Positive Hysteresis");
|
||||
|
||||
ipmi_sdr_print_sensor_hysteresis(sensor, full,
|
||||
full ? full->threshold.hysteresis.negative :
|
||||
compact->threshold.hysteresis.negative,
|
||||
"Negative Hysteresis");
|
||||
} else {
|
||||
printf(" Sensor Threshold Settings not available\n");
|
||||
}
|
||||
} else {
|
||||
printf(" Unable to read sensor: Device Not Present\n\n");
|
||||
printf(" Unable to read sensor: Device Not Present\n\n");
|
||||
}
|
||||
|
||||
ipmi_sdr_print_sensor_event_status(intf,
|
||||
@ -478,104 +476,14 @@ ipmi_sensor_print_full_analog(struct ipmi_intf *intf,
|
||||
}
|
||||
|
||||
int
|
||||
ipmi_sensor_print_full(struct ipmi_intf *intf,
|
||||
struct sdr_record_full_sensor *sensor)
|
||||
ipmi_sensor_print_fc(struct ipmi_intf *intf,
|
||||
struct sdr_record_common_sensor *sensor,
|
||||
uint8_t sdr_record_type)
|
||||
{
|
||||
if (sensor->unit.analog != 3)
|
||||
return ipmi_sensor_print_full_analog(intf, sensor);
|
||||
if (IS_THRESHOLD_SENSOR(sensor))
|
||||
return ipmi_sensor_print_fc_threshold(intf, sensor, sdr_record_type);
|
||||
else
|
||||
return ipmi_sensor_print_full_discrete(intf, sensor);
|
||||
}
|
||||
|
||||
int
|
||||
ipmi_sensor_print_compact(struct ipmi_intf *intf,
|
||||
struct sdr_record_compact_sensor *sensor)
|
||||
{
|
||||
char id[17];
|
||||
char *unitstr = "discrete";
|
||||
int validread = 1;
|
||||
uint8_t val = 0;
|
||||
struct ipmi_rs *rsp;
|
||||
|
||||
if (sensor == NULL)
|
||||
return -1;
|
||||
|
||||
memset(id, 0, sizeof (id));
|
||||
memcpy(id, sensor->id_string, 16);
|
||||
|
||||
/*
|
||||
* Get current reading
|
||||
*/
|
||||
rsp = ipmi_sdr_get_sensor_reading_ipmb(intf,
|
||||
sensor->keys.sensor_num,
|
||||
sensor->keys.owner_id,
|
||||
sensor->keys.lun,
|
||||
sensor->keys.channel);
|
||||
if (rsp == NULL) {
|
||||
lprintf(LOG_ERR, "Error reading sensor %s (#%02x)",
|
||||
id, sensor->keys.sensor_num);
|
||||
return -1;
|
||||
} else if (rsp->ccode || (rsp->data[1] & READING_UNAVAILABLE)) {
|
||||
validread = 0;
|
||||
} else if (!(rsp->data[1] & SCANNING_DISABLED)) {
|
||||
validread = 0;
|
||||
} else {
|
||||
/* convert RAW reading into units */
|
||||
val = rsp->data[0];
|
||||
}
|
||||
|
||||
if (csv_output) {
|
||||
/* NOT IMPLEMENTED */
|
||||
} else {
|
||||
if (!verbose) {
|
||||
/* output format
|
||||
* id value units status thresholds....
|
||||
*/
|
||||
printf("%-16s ", id);
|
||||
|
||||
if (validread) {
|
||||
printf("| 0x%-8x | %-10s | 0x%02x%02x",
|
||||
val, unitstr,
|
||||
rsp->data[2], rsp->data[3]);
|
||||
} else {
|
||||
printf("| %-10s | %-10s | %-6s",
|
||||
"na", unitstr, "na");
|
||||
}
|
||||
|
||||
printf("| %-10s| %-10s| %-10s| %-10s| %-10s| %-10s",
|
||||
"na", "na", "na", "na", "na", "na");
|
||||
printf("\n");
|
||||
} else {
|
||||
printf("Sensor ID : %s (0x%x)\n",
|
||||
id, sensor->keys.sensor_num);
|
||||
printf(" Entity ID : %d.%d\n",
|
||||
sensor->entity.id, sensor->entity.instance);
|
||||
printf(" Sensor Type (Discrete): %s\n",
|
||||
ipmi_sdr_get_sensor_type_desc(sensor->sensor.
|
||||
type));
|
||||
|
||||
if(validread)
|
||||
{
|
||||
ipmi_sdr_print_discrete_state("States Asserted",
|
||||
sensor->sensor.type,
|
||||
sensor->event_type,
|
||||
rsp->data[2],
|
||||
rsp->data[3]);
|
||||
printf(" Raw Data: %X", rsp->data[1]);
|
||||
if(rsp->data_len > 2)
|
||||
printf(" %X", rsp->data[2]);
|
||||
if(rsp->data_len > 3)
|
||||
printf(" %X", rsp->data[3]);
|
||||
printf("\n");
|
||||
printf("\n");
|
||||
} else {
|
||||
printf(" Unable to read sensor: Device Not Present\n\n");
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
return (validread ? 0 : -1 );
|
||||
return ipmi_sensor_print_fc_discrete(intf, sensor, sdr_record_type);
|
||||
}
|
||||
|
||||
static int
|
||||
@ -605,16 +513,12 @@ ipmi_sensor_list(struct ipmi_intf *intf)
|
||||
|
||||
switch (header->type) {
|
||||
case SDR_RECORD_TYPE_FULL_SENSOR:
|
||||
r = ipmi_sensor_print_full(intf,
|
||||
(struct
|
||||
sdr_record_full_sensor *)
|
||||
rec);
|
||||
break;
|
||||
case SDR_RECORD_TYPE_COMPACT_SENSOR:
|
||||
r = ipmi_sensor_print_compact(intf,
|
||||
(struct
|
||||
sdr_record_compact_sensor
|
||||
*) rec);
|
||||
r = ipmi_sensor_print_fc(intf,
|
||||
(struct
|
||||
sdr_record_common_sensor *)
|
||||
rec,
|
||||
header->type);
|
||||
break;
|
||||
}
|
||||
free(rec);
|
||||
@ -662,6 +566,28 @@ __ipmi_sensor_set_threshold(struct ipmi_intf *intf,
|
||||
return 0;
|
||||
}
|
||||
|
||||
static uint8_t
|
||||
__ipmi_sensor_threshold_value_to_raw(struct sdr_record_full_sensor *full, double value)
|
||||
{
|
||||
if (!UNITS_ARE_DISCRETE(&full->cmn)) { /* Has an analog reading */
|
||||
/* Has an analog reading and supports mx+b */
|
||||
return sdr_convert_sensor_value_to_raw(full, value);
|
||||
}
|
||||
else {
|
||||
/* Does not have an analog reading and/or does not support mx+b */
|
||||
if (value > 255) {
|
||||
return 255;
|
||||
}
|
||||
else if (value < 0) {
|
||||
return 0;
|
||||
}
|
||||
else {
|
||||
return (uint8_t )value;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static int
|
||||
ipmi_sensor_set_threshold(struct ipmi_intf *intf, int argc, char **argv)
|
||||
{
|
||||
@ -763,90 +689,89 @@ ipmi_sensor_set_threshold(struct ipmi_intf *intf, int argc, char **argv)
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (!IS_THRESHOLD_SENSOR(sdr->record.common)) {
|
||||
lprintf(LOG_ERR, "Invalid sensor event type %02x", sdr->record.common->event_type);
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
if (allUpper) {
|
||||
settingMask = UPPER_NON_CRIT_SPECIFIED;
|
||||
printf("Setting sensor \"%s\" %s threshold to %.3f\n",
|
||||
sdr->record.full->id_string,
|
||||
val2str(settingMask, threshold_vals), setting1);
|
||||
ret = __ipmi_sensor_set_threshold(intf,
|
||||
sdr->record.full->keys.
|
||||
sdr->record.common->keys.
|
||||
sensor_num, settingMask,
|
||||
sdr_convert_sensor_value_to_raw
|
||||
(sdr->record.full, setting1),
|
||||
sdr->record.full->keys.owner_id,
|
||||
sdr->record.full->keys.lun);
|
||||
__ipmi_sensor_threshold_value_to_raw(sdr->record.full, setting1),
|
||||
sdr->record.common->keys.owner_id,
|
||||
sdr->record.common->keys.lun);
|
||||
|
||||
settingMask = UPPER_CRIT_SPECIFIED;
|
||||
printf("Setting sensor \"%s\" %s threshold to %.3f\n",
|
||||
sdr->record.full->id_string,
|
||||
val2str(settingMask, threshold_vals), setting2);
|
||||
ret = __ipmi_sensor_set_threshold(intf,
|
||||
sdr->record.full->keys.
|
||||
sdr->record.common->keys.
|
||||
sensor_num, settingMask,
|
||||
sdr_convert_sensor_value_to_raw
|
||||
(sdr->record.full, setting2),
|
||||
sdr->record.full->keys.owner_id,
|
||||
sdr->record.full->keys.lun);
|
||||
__ipmi_sensor_threshold_value_to_raw(sdr->record.full, setting2),
|
||||
sdr->record.common->keys.owner_id,
|
||||
sdr->record.common->keys.lun);
|
||||
|
||||
settingMask = UPPER_NON_RECOV_SPECIFIED;
|
||||
printf("Setting sensor \"%s\" %s threshold to %.3f\n",
|
||||
sdr->record.full->id_string,
|
||||
val2str(settingMask, threshold_vals), setting3);
|
||||
ret = __ipmi_sensor_set_threshold(intf,
|
||||
sdr->record.full->keys.
|
||||
sdr->record.common->keys.
|
||||
sensor_num, settingMask,
|
||||
sdr_convert_sensor_value_to_raw
|
||||
(sdr->record.full, setting3),
|
||||
sdr->record.full->keys.owner_id,
|
||||
sdr->record.full->keys.lun);
|
||||
__ipmi_sensor_threshold_value_to_raw(sdr->record.full, setting3),
|
||||
sdr->record.common->keys.owner_id,
|
||||
sdr->record.common->keys.lun);
|
||||
} else if (allLower) {
|
||||
settingMask = LOWER_NON_RECOV_SPECIFIED;
|
||||
printf("Setting sensor \"%s\" %s threshold to %.3f\n",
|
||||
sdr->record.full->id_string,
|
||||
val2str(settingMask, threshold_vals), setting1);
|
||||
ret = __ipmi_sensor_set_threshold(intf,
|
||||
sdr->record.full->keys.
|
||||
sdr->record.common->keys.
|
||||
sensor_num, settingMask,
|
||||
sdr_convert_sensor_value_to_raw
|
||||
(sdr->record.full, setting1),
|
||||
sdr->record.full->keys.owner_id,
|
||||
sdr->record.full->keys.lun);
|
||||
__ipmi_sensor_threshold_value_to_raw(sdr->record.full, setting1),
|
||||
sdr->record.common->keys.owner_id,
|
||||
sdr->record.common->keys.lun);
|
||||
|
||||
settingMask = LOWER_CRIT_SPECIFIED;
|
||||
printf("Setting sensor \"%s\" %s threshold to %.3f\n",
|
||||
sdr->record.full->id_string,
|
||||
val2str(settingMask, threshold_vals), setting2);
|
||||
ret = __ipmi_sensor_set_threshold(intf,
|
||||
sdr->record.full->keys.
|
||||
sdr->record.common->keys.
|
||||
sensor_num, settingMask,
|
||||
sdr_convert_sensor_value_to_raw
|
||||
(sdr->record.full, setting2),
|
||||
sdr->record.full->keys.owner_id,
|
||||
sdr->record.full->keys.lun);
|
||||
__ipmi_sensor_threshold_value_to_raw(sdr->record.full, setting2),
|
||||
sdr->record.common->keys.owner_id,
|
||||
sdr->record.common->keys.lun);
|
||||
|
||||
settingMask = LOWER_NON_CRIT_SPECIFIED;
|
||||
printf("Setting sensor \"%s\" %s threshold to %.3f\n",
|
||||
sdr->record.full->id_string,
|
||||
val2str(settingMask, threshold_vals), setting3);
|
||||
ret = __ipmi_sensor_set_threshold(intf,
|
||||
sdr->record.full->keys.
|
||||
sdr->record.common->keys.
|
||||
sensor_num, settingMask,
|
||||
sdr_convert_sensor_value_to_raw
|
||||
(sdr->record.full, setting3),
|
||||
sdr->record.full->keys.owner_id,
|
||||
sdr->record.full->keys.lun);
|
||||
__ipmi_sensor_threshold_value_to_raw(sdr->record.full, setting3),
|
||||
sdr->record.common->keys.owner_id,
|
||||
sdr->record.common->keys.lun);
|
||||
} else {
|
||||
printf("Setting sensor \"%s\" %s threshold to %.3f\n",
|
||||
sdr->record.full->id_string,
|
||||
val2str(settingMask, threshold_vals), setting1);
|
||||
|
||||
ret = __ipmi_sensor_set_threshold(intf,
|
||||
sdr->record.full->keys.
|
||||
sdr->record.common->keys.
|
||||
sensor_num, settingMask,
|
||||
sdr_convert_sensor_value_to_raw
|
||||
(sdr->record.full, setting1),
|
||||
sdr->record.full->keys.owner_id,
|
||||
sdr->record.full->keys.lun);
|
||||
__ipmi_sensor_threshold_value_to_raw(sdr->record.full, setting1),
|
||||
sdr->record.common->keys.owner_id,
|
||||
sdr->record.common->keys.lun);
|
||||
}
|
||||
|
||||
return ret;
|
||||
@ -877,24 +802,29 @@ ipmi_sensor_get_reading(struct ipmi_intf *intf, int argc, char **argv)
|
||||
|
||||
switch (sdr->type) {
|
||||
case SDR_RECORD_TYPE_FULL_SENSOR:
|
||||
/* Only Threshold can return an analog reading */
|
||||
if (!IS_THRESHOLD_SENSOR(sdr->record.common)) {
|
||||
lprintf(LOG_ERR, "Sensor \"%s\" is a discrete sensor!", argv[i]);
|
||||
continue;
|
||||
}
|
||||
if (sdr->record.full->linearization >= SDR_SENSOR_L_NONLINEAR) {
|
||||
lprintf(LOG_ERR, "Sensor \"%s\" non-linear!", argv[i]);
|
||||
continue;
|
||||
}
|
||||
rsp = ipmi_sdr_get_sensor_reading_ipmb(intf,
|
||||
sdr->record.full->keys.sensor_num,
|
||||
sdr->record.full->keys.owner_id,
|
||||
sdr->record.full->keys.lun,
|
||||
sdr->record.full->keys.channel);
|
||||
sdr->record.common->keys.sensor_num,
|
||||
sdr->record.common->keys.owner_id,
|
||||
sdr->record.common->keys.lun,
|
||||
sdr->record.common->keys.channel);
|
||||
if (rsp == NULL) {
|
||||
lprintf(LOG_ERR, "Error reading sensor \"%s\"", argv[i]);
|
||||
rc = -1;
|
||||
continue;
|
||||
} else if (rsp->ccode > 0) {
|
||||
continue;
|
||||
} else if (rsp->data[1] & READING_UNAVAILABLE) {
|
||||
} else if (IS_READING_UNAVAILABLE(rsp->data[1])) {
|
||||
continue;
|
||||
} else if (!(rsp->data[1] & SCANNING_DISABLED)) {
|
||||
} else if (IS_SCANNING_DISABLED(rsp->data[1])) {
|
||||
continue;
|
||||
} else if (rsp->data[0] > 0) {
|
||||
/* convert RAW reading into units */
|
||||
@ -953,11 +883,9 @@ ipmi_sensor_get(struct ipmi_intf *intf, int argc, char **argv)
|
||||
verbose = 1;
|
||||
switch (sdr->type) {
|
||||
case SDR_RECORD_TYPE_FULL_SENSOR:
|
||||
r = ipmi_sensor_print_full(intf, sdr->record.full);
|
||||
break;
|
||||
case SDR_RECORD_TYPE_COMPACT_SENSOR:
|
||||
r = ipmi_sensor_print_compact(intf,
|
||||
sdr->record.compact);
|
||||
r = ipmi_sensor_print_fc(intf, sdr->record.common,
|
||||
sdr->type);
|
||||
break;
|
||||
case SDR_RECORD_TYPE_EVENTONLY_SENSOR:
|
||||
r = ipmi_sdr_print_sensor_eventonly(intf,
|
||||
|
@ -284,10 +284,10 @@ log_event(struct ipmi_event_intf * eintf, struct sel_event_record * evt)
|
||||
((evt->sel_type.standard_type.event_data[0] & 0xf) % 2) ? ">" : "<",
|
||||
(threshold_reading==(int)threshold_reading) ? 0 : 2,
|
||||
threshold_reading,
|
||||
ipmi_sdr_get_unit_string(sdr->record.full->unit.pct,
|
||||
sdr->record.full->unit.modifier,
|
||||
sdr->record.full->unit.type.base,
|
||||
sdr->record.full->unit.type.modifier));
|
||||
ipmi_sdr_get_unit_string(sdr->record.common->unit.pct,
|
||||
sdr->record.common->unit.modifier,
|
||||
sdr->record.common->unit.type.base,
|
||||
sdr->record.common->unit.type.modifier));
|
||||
}
|
||||
else if ((evt->sel_type.standard_type.event_type >= 0x2 && evt->sel_type.standard_type.event_type <= 0xc) ||
|
||||
(evt->sel_type.standard_type.event_type == 0x6f)) {
|
||||
|
@ -746,7 +746,8 @@ ipmi_lan_poll_recv(struct ipmi_intf * intf)
|
||||
rsp->payload.ipmi_response.cmd == 0x34) {
|
||||
memcpy(rsp->data, &rsp->data[offset],
|
||||
(rsp->data_len-offset));
|
||||
printbuf( &rsp->data[offset],
|
||||
if (verbose > 2)
|
||||
printbuf( &rsp->data[offset],
|
||||
(rsp->data_len-offset),
|
||||
"bridge command response");
|
||||
}
|
||||
@ -2089,10 +2090,16 @@ ipmi_lanplus_send_payload(
|
||||
int try = 0;
|
||||
int xmit = 1;
|
||||
time_t ltime;
|
||||
uint32_t timeout;
|
||||
|
||||
if (!intf->opened && intf->open && intf->open(intf) < 0)
|
||||
return NULL;
|
||||
|
||||
/*
|
||||
* The session timeout is initialized in the above interface open,
|
||||
* so it will only be valid after the open completes.
|
||||
*/
|
||||
timeout = session->timeout;
|
||||
while (try < session->retry) {
|
||||
//ltime = time(NULL);
|
||||
|
||||
@ -2287,21 +2294,19 @@ ipmi_lanplus_send_payload(
|
||||
break;
|
||||
}
|
||||
|
||||
xmit = ((time(NULL) - ltime) >= intf->session->timeout);
|
||||
/* only timeout if time exceeds the timeout value */
|
||||
xmit = ((time(NULL) - ltime) > timeout);
|
||||
|
||||
usleep(5000);
|
||||
|
||||
if (xmit) {
|
||||
/* incremet session timeout each retry */
|
||||
intf->session->timeout++;
|
||||
/* increment session timeout by 1 second each retry */
|
||||
timeout++;
|
||||
}
|
||||
|
||||
try++;
|
||||
}
|
||||
|
||||
/* Reset timeout after retry loop completes */
|
||||
intf->session->timeout = IPMI_LAN_TIMEOUT;
|
||||
|
||||
/* IPMI messages are deleted under ipmi_lan_poll_recv() */
|
||||
switch (payload->payload_type) {
|
||||
case IPMI_PAYLOAD_TYPE_RMCP_OPEN_REQUEST:
|
||||
|
Loading…
x
Reference in New Issue
Block a user