Index: usr.sbin/sesutil/eltsub.h =================================================================== --- usr.sbin/sesutil/eltsub.h +++ usr.sbin/sesutil/eltsub.h @@ -32,5 +32,6 @@ * mjacob@feral.com */ -char * geteltnm(int); -char * stat2ascii(int, u_char *); +char *geteltnm(int); +char *scode2ascii(u_char); +void print_stat(int, u_char *); Index: usr.sbin/sesutil/eltsub.c =================================================================== --- usr.sbin/sesutil/eltsub.c +++ usr.sbin/sesutil/eltsub.c @@ -32,6 +32,8 @@ * mjacob@feral.com */ +#include + #include #include #include @@ -43,6 +45,13 @@ #include "eltsub.h" +/* + * offset by +20 degrees. + * The range of the value expresses a temperature between -19 and +235 degrees + * Celsius. A value of 00h is reserved. + */ +#define TEMPERATURE_OFFSET 20 + char * geteltnm(int type) { @@ -134,7 +143,7 @@ return (rbuf); } -static char * +char * scode2ascii(u_char code) { static char rbuf[32]; @@ -173,22 +182,43 @@ return (rbuf); } - -char * -stat2ascii(int eletype, u_char *cstat) +void +print_stat(int eletype, u_char *cstat) { - static char ebuf[256], *scode; - scode = scode2ascii(cstat[0]); - sprintf(ebuf, "%s%s%s%s%s%s (0x%02x 0x%02x 0x%02x 0x%02x)", - scode, - (cstat[0] & 0x40) ? ", Prd.Fail" : "", - (cstat[0] & 0x20) ? ", Disabled" : "", - (cstat[0] & 0x10) ? ", Swapped" : "", - ((eletype == ELMTYP_DEVICE || eletype == ELMTYP_ARRAY_DEV) - && (cstat[2] & 0x02)) ? ", LED=Locate" : "", - ((eletype == ELMTYP_DEVICE || eletype == ELMTYP_ARRAY_DEV) - && (cstat[3] & 0x20)) ? ", LED=Fault" : "", - cstat[0], cstat[1], cstat[2], cstat[3]); - return (ebuf); + if (cstat[0] & 0x40) + printf("\t\t- Predicter Failure\n"); + if (cstat[0] & 0x20) + printf("\t\t- Disabled\n"); + if (cstat[0] & 0x10) + printf("\t\t- Swapped\n"); + switch (eletype) { + case ELMTYP_DEVICE: + if (cstat[2] & 0x02) + printf("\t\t- LED=locate\n"); + if (cstat[2] & 0x20) + printf("\t\t- LED=fault\n"); + break; + case ELMTYP_ARRAY_DEV: + if (cstat[2] & 0x02) + printf("\t\t- LED=locate\n"); + if (cstat[2] & 0x20) + printf("\t\t- LED=fault\n"); + break; + case ELMTYP_FAN: + printf("\t\t- speed: %d rpm\n", + (((0x7 & cstat[1]) << 8) + cstat[2]) * 10); + break; + case ELMTYP_THERM: + if (cstat[2]) { + printf("\t\t- Temperature: %d C\n", + cstat[2] - TEMPERATURE_OFFSET); + } else { + printf("\t\t- Temperature: -reserved-\n"); + } + break; + case ELMTYP_VOM: + printf("\t\t- Voltage: %.2f V\n", be16dec(cstat + 2) / 100.0); + break; + } } Index: usr.sbin/sesutil/sesutil.c =================================================================== --- usr.sbin/sesutil/sesutil.c +++ usr.sbin/sesutil/sesutil.c @@ -391,8 +391,10 @@ } printf("\tElement %u, Type: %s\n", e_ptr[j].elm_idx, geteltnm(e_ptr[j].elm_type)); - printf("\t\tStatus: %s\n", - stat2ascii(e_ptr[j].elm_type, e_status.cstat)); + printf("\t\tStatus: %s (0x%02x 0x%02x 0x%02x 0x%02x)\n", + scode2ascii(e_status.cstat[0]), e_status.cstat[0], + e_status.cstat[1], e_status.cstat[2], + e_status.cstat[3]); if (e_desc.elm_desc_len > 0) { printf("\t\tDescription: %s\n", e_desc.elm_desc_str); @@ -401,6 +403,8 @@ printf("\t\tDevice Names: %s\n", e_devname.elm_devnames); } + printf("\t\tExtra status:\n"); + print_stat(e_ptr[j].elm_type, e_status.cstat); free(e_devname.elm_devnames); } close(fd);