From cacdd1b6ec9bf04ea7dcaf6d66cc5cacbce56aa7 Mon Sep 17 00:00:00 2001 From: Jens Nyberg Date: Thu, 10 Mar 2016 08:42:35 +0000 Subject: [PATCH] ID:431 - Fix correct interpretation of led states The LED state bits are not mutually exclusive. Bit [0] says LEDs can be controlled locally and the state bit [1] says wheter the default local settings or the override settings are used. This means that both bits can be set at the same time. Bit [2], the lamp test, indicates wether the test is in progress and logically works the same as [1]. If bit [0] is not set then bit [1] and [2] has no meaning. Signed-off-by: Jens Nyberg --- lib/ipmi_picmg.c | 54 ++++++++++++++++++++++++++---------------------- 1 file changed, 29 insertions(+), 25 deletions(-) diff --git a/lib/ipmi_picmg.c b/lib/ipmi_picmg.c index f47577e..70f845d 100644 --- a/lib/ipmi_picmg.c +++ b/lib/ipmi_picmg.c @@ -1280,49 +1280,53 @@ ipmi_picmg_get_led_state(struct ipmi_intf * intf, int argc, char ** argv) } printf("LED states: %x ", rsp->data[1] ); - if (rsp->data[1] == 0x1) - printf("[LOCAL CONTROL]\n"); - else if (rsp->data[1] == 0x2) - printf("[OVERRIDE]\n"); - else if (rsp->data[1] == 0x4) - printf("[LAMPTEST]\n"); - else - printf("\n"); + + if (!(rsp->data[1] & 0x1)) { + printf("[NO LOCAL CONTROL]\n"); + return 0; + } + + printf("[LOCAL CONTROL"); + + if (rsp->data[1] & 0x2) { + printf("|OVERRIDE"); + } + + if (rsp->data[1] & 0x4) { + printf("|LAMPTEST"); + } + + printf("]\n"); printf(" Local Control function: %x ", rsp->data[2] ); - if (rsp->data[2] == 0x0) + if (rsp->data[2] == 0x0) { printf("[OFF]\n"); - else if (rsp->data[2] == 0xff) + } else if (rsp->data[2] == 0xff) { printf("[ON]\n"); - else + } else { printf("[BLINKING]\n"); + } printf(" Local Control On-Duration: %x\n", rsp->data[3] ); printf(" Local Control Color: %x [%s]\n", rsp->data[4], led_color_str[ rsp->data[4] ]); /* override state or lamp test */ - if (rsp->data[1] == 0x02) { + if (rsp->data[1] & 0x02) { printf(" Override function: %x ", rsp->data[5] ); - if (rsp->data[2] == 0x0) + if (rsp->data[2] == 0x0) { printf("[OFF]\n"); - else if (rsp->data[2] == 0xff) + } else if (rsp->data[2] == 0xff) { printf("[ON]\n"); - else + } else { printf("[BLINKING]\n"); + } printf(" Override On-Duration: %x\n", rsp->data[6] ); printf(" Override Color: %x [%s]\n", rsp->data[7], led_color_str[ rsp->data[7] ]); - }else if (rsp->data[1] == 0x06) { - printf(" Override function: %x ", rsp->data[5] ); - if (rsp->data[2] == 0x0) - printf("[OFF]\n"); - else if (rsp->data[2] == 0xff) - printf("[ON]\n"); - else - printf("[BLINKING]\n"); - printf(" Override On-Duration: %x\n", rsp->data[6] ); - printf(" Override Color: %x [%s]\n", rsp->data[7], led_color_str[ rsp->data[7] ]); + } + + if (rsp->data[1] & 0x04) { printf(" Lamp test duration: %x\n", rsp->data[8] ); }