summaryrefslogtreecommitdiff
path: root/util/oem_hp.c
diff options
context:
space:
mode:
authorJörg Frings-Fürst <debian@jff.email>2018-10-01 22:44:56 +0200
committerJörg Frings-Fürst <debian@jff.email>2018-10-01 22:44:56 +0200
commit499ce7f7eb7c228d72e646527ce9a5c2950ad58f (patch)
treecff9b45c548b4d2ad6c10c2f3cdb0e08f6fc70c5 /util/oem_hp.c
parent9bf6d68108836bfbcc5296a50a48cfd6af9151b7 (diff)
New upstream version 3.1.3upstream/3.1.3
Diffstat (limited to 'util/oem_hp.c')
-rw-r--r--util/oem_hp.c101
1 files changed, 62 insertions, 39 deletions
diff --git a/util/oem_hp.c b/util/oem_hp.c
index f551176..98ba86e 100644
--- a/util/oem_hp.c
+++ b/util/oem_hp.c
@@ -48,7 +48,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
extern char * progver; /*from ipmiutil.c*/
static char * progname = "ipmiutil hpoem";
#else
-static char * progver = "3.08";
+static char * progver = "3.13";
static char * progname = "ihpoem";
#endif
@@ -81,6 +81,11 @@ int decode_sensor_hp(uchar *sdr,uchar *reading,char *pstring, int slen)
char *pstr = NULL;
uchar stype, evtype, b;
ushort v;
+ int analog = 0;
+ int fshort = 1;
+ double val;
+ char *typestr = NULL;
+ SDR01REC *sdr01 = (SDR01REC *)sdr;
if (sdr == NULL || reading == NULL) return(rv);
if (pstring == NULL || slen == 0) return(rv);
@@ -92,8 +97,8 @@ int decode_sensor_hp(uchar *sdr,uchar *reading,char *pstring, int slen)
rv = 0;
} else {
#ifdef OLD
- int vend, prod;
- get_mfgid(&vend,&prod);
+ int vend, prod;
+ get_mfgid(&vend,&prod);
/* This was an anomaly for an older HP DL380 but is no longer valid */
if ((prod == 0x2000) && ((reading[2] & 0x40) == 0x40)) {
/*custom Init/Unavail state if DL380*/
@@ -101,48 +106,66 @@ int decode_sensor_hp(uchar *sdr,uchar *reading,char *pstring, int slen)
rv = 0;
} else
#endif
+ /* HP has packed analog readings into some of their non-Threshold sensors
+ * so we have to handle that. */
+ if (sdr[3] == 0x01) { /*only full sensors can be analog*/
+ if (evtype == 0x01) analog = 1; /*threshold*/
+ else { /*if units are defined, assume analog reading */
+ if ((sdr01->sens_units & 0x07) != 0) analog = 1;
+ if (sdr01->sens_base != 0) analog = 1;
+ if (sdr01->sens_mod != 0) analog = 1;
+ }
+ if ((reading[1] & 0x20) != 0) analog = 0; /*Init state, no analog*/
+ else if (sdr01->sens_units == 0xC0) analog = 0; /*reading NotAvailable*/
+ else if (reading[2] == 0xc7) analog = 0; /* Absent (Intel) */
+ }
if (evtype == 0x6f) { /*evtype==0x6f special*/
- pstr = "DiscreteEvt";
- if (stype == 0x08) { /*Power Supply presence*/
- if (reading[2] & 0x01) pstr = "Present";
- else pstr = "Absent";
- }
- snprintf(pstring,slen,"%02x%02x %s",reading[3],reading[2],pstr);
- rv = 0;
+ pstr = "DiscreteEvt";
+ if (stype == 0x08) { /*Power Supply presence*/
+ if (reading[2] & 0x01) pstr = "Present";
+ else pstr = "Absent";
+ }
+ rv = 0;
} else if (evtype == 0x0B) { /*Redundancy*/
- b = reading[2] & 0x3f;
- pstr = "DiscretePS"; /*Power Supplies*/
- if (evtype == 0x0b) pstr = redund_str(b);
- snprintf(pstring,slen,"%02x%02x %s",reading[3],reading[2],pstr);
- rv = 0;
+ b = reading[2] & 0x3f;
+ pstr = "DiscretePS"; /*Power Supplies*/
+ if (evtype == 0x0b) pstr = redund_str(b);
+ rv = 0;
} else if (evtype == 0x0A) { /*Discrete Fan*/
- v = reading[2] + (reading[3] & 0x3f);
- if (v & 0x001) pstr = "Transition to Running";
- else if (v & 0x002) pstr = "Transition to In Test";
- else if (v & 0x004) pstr = "Transition to Power Off";
- else if (v & 0x008) pstr = "Transition to On Line";
- else if (v & 0x010) pstr = "Transition to Off Line";
- else if (v & 0x020) pstr = "Transition to Off Duty";
- else if (v & 0x040) pstr = "Transition to Degraded";
- else if (v & 0x080) pstr = "Transition to Power";
- else if (v & 0x100) pstr = "Install Error";
- else pstr = "Unknown";
- snprintf(pstring,slen,"%02x%02x %s",reading[3],reading[2],pstr);
- rv = 0;
+ v = reading[2] + (reading[3] & 0x3f);
+ if (v & 0x001) pstr = "Transition to Running";
+ else if (v & 0x002) pstr = "Transition to In Test";
+ else if (v & 0x004) pstr = "Transition to Power Off";
+ else if (v & 0x008) pstr = "Transition to On Line";
+ else if (v & 0x010) pstr = "Transition to Off Line";
+ else if (v & 0x020) pstr = "Transition to Off Duty";
+ else if (v & 0x040) pstr = "Transition to Degraded";
+ else if (v & 0x080) pstr = "Transition to Power";
+ else if (v & 0x100) pstr = "Install Error";
+ else pstr = "Unknown";
+ rv = 0;
} else if (evtype == 0x09) { /* stype==0x03 Power Meter */
- b = reading[2] & 0x3f;
- if (b & 0x01) pstr = "Disabled";
- else if (b & 0x02) pstr = "Enabled";
- else pstr = "Unknown";
- snprintf(pstring,slen,"%02x%02x %s",reading[3],reading[2],pstr);
- rv = 0;
+ b = reading[2] & 0x3f;
+ if (b & 0x01) pstr = "Disabled";
+ else if (b & 0x02) pstr = "Enabled";
+ else pstr = "Unknown";
+ rv = 0;
} else if ((sdr[20] & 0xC0) == 0xC0) { /*unit1==discrete*/
- b = reading[2] & 0x3f;
- pstr = "DiscreteUnit";
- if (evtype == 0x0b) pstr = redund_str(b);
- snprintf(pstring,slen,"%02x%02x %s",reading[3],reading[2],pstr);
- rv = 0;
+ b = reading[2] & 0x3f;
+ pstr = "DiscreteUnit";
+ if (evtype == 0x0b) pstr = redund_str(b);
+ rv = 0;
}
+ if (rv == 0) {
+ if (analog == 1) {
+ val = RawToFloat(reading[0],sdr);
+ typestr = get_unit_type(sdr01->sens_units, sdr01->sens_base,
+ sdr01->sens_mod, fshort);
+ snprintf(pstring,slen,"%.2f %s, %s",val,typestr,pstr);
+ } else {
+ snprintf(pstring,slen,"%02x%02x %s",reading[3],reading[2],pstr);
+ }
+ }
}
return(rv);
}