clean up output and shorten blink names

This commit is contained in:
Duncan Laurie 2005-05-15 05:55:09 +00:00
parent 12c19f88ca
commit f04b6d858f

View File

@ -68,10 +68,18 @@ static const struct valstr sunoem_led_type_vals[] = {
static const struct valstr sunoem_led_mode_vals[] = { static const struct valstr sunoem_led_mode_vals[] = {
{ 0, "OFF" }, { 0, "OFF" },
{ 1, "ON" }, { 1, "ON" },
{ 2, "STANDBY" },
{ 3, "SLOW" },
{ 4, "FAST" },
{ 0xFF, NULL },
};
static const struct valstr sunoem_led_mode_optvals[] = {
{ 0, "STEADY_OFF" },
{ 1, "STEADY_ON" },
{ 2, "STANDBY_BLINK" }, { 2, "STANDBY_BLINK" },
{ 3, "SLOW_BLINK" }, { 3, "SLOW_BLINK" },
{ 4, "FAST_BLINK" }, { 4, "FAST_BLINK" },
{ 0, NULL }, { 0xFF, NULL },
}; };
static void static void
@ -99,19 +107,19 @@ ipmi_sunoem_usage(void)
lprintf(LOG_NOTICE, " Use 'sdr list generic' command to get list of Generic"); lprintf(LOG_NOTICE, " Use 'sdr list generic' command to get list of Generic");
lprintf(LOG_NOTICE, " Devices that are controllable LEDs."); lprintf(LOG_NOTICE, " Devices that are controllable LEDs.");
lprintf(LOG_NOTICE, ""); lprintf(LOG_NOTICE, "");
lprintf(LOG_NOTICE, " Required SIS LED Mode:");
lprintf(LOG_NOTICE, " OFF Off");
lprintf(LOG_NOTICE, " ON Steady On");
lprintf(LOG_NOTICE, " STANDBY 100ms on 2900ms off blink rate");
lprintf(LOG_NOTICE, " SLOW 1HZ blink rate");
lprintf(LOG_NOTICE, " FAST 4HZ blink rate");
lprintf(LOG_NOTICE, "");
lprintf(LOG_NOTICE, " Optional SIS LED Type:"); lprintf(LOG_NOTICE, " Optional SIS LED Type:");
lprintf(LOG_NOTICE, " OK2RM OK to Remove"); lprintf(LOG_NOTICE, " OK2RM OK to Remove");
lprintf(LOG_NOTICE, " SERVICE Service Required"); lprintf(LOG_NOTICE, " SERVICE Service Required");
lprintf(LOG_NOTICE, " ACT Activity"); lprintf(LOG_NOTICE, " ACT Activity");
lprintf(LOG_NOTICE, " LOCATE Locate"); lprintf(LOG_NOTICE, " LOCATE Locate");
lprintf(LOG_NOTICE, ""); lprintf(LOG_NOTICE, "");
lprintf(LOG_NOTICE, " Required SIS LED Mode:");
lprintf(LOG_NOTICE, " OFF Off");
lprintf(LOG_NOTICE, " ON Steady On");
lprintf(LOG_NOTICE, " STANDBY_BLINK 100ms on 2900ms off blink rate");
lprintf(LOG_NOTICE, " SLOW_BLINK 1HZ blink rate");
lprintf(LOG_NOTICE, " FAST_BLINK 4HZ blink rate");
lprintf(LOG_NOTICE, "");
} }
/* /*
@ -166,6 +174,12 @@ __sdr_list_empty(struct sdr_record_list * head)
head = NULL; head = NULL;
} }
static void
led_print(const char * name, uint8_t state)
{
printf("%-16s | %s\n", name, val2str(state, sunoem_led_mode_vals));
}
static struct ipmi_rs * static struct ipmi_rs *
sunoem_led_get(struct ipmi_intf * intf, sunoem_led_get(struct ipmi_intf * intf,
struct sdr_record_generic_locator * dev, struct sdr_record_generic_locator * dev,
@ -266,9 +280,7 @@ sunoem_led_get_byentity(struct ipmi_intf * intf, uint8_t entity_id,
continue; continue;
rsp = sunoem_led_get(intf, e->record.genloc, ledtype); rsp = sunoem_led_get(intf, e->record.genloc, ledtype);
if (rsp && rsp->data_len == 1) { if (rsp && rsp->data_len == 1) {
printf("LED %s is %s\n", led_print(e->record.genloc->id_string, rsp->data[0]);
e->record.genloc->id_string,
val2str(rsp->data[0], sunoem_led_mode_vals));
} }
} }
@ -299,9 +311,7 @@ sunoem_led_set_byentity(struct ipmi_intf * intf, uint8_t entity_id,
continue; continue;
rsp = sunoem_led_set(intf, e->record.genloc, ledtype, ledmode); rsp = sunoem_led_set(intf, e->record.genloc, ledtype, ledmode);
if (rsp && rsp->data_len == 0) { if (rsp && rsp->data_len == 0) {
printf("Set LED %s to %s\n", led_print(e->record.genloc->id_string, ledmode);
e->record.genloc->id_string,
val2str(ledmode, sunoem_led_mode_vals));
} }
} }
@ -354,9 +364,7 @@ ipmi_sunoem_led_get(struct ipmi_intf * intf, int argc, char ** argv)
continue; continue;
rsp = sunoem_led_get(intf, a->record.genloc, ledtype); rsp = sunoem_led_get(intf, a->record.genloc, ledtype);
if (rsp && rsp->data_len == 1) { if (rsp && rsp->data_len == 1) {
printf("LED %s is %s\n", led_print(a->record.genloc->id_string, rsp->data[0]);
a->record.genloc->id_string,
val2str(rsp->data[0], sunoem_led_mode_vals));
} }
} }
__sdr_list_empty(alist); __sdr_list_empty(alist);
@ -382,9 +390,7 @@ ipmi_sunoem_led_get(struct ipmi_intf * intf, int argc, char ** argv)
*/ */
rsp = sunoem_led_get(intf, sdr->record.genloc, ledtype); rsp = sunoem_led_get(intf, sdr->record.genloc, ledtype);
if (rsp && rsp->data_len == 1) { if (rsp && rsp->data_len == 1) {
printf("LED %s is %s\n", led_print(sdr->record.genloc->id_string, rsp->data[0]);
sdr->record.genloc->id_string,
val2str(rsp->data[0], sunoem_led_mode_vals));
} }
return 0; return 0;
} }
@ -456,7 +462,7 @@ ipmi_sunoem_led_get(struct ipmi_intf * intf, int argc, char ** argv)
* [byte 2] ctrlrAddr Controller address; value from the "Device * [byte 2] ctrlrAddr Controller address; value from the "Device
* Access Address" field, 0x20 if the LED is local * Access Address" field, 0x20 if the LED is local
* [byte 3] hwInfo The OEM field from the SDR record * [byte 3] hwInfo The OEM field from the SDR record
* [byte 4] mode LED Mode: OFF, ON, STANDBY_BLINK, SLOW_BLINK, FAST_BLINK * [byte 4] mode LED Mode: OFF, ON, STANDBY, SLOW, FAST
* [byte 5] force TRUE - directly access the device * [byte 5] force TRUE - directly access the device
* FALSE - go thru its controller * FALSE - go thru its controller
* Ignored if LED is local * Ignored if LED is local
@ -465,7 +471,7 @@ ipmi_sunoem_led_get(struct ipmi_intf * intf, int argc, char ** argv)
* *
* IPMI Response Data: 1 byte * IPMI Response Data: 1 byte
* *
* [byte 0] mode LED Mode: OFF, ON, STANDBY_BLINK, SLOW_BLINK, FAST_BLINK * [byte 0] mode LED Mode: OFF, ON, STANDBY, SLOW, FAST
*/ */
static int static int
@ -489,15 +495,16 @@ ipmi_sunoem_led_set(struct ipmi_intf * intf, int argc, char ** argv)
} }
ledmode = str2val(argv[1], sunoem_led_mode_vals); ledmode = str2val(argv[1], sunoem_led_mode_vals);
if (ledmode < 0) { if (ledmode == 0xFF) {
ledmode = str2val(argv[1], sunoem_led_mode_optvals);
if (ledmode == 0xFF) {
lprintf(LOG_NOTICE, "Invalid LED Mode: %s", argv[1]); lprintf(LOG_NOTICE, "Invalid LED Mode: %s", argv[1]);
return -1; return -1;
} }
}
if (argc > 3) { if (argc > 3) {
ledtype = str2val(argv[2], sunoem_led_type_vals); ledtype = str2val(argv[2], sunoem_led_type_vals);
if (ledtype < 0)
ledtype = 0;
} }
if (strncasecmp(argv[0], "all", 3) == 0) { if (strncasecmp(argv[0], "all", 3) == 0) {
@ -510,9 +517,7 @@ ipmi_sunoem_led_set(struct ipmi_intf * intf, int argc, char ** argv)
continue; continue;
rsp = sunoem_led_set(intf, a->record.genloc, ledtype, ledmode); rsp = sunoem_led_set(intf, a->record.genloc, ledtype, ledmode);
if (rsp && rsp->ccode == 0) { if (rsp && rsp->ccode == 0) {
printf("Set LED %s to %s\n", led_print(a->record.genloc->id_string, ledmode);
a->record.genloc->id_string,
val2str(ledmode, sunoem_led_mode_vals));
} }
} }
__sdr_list_empty(alist); __sdr_list_empty(alist);
@ -539,8 +544,7 @@ ipmi_sunoem_led_set(struct ipmi_intf * intf, int argc, char ** argv)
*/ */
rsp = sunoem_led_set(intf, sdr->record.genloc, ledtype, ledmode); rsp = sunoem_led_set(intf, sdr->record.genloc, ledtype, ledmode);
if (rsp && rsp->ccode == 0) { if (rsp && rsp->ccode == 0) {
printf("Set LED %s to %s\n", argv[0], led_print(argv[0], ledmode);
val2str(ledmode, sunoem_led_mode_vals));
} }
return 0; return 0;
} }
@ -739,11 +743,12 @@ ipmi_sunoem_main(struct ipmi_intf * intf, int argc, char ** argv)
} }
if (strncmp(argv[1], "get", 3) == 0) { if (strncmp(argv[1], "get", 3) == 0) {
if (argc < 3) { if (argc < 3) {
ipmi_sunoem_usage(); char * arg[] = { "all" };
return -1; rc = ipmi_sunoem_led_get(intf, 1, arg);
} } else {
rc = ipmi_sunoem_led_get(intf, argc-2, &(argv[2])); rc = ipmi_sunoem_led_get(intf, argc-2, &(argv[2]));
} }
}
else if (strncmp(argv[1], "set", 3) == 0) { else if (strncmp(argv[1], "set", 3) == 0) {
if (argc < 4) { if (argc < 4) {
ipmi_sunoem_usage(); ipmi_sunoem_usage();